equal
deleted
inserted
replaced
2117 void QAbstractItemView::focusOutEvent(QFocusEvent *event) |
2117 void QAbstractItemView::focusOutEvent(QFocusEvent *event) |
2118 { |
2118 { |
2119 Q_D(QAbstractItemView); |
2119 Q_D(QAbstractItemView); |
2120 QAbstractScrollArea::focusOutEvent(event); |
2120 QAbstractScrollArea::focusOutEvent(event); |
2121 d->viewport->update(); |
2121 d->viewport->update(); |
|
2122 |
|
2123 #ifdef QT_SOFTKEYS_ENABLED |
|
2124 if(!hasEditFocus()) |
|
2125 removeAction(d->doneSoftKey); |
|
2126 #endif |
2122 } |
2127 } |
2123 |
2128 |
2124 /*! |
2129 /*! |
2125 This function is called with the given \a event when a key event is sent to |
2130 This function is called with the given \a event when a key event is sent to |
2126 the widget. The default implementation handles basic cursor movement, e.g. Up, |
2131 the widget. The default implementation handles basic cursor movement, e.g. Up, |
2142 case Qt::Key_Select: |
2147 case Qt::Key_Select: |
2143 if (QApplication::keypadNavigationEnabled()) { |
2148 if (QApplication::keypadNavigationEnabled()) { |
2144 if (!hasEditFocus()) { |
2149 if (!hasEditFocus()) { |
2145 setEditFocus(true); |
2150 setEditFocus(true); |
2146 #ifdef QT_SOFTKEYS_ENABLED |
2151 #ifdef QT_SOFTKEYS_ENABLED |
2147 addAction(d->doneSoftKey); |
2152 // If we can't keypad navigate to any direction, there is no sense to add |
|
2153 // "Done" softkey, since it basically does nothing when there is |
|
2154 // only one widget in screen |
|
2155 if(QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) |
|
2156 || QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) |
|
2157 addAction(d->doneSoftKey); |
2148 #endif |
2158 #endif |
2149 return; |
2159 return; |
2150 } |
2160 } |
2151 } |
2161 } |
2152 break; |
2162 break; |
2158 setEditFocus(false); |
2168 setEditFocus(false); |
2159 } else { |
2169 } else { |
2160 event->ignore(); |
2170 event->ignore(); |
2161 } |
2171 } |
2162 return; |
2172 return; |
|
2173 case Qt::Key_Down: |
|
2174 case Qt::Key_Up: |
|
2175 // Let's ignore vertical navigation events, only if there is no other widget |
|
2176 // what can take the focus in vertical direction. This means widget can handle navigation events |
|
2177 // even the widget don't have edit focus, and there is no other widget in requested direction. |
|
2178 if(QApplication::keypadNavigationEnabled() && !hasEditFocus() |
|
2179 && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) { |
|
2180 event->ignore(); |
|
2181 return; |
|
2182 } |
|
2183 break; |
|
2184 case Qt::Key_Left: |
|
2185 case Qt::Key_Right: |
|
2186 // Similar logic as in up and down events |
|
2187 if(QApplication::keypadNavigationEnabled() && !hasEditFocus() |
|
2188 && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this))) { |
|
2189 event->ignore(); |
|
2190 return; |
|
2191 } |
|
2192 break; |
2163 default: |
2193 default: |
2164 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { |
2194 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { |
2165 event->ignore(); |
2195 event->ignore(); |
2166 return; |
2196 return; |
2167 } |
2197 } |
2243 switch (event->key()) { |
2273 switch (event->key()) { |
2244 // ignored keys |
2274 // ignored keys |
2245 case Qt::Key_Down: |
2275 case Qt::Key_Down: |
2246 case Qt::Key_Up: |
2276 case Qt::Key_Up: |
2247 #ifdef QT_KEYPAD_NAVIGATION |
2277 #ifdef QT_KEYPAD_NAVIGATION |
2248 if (QApplication::keypadNavigationEnabled()) { |
2278 if (QApplication::keypadNavigationEnabled() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) { |
2249 event->accept(); // don't change focus |
2279 event->accept(); // don't change focus |
2250 break; |
2280 break; |
2251 } |
2281 } |
2252 #endif |
2282 #endif |
2253 case Qt::Key_Left: |
2283 case Qt::Key_Left: |
2254 case Qt::Key_Right: |
2284 case Qt::Key_Right: |
2255 #ifdef QT_KEYPAD_NAVIGATION |
2285 #ifdef QT_KEYPAD_NAVIGATION |
2256 if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { |
2286 if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional |
2257 event->accept(); // don't change horizontal focus in directional mode |
2287 && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) |
|
2288 || (QWidgetPrivate::inTabWidget(this) && d->model->columnCount(d->root) > 1))) { |
|
2289 event->accept(); // don't change focus |
2258 break; |
2290 break; |
2259 } |
2291 } |
2260 #endif // QT_KEYPAD_NAVIGATION |
2292 #endif // QT_KEYPAD_NAVIGATION |
2261 case Qt::Key_Home: |
2293 case Qt::Key_Home: |
2262 case Qt::Key_End: |
2294 case Qt::Key_End: |
2534 if(d->editors.isEmpty()) |
2566 if(d->editors.isEmpty()) |
2535 return; |
2567 return; |
2536 QStyleOptionViewItemV4 option = d->viewOptionsV4(); |
2568 QStyleOptionViewItemV4 option = d->viewOptionsV4(); |
2537 QList<QEditorInfo>::iterator it = d->editors.begin(); |
2569 QList<QEditorInfo>::iterator it = d->editors.begin(); |
2538 QWidgetList editorsToRelease; |
2570 QWidgetList editorsToRelease; |
|
2571 QWidgetList editorsToHide; |
2539 while (it != d->editors.end()) { |
2572 while (it != d->editors.end()) { |
2540 QModelIndex index = it->index; |
2573 QModelIndex index = it->index; |
2541 QWidget *editor = it->editor; |
2574 QWidget *editor = it->editor; |
2542 if (index.isValid() && editor) { |
2575 if (index.isValid() && editor) { |
2543 option.rect = visualRect(index); |
2576 option.rect = visualRect(index); |
2545 editor->show(); |
2578 editor->show(); |
2546 QAbstractItemDelegate *delegate = d->delegateForIndex(index); |
2579 QAbstractItemDelegate *delegate = d->delegateForIndex(index); |
2547 if (delegate) |
2580 if (delegate) |
2548 delegate->updateEditorGeometry(editor, option, index); |
2581 delegate->updateEditorGeometry(editor, option, index); |
2549 } else { |
2582 } else { |
2550 editor->hide(); |
2583 editorsToHide << editor; |
2551 } |
2584 } |
2552 ++it; |
2585 ++it; |
2553 } else { |
2586 } else { |
2554 it = d->editors.erase(it); |
2587 it = d->editors.erase(it); |
2555 editorsToRelease << editor; |
2588 editorsToRelease << editor; |
2556 } |
2589 } |
2557 } |
2590 } |
2558 |
2591 |
2559 //we release the editor outside of the loop because it might change the focus and try |
2592 //we hide and release the editor outside of the loop because it might change the focus and try |
2560 //to change the d->editors list. |
2593 //to change the d->editors list. |
|
2594 for (int i = 0; i < editorsToHide.count(); ++i) { |
|
2595 editorsToHide.at(i)->hide(); |
|
2596 } |
2561 for (int i = 0; i < editorsToRelease.count(); ++i) { |
2597 for (int i = 0; i < editorsToRelease.count(); ++i) { |
2562 d->releaseEditor(editorsToRelease.at(i)); |
2598 d->releaseEditor(editorsToRelease.at(i)); |
2563 } |
2599 } |
2564 } |
2600 } |
2565 |
2601 |
3012 { |
3048 { |
3013 Q_D(QAbstractItemView); |
3049 Q_D(QAbstractItemView); |
3014 if (!d->isIndexValid(index)) |
3050 if (!d->isIndexValid(index)) |
3015 return; |
3051 return; |
3016 if (QWidget *oldWidget = indexWidget(index)) { |
3052 if (QWidget *oldWidget = indexWidget(index)) { |
|
3053 d->persistent.remove(oldWidget); |
3017 d->removeEditor(oldWidget); |
3054 d->removeEditor(oldWidget); |
3018 oldWidget->deleteLater(); |
3055 oldWidget->deleteLater(); |
3019 } |
3056 } |
3020 if (widget) { |
3057 if (widget) { |
3021 widget->setParent(viewport()); |
3058 widget->setParent(viewport()); |