102 textElideMode(Qt::ElideRight), |
102 textElideMode(Qt::ElideRight), |
103 verticalScrollMode(QAbstractItemView::ScrollPerItem), |
103 verticalScrollMode(QAbstractItemView::ScrollPerItem), |
104 horizontalScrollMode(QAbstractItemView::ScrollPerItem), |
104 horizontalScrollMode(QAbstractItemView::ScrollPerItem), |
105 currentIndexSet(false), |
105 currentIndexSet(false), |
106 wrapItemText(false), |
106 wrapItemText(false), |
107 delayedPendingLayout(false) |
107 delayedPendingLayout(true), |
108 { |
108 moveCursorUpdatedView(false) |
|
109 { |
|
110 keyboardInputTime.invalidate(); |
109 } |
111 } |
110 |
112 |
111 QAbstractItemViewPrivate::~QAbstractItemViewPrivate() |
113 QAbstractItemViewPrivate::~QAbstractItemViewPrivate() |
112 { |
114 { |
113 } |
115 } |
128 q, SLOT(verticalScrollbarValueChanged(int))); |
130 q, SLOT(verticalScrollbarValueChanged(int))); |
129 QObject::connect(hbar, SIGNAL(valueChanged(int)), |
131 QObject::connect(hbar, SIGNAL(valueChanged(int)), |
130 q, SLOT(horizontalScrollbarValueChanged(int))); |
132 q, SLOT(horizontalScrollbarValueChanged(int))); |
131 |
133 |
132 viewport->setBackgroundRole(QPalette::Base); |
134 viewport->setBackgroundRole(QPalette::Base); |
133 |
|
134 doDelayedItemsLayout(); |
|
135 |
135 |
136 q->setAttribute(Qt::WA_InputMethodEnabled); |
136 q->setAttribute(Qt::WA_InputMethodEnabled); |
137 |
137 |
138 #ifdef QT_SOFTKEYS_ENABLED |
138 #ifdef QT_SOFTKEYS_ENABLED |
139 doneSoftKey = QSoftKeyManager::createKeyedAction(QSoftKeyManager::DoneSoftKey, Qt::Key_Back, q); |
139 doneSoftKey = QSoftKeyManager::createKeyedAction(QSoftKeyManager::DoneSoftKey, Qt::Key_Back, q); |
677 this, SLOT(_q_columnsInserted(QModelIndex,int,int))); |
677 this, SLOT(_q_columnsInserted(QModelIndex,int,int))); |
678 |
678 |
679 connect(d->model, SIGNAL(modelReset()), this, SLOT(reset())); |
679 connect(d->model, SIGNAL(modelReset()), this, SLOT(reset())); |
680 connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); |
680 connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); |
681 } |
681 } |
682 setSelectionModel(new QItemSelectionModel(d->model, this)); |
682 |
|
683 QItemSelectionModel *selection_model = new QItemSelectionModel(d->model, this); |
|
684 connect(d->model, SIGNAL(destroyed()), selection_model, SLOT(deleteLater())); |
|
685 setSelectionModel(selection_model); |
|
686 |
683 reset(); // kill editors, set new root and do layout |
687 reset(); // kill editors, set new root and do layout |
684 } |
688 } |
685 |
689 |
686 /*! |
690 /*! |
687 Returns the model that this view is presenting. |
691 Returns the model that this view is presenting. |
2091 && !d->currentIndexSet |
2095 && !d->currentIndexSet |
2092 && !currentIndexValid) { |
2096 && !currentIndexValid) { |
2093 bool autoScroll = d->autoScroll; |
2097 bool autoScroll = d->autoScroll; |
2094 d->autoScroll = false; |
2098 d->autoScroll = false; |
2095 QModelIndex index = moveCursor(MoveNext, Qt::NoModifier); // first visible index |
2099 QModelIndex index = moveCursor(MoveNext, Qt::NoModifier); // first visible index |
2096 if (index.isValid() && d->isIndexEnabled(index)) |
2100 if (index.isValid() && d->isIndexEnabled(index) && event->reason() != Qt::MouseFocusReason) |
2097 selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); |
2101 selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); |
2098 d->autoScroll = autoScroll; |
2102 d->autoScroll = autoScroll; |
2099 } |
2103 } |
2100 |
2104 |
2101 if (model && currentIndexValid) { |
2105 if (model && currentIndexValid) { |
2267 d->pressedPosition = visualRect(newCurrent).center() + d->offset(); |
2272 d->pressedPosition = visualRect(newCurrent).center() + d->offset(); |
2268 // We copy the same behaviour as for mousePressEvent(). |
2273 // We copy the same behaviour as for mousePressEvent(). |
2269 QRect rect(d->pressedPosition - d->offset(), QSize(1, 1)); |
2274 QRect rect(d->pressedPosition - d->offset(), QSize(1, 1)); |
2270 setSelection(rect, command); |
2275 setSelection(rect, command); |
2271 } |
2276 } |
|
2277 event->accept(); |
2272 return; |
2278 return; |
2273 } |
2279 } |
2274 } |
2280 } |
2275 |
2281 |
2276 switch (event->key()) { |
2282 switch (event->key()) { |
2298 case Qt::Key_PageUp: |
2304 case Qt::Key_PageUp: |
2299 case Qt::Key_PageDown: |
2305 case Qt::Key_PageDown: |
2300 case Qt::Key_Escape: |
2306 case Qt::Key_Escape: |
2301 case Qt::Key_Shift: |
2307 case Qt::Key_Shift: |
2302 case Qt::Key_Control: |
2308 case Qt::Key_Control: |
|
2309 case Qt::Key_Delete: |
|
2310 case Qt::Key_Backspace: |
2303 event->ignore(); |
2311 event->ignore(); |
2304 break; |
2312 break; |
2305 case Qt::Key_Space: |
2313 case Qt::Key_Space: |
2306 case Qt::Key_Select: |
2314 case Qt::Key_Select: |
2307 if (!edit(currentIndex(), AnyKeyPressed, event) && d->selectionModel) |
2315 if (!edit(currentIndex(), AnyKeyPressed, event) && d->selectionModel) |
2838 if (!d->model->rowCount(d->root) || !d->model->columnCount(d->root)) |
2848 if (!d->model->rowCount(d->root) || !d->model->columnCount(d->root)) |
2839 return; |
2849 return; |
2840 |
2850 |
2841 QModelIndex start = currentIndex().isValid() ? currentIndex() |
2851 QModelIndex start = currentIndex().isValid() ? currentIndex() |
2842 : d->model->index(0, 0, d->root); |
2852 : d->model->index(0, 0, d->root); |
2843 QTime now(QTime::currentTime()); |
|
2844 bool skipRow = false; |
2853 bool skipRow = false; |
2845 if (search.isEmpty() |
2854 bool keyboardTimeWasValid = d->keyboardInputTime.isValid(); |
2846 || (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) { |
2855 qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart(); |
|
2856 if (search.isEmpty() || !keyboardTimeWasValid |
|
2857 || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) { |
2847 d->keyboardInput = search; |
2858 d->keyboardInput = search; |
2848 skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0) |
2859 skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0) |
2849 } else { |
2860 } else { |
2850 d->keyboardInput += search; |
2861 d->keyboardInput += search; |
2851 } |
2862 } |
2852 d->keyboardInputTime = now; |
|
2853 |
2863 |
2854 // special case for searches with same key like 'aaaaa' |
2864 // special case for searches with same key like 'aaaaa' |
2855 bool sameKey = false; |
2865 bool sameKey = false; |
2856 if (d->keyboardInput.length() > 1) { |
2866 if (d->keyboardInput.length() > 1) { |
2857 int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1)); |
2867 int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1)); |