equal
deleted
inserted
replaced
1538 d->checkPersistentEditorFocus(); |
1538 d->checkPersistentEditorFocus(); |
1539 break; |
1539 break; |
1540 case QEvent::FontChange: |
1540 case QEvent::FontChange: |
1541 d->doDelayedItemsLayout(); // the size of the items will change |
1541 d->doDelayedItemsLayout(); // the size of the items will change |
1542 break; |
1542 break; |
|
1543 #ifdef QT_SOFTKEYS_ENABLED |
|
1544 case QEvent::LanguageChange: |
|
1545 d->doneSoftKey->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::DoneSoftKey)); |
|
1546 break; |
|
1547 #endif |
1543 default: |
1548 default: |
1544 break; |
1549 break; |
1545 } |
1550 } |
1546 return QAbstractScrollArea::event(event); |
1551 return QAbstractScrollArea::event(event); |
1547 } |
1552 } |
2112 void QAbstractItemView::focusOutEvent(QFocusEvent *event) |
2117 void QAbstractItemView::focusOutEvent(QFocusEvent *event) |
2113 { |
2118 { |
2114 Q_D(QAbstractItemView); |
2119 Q_D(QAbstractItemView); |
2115 QAbstractScrollArea::focusOutEvent(event); |
2120 QAbstractScrollArea::focusOutEvent(event); |
2116 d->viewport->update(); |
2121 d->viewport->update(); |
|
2122 |
|
2123 #ifdef QT_SOFTKEYS_ENABLED |
|
2124 if(!hasEditFocus()) |
|
2125 removeAction(d->doneSoftKey); |
|
2126 #endif |
2117 } |
2127 } |
2118 |
2128 |
2119 /*! |
2129 /*! |
2120 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 |
2121 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, |
2137 case Qt::Key_Select: |
2147 case Qt::Key_Select: |
2138 if (QApplication::keypadNavigationEnabled()) { |
2148 if (QApplication::keypadNavigationEnabled()) { |
2139 if (!hasEditFocus()) { |
2149 if (!hasEditFocus()) { |
2140 setEditFocus(true); |
2150 setEditFocus(true); |
2141 #ifdef QT_SOFTKEYS_ENABLED |
2151 #ifdef QT_SOFTKEYS_ENABLED |
2142 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); |
2143 #endif |
2158 #endif |
2144 return; |
2159 return; |
2145 } |
2160 } |
2146 } |
2161 } |
2147 break; |
2162 break; |
2153 setEditFocus(false); |
2168 setEditFocus(false); |
2154 } else { |
2169 } else { |
2155 event->ignore(); |
2170 event->ignore(); |
2156 } |
2171 } |
2157 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; |
2158 default: |
2193 default: |
2159 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { |
2194 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { |
2160 event->ignore(); |
2195 event->ignore(); |
2161 return; |
2196 return; |
2162 } |
2197 } |
2238 switch (event->key()) { |
2273 switch (event->key()) { |
2239 // ignored keys |
2274 // ignored keys |
2240 case Qt::Key_Down: |
2275 case Qt::Key_Down: |
2241 case Qt::Key_Up: |
2276 case Qt::Key_Up: |
2242 #ifdef QT_KEYPAD_NAVIGATION |
2277 #ifdef QT_KEYPAD_NAVIGATION |
2243 if (QApplication::keypadNavigationEnabled()) { |
2278 if (QApplication::keypadNavigationEnabled() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) { |
2244 event->accept(); // don't change focus |
2279 event->accept(); // don't change focus |
2245 break; |
2280 break; |
2246 } |
2281 } |
2247 #endif |
2282 #endif |
2248 case Qt::Key_Left: |
2283 case Qt::Key_Left: |
2249 case Qt::Key_Right: |
2284 case Qt::Key_Right: |
2250 #ifdef QT_KEYPAD_NAVIGATION |
2285 #ifdef QT_KEYPAD_NAVIGATION |
2251 if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { |
2286 if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional |
2252 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 |
2253 break; |
2290 break; |
2254 } |
2291 } |
2255 #endif // QT_KEYPAD_NAVIGATION |
2292 #endif // QT_KEYPAD_NAVIGATION |
2256 case Qt::Key_Home: |
2293 case Qt::Key_Home: |
2257 case Qt::Key_End: |
2294 case Qt::Key_End: |
2529 if(d->editors.isEmpty()) |
2566 if(d->editors.isEmpty()) |
2530 return; |
2567 return; |
2531 QStyleOptionViewItemV4 option = d->viewOptionsV4(); |
2568 QStyleOptionViewItemV4 option = d->viewOptionsV4(); |
2532 QList<QEditorInfo>::iterator it = d->editors.begin(); |
2569 QList<QEditorInfo>::iterator it = d->editors.begin(); |
2533 QWidgetList editorsToRelease; |
2570 QWidgetList editorsToRelease; |
|
2571 QWidgetList editorsToHide; |
2534 while (it != d->editors.end()) { |
2572 while (it != d->editors.end()) { |
2535 QModelIndex index = it->index; |
2573 QModelIndex index = it->index; |
2536 QWidget *editor = it->editor; |
2574 QWidget *editor = it->editor; |
2537 if (index.isValid() && editor) { |
2575 if (index.isValid() && editor) { |
2538 option.rect = visualRect(index); |
2576 option.rect = visualRect(index); |
2540 editor->show(); |
2578 editor->show(); |
2541 QAbstractItemDelegate *delegate = d->delegateForIndex(index); |
2579 QAbstractItemDelegate *delegate = d->delegateForIndex(index); |
2542 if (delegate) |
2580 if (delegate) |
2543 delegate->updateEditorGeometry(editor, option, index); |
2581 delegate->updateEditorGeometry(editor, option, index); |
2544 } else { |
2582 } else { |
2545 editor->hide(); |
2583 editorsToHide << editor; |
2546 } |
2584 } |
2547 ++it; |
2585 ++it; |
2548 } else { |
2586 } else { |
2549 it = d->editors.erase(it); |
2587 it = d->editors.erase(it); |
2550 editorsToRelease << editor; |
2588 editorsToRelease << editor; |
2551 } |
2589 } |
2552 } |
2590 } |
2553 |
2591 |
2554 //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 |
2555 //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 } |
2556 for (int i = 0; i < editorsToRelease.count(); ++i) { |
2597 for (int i = 0; i < editorsToRelease.count(); ++i) { |
2557 d->releaseEditor(editorsToRelease.at(i)); |
2598 d->releaseEditor(editorsToRelease.at(i)); |
2558 } |
2599 } |
2559 } |
2600 } |
2560 |
2601 |
3007 { |
3048 { |
3008 Q_D(QAbstractItemView); |
3049 Q_D(QAbstractItemView); |
3009 if (!d->isIndexValid(index)) |
3050 if (!d->isIndexValid(index)) |
3010 return; |
3051 return; |
3011 if (QWidget *oldWidget = indexWidget(index)) { |
3052 if (QWidget *oldWidget = indexWidget(index)) { |
|
3053 d->persistent.remove(oldWidget); |
3012 d->removeEditor(oldWidget); |
3054 d->removeEditor(oldWidget); |
3013 oldWidget->deleteLater(); |
3055 oldWidget->deleteLater(); |
3014 } |
3056 } |
3015 if (widget) { |
3057 if (widget) { |
3016 widget->setParent(viewport()); |
3058 widget->setParent(viewport()); |