| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qabstractitemview.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | QAbstractItemViewPrivate::QAbstractItemViewPrivate() | - | ||||||||||||||||||
| 13 | : model(QAbstractItemModelPrivate::staticEmptyModel()), | - | ||||||||||||||||||
| 14 | itemDelegate(0), | - | ||||||||||||||||||
| 15 | selectionModel(0), | - | ||||||||||||||||||
| 16 | ctrlDragSelectionFlag(QItemSelectionModel::NoUpdate), | - | ||||||||||||||||||
| 17 | noSelectionOnMousePress(false), | - | ||||||||||||||||||
| 18 | selectionMode(QAbstractItemView::ExtendedSelection), | - | ||||||||||||||||||
| 19 | selectionBehavior(QAbstractItemView::SelectItems), | - | ||||||||||||||||||
| 20 | currentlyCommittingEditor(0), | - | ||||||||||||||||||
| 21 | pressedModifiers(Qt::NoModifier), | - | ||||||||||||||||||
| 22 | pressedPosition(QPoint(-1, -1)), | - | ||||||||||||||||||
| 23 | pressedAlreadySelected(false), | - | ||||||||||||||||||
| 24 | viewportEnteredNeeded(false), | - | ||||||||||||||||||
| 25 | state(QAbstractItemView::NoState), | - | ||||||||||||||||||
| 26 | stateBeforeAnimation(QAbstractItemView::NoState), | - | ||||||||||||||||||
| 27 | editTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed), | - | ||||||||||||||||||
| 28 | lastTrigger(QAbstractItemView::NoEditTriggers), | - | ||||||||||||||||||
| 29 | tabKeyNavigation(false), | - | ||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | showDropIndicator(true), | - | ||||||||||||||||||
| 32 | dragEnabled(false), | - | ||||||||||||||||||
| 33 | dragDropMode(QAbstractItemView::NoDragDrop), | - | ||||||||||||||||||
| 34 | overwrite(false), | - | ||||||||||||||||||
| 35 | dropIndicatorPosition(QAbstractItemView::OnItem), | - | ||||||||||||||||||
| 36 | defaultDropAction(Qt::IgnoreAction), | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | autoScroll(true), | - | ||||||||||||||||||
| 39 | autoScrollMargin(16), | - | ||||||||||||||||||
| 40 | autoScrollCount(0), | - | ||||||||||||||||||
| 41 | shouldScrollToCurrentOnShow(false), | - | ||||||||||||||||||
| 42 | shouldClearStatusTip(false), | - | ||||||||||||||||||
| 43 | alternatingColors(false), | - | ||||||||||||||||||
| 44 | textElideMode(Qt::ElideRight), | - | ||||||||||||||||||
| 45 | verticalScrollMode(QAbstractItemView::ScrollPerItem), | - | ||||||||||||||||||
| 46 | horizontalScrollMode(QAbstractItemView::ScrollPerItem), | - | ||||||||||||||||||
| 47 | currentIndexSet(false), | - | ||||||||||||||||||
| 48 | wrapItemText(false), | - | ||||||||||||||||||
| 49 | delayedPendingLayout(true), | - | ||||||||||||||||||
| 50 | moveCursorUpdatedView(false), | - | ||||||||||||||||||
| 51 | verticalScrollModeSet(false), | - | ||||||||||||||||||
| 52 | horizontalScrollModeSet(false) | - | ||||||||||||||||||
| 53 | { | - | ||||||||||||||||||
| 54 | keyboardInputTime.invalidate(); | - | ||||||||||||||||||
| 55 | } never executed: end of block | 0 | ||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | QAbstractItemViewPrivate::~QAbstractItemViewPrivate() | - | ||||||||||||||||||
| 58 | { | - | ||||||||||||||||||
| 59 | } | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | void QAbstractItemViewPrivate::init() | - | ||||||||||||||||||
| 62 | { | - | ||||||||||||||||||
| 63 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 64 | q->setItemDelegate(new QStyledItemDelegate(q)); | - | ||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | vbar->setRange(0, 0); | - | ||||||||||||||||||
| 67 | hbar->setRange(0, 0); | - | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | QObject::connect(vbar, qFlagLocation("2""actionTriggered(int)" "\0" __FILE__ ":" "121""132"), | - | ||||||||||||||||||
| 70 | q, qFlagLocation("1""verticalScrollbarAction(int)" "\0" __FILE__ ":" "122""133")); | - | ||||||||||||||||||
| 71 | QObject::connect(hbar, qFlagLocation("2""actionTriggered(int)" "\0" __FILE__ ":" "123""134"), | - | ||||||||||||||||||
| 72 | q, qFlagLocation("1""horizontalScrollbarAction(int)" "\0" __FILE__ ":" "124""135")); | - | ||||||||||||||||||
| 73 | QObject::connect(vbar, qFlagLocation("2""valueChanged(int)" "\0" __FILE__ ":" "125""136"), | - | ||||||||||||||||||
| 74 | q, qFlagLocation("1""verticalScrollbarValueChanged(int)" "\0" __FILE__ ":" "126""137")); | - | ||||||||||||||||||
| 75 | QObject::connect(hbar, qFlagLocation("2""valueChanged(int)" "\0" __FILE__ ":" "127""138"), | - | ||||||||||||||||||
| 76 | q, qFlagLocation("1""horizontalScrollbarValueChanged(int)" "\0" __FILE__ ":" "128""139")); | - | ||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | viewport->setBackgroundRole(QPalette::Base); | - | ||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | q->setAttribute(Qt::WA_InputMethodEnabled); | - | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | verticalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, q, 0)); | - | ||||||||||||||||||
| 83 | horizontalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, q, 0)); | - | ||||||||||||||||||
| 84 | } never executed: end of block | 0 | ||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | void QAbstractItemViewPrivate::setHoverIndex(const QPersistentModelIndex &index) | - | ||||||||||||||||||
| 87 | { | - | ||||||||||||||||||
| 88 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 89 | if (hover == index) | - | ||||||||||||||||||
| 90 | return; | - | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | if (selectionBehavior != QAbstractItemView::SelectRows) { | - | ||||||||||||||||||
| 93 | q->update(hover); | - | ||||||||||||||||||
| 94 | q->update(index); | - | ||||||||||||||||||
| 95 | } else { | - | ||||||||||||||||||
| 96 | QRect oldHoverRect = q->visualRect(hover); | - | ||||||||||||||||||
| 97 | QRect newHoverRect = q->visualRect(index); | - | ||||||||||||||||||
| 98 | viewport->update(QRect(0, newHoverRect.y(), viewport->width(), newHoverRect.height())); | - | ||||||||||||||||||
| 99 | viewport->update(QRect(0, oldHoverRect.y(), viewport->width(), oldHoverRect.height())); | - | ||||||||||||||||||
| 100 | } | - | ||||||||||||||||||
| 101 | hover = index; | - | ||||||||||||||||||
| 102 | } | - | ||||||||||||||||||
| 103 | - | |||||||||||||||||||
| 104 | void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index) | - | ||||||||||||||||||
| 105 | { | - | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 108 | setHoverIndex(index); | - | ||||||||||||||||||
| 109 | if (viewportEnteredNeeded || enteredIndex != index) { | - | ||||||||||||||||||
| 110 | viewportEnteredNeeded = false; | - | ||||||||||||||||||
| 111 | - | |||||||||||||||||||
| 112 | if (index.isValid()) { | - | ||||||||||||||||||
| 113 | q->entered(index); | - | ||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | QString statustip = model->data(index, Qt::StatusTipRole).toString(); | - | ||||||||||||||||||
| 116 | if (parent && (shouldClearStatusTip || !statustip.isEmpty())) { | - | ||||||||||||||||||
| 117 | QStatusTipEvent tip(statustip); | - | ||||||||||||||||||
| 118 | QApplication::sendEvent(parent, &tip); | - | ||||||||||||||||||
| 119 | shouldClearStatusTip = !statustip.isEmpty(); | - | ||||||||||||||||||
| 120 | } | - | ||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | } else { | - | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | if (parent && shouldClearStatusTip) { | - | ||||||||||||||||||
| 125 | QString emptyString; | - | ||||||||||||||||||
| 126 | QStatusTipEvent tip( emptyString ); | - | ||||||||||||||||||
| 127 | QApplication::sendEvent(parent, &tip); | - | ||||||||||||||||||
| 128 | } | - | ||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | q->viewportEntered(); | - | ||||||||||||||||||
| 131 | } | - | ||||||||||||||||||
| 132 | enteredIndex = index; | - | ||||||||||||||||||
| 133 | } | - | ||||||||||||||||||
| 134 | } | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | void QAbstractItemViewPrivate::_q_scrollerStateChanged() | - | ||||||||||||||||||
| 140 | { | - | ||||||||||||||||||
| 141 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | if (QScroller *scroller = QScroller::scroller(viewport)) { | - | ||||||||||||||||||
| 144 | switch (scroller->state()) { | - | ||||||||||||||||||
| 145 | case QScroller::Pressed: | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | if (q->selectionModel()) { | - | ||||||||||||||||||
| 148 | oldSelection = q->selectionModel()->selection(); | - | ||||||||||||||||||
| 149 | oldCurrent = q->selectionModel()->currentIndex(); | - | ||||||||||||||||||
| 150 | } | - | ||||||||||||||||||
| 151 | break; | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | case QScroller::Dragging: | - | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | if (q->selectionModel()) { | - | ||||||||||||||||||
| 156 | q->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect); | - | ||||||||||||||||||
| 157 | q->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate); | - | ||||||||||||||||||
| 158 | } | - | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | default: | - | ||||||||||||||||||
| 162 | oldSelection = QItemSelection(); | - | ||||||||||||||||||
| 163 | oldCurrent = QModelIndex(); | - | ||||||||||||||||||
| 164 | break; | - | ||||||||||||||||||
| 165 | } | - | ||||||||||||||||||
| 166 | } | - | ||||||||||||||||||
| 167 | } | - | ||||||||||||||||||
| 168 | QAbstractItemView::QAbstractItemView(QWidget *parent) | - | ||||||||||||||||||
| 169 | : QAbstractScrollArea(*(new QAbstractItemViewPrivate), parent) | - | ||||||||||||||||||
| 170 | { | - | ||||||||||||||||||
| 171 | d_func()->init(); | - | ||||||||||||||||||
| 172 | } | - | ||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | QAbstractItemView::QAbstractItemView(QAbstractItemViewPrivate &dd, QWidget *parent) | - | ||||||||||||||||||
| 178 | : QAbstractScrollArea(dd, parent) | - | ||||||||||||||||||
| 179 | { | - | ||||||||||||||||||
| 180 | d_func()->init(); | - | ||||||||||||||||||
| 181 | } | - | ||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | - | |||||||||||||||||||
| 186 | QAbstractItemView::~QAbstractItemView() | - | ||||||||||||||||||
| 187 | { | - | ||||||||||||||||||
| 188 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | d->delayedReset.stop(); | - | ||||||||||||||||||
| 191 | d->updateTimer.stop(); | - | ||||||||||||||||||
| 192 | d->delayedEditing.stop(); | - | ||||||||||||||||||
| 193 | d->delayedAutoScroll.stop(); | - | ||||||||||||||||||
| 194 | d->autoScrollTimer.stop(); | - | ||||||||||||||||||
| 195 | d->delayedLayout.stop(); | - | ||||||||||||||||||
| 196 | d->fetchMoreTimer.stop(); | - | ||||||||||||||||||
| 197 | } | - | ||||||||||||||||||
| 198 | void QAbstractItemView::setModel(QAbstractItemModel *model) | - | ||||||||||||||||||
| 199 | { | - | ||||||||||||||||||
| 200 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 201 | if (model == d->model) | - | ||||||||||||||||||
| 202 | return; | - | ||||||||||||||||||
| 203 | if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) { | - | ||||||||||||||||||
| 204 | disconnect(d->model, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "656""675"), | - | ||||||||||||||||||
| 205 | this, qFlagLocation("1""_q_modelDestroyed()" "\0" __FILE__ ":" "657""676")); | - | ||||||||||||||||||
| 206 | disconnect(d->model, qFlagLocation("2""dataChanged(QModelIndex,QModelIndex,QVector<int>)" "\0" __FILE__ ":" "658""677"), | - | ||||||||||||||||||
| 207 | this, qFlagLocation("1""dataChanged(QModelIndex,QModelIndex,QVector<int>)" "\0" __FILE__ ":" "659""678")); | - | ||||||||||||||||||
| 208 | disconnect(d->model, qFlagLocation("2""headerDataChanged(Qt::Orientation,int,int)" "\0" __FILE__ ":" "660""679"), | - | ||||||||||||||||||
| 209 | this, qFlagLocation("1""_q_headerDataChanged()" "\0" __FILE__ ":" "661""680")); | - | ||||||||||||||||||
| 210 | disconnect(d->model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "662""681"), | - | ||||||||||||||||||
| 211 | this, qFlagLocation("1""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "663""682")); | - | ||||||||||||||||||
| 212 | disconnect(d->model, qFlagLocation("2""rowsAboutToBeRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "664""683"), | - | ||||||||||||||||||
| 213 | this, qFlagLocation("1""rowsAboutToBeRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "665""684")); | - | ||||||||||||||||||
| 214 | disconnect(d->model, qFlagLocation("2""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "666""685"), | - | ||||||||||||||||||
| 215 | this, qFlagLocation("1""_q_rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "667""686")); | - | ||||||||||||||||||
| 216 | disconnect(d->model, qFlagLocation("2""rowsMoved(QModelIndex,int,int,QModelIndex,int)" "\0" __FILE__ ":" "668""687"), | - | ||||||||||||||||||
| 217 | this, qFlagLocation("1""_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)" "\0" __FILE__ ":" "669""688")); | - | ||||||||||||||||||
| 218 | disconnect(d->model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "670""689"), | - | ||||||||||||||||||
| 219 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "671""690")); | - | ||||||||||||||||||
| 220 | disconnect(d->model, qFlagLocation("2""columnsAboutToBeRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "672""691"), | - | ||||||||||||||||||
| 221 | this, qFlagLocation("1""_q_columnsAboutToBeRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "673""692")); | - | ||||||||||||||||||
| 222 | disconnect(d->model, qFlagLocation("2""columnsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "674""693"), | - | ||||||||||||||||||
| 223 | this, qFlagLocation("1""_q_columnsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "675""694")); | - | ||||||||||||||||||
| 224 | disconnect(d->model, qFlagLocation("2""columnsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "676""695"), | - | ||||||||||||||||||
| 225 | this, qFlagLocation("1""_q_columnsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "677""696")); | - | ||||||||||||||||||
| 226 | disconnect(d->model, qFlagLocation("2""columnsMoved(QModelIndex,int,int,QModelIndex,int)" "\0" __FILE__ ":" "678""697"), | - | ||||||||||||||||||
| 227 | this, qFlagLocation("1""_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)" "\0" __FILE__ ":" "679""698")); | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | disconnect(d->model, qFlagLocation("2""modelReset()" "\0" __FILE__ ":" "681""700"), this, qFlagLocation("1""reset()" "\0" __FILE__ ":" "681""700")); | - | ||||||||||||||||||
| 230 | disconnect(d->model, qFlagLocation("2""layoutChanged()" "\0" __FILE__ ":" "682""701"), this, qFlagLocation("1""_q_layoutChanged()" "\0" __FILE__ ":" "682""701")); | - | ||||||||||||||||||
| 231 | } | - | ||||||||||||||||||
| 232 | d->model = (model ? model : QAbstractItemModelPrivate::staticEmptyModel()); | - | ||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | ((!(d->model->index(0,0) == d->model->index(0,0))) ? qt_assert_x("QAbstractItemView::setModel", "A model should return the exact same index " "(including its internal id/pointer) when asked for it twice in a row.", | - | ||||||||||||||||||
| 236 | - | |||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | __FILE__ | - | ||||||||||||||||||
| 239 | , | - | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | 690709 | - | ||||||||||||||||||
| 243 | ) : qt_noop()) | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | ; | - | ||||||||||||||||||
| 247 | ((!(!d->model->index(0,0).parent().isValid())) ? qt_assert_x("QAbstractItemView::setModel", "The parent of a top level index should be invalid", | - | ||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | __FILE__ | - | ||||||||||||||||||
| 250 | , | - | ||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | 693712 | - | ||||||||||||||||||
| 253 | ) : qt_noop()) | - | ||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | ; | - | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | if (d->model != QAbstractItemModelPrivate::staticEmptyModel()) { | - | ||||||||||||||||||
| 258 | connect(d->model, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "696""715"), | - | ||||||||||||||||||
| 259 | this, qFlagLocation("1""_q_modelDestroyed()" "\0" __FILE__ ":" "697""716")); | - | ||||||||||||||||||
| 260 | connect(d->model, qFlagLocation("2""dataChanged(QModelIndex,QModelIndex,QVector<int>)" "\0" __FILE__ ":" "698""717"), | - | ||||||||||||||||||
| 261 | this, qFlagLocation("1""dataChanged(QModelIndex,QModelIndex,QVector<int>)" "\0" __FILE__ ":" "699""718")); | - | ||||||||||||||||||
| 262 | connect(d->model, qFlagLocation("2""headerDataChanged(Qt::Orientation,int,int)" "\0" __FILE__ ":" "700""719"), | - | ||||||||||||||||||
| 263 | this, qFlagLocation("1""_q_headerDataChanged()" "\0" __FILE__ ":" "701""720")); | - | ||||||||||||||||||
| 264 | connect(d->model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "702""721"), | - | ||||||||||||||||||
| 265 | this, qFlagLocation("1""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "703""722")); | - | ||||||||||||||||||
| 266 | connect(d->model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "704""723"), | - | ||||||||||||||||||
| 267 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "705""724")); | - | ||||||||||||||||||
| 268 | connect(d->model, qFlagLocation("2""rowsAboutToBeRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "706""725"), | - | ||||||||||||||||||
| 269 | this, qFlagLocation("1""rowsAboutToBeRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "707""726")); | - | ||||||||||||||||||
| 270 | connect(d->model, qFlagLocation("2""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "708""727"), | - | ||||||||||||||||||
| 271 | this, qFlagLocation("1""_q_rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "709""728")); | - | ||||||||||||||||||
| 272 | connect(d->model, qFlagLocation("2""rowsMoved(QModelIndex,int,int,QModelIndex,int)" "\0" __FILE__ ":" "710""729"), | - | ||||||||||||||||||
| 273 | this, qFlagLocation("1""_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)" "\0" __FILE__ ":" "711""730")); | - | ||||||||||||||||||
| 274 | connect(d->model, qFlagLocation("2""columnsAboutToBeRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "712""731"), | - | ||||||||||||||||||
| 275 | this, qFlagLocation("1""_q_columnsAboutToBeRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "713""732")); | - | ||||||||||||||||||
| 276 | connect(d->model, qFlagLocation("2""columnsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "714""733"), | - | ||||||||||||||||||
| 277 | this, qFlagLocation("1""_q_columnsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "715""734")); | - | ||||||||||||||||||
| 278 | connect(d->model, qFlagLocation("2""columnsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "716""735"), | - | ||||||||||||||||||
| 279 | this, qFlagLocation("1""_q_columnsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "717""736")); | - | ||||||||||||||||||
| 280 | connect(d->model, qFlagLocation("2""columnsMoved(QModelIndex,int,int,QModelIndex,int)" "\0" __FILE__ ":" "718""737"), | - | ||||||||||||||||||
| 281 | this, qFlagLocation("1""_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)" "\0" __FILE__ ":" "719""738")); | - | ||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | connect(d->model, qFlagLocation("2""modelReset()" "\0" __FILE__ ":" "721""740"), this, qFlagLocation("1""reset()" "\0" __FILE__ ":" "721""740")); | - | ||||||||||||||||||
| 284 | connect(d->model, qFlagLocation("2""layoutChanged()" "\0" __FILE__ ":" "722""741"), this, qFlagLocation("1""_q_layoutChanged()" "\0" __FILE__ ":" "722""741")); | - | ||||||||||||||||||
| 285 | } | - | ||||||||||||||||||
| 286 | - | |||||||||||||||||||
| 287 | QItemSelectionModel *selection_model = new QItemSelectionModel(d->model, this); | - | ||||||||||||||||||
| 288 | connect(d->model, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "726""745"), selection_model, qFlagLocation("1""deleteLater()" "\0" __FILE__ ":" "726""745")); | - | ||||||||||||||||||
| 289 | setSelectionModel(selection_model); | - | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | reset(); | - | ||||||||||||||||||
| 292 | } | - | ||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | QAbstractItemModel *QAbstractItemView::model() const | - | ||||||||||||||||||
| 298 | { | - | ||||||||||||||||||
| 299 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 300 | return (d->model == QAbstractItemModelPrivate::staticEmptyModel() ? 0 : d->model); | - | ||||||||||||||||||
| 301 | } | - | ||||||||||||||||||
| 302 | void QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel) | - | ||||||||||||||||||
| 303 | { | - | ||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | ((!(selectionModel)) ? qt_assert("selectionModel",__FILE__,758777) : qt_noop()); | - | ||||||||||||||||||
| 306 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | if (__builtin_expect(!!(
| 0 | ||||||||||||||||||
| 309 | QMessageLogger(__FILE__, 762781, __PRETTY_FUNCTION__).warning("QAbstractItemView::setSelectionModel() failed: " | - | ||||||||||||||||||
| 310 | "Trying to set a selection model, which works on " | - | ||||||||||||||||||
| 311 | "a different model than the view."); | - | ||||||||||||||||||
| 312 | return; never executed: return; | 0 | ||||||||||||||||||
| 313 | } | - | ||||||||||||||||||
| 314 | - | |||||||||||||||||||
| 315 | QItemSelection oldSelection; | - | ||||||||||||||||||
| 316 | QModelIndex oldCurrentIndex; | - | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | if (d->selectionModel
| 0 | ||||||||||||||||||
| 319 | if (d->selectionModel->model() == selectionModel->model()
| 0 | ||||||||||||||||||
| 320 | oldSelection = d->selectionModel->selection(); | - | ||||||||||||||||||
| 321 | oldCurrentIndex = d->selectionModel->currentIndex(); | - | ||||||||||||||||||
| 322 | } never executed: end of block | 0 | ||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | disconnect(d->selectionModel, qFlagLocation("2""selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "777""796"), | - | ||||||||||||||||||
| 325 | this, qFlagLocation("1""selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "778""797")); | - | ||||||||||||||||||
| 326 | disconnect(d->selectionModel, qFlagLocation("2""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "779""798"), | - | ||||||||||||||||||
| 327 | this, qFlagLocation("1""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "780""799")); | - | ||||||||||||||||||
| 328 | } never executed: end of block | 0 | ||||||||||||||||||
| 329 | - | |||||||||||||||||||
| 330 | d->selectionModel = selectionModel; | - | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | if (d->selectionModel
| 0 | ||||||||||||||||||
| 333 | connect(d->selectionModel, qFlagLocation("2""selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "786""805"), | - | ||||||||||||||||||
| 334 | this, qFlagLocation("1""selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "787""806")); | - | ||||||||||||||||||
| 335 | connect(d->selectionModel, qFlagLocation("2""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "788""807"), | - | ||||||||||||||||||
| 336 | this, qFlagLocation("1""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "789""808")); | - | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | selectionChanged(d->selectionModel->selection(), oldSelection); | - | ||||||||||||||||||
| 339 | currentChanged(d->selectionModel->currentIndex(), oldCurrentIndex); | - | ||||||||||||||||||
| 340 | } never executed: end of block | 0 | ||||||||||||||||||
| 341 | } never executed: end of block | 0 | ||||||||||||||||||
| 342 | - | |||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | - | |||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | QItemSelectionModel* QAbstractItemView::selectionModel() const | - | ||||||||||||||||||
| 349 | { | - | ||||||||||||||||||
| 350 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 351 | return d->selectionModel; | - | ||||||||||||||||||
| 352 | } | - | ||||||||||||||||||
| 353 | void QAbstractItemView::setItemDelegate(QAbstractItemDelegate *delegate) | - | ||||||||||||||||||
| 354 | { | - | ||||||||||||||||||
| 355 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 356 | if (delegate == d->itemDelegate) | - | ||||||||||||||||||
| 357 | return; | - | ||||||||||||||||||
| 358 | - | |||||||||||||||||||
| 359 | if (d->itemDelegate) { | - | ||||||||||||||||||
| 360 | if (d->delegateRefCount(d->itemDelegate) == 1) { | - | ||||||||||||||||||
| 361 | disconnect(d->itemDelegate, qFlagLocation("2""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "830""849"), | - | ||||||||||||||||||
| 362 | this, qFlagLocation("1""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "831""850")); | - | ||||||||||||||||||
| 363 | disconnect(d->itemDelegate, qFlagLocation("2""commitData(QWidget*)" "\0" __FILE__ ":" "832""851"), this, qFlagLocation("1""commitData(QWidget*)" "\0" __FILE__ ":" "832""851")); | - | ||||||||||||||||||
| 364 | disconnect(d->itemDelegate, qFlagLocation("2""sizeHintChanged(QModelIndex)" "\0" __FILE__ ":" "833""852"), this, qFlagLocation("1""doItemsLayout()" "\0" __FILE__ ":" "833""852")); | - | ||||||||||||||||||
| 365 | } | - | ||||||||||||||||||
| 366 | } | - | ||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | if (delegate) { | - | ||||||||||||||||||
| 369 | if (d->delegateRefCount(delegate) == 0) { | - | ||||||||||||||||||
| 370 | connect(delegate, qFlagLocation("2""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "839""858"), | - | ||||||||||||||||||
| 371 | this, qFlagLocation("1""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "840""859")); | - | ||||||||||||||||||
| 372 | connect(delegate, qFlagLocation("2""commitData(QWidget*)" "\0" __FILE__ ":" "841""860"), this, qFlagLocation("1""commitData(QWidget*)" "\0" __FILE__ ":" "841""860")); | - | ||||||||||||||||||
| 373 | connect(delegate, qFlagLocation("2""sizeHintChanged(QModelIndex)" "\0" __FILE__ ":" "842""861"), this, qFlagLocation("1""doItemsLayout()" "\0" __FILE__ ":" "842""861"), Qt::QueuedConnection); | - | ||||||||||||||||||
| 374 | } | - | ||||||||||||||||||
| 375 | } | - | ||||||||||||||||||
| 376 | d->itemDelegate = delegate; | - | ||||||||||||||||||
| 377 | viewport()->update(); | - | ||||||||||||||||||
| 378 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||
| 379 | } | - | ||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | - | |||||||||||||||||||
| 382 | - | |||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | - | |||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | QAbstractItemDelegate *QAbstractItemView::itemDelegate() const | - | ||||||||||||||||||
| 388 | { | - | ||||||||||||||||||
| 389 | return d_func()->itemDelegate; | - | ||||||||||||||||||
| 390 | } | - | ||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | - | |||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | QVariant QAbstractItemView::inputMethodQuery(Qt::InputMethodQuery query) const | - | ||||||||||||||||||
| 396 | { | - | ||||||||||||||||||
| 397 | const QModelIndex current = currentIndex(); | - | ||||||||||||||||||
| 398 | if (!current.isValid() || query != Qt::ImCursorRectangle) | - | ||||||||||||||||||
| 399 | return QAbstractScrollArea::inputMethodQuery(query); | - | ||||||||||||||||||
| 400 | return visualRect(current); | - | ||||||||||||||||||
| 401 | } | - | ||||||||||||||||||
| 402 | void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *delegate) | - | ||||||||||||||||||
| 403 | { | - | ||||||||||||||||||
| 404 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 405 | if (QAbstractItemDelegate *rowDelegate = d->rowDelegates.value(row, 0)) { | - | ||||||||||||||||||
| 406 | if (d->delegateRefCount(rowDelegate) == 1) { | - | ||||||||||||||||||
| 407 | disconnect(rowDelegate, qFlagLocation("2""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "898""917"), | - | ||||||||||||||||||
| 408 | this, qFlagLocation("1""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "899""918")); | - | ||||||||||||||||||
| 409 | disconnect(rowDelegate, qFlagLocation("2""commitData(QWidget*)" "\0" __FILE__ ":" "900""919"), this, qFlagLocation("1""commitData(QWidget*)" "\0" __FILE__ ":" "900""919")); | - | ||||||||||||||||||
| 410 | disconnect(rowDelegate, qFlagLocation("2""sizeHintChanged(QModelIndex)" "\0" __FILE__ ":" "901""920"), this, qFlagLocation("1""doItemsLayout()" "\0" __FILE__ ":" "901""920")); | - | ||||||||||||||||||
| 411 | } | - | ||||||||||||||||||
| 412 | d->rowDelegates.remove(row); | - | ||||||||||||||||||
| 413 | } | - | ||||||||||||||||||
| 414 | if (delegate) { | - | ||||||||||||||||||
| 415 | if (d->delegateRefCount(delegate) == 0) { | - | ||||||||||||||||||
| 416 | connect(delegate, qFlagLocation("2""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "907""926"), | - | ||||||||||||||||||
| 417 | this, qFlagLocation("1""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "908""927")); | - | ||||||||||||||||||
| 418 | connect(delegate, qFlagLocation("2""commitData(QWidget*)" "\0" __FILE__ ":" "909""928"), this, qFlagLocation("1""commitData(QWidget*)" "\0" __FILE__ ":" "909""928")); | - | ||||||||||||||||||
| 419 | connect(delegate, qFlagLocation("2""sizeHintChanged(QModelIndex)" "\0" __FILE__ ":" "910""929"), this, qFlagLocation("1""doItemsLayout()" "\0" __FILE__ ":" "910""929"), Qt::QueuedConnection); | - | ||||||||||||||||||
| 420 | } | - | ||||||||||||||||||
| 421 | d->rowDelegates.insert(row, delegate); | - | ||||||||||||||||||
| 422 | } | - | ||||||||||||||||||
| 423 | viewport()->update(); | - | ||||||||||||||||||
| 424 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||
| 425 | } | - | ||||||||||||||||||
| 426 | QAbstractItemDelegate *QAbstractItemView::itemDelegateForRow(int row) const | - | ||||||||||||||||||
| 427 | { | - | ||||||||||||||||||
| 428 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 429 | return d->rowDelegates.value(row, 0); | - | ||||||||||||||||||
| 430 | } | - | ||||||||||||||||||
| 431 | void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate) | - | ||||||||||||||||||
| 432 | { | - | ||||||||||||||||||
| 433 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 434 | if (QAbstractItemDelegate *columnDelegate = d->columnDelegates.value(column, 0)) { | - | ||||||||||||||||||
| 435 | if (d->delegateRefCount(columnDelegate) == 1) { | - | ||||||||||||||||||
| 436 | disconnect(columnDelegate, qFlagLocation("2""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "958""977"), | - | ||||||||||||||||||
| 437 | this, qFlagLocation("1""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "959""978")); | - | ||||||||||||||||||
| 438 | disconnect(columnDelegate, qFlagLocation("2""commitData(QWidget*)" "\0" __FILE__ ":" "960""979"), this, qFlagLocation("1""commitData(QWidget*)" "\0" __FILE__ ":" "960""979")); | - | ||||||||||||||||||
| 439 | disconnect(columnDelegate, qFlagLocation("2""sizeHintChanged(QModelIndex)" "\0" __FILE__ ":" "961""980"), this, qFlagLocation("1""doItemsLayout()" "\0" __FILE__ ":" "961""980")); | - | ||||||||||||||||||
| 440 | } | - | ||||||||||||||||||
| 441 | d->columnDelegates.remove(column); | - | ||||||||||||||||||
| 442 | } | - | ||||||||||||||||||
| 443 | if (delegate) { | - | ||||||||||||||||||
| 444 | if (d->delegateRefCount(delegate) == 0) { | - | ||||||||||||||||||
| 445 | connect(delegate, qFlagLocation("2""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "967""986"), | - | ||||||||||||||||||
| 446 | this, qFlagLocation("1""closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)" "\0" __FILE__ ":" "968""987")); | - | ||||||||||||||||||
| 447 | connect(delegate, qFlagLocation("2""commitData(QWidget*)" "\0" __FILE__ ":" "969""988"), this, qFlagLocation("1""commitData(QWidget*)" "\0" __FILE__ ":" "969""988")); | - | ||||||||||||||||||
| 448 | connect(delegate, qFlagLocation("2""sizeHintChanged(QModelIndex)" "\0" __FILE__ ":" "970""989"), this, qFlagLocation("1""doItemsLayout()" "\0" __FILE__ ":" "970""989"), Qt::QueuedConnection); | - | ||||||||||||||||||
| 449 | } | - | ||||||||||||||||||
| 450 | d->columnDelegates.insert(column, delegate); | - | ||||||||||||||||||
| 451 | } | - | ||||||||||||||||||
| 452 | viewport()->update(); | - | ||||||||||||||||||
| 453 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||
| 454 | } | - | ||||||||||||||||||
| 455 | QAbstractItemDelegate *QAbstractItemView::itemDelegateForColumn(int column) const | - | ||||||||||||||||||
| 456 | { | - | ||||||||||||||||||
| 457 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 458 | return d->columnDelegates.value(column, 0); | - | ||||||||||||||||||
| 459 | } | - | ||||||||||||||||||
| 460 | - | |||||||||||||||||||
| 461 | - | |||||||||||||||||||
| 462 | - | |||||||||||||||||||
| 463 | - | |||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | QAbstractItemDelegate *QAbstractItemView::itemDelegate(const QModelIndex &index) const | - | ||||||||||||||||||
| 466 | { | - | ||||||||||||||||||
| 467 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 468 | return d->delegateForIndex(index); | - | ||||||||||||||||||
| 469 | } | - | ||||||||||||||||||
| 470 | void QAbstractItemView::setSelectionMode(SelectionMode mode) | - | ||||||||||||||||||
| 471 | { | - | ||||||||||||||||||
| 472 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 473 | d->selectionMode = mode; | - | ||||||||||||||||||
| 474 | } | - | ||||||||||||||||||
| 475 | - | |||||||||||||||||||
| 476 | QAbstractItemView::SelectionMode QAbstractItemView::selectionMode() const | - | ||||||||||||||||||
| 477 | { | - | ||||||||||||||||||
| 478 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 479 | return d->selectionMode; | - | ||||||||||||||||||
| 480 | } | - | ||||||||||||||||||
| 481 | void QAbstractItemView::setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior) | - | ||||||||||||||||||
| 482 | { | - | ||||||||||||||||||
| 483 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 484 | d->selectionBehavior = behavior; | - | ||||||||||||||||||
| 485 | } | - | ||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | QAbstractItemView::SelectionBehavior QAbstractItemView::selectionBehavior() const | - | ||||||||||||||||||
| 488 | { | - | ||||||||||||||||||
| 489 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 490 | return d->selectionBehavior; | - | ||||||||||||||||||
| 491 | } | - | ||||||||||||||||||
| 492 | void QAbstractItemView::setCurrentIndex(const QModelIndex &index) | - | ||||||||||||||||||
| 493 | { | - | ||||||||||||||||||
| 494 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 495 | if (d->selectionModel && (!index.isValid() || d->isIndexEnabled(index))) { | - | ||||||||||||||||||
| 496 | QItemSelectionModel::SelectionFlags command = selectionCommand(index, 0); | - | ||||||||||||||||||
| 497 | d->selectionModel->setCurrentIndex(index, command); | - | ||||||||||||||||||
| 498 | d->currentIndexSet = true; | - | ||||||||||||||||||
| 499 | if ((command & QItemSelectionModel::Current) == 0) | - | ||||||||||||||||||
| 500 | d->currentSelectionStartIndex = index; | - | ||||||||||||||||||
| 501 | } | - | ||||||||||||||||||
| 502 | } | - | ||||||||||||||||||
| 503 | - | |||||||||||||||||||
| 504 | - | |||||||||||||||||||
| 505 | - | |||||||||||||||||||
| 506 | - | |||||||||||||||||||
| 507 | - | |||||||||||||||||||
| 508 | - | |||||||||||||||||||
| 509 | QModelIndex QAbstractItemView::currentIndex() const | - | ||||||||||||||||||
| 510 | { | - | ||||||||||||||||||
| 511 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 512 | return d->selectionModel ? d->selectionModel->currentIndex() : QModelIndex(); | - | ||||||||||||||||||
| 513 | } | - | ||||||||||||||||||
| 514 | void QAbstractItemView::reset() | - | ||||||||||||||||||
| 515 | { | - | ||||||||||||||||||
| 516 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 517 | d->delayedReset.stop(); | - | ||||||||||||||||||
| 518 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->indexEditorHash)>::type> _container_((d->indexEditorHash)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QEditorInfo &info = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
| 519 | if (info.widget) | - | ||||||||||||||||||
| 520 | d->releaseEditor(info.widget.data(), d->indexForEditor(info.widget.data())); | - | ||||||||||||||||||
| 521 | } | - | ||||||||||||||||||
| 522 | d->editorIndexHash.clear(); | - | ||||||||||||||||||
| 523 | d->indexEditorHash.clear(); | - | ||||||||||||||||||
| 524 | d->persistent.clear(); | - | ||||||||||||||||||
| 525 | d->currentIndexSet = false; | - | ||||||||||||||||||
| 526 | setState(NoState); | - | ||||||||||||||||||
| 527 | setRootIndex(QModelIndex()); | - | ||||||||||||||||||
| 528 | if (d->selectionModel) | - | ||||||||||||||||||
| 529 | d->selectionModel->reset(); | - | ||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 | if (QAccessible::isActive()) { | - | ||||||||||||||||||
| 532 | QAccessibleTableModelChangeEvent accessibleEvent(this, QAccessibleTableModelChangeEvent::ModelReset); | - | ||||||||||||||||||
| 533 | QAccessible::updateAccessibility(&accessibleEvent); | - | ||||||||||||||||||
| 534 | } | - | ||||||||||||||||||
| 535 | - | |||||||||||||||||||
| 536 | d->updateGeometry(); | - | ||||||||||||||||||
| 537 | } | - | ||||||||||||||||||
| 538 | - | |||||||||||||||||||
| 539 | - | |||||||||||||||||||
| 540 | - | |||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | - | |||||||||||||||||||
| 543 | - | |||||||||||||||||||
| 544 | void QAbstractItemView::setRootIndex(const QModelIndex &index) | - | ||||||||||||||||||
| 545 | { | - | ||||||||||||||||||
| 546 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 547 | if (__builtin_expect(!!(
| 0 | ||||||||||||||||||
| 548 | QMessageLogger(__FILE__, 11281147, __PRETTY_FUNCTION__).warning("QAbstractItemView::setRootIndex failed : index must be from the currently set model"); | - | ||||||||||||||||||
| 549 | return; never executed: return; | 0 | ||||||||||||||||||
| 550 | } | - | ||||||||||||||||||
| 551 | d->root = index; | - | ||||||||||||||||||
| 552 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||
| 553 | d->updateGeometry(); | - | ||||||||||||||||||
| 554 | } never executed: end of block | 0 | ||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | - | |||||||||||||||||||
| 558 | - | |||||||||||||||||||
| 559 | - | |||||||||||||||||||
| 560 | - | |||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | QModelIndex QAbstractItemView::rootIndex() const | - | ||||||||||||||||||
| 563 | { | - | ||||||||||||||||||
| 564 | return QModelIndex(d_func()->root); | - | ||||||||||||||||||
| 565 | } | - | ||||||||||||||||||
| 566 | void QAbstractItemView::selectAll() | - | ||||||||||||||||||
| 567 | { | - | ||||||||||||||||||
| 568 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 569 | SelectionMode mode = d->selectionMode; | - | ||||||||||||||||||
| 570 | if (mode == MultiSelection || mode == ExtendedSelection) | - | ||||||||||||||||||
| 571 | d->selectAll(QItemSelectionModel::ClearAndSelect | - | ||||||||||||||||||
| 572 | |d->selectionBehaviorFlags()); | - | ||||||||||||||||||
| 573 | else if (mode != SingleSelection) | - | ||||||||||||||||||
| 574 | d->selectAll(selectionCommand(d->model->index(0, 0, d->root))); | - | ||||||||||||||||||
| 575 | } | - | ||||||||||||||||||
| 576 | void QAbstractItemView::edit(const QModelIndex &index) | - | ||||||||||||||||||
| 577 | { | - | ||||||||||||||||||
| 578 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 579 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||||||||
| 580 | QMessageLogger(__FILE__, 11811200, __PRETTY_FUNCTION__).warning("edit: index was invalid"); never executed: QMessageLogger(__FILE__, 1200, __PRETTY_FUNCTION__).warning("edit: index was invalid"); | 0 | ||||||||||||||||||
| 581 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||||||||
| 582 | QMessageLogger(__FILE__, 11831202, __PRETTY_FUNCTION__).warning("edit: editing failed"); never executed: QMessageLogger(__FILE__, 1202, __PRETTY_FUNCTION__).warning("edit: editing failed"); | 0 | ||||||||||||||||||
| 583 | } never executed: end of block | 0 | ||||||||||||||||||
| 584 | - | |||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | - | |||||||||||||||||||
| 587 | - | |||||||||||||||||||
| 588 | - | |||||||||||||||||||
| 589 | - | |||||||||||||||||||
| 590 | void QAbstractItemView::clearSelection() | - | ||||||||||||||||||
| 591 | { | - | ||||||||||||||||||
| 592 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 593 | if (d->selectionModel) | - | ||||||||||||||||||
| 594 | d->selectionModel->clearSelection(); | - | ||||||||||||||||||
| 595 | } | - | ||||||||||||||||||
| 596 | - | |||||||||||||||||||
| 597 | - | |||||||||||||||||||
| 598 | - | |||||||||||||||||||
| 599 | - | |||||||||||||||||||
| 600 | - | |||||||||||||||||||
| 601 | - | |||||||||||||||||||
| 602 | - | |||||||||||||||||||
| 603 | void QAbstractItemView::doItemsLayout() | - | ||||||||||||||||||
| 604 | { | - | ||||||||||||||||||
| 605 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 606 | d->interruptDelayedItemsLayout(); | - | ||||||||||||||||||
| 607 | updateGeometries(); | - | ||||||||||||||||||
| 608 | d->viewport->update(); | - | ||||||||||||||||||
| 609 | } | - | ||||||||||||||||||
| 610 | void QAbstractItemView::setEditTriggers(EditTriggers actions) | - | ||||||||||||||||||
| 611 | { | - | ||||||||||||||||||
| 612 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 613 | d->editTriggers = actions; | - | ||||||||||||||||||
| 614 | } | - | ||||||||||||||||||
| 615 | - | |||||||||||||||||||
| 616 | QAbstractItemView::EditTriggers QAbstractItemView::editTriggers() const | - | ||||||||||||||||||
| 617 | { | - | ||||||||||||||||||
| 618 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 619 | return d->editTriggers; | - | ||||||||||||||||||
| 620 | } | - | ||||||||||||||||||
| 621 | void QAbstractItemView::setVerticalScrollMode(ScrollMode mode) | - | ||||||||||||||||||
| 622 | { | - | ||||||||||||||||||
| 623 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 624 | d->verticalScrollModeSet = true; | - | ||||||||||||||||||
| 625 | if (mode == d->verticalScrollMode
| 0 | ||||||||||||||||||
| 626 | return; never executed: return; | 0 | ||||||||||||||||||
| 627 | QModelIndex topLeft = indexAt(QPoint(0, 0)); | - | ||||||||||||||||||
| 628 | d->verticalScrollMode = mode; | - | ||||||||||||||||||
| 629 | if (mode == ScrollPerItem
| 0 | ||||||||||||||||||
| 630 | verticalScrollBar()->d_func()->itemviewChangeSingleStep(1); never executed: verticalScrollBar()->d_func()->itemviewChangeSingleStep(1); | 0 | ||||||||||||||||||
| 631 | else | - | ||||||||||||||||||
| 632 | verticalScrollBar()->setSingleStep(-1); never executed: verticalScrollBar()->setSingleStep(-1); | 0 | ||||||||||||||||||
| 633 | updateGeometries(); | - | ||||||||||||||||||
| 634 | scrollTo(topLeft, QAbstractItemView::PositionAtTop); | - | ||||||||||||||||||
| 635 | } never executed: end of block | 0 | ||||||||||||||||||
| 636 | - | |||||||||||||||||||
| 637 | QAbstractItemView::ScrollMode QAbstractItemView::verticalScrollMode() const | - | ||||||||||||||||||
| 638 | { | - | ||||||||||||||||||
| 639 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 640 | return d->verticalScrollMode; | - | ||||||||||||||||||
| 641 | } | - | ||||||||||||||||||
| 642 | - | |||||||||||||||||||
| 643 | void QAbstractItemView::resetVerticalScrollMode() | - | ||||||||||||||||||
| 644 | { | - | ||||||||||||||||||
| 645 | auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, this, 0)); | - | ||||||||||||||||||
| 646 | setVerticalScrollMode(sm); | - | ||||||||||||||||||
| 647 | d_func()->verticalScrollModeSet = false; | - | ||||||||||||||||||
| 648 | } never executed: end of block | 0 | ||||||||||||||||||
| 649 | void QAbstractItemView::setHorizontalScrollMode(ScrollMode mode) | - | ||||||||||||||||||
| 650 | { | - | ||||||||||||||||||
| 651 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 652 | d->horizontalScrollModeSet = true; | - | ||||||||||||||||||
| 653 | if (mode == d->horizontalScrollMode
| 0 | ||||||||||||||||||
| 654 | return; never executed: return; | 0 | ||||||||||||||||||
| 655 | d->horizontalScrollMode = mode; | - | ||||||||||||||||||
| 656 | if (mode == ScrollPerItem
| 0 | ||||||||||||||||||
| 657 | horizontalScrollBar()->d_func()->itemviewChangeSingleStep(1); never executed: horizontalScrollBar()->d_func()->itemviewChangeSingleStep(1); | 0 | ||||||||||||||||||
| 658 | else | - | ||||||||||||||||||
| 659 | horizontalScrollBar()->setSingleStep(-1); never executed: horizontalScrollBar()->setSingleStep(-1); | 0 | ||||||||||||||||||
| 660 | updateGeometries(); | - | ||||||||||||||||||
| 661 | } never executed: end of block | 0 | ||||||||||||||||||
| 662 | - | |||||||||||||||||||
| 663 | QAbstractItemView::ScrollMode QAbstractItemView::horizontalScrollMode() const | - | ||||||||||||||||||
| 664 | { | - | ||||||||||||||||||
| 665 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 666 | return d->horizontalScrollMode; | - | ||||||||||||||||||
| 667 | } | - | ||||||||||||||||||
| 668 | - | |||||||||||||||||||
| 669 | void QAbstractItemView::resetHorizontalScrollMode() | - | ||||||||||||||||||
| 670 | { | - | ||||||||||||||||||
| 671 | auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, this, 0)); | - | ||||||||||||||||||
| 672 | setHorizontalScrollMode(sm); | - | ||||||||||||||||||
| 673 | d_func()->horizontalScrollModeSet = false; | - | ||||||||||||||||||
| 674 | } never executed: end of block | 0 | ||||||||||||||||||
| 675 | void QAbstractItemView::setDragDropOverwriteMode(bool overwrite) | - | ||||||||||||||||||
| 676 | { | - | ||||||||||||||||||
| 677 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 678 | d->overwrite = overwrite; | - | ||||||||||||||||||
| 679 | } | - | ||||||||||||||||||
| 680 | - | |||||||||||||||||||
| 681 | bool QAbstractItemView::dragDropOverwriteMode() const | - | ||||||||||||||||||
| 682 | { | - | ||||||||||||||||||
| 683 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 684 | return d->overwrite; | - | ||||||||||||||||||
| 685 | } | - | ||||||||||||||||||
| 686 | void QAbstractItemView::setAutoScroll(bool enable) | - | ||||||||||||||||||
| 687 | { | - | ||||||||||||||||||
| 688 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 689 | d->autoScroll = enable; | - | ||||||||||||||||||
| 690 | } | - | ||||||||||||||||||
| 691 | - | |||||||||||||||||||
| 692 | bool QAbstractItemView::hasAutoScroll() const | - | ||||||||||||||||||
| 693 | { | - | ||||||||||||||||||
| 694 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 695 | return d->autoScroll; | - | ||||||||||||||||||
| 696 | } | - | ||||||||||||||||||
| 697 | void QAbstractItemView::setAutoScrollMargin(int margin) | - | ||||||||||||||||||
| 698 | { | - | ||||||||||||||||||
| 699 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 700 | d->autoScrollMargin = margin; | - | ||||||||||||||||||
| 701 | } | - | ||||||||||||||||||
| 702 | - | |||||||||||||||||||
| 703 | int QAbstractItemView::autoScrollMargin() const | - | ||||||||||||||||||
| 704 | { | - | ||||||||||||||||||
| 705 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 706 | return d->autoScrollMargin; | - | ||||||||||||||||||
| 707 | } | - | ||||||||||||||||||
| 708 | - | |||||||||||||||||||
| 709 | - | |||||||||||||||||||
| 710 | - | |||||||||||||||||||
| 711 | - | |||||||||||||||||||
| 712 | - | |||||||||||||||||||
| 713 | - | |||||||||||||||||||
| 714 | void QAbstractItemView::setTabKeyNavigation(bool enable) | - | ||||||||||||||||||
| 715 | { | - | ||||||||||||||||||
| 716 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 717 | d->tabKeyNavigation = enable; | - | ||||||||||||||||||
| 718 | } | - | ||||||||||||||||||
| 719 | - | |||||||||||||||||||
| 720 | bool QAbstractItemView::tabKeyNavigation() const | - | ||||||||||||||||||
| 721 | { | - | ||||||||||||||||||
| 722 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 723 | return d->tabKeyNavigation; | - | ||||||||||||||||||
| 724 | } | - | ||||||||||||||||||
| 725 | - | |||||||||||||||||||
| 726 | - | |||||||||||||||||||
| 727 | - | |||||||||||||||||||
| 728 | - | |||||||||||||||||||
| 729 | - | |||||||||||||||||||
| 730 | QSize QAbstractItemView::viewportSizeHint() const | - | ||||||||||||||||||
| 731 | { | - | ||||||||||||||||||
| 732 | return QAbstractScrollArea::viewportSizeHint(); | - | ||||||||||||||||||
| 733 | } | - | ||||||||||||||||||
| 734 | void QAbstractItemView::setDropIndicatorShown(bool enable) | - | ||||||||||||||||||
| 735 | { | - | ||||||||||||||||||
| 736 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 737 | d->showDropIndicator = enable; | - | ||||||||||||||||||
| 738 | } | - | ||||||||||||||||||
| 739 | - | |||||||||||||||||||
| 740 | bool QAbstractItemView::showDropIndicator() const | - | ||||||||||||||||||
| 741 | { | - | ||||||||||||||||||
| 742 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 743 | return d->showDropIndicator; | - | ||||||||||||||||||
| 744 | } | - | ||||||||||||||||||
| 745 | void QAbstractItemView::setDragEnabled(bool enable) | - | ||||||||||||||||||
| 746 | { | - | ||||||||||||||||||
| 747 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 748 | d->dragEnabled = enable; | - | ||||||||||||||||||
| 749 | } | - | ||||||||||||||||||
| 750 | - | |||||||||||||||||||
| 751 | bool QAbstractItemView::dragEnabled() const | - | ||||||||||||||||||
| 752 | { | - | ||||||||||||||||||
| 753 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 754 | return d->dragEnabled; | - | ||||||||||||||||||
| 755 | } | - | ||||||||||||||||||
| 756 | void QAbstractItemView::setDragDropMode(DragDropMode behavior) | - | ||||||||||||||||||
| 757 | { | - | ||||||||||||||||||
| 758 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 759 | d->dragDropMode = behavior; | - | ||||||||||||||||||
| 760 | setDragEnabled(behavior == DragOnly || behavior == DragDrop || behavior == InternalMove); | - | ||||||||||||||||||
| 761 | setAcceptDrops(behavior == DropOnly || behavior == DragDrop || behavior == InternalMove); | - | ||||||||||||||||||
| 762 | } | - | ||||||||||||||||||
| 763 | - | |||||||||||||||||||
| 764 | QAbstractItemView::DragDropMode QAbstractItemView::dragDropMode() const | - | ||||||||||||||||||
| 765 | { | - | ||||||||||||||||||
| 766 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 767 | DragDropMode setBehavior = d->dragDropMode; | - | ||||||||||||||||||
| 768 | if (!dragEnabled() && !acceptDrops()) | - | ||||||||||||||||||
| 769 | return NoDragDrop; | - | ||||||||||||||||||
| 770 | - | |||||||||||||||||||
| 771 | if (dragEnabled() && !acceptDrops()) | - | ||||||||||||||||||
| 772 | return DragOnly; | - | ||||||||||||||||||
| 773 | - | |||||||||||||||||||
| 774 | if (!dragEnabled() && acceptDrops()) | - | ||||||||||||||||||
| 775 | return DropOnly; | - | ||||||||||||||||||
| 776 | - | |||||||||||||||||||
| 777 | if (dragEnabled() && acceptDrops()) { | - | ||||||||||||||||||
| 778 | if (setBehavior == InternalMove) | - | ||||||||||||||||||
| 779 | return setBehavior; | - | ||||||||||||||||||
| 780 | else | - | ||||||||||||||||||
| 781 | return DragDrop; | - | ||||||||||||||||||
| 782 | } | - | ||||||||||||||||||
| 783 | - | |||||||||||||||||||
| 784 | return NoDragDrop; | - | ||||||||||||||||||
| 785 | } | - | ||||||||||||||||||
| 786 | void QAbstractItemView::setDefaultDropAction(Qt::DropAction dropAction) | - | ||||||||||||||||||
| 787 | { | - | ||||||||||||||||||
| 788 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 789 | d->defaultDropAction = dropAction; | - | ||||||||||||||||||
| 790 | } | - | ||||||||||||||||||
| 791 | - | |||||||||||||||||||
| 792 | Qt::DropAction QAbstractItemView::defaultDropAction() const | - | ||||||||||||||||||
| 793 | { | - | ||||||||||||||||||
| 794 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 795 | return d->defaultDropAction; | - | ||||||||||||||||||
| 796 | } | - | ||||||||||||||||||
| 797 | void QAbstractItemView::setAlternatingRowColors(bool enable) | - | ||||||||||||||||||
| 798 | { | - | ||||||||||||||||||
| 799 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 800 | d->alternatingColors = enable; | - | ||||||||||||||||||
| 801 | if (isVisible()) | - | ||||||||||||||||||
| 802 | d->viewport->update(); | - | ||||||||||||||||||
| 803 | } | - | ||||||||||||||||||
| 804 | - | |||||||||||||||||||
| 805 | bool QAbstractItemView::alternatingRowColors() const | - | ||||||||||||||||||
| 806 | { | - | ||||||||||||||||||
| 807 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 808 | return d->alternatingColors; | - | ||||||||||||||||||
| 809 | } | - | ||||||||||||||||||
| 810 | void QAbstractItemView::setIconSize(const QSize &size) | - | ||||||||||||||||||
| 811 | { | - | ||||||||||||||||||
| 812 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 813 | if (size == d->iconSize) | - | ||||||||||||||||||
| 814 | return; | - | ||||||||||||||||||
| 815 | d->iconSize = size; | - | ||||||||||||||||||
| 816 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||
| 817 | iconSizeChanged(size); | - | ||||||||||||||||||
| 818 | } | - | ||||||||||||||||||
| 819 | - | |||||||||||||||||||
| 820 | QSize QAbstractItemView::iconSize() const | - | ||||||||||||||||||
| 821 | { | - | ||||||||||||||||||
| 822 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 823 | return d->iconSize; | - | ||||||||||||||||||
| 824 | } | - | ||||||||||||||||||
| 825 | void QAbstractItemView::setTextElideMode(Qt::TextElideMode mode) | - | ||||||||||||||||||
| 826 | { | - | ||||||||||||||||||
| 827 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 828 | d->textElideMode = mode; | - | ||||||||||||||||||
| 829 | } | - | ||||||||||||||||||
| 830 | - | |||||||||||||||||||
| 831 | Qt::TextElideMode QAbstractItemView::textElideMode() const | - | ||||||||||||||||||
| 832 | { | - | ||||||||||||||||||
| 833 | return d_func()->textElideMode; | - | ||||||||||||||||||
| 834 | } | - | ||||||||||||||||||
| 835 | - | |||||||||||||||||||
| 836 | - | |||||||||||||||||||
| 837 | - | |||||||||||||||||||
| 838 | - | |||||||||||||||||||
| 839 | bool QAbstractItemView::focusNextPrevChild(bool next) | - | ||||||||||||||||||
| 840 | { | - | ||||||||||||||||||
| 841 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 842 | if (d->tabKeyNavigation && isEnabled() && d->viewport->isEnabled()) { | - | ||||||||||||||||||
| 843 | QKeyEvent event(QEvent::KeyPress, next ? Qt::Key_Tab : Qt::Key_Backtab, Qt::NoModifier); | - | ||||||||||||||||||
| 844 | keyPressEvent(&event); | - | ||||||||||||||||||
| 845 | if (event.isAccepted()) | - | ||||||||||||||||||
| 846 | return true; | - | ||||||||||||||||||
| 847 | } | - | ||||||||||||||||||
| 848 | return QAbstractScrollArea::focusNextPrevChild(next); | - | ||||||||||||||||||
| 849 | } | - | ||||||||||||||||||
| 850 | - | |||||||||||||||||||
| 851 | - | |||||||||||||||||||
| 852 | - | |||||||||||||||||||
| 853 | - | |||||||||||||||||||
| 854 | bool QAbstractItemView::event(QEvent *event) | - | ||||||||||||||||||
| 855 | { | - | ||||||||||||||||||
| 856 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 857 | switch (event->type()) { | - | ||||||||||||||||||
| 858 | case never executed: QEvent::Paint:case QEvent::Paint:never executed: case QEvent::Paint: | 0 | ||||||||||||||||||
| 859 | - | |||||||||||||||||||
| 860 | - | |||||||||||||||||||
| 861 | d->executePostedLayout(); | - | ||||||||||||||||||
| 862 | break; never executed: break; | 0 | ||||||||||||||||||
| 863 | case never executed: QEvent::Show:case QEvent::Show:never executed: case QEvent::Show: | 0 | ||||||||||||||||||
| 864 | d->executePostedLayout(); | - | ||||||||||||||||||
| 865 | if (d->shouldScrollToCurrentOnShow
| 0 | ||||||||||||||||||
| 866 | d->shouldScrollToCurrentOnShow = false; | - | ||||||||||||||||||
| 867 | const QModelIndex current = currentIndex(); | - | ||||||||||||||||||
| 868 | if (current.isValid()
| 0 | ||||||||||||||||||
| 869 | scrollTo(current); never executed: scrollTo(current); | 0 | ||||||||||||||||||
| 870 | } never executed: end of block | 0 | ||||||||||||||||||
| 871 | break; never executed: break; | 0 | ||||||||||||||||||
| 872 | case never executed: QEvent::LocaleChange:case QEvent::LocaleChange:never executed: case QEvent::LocaleChange: | 0 | ||||||||||||||||||
| 873 | viewport()->update(); | - | ||||||||||||||||||
| 874 | break; never executed: break; | 0 | ||||||||||||||||||
| 875 | case never executed: QEvent::LayoutDirectionChange:case QEvent::LayoutDirectionChange:never executed: case QEvent::LayoutDirectionChange: | 0 | ||||||||||||||||||
| 876 | case never executed: QEvent::ApplicationLayoutDirectionChange:case QEvent::ApplicationLayoutDirectionChange:never executed: case QEvent::ApplicationLayoutDirectionChange: | 0 | ||||||||||||||||||
| 877 | updateGeometries(); | - | ||||||||||||||||||
| 878 | break; never executed: break; | 0 | ||||||||||||||||||
| 879 | case never executed: QEvent::StyleChange:case QEvent::StyleChange:never executed: case QEvent::StyleChange: | 0 | ||||||||||||||||||
| 880 | doItemsLayout(); | - | ||||||||||||||||||
| 881 | if (!d->verticalScrollModeSet
| 0 | ||||||||||||||||||
| 882 | resetVerticalScrollMode(); never executed: resetVerticalScrollMode(); | 0 | ||||||||||||||||||
| 883 | if (!d->horizontalScrollModeSet
| 0 | ||||||||||||||||||
| 884 | resetHorizontalScrollMode never executed: resetHorizontalScrollMode();never executed: ();resetHorizontalScrollMode();never executed: resetHorizontalScrollMode(); | 0 | ||||||||||||||||||
| 885 | break; never executed: break; | 0 | ||||||||||||||||||
| 886 | case never executed: QEvent::FocusOut:case QEvent::FocusOut:never executed: case QEvent::FocusOut: | 0 | ||||||||||||||||||
| 887 | d->checkPersistentEditorFocus(); | - | ||||||||||||||||||
| 888 | break; never executed: break; | 0 | ||||||||||||||||||
| 889 | case never executed: QEvent::FontChange:case QEvent::FontChange:never executed: case QEvent::FontChange: | 0 | ||||||||||||||||||
| 890 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||
| 891 | break; never executed: break; | 0 | ||||||||||||||||||
| 892 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 893 | break; never executed: break; | 0 | ||||||||||||||||||
| 894 | } | - | ||||||||||||||||||
| 895 | return never executed: QAbstractScrollArea::event(event);return QAbstractScrollArea::event(event);never executed: return QAbstractScrollArea::event(event); | 0 | ||||||||||||||||||
| 896 | } | - | ||||||||||||||||||
| 897 | bool QAbstractItemView::viewportEvent(QEvent *event) | - | ||||||||||||||||||
| 898 | { | - | ||||||||||||||||||
| 899 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 900 | switch (event->type()) { | - | ||||||||||||||||||
| 901 | case QEvent::HoverMove: | - | ||||||||||||||||||
| 902 | case QEvent::HoverEnter: | - | ||||||||||||||||||
| 903 | d->setHoverIndex(indexAt(static_cast<QHoverEvent*>(event)->pos())); | - | ||||||||||||||||||
| 904 | break; | - | ||||||||||||||||||
| 905 | case QEvent::HoverLeave: | - | ||||||||||||||||||
| 906 | d->setHoverIndex(QModelIndex()); | - | ||||||||||||||||||
| 907 | break; | - | ||||||||||||||||||
| 908 | case QEvent::Enter: | - | ||||||||||||||||||
| 909 | d->viewportEnteredNeeded = true; | - | ||||||||||||||||||
| 910 | break; | - | ||||||||||||||||||
| 911 | case QEvent::Leave: | - | ||||||||||||||||||
| 912 | - | |||||||||||||||||||
| 913 | if (d->shouldClearStatusTip && d->parent) { | - | ||||||||||||||||||
| 914 | QString empty; | - | ||||||||||||||||||
| 915 | QStatusTipEvent tip(empty); | - | ||||||||||||||||||
| 916 | QApplication::sendEvent(d->parent, &tip); | - | ||||||||||||||||||
| 917 | d->shouldClearStatusTip = false; | - | ||||||||||||||||||
| 918 | } | - | ||||||||||||||||||
| 919 | - | |||||||||||||||||||
| 920 | d->enteredIndex = QModelIndex(); | - | ||||||||||||||||||
| 921 | break; | - | ||||||||||||||||||
| 922 | case QEvent::ToolTip: | - | ||||||||||||||||||
| 923 | case QEvent::QueryWhatsThis: | - | ||||||||||||||||||
| 924 | case QEvent::WhatsThis: { | - | ||||||||||||||||||
| 925 | QHelpEvent *he = static_cast<QHelpEvent*>(event); | - | ||||||||||||||||||
| 926 | const QModelIndex index = indexAt(he->pos()); | - | ||||||||||||||||||
| 927 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||
| 928 | option.rect = visualRect(index); | - | ||||||||||||||||||
| 929 | option.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None); | - | ||||||||||||||||||
| 930 | - | |||||||||||||||||||
| 931 | QAbstractItemDelegate *delegate = d->delegateForIndex(index); | - | ||||||||||||||||||
| 932 | if (!delegate) | - | ||||||||||||||||||
| 933 | return false; | - | ||||||||||||||||||
| 934 | return delegate->helpEvent(he, this, option, index); | - | ||||||||||||||||||
| 935 | } | - | ||||||||||||||||||
| 936 | case QEvent::FontChange: | - | ||||||||||||||||||
| 937 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||
| 938 | break; | - | ||||||||||||||||||
| 939 | case QEvent::WindowActivate: | - | ||||||||||||||||||
| 940 | case QEvent::WindowDeactivate: | - | ||||||||||||||||||
| 941 | d->viewport->update(); | - | ||||||||||||||||||
| 942 | break; | - | ||||||||||||||||||
| 943 | case QEvent::ScrollPrepare: | - | ||||||||||||||||||
| 944 | executeDelayedItemsLayout(); | - | ||||||||||||||||||
| 945 | - | |||||||||||||||||||
| 946 | connect(QScroller::scroller(d->viewport), qFlagLocation("2""stateChanged(QScroller::State)" "\0" __FILE__ ":" "1689""1740"), this, qFlagLocation("1""_q_scrollerStateChanged()" "\0" __FILE__ ":" "1689""1740"), Qt::UniqueConnection); | - | ||||||||||||||||||
| 947 | - | |||||||||||||||||||
| 948 | break; | - | ||||||||||||||||||
| 949 | - | |||||||||||||||||||
| 950 | default: | - | ||||||||||||||||||
| 951 | break; | - | ||||||||||||||||||
| 952 | } | - | ||||||||||||||||||
| 953 | return QAbstractScrollArea::viewportEvent(event); | - | ||||||||||||||||||
| 954 | } | - | ||||||||||||||||||
| 955 | - | |||||||||||||||||||
| 956 | - | |||||||||||||||||||
| 957 | - | |||||||||||||||||||
| 958 | - | |||||||||||||||||||
| 959 | - | |||||||||||||||||||
| 960 | - | |||||||||||||||||||
| 961 | void QAbstractItemView::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||
| 962 | { | - | ||||||||||||||||||
| 963 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 964 | d->delayedAutoScroll.stop(); | - | ||||||||||||||||||
| 965 | QPoint pos = event->pos(); | - | ||||||||||||||||||
| 966 | QPersistentModelIndex index = indexAt(pos); | - | ||||||||||||||||||
| 967 | - | |||||||||||||||||||
| 968 | if (!d->selectionModel | - | ||||||||||||||||||
| 969 | || (d->state == EditingState && d->hasEditor(index))) | - | ||||||||||||||||||
| 970 | return; | - | ||||||||||||||||||
| 971 | - | |||||||||||||||||||
| 972 | d->pressedAlreadySelected = d->selectionModel->isSelected(index); | - | ||||||||||||||||||
| 973 | d->pressedIndex = index; | - | ||||||||||||||||||
| 974 | d->pressedModifiers = event->modifiers(); | - | ||||||||||||||||||
| 975 | QItemSelectionModel::SelectionFlags command = selectionCommand(index, event); | - | ||||||||||||||||||
| 976 | d->noSelectionOnMousePress = command == QItemSelectionModel::NoUpdate || !index.isValid(); | - | ||||||||||||||||||
| 977 | QPoint offset = d->offset(); | - | ||||||||||||||||||
| 978 | if ((command & QItemSelectionModel::Current) == 0) { | - | ||||||||||||||||||
| 979 | d->pressedPosition = pos + offset; | - | ||||||||||||||||||
| 980 | d->currentSelectionStartIndex = index; | - | ||||||||||||||||||
| 981 | } | - | ||||||||||||||||||
| 982 | else if (!d->currentSelectionStartIndex.isValid()) | - | ||||||||||||||||||
| 983 | d->currentSelectionStartIndex = currentIndex(); | - | ||||||||||||||||||
| 984 | - | |||||||||||||||||||
| 985 | if (edit(index, NoEditTriggers, event)) | - | ||||||||||||||||||
| 986 | return; | - | ||||||||||||||||||
| 987 | - | |||||||||||||||||||
| 988 | if (index.isValid() && d->isIndexEnabled(index)) { | - | ||||||||||||||||||
| 989 | - | |||||||||||||||||||
| 990 | - | |||||||||||||||||||
| 991 | bool autoScroll = d->autoScroll; | - | ||||||||||||||||||
| 992 | d->autoScroll = false; | - | ||||||||||||||||||
| 993 | d->selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | - | ||||||||||||||||||
| 994 | d->autoScroll = autoScroll; | - | ||||||||||||||||||
| 995 | if (command.testFlag(QItemSelectionModel::Toggle)) { | - | ||||||||||||||||||
| 996 | command &= ~QItemSelectionModel::Toggle; | - | ||||||||||||||||||
| 997 | d->ctrlDragSelectionFlag = d->selectionModel->isSelected(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; | - | ||||||||||||||||||
| 998 | command |= d->ctrlDragSelectionFlag; | - | ||||||||||||||||||
| 999 | } | - | ||||||||||||||||||
| 1000 | - | |||||||||||||||||||
| 1001 | if ((command & QItemSelectionModel::Current) == 0) { | - | ||||||||||||||||||
| 1002 | setSelection(QRect(pos, QSize(1, 1)), command); | - | ||||||||||||||||||
| 1003 | } else { | - | ||||||||||||||||||
| 1004 | QRect rect(visualRect(d->currentSelectionStartIndex).center(), pos); | - | ||||||||||||||||||
| 1005 | setSelection(rect, command); | - | ||||||||||||||||||
| 1006 | } | - | ||||||||||||||||||
| 1007 | - | |||||||||||||||||||
| 1008 | - | |||||||||||||||||||
| 1009 | pressed(index); | - | ||||||||||||||||||
| 1010 | if (d->autoScroll) { | - | ||||||||||||||||||
| 1011 | - | |||||||||||||||||||
| 1012 | - | |||||||||||||||||||
| 1013 | d->delayedAutoScroll.start(QApplication::doubleClickInterval()+100, this); | - | ||||||||||||||||||
| 1014 | } | - | ||||||||||||||||||
| 1015 | - | |||||||||||||||||||
| 1016 | } else { | - | ||||||||||||||||||
| 1017 | - | |||||||||||||||||||
| 1018 | d->selectionModel->select(QModelIndex(), QItemSelectionModel::Select); | - | ||||||||||||||||||
| 1019 | } | - | ||||||||||||||||||
| 1020 | } | - | ||||||||||||||||||
| 1021 | - | |||||||||||||||||||
| 1022 | - | |||||||||||||||||||
| 1023 | - | |||||||||||||||||||
| 1024 | - | |||||||||||||||||||
| 1025 | - | |||||||||||||||||||
| 1026 | - | |||||||||||||||||||
| 1027 | void QAbstractItemView::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||
| 1028 | { | - | ||||||||||||||||||
| 1029 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1030 | QPoint topLeft; | - | ||||||||||||||||||
| 1031 | QPoint bottomRight = event->pos(); | - | ||||||||||||||||||
| 1032 | - | |||||||||||||||||||
| 1033 | if (state() == ExpandingState || state() == CollapsingState) | - | ||||||||||||||||||
| 1034 | return; | - | ||||||||||||||||||
| 1035 | - | |||||||||||||||||||
| 1036 | - | |||||||||||||||||||
| 1037 | if (state() == DraggingState) { | - | ||||||||||||||||||
| 1038 | topLeft = d->pressedPosition - d->offset(); | - | ||||||||||||||||||
| 1039 | if ((topLeft - bottomRight).manhattanLength() > QApplication::startDragDistance()) { | - | ||||||||||||||||||
| 1040 | d->pressedIndex = QModelIndex(); | - | ||||||||||||||||||
| 1041 | startDrag(d->model->supportedDragActions()); | - | ||||||||||||||||||
| 1042 | setState(NoState); | - | ||||||||||||||||||
| 1043 | stopAutoScroll(); | - | ||||||||||||||||||
| 1044 | } | - | ||||||||||||||||||
| 1045 | return; | - | ||||||||||||||||||
| 1046 | } | - | ||||||||||||||||||
| 1047 | - | |||||||||||||||||||
| 1048 | - | |||||||||||||||||||
| 1049 | QPersistentModelIndex index = indexAt(bottomRight); | - | ||||||||||||||||||
| 1050 | QModelIndex buddy = d->model->buddy(d->pressedIndex); | - | ||||||||||||||||||
| 1051 | if ((state() == EditingState && d->hasEditor(buddy)) | - | ||||||||||||||||||
| 1052 | || edit(index, NoEditTriggers, event)) | - | ||||||||||||||||||
| 1053 | return; | - | ||||||||||||||||||
| 1054 | - | |||||||||||||||||||
| 1055 | if (d->selectionMode != SingleSelection) | - | ||||||||||||||||||
| 1056 | topLeft = d->pressedPosition - d->offset(); | - | ||||||||||||||||||
| 1057 | else | - | ||||||||||||||||||
| 1058 | topLeft = bottomRight; | - | ||||||||||||||||||
| 1059 | - | |||||||||||||||||||
| 1060 | d->checkMouseMove(index); | - | ||||||||||||||||||
| 1061 | - | |||||||||||||||||||
| 1062 | - | |||||||||||||||||||
| 1063 | if (d->pressedIndex.isValid() | - | ||||||||||||||||||
| 1064 | && d->dragEnabled | - | ||||||||||||||||||
| 1065 | && (state() != DragSelectingState) | - | ||||||||||||||||||
| 1066 | && (event->buttons() != Qt::NoButton) | - | ||||||||||||||||||
| 1067 | && !d->selectedDraggableIndexes().isEmpty()) { | - | ||||||||||||||||||
| 1068 | setState(DraggingState); | - | ||||||||||||||||||
| 1069 | return; | - | ||||||||||||||||||
| 1070 | } | - | ||||||||||||||||||
| 1071 | - | |||||||||||||||||||
| 1072 | - | |||||||||||||||||||
| 1073 | if ((event->buttons() & Qt::LeftButton) && d->selectionAllowed(index) && d->selectionModel) { | - | ||||||||||||||||||
| 1074 | setState(DragSelectingState); | - | ||||||||||||||||||
| 1075 | QItemSelectionModel::SelectionFlags command = selectionCommand(index, event); | - | ||||||||||||||||||
| 1076 | if (d->ctrlDragSelectionFlag != QItemSelectionModel::NoUpdate && command.testFlag(QItemSelectionModel::Toggle)) { | - | ||||||||||||||||||
| 1077 | command &= ~QItemSelectionModel::Toggle; | - | ||||||||||||||||||
| 1078 | command |= d->ctrlDragSelectionFlag; | - | ||||||||||||||||||
| 1079 | } | - | ||||||||||||||||||
| 1080 | - | |||||||||||||||||||
| 1081 | - | |||||||||||||||||||
| 1082 | QRect selectionRect = QRect(topLeft, bottomRight); | - | ||||||||||||||||||
| 1083 | setSelection(selectionRect, command); | - | ||||||||||||||||||
| 1084 | - | |||||||||||||||||||
| 1085 | - | |||||||||||||||||||
| 1086 | if (index.isValid() | - | ||||||||||||||||||
| 1087 | && (index != d->selectionModel->currentIndex()) | - | ||||||||||||||||||
| 1088 | && d->isIndexEnabled(index)) | - | ||||||||||||||||||
| 1089 | d->selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | - | ||||||||||||||||||
| 1090 | } | - | ||||||||||||||||||
| 1091 | } | - | ||||||||||||||||||
| 1092 | void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||
| 1093 | { | - | ||||||||||||||||||
| 1094 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1095 | - | |||||||||||||||||||
| 1096 | QPoint pos = event->pos(); | - | ||||||||||||||||||
| 1097 | QPersistentModelIndex index = indexAt(pos); | - | ||||||||||||||||||
| 1098 | - | |||||||||||||||||||
| 1099 | if (state() == EditingState) { | - | ||||||||||||||||||
| 1100 | if (d->isIndexValid(index) | - | ||||||||||||||||||
| 1101 | && d->isIndexEnabled(index) | - | ||||||||||||||||||
| 1102 | && d->sendDelegateEvent(index, event)) | - | ||||||||||||||||||
| 1103 | update(index); | - | ||||||||||||||||||
| 1104 | return; | - | ||||||||||||||||||
| 1105 | } | - | ||||||||||||||||||
| 1106 | - | |||||||||||||||||||
| 1107 | bool click = (index == d->pressedIndex && index.isValid()); | - | ||||||||||||||||||
| 1108 | bool selectedClicked = click && (event->button() == Qt::LeftButton) && d->pressedAlreadySelected; | - | ||||||||||||||||||
| 1109 | EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers); | - | ||||||||||||||||||
| 1110 | bool edited = edit(index, trigger, event); | - | ||||||||||||||||||
| 1111 | - | |||||||||||||||||||
| 1112 | d->ctrlDragSelectionFlag = QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 1113 | - | |||||||||||||||||||
| 1114 | if (d->selectionModel && d->noSelectionOnMousePress) { | - | ||||||||||||||||||
| 1115 | d->noSelectionOnMousePress = false; | - | ||||||||||||||||||
| 1116 | d->selectionModel->select(index, selectionCommand(index, event)); | - | ||||||||||||||||||
| 1117 | } | - | ||||||||||||||||||
| 1118 | - | |||||||||||||||||||
| 1119 | setState(NoState); | - | ||||||||||||||||||
| 1120 | - | |||||||||||||||||||
| 1121 | if (click) { | - | ||||||||||||||||||
| 1122 | if (event->button() == Qt::LeftButton) | - | ||||||||||||||||||
| 1123 | clicked(index); | - | ||||||||||||||||||
| 1124 | if (edited) | - | ||||||||||||||||||
| 1125 | return; | - | ||||||||||||||||||
| 1126 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||
| 1127 | if (d->pressedAlreadySelected) | - | ||||||||||||||||||
| 1128 | option.state |= QStyle::State_Selected; | - | ||||||||||||||||||
| 1129 | if ((model()->flags(index) & Qt::ItemIsEnabled) | - | ||||||||||||||||||
| 1130 | && style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, &option, this)) | - | ||||||||||||||||||
| 1131 | activated(index); | - | ||||||||||||||||||
| 1132 | } | - | ||||||||||||||||||
| 1133 | } | - | ||||||||||||||||||
| 1134 | - | |||||||||||||||||||
| 1135 | - | |||||||||||||||||||
| 1136 | - | |||||||||||||||||||
| 1137 | - | |||||||||||||||||||
| 1138 | - | |||||||||||||||||||
| 1139 | - | |||||||||||||||||||
| 1140 | void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event) | - | ||||||||||||||||||
| 1141 | { | - | ||||||||||||||||||
| 1142 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1143 | - | |||||||||||||||||||
| 1144 | QModelIndex index = indexAt(event->pos()); | - | ||||||||||||||||||
| 1145 | if (!index.isValid() | - | ||||||||||||||||||
| 1146 | || !d->isIndexEnabled(index) | - | ||||||||||||||||||
| 1147 | || (d->pressedIndex != index)) { | - | ||||||||||||||||||
| 1148 | QMouseEvent me(QEvent::MouseButtonPress, | - | ||||||||||||||||||
| 1149 | event->localPos(), event->windowPos(), event->screenPos(), | - | ||||||||||||||||||
| 1150 | event->button(), event->buttons(), event->modifiers(), event->source()); | - | ||||||||||||||||||
| 1151 | mousePressEvent(&me); | - | ||||||||||||||||||
| 1152 | return; | - | ||||||||||||||||||
| 1153 | } | - | ||||||||||||||||||
| 1154 | - | |||||||||||||||||||
| 1155 | QPersistentModelIndex persistent = index; | - | ||||||||||||||||||
| 1156 | doubleClicked(persistent); | - | ||||||||||||||||||
| 1157 | if ((event->button() == Qt::LeftButton) && !edit(persistent, DoubleClicked, event) | - | ||||||||||||||||||
| 1158 | && !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this)) | - | ||||||||||||||||||
| 1159 | activated(persistent); | - | ||||||||||||||||||
| 1160 | } | - | ||||||||||||||||||
| 1161 | void QAbstractItemView::dragEnterEvent(QDragEnterEvent *event) | - | ||||||||||||||||||
| 1162 | { | - | ||||||||||||||||||
| 1163 | if (dragDropMode() == InternalMove | - | ||||||||||||||||||
| 1164 | && (event->source() != this|| !(event->possibleActions() & Qt::MoveAction))) | - | ||||||||||||||||||
| 1165 | return; | - | ||||||||||||||||||
| 1166 | - | |||||||||||||||||||
| 1167 | if (d_func()->canDrop(event)) { | - | ||||||||||||||||||
| 1168 | event->accept(); | - | ||||||||||||||||||
| 1169 | setState(DraggingState); | - | ||||||||||||||||||
| 1170 | } else { | - | ||||||||||||||||||
| 1171 | event->ignore(); | - | ||||||||||||||||||
| 1172 | } | - | ||||||||||||||||||
| 1173 | } | - | ||||||||||||||||||
| 1174 | void QAbstractItemView::dragMoveEvent(QDragMoveEvent *event) | - | ||||||||||||||||||
| 1175 | { | - | ||||||||||||||||||
| 1176 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1177 | if (dragDropMode() == InternalMove | - | ||||||||||||||||||
| 1178 | && (event->source() != this || !(event->possibleActions() & Qt::MoveAction))) | - | ||||||||||||||||||
| 1179 | return; | - | ||||||||||||||||||
| 1180 | - | |||||||||||||||||||
| 1181 | - | |||||||||||||||||||
| 1182 | event->ignore(); | - | ||||||||||||||||||
| 1183 | - | |||||||||||||||||||
| 1184 | QModelIndex index = indexAt(event->pos()); | - | ||||||||||||||||||
| 1185 | d->hover = index; | - | ||||||||||||||||||
| 1186 | if (!d->droppingOnItself(event, index) | - | ||||||||||||||||||
| 1187 | && d->canDrop(event)) { | - | ||||||||||||||||||
| 1188 | - | |||||||||||||||||||
| 1189 | if (index.isValid() && d->showDropIndicator) { | - | ||||||||||||||||||
| 1190 | QRect rect = visualRect(index); | - | ||||||||||||||||||
| 1191 | d->dropIndicatorPosition = d->position(event->pos(), rect, index); | - | ||||||||||||||||||
| 1192 | switch (d->dropIndicatorPosition) { | - | ||||||||||||||||||
| 1193 | case AboveItem: | - | ||||||||||||||||||
| 1194 | if (d->isIndexDropEnabled(index.parent())) { | - | ||||||||||||||||||
| 1195 | d->dropIndicatorRect = QRect(rect.left(), rect.top(), rect.width(), 0); | - | ||||||||||||||||||
| 1196 | event->acceptProposedAction(); | - | ||||||||||||||||||
| 1197 | } else { | - | ||||||||||||||||||
| 1198 | d->dropIndicatorRect = QRect(); | - | ||||||||||||||||||
| 1199 | } | - | ||||||||||||||||||
| 1200 | break; | - | ||||||||||||||||||
| 1201 | case BelowItem: | - | ||||||||||||||||||
| 1202 | if (d->isIndexDropEnabled(index.parent())) { | - | ||||||||||||||||||
| 1203 | d->dropIndicatorRect = QRect(rect.left(), rect.bottom(), rect.width(), 0); | - | ||||||||||||||||||
| 1204 | event->acceptProposedAction(); | - | ||||||||||||||||||
| 1205 | } else { | - | ||||||||||||||||||
| 1206 | d->dropIndicatorRect = QRect(); | - | ||||||||||||||||||
| 1207 | } | - | ||||||||||||||||||
| 1208 | break; | - | ||||||||||||||||||
| 1209 | case OnItem: | - | ||||||||||||||||||
| 1210 | if (d->isIndexDropEnabled(index)) { | - | ||||||||||||||||||
| 1211 | d->dropIndicatorRect = rect; | - | ||||||||||||||||||
| 1212 | event->acceptProposedAction(); | - | ||||||||||||||||||
| 1213 | } else { | - | ||||||||||||||||||
| 1214 | d->dropIndicatorRect = QRect(); | - | ||||||||||||||||||
| 1215 | } | - | ||||||||||||||||||
| 1216 | break; | - | ||||||||||||||||||
| 1217 | case OnViewport: | - | ||||||||||||||||||
| 1218 | d->dropIndicatorRect = QRect(); | - | ||||||||||||||||||
| 1219 | if (d->isIndexDropEnabled(rootIndex())) { | - | ||||||||||||||||||
| 1220 | event->acceptProposedAction(); | - | ||||||||||||||||||
| 1221 | } | - | ||||||||||||||||||
| 1222 | break; | - | ||||||||||||||||||
| 1223 | } | - | ||||||||||||||||||
| 1224 | } else { | - | ||||||||||||||||||
| 1225 | d->dropIndicatorRect = QRect(); | - | ||||||||||||||||||
| 1226 | d->dropIndicatorPosition = OnViewport; | - | ||||||||||||||||||
| 1227 | if (d->isIndexDropEnabled(rootIndex())) { | - | ||||||||||||||||||
| 1228 | event->acceptProposedAction(); | - | ||||||||||||||||||
| 1229 | } | - | ||||||||||||||||||
| 1230 | } | - | ||||||||||||||||||
| 1231 | d->viewport->update(); | - | ||||||||||||||||||
| 1232 | } | - | ||||||||||||||||||
| 1233 | - | |||||||||||||||||||
| 1234 | if (d->shouldAutoScroll(event->pos())) | - | ||||||||||||||||||
| 1235 | startAutoScroll(); | - | ||||||||||||||||||
| 1236 | } | - | ||||||||||||||||||
| 1237 | - | |||||||||||||||||||
| 1238 | - | |||||||||||||||||||
| 1239 | - | |||||||||||||||||||
| 1240 | - | |||||||||||||||||||
| 1241 | - | |||||||||||||||||||
| 1242 | - | |||||||||||||||||||
| 1243 | bool QAbstractItemViewPrivate::droppingOnItself(QDropEvent *event, const QModelIndex &index) | - | ||||||||||||||||||
| 1244 | { | - | ||||||||||||||||||
| 1245 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 1246 | Qt::DropAction dropAction = event->dropAction(); | - | ||||||||||||||||||
| 1247 | if (q->dragDropMode() == QAbstractItemView::InternalMove) | - | ||||||||||||||||||
| 1248 | dropAction = Qt::MoveAction; | - | ||||||||||||||||||
| 1249 | if (event->source() == q | - | ||||||||||||||||||
| 1250 | && event->possibleActions() & Qt::MoveAction | - | ||||||||||||||||||
| 1251 | && dropAction == Qt::MoveAction) { | - | ||||||||||||||||||
| 1252 | QModelIndexList selectedIndexes = q->selectedIndexes(); | - | ||||||||||||||||||
| 1253 | QModelIndex child = index; | - | ||||||||||||||||||
| 1254 | while (child.isValid() && child != root) { | - | ||||||||||||||||||
| 1255 | if (selectedIndexes.contains(child)) | - | ||||||||||||||||||
| 1256 | return true; | - | ||||||||||||||||||
| 1257 | child = child.parent(); | - | ||||||||||||||||||
| 1258 | } | - | ||||||||||||||||||
| 1259 | } | - | ||||||||||||||||||
| 1260 | return false; | - | ||||||||||||||||||
| 1261 | } | - | ||||||||||||||||||
| 1262 | - | |||||||||||||||||||
| 1263 | - | |||||||||||||||||||
| 1264 | - | |||||||||||||||||||
| 1265 | - | |||||||||||||||||||
| 1266 | - | |||||||||||||||||||
| 1267 | - | |||||||||||||||||||
| 1268 | - | |||||||||||||||||||
| 1269 | void QAbstractItemView::dragLeaveEvent(QDragLeaveEvent *) | - | ||||||||||||||||||
| 1270 | { | - | ||||||||||||||||||
| 1271 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1272 | stopAutoScroll(); | - | ||||||||||||||||||
| 1273 | setState(NoState); | - | ||||||||||||||||||
| 1274 | d->hover = QModelIndex(); | - | ||||||||||||||||||
| 1275 | d->viewport->update(); | - | ||||||||||||||||||
| 1276 | } | - | ||||||||||||||||||
| 1277 | void QAbstractItemView::dropEvent(QDropEvent *event) | - | ||||||||||||||||||
| 1278 | { | - | ||||||||||||||||||
| 1279 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1280 | if (dragDropMode() == InternalMove) { | - | ||||||||||||||||||
| 1281 | if (event->source() != this || !(event->possibleActions() & Qt::MoveAction)) | - | ||||||||||||||||||
| 1282 | return; | - | ||||||||||||||||||
| 1283 | } | - | ||||||||||||||||||
| 1284 | - | |||||||||||||||||||
| 1285 | QModelIndex index; | - | ||||||||||||||||||
| 1286 | int col = -1; | - | ||||||||||||||||||
| 1287 | int row = -1; | - | ||||||||||||||||||
| 1288 | if (d->dropOn(event, &row, &col, &index)) { | - | ||||||||||||||||||
| 1289 | const Qt::DropAction action = dragDropMode() == InternalMove ? Qt::MoveAction : event->dropAction(); | - | ||||||||||||||||||
| 1290 | if (d->model->dropMimeData(event->mimeData(), action, row, col, index)) { | - | ||||||||||||||||||
| 1291 | if (action != event->dropAction()) { | - | ||||||||||||||||||
| 1292 | event->setDropAction(action); | - | ||||||||||||||||||
| 1293 | event->accept(); | - | ||||||||||||||||||
| 1294 | } else { | - | ||||||||||||||||||
| 1295 | event->acceptProposedAction(); | - | ||||||||||||||||||
| 1296 | } | - | ||||||||||||||||||
| 1297 | } | - | ||||||||||||||||||
| 1298 | } | - | ||||||||||||||||||
| 1299 | stopAutoScroll(); | - | ||||||||||||||||||
| 1300 | setState(NoState); | - | ||||||||||||||||||
| 1301 | d->viewport->update(); | - | ||||||||||||||||||
| 1302 | } | - | ||||||||||||||||||
| 1303 | bool QAbstractItemViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex) | - | ||||||||||||||||||
| 1304 | { | - | ||||||||||||||||||
| 1305 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 1306 | if (event->isAccepted()) | - | ||||||||||||||||||
| 1307 | return false; | - | ||||||||||||||||||
| 1308 | - | |||||||||||||||||||
| 1309 | QModelIndex index; | - | ||||||||||||||||||
| 1310 | - | |||||||||||||||||||
| 1311 | if (viewport->rect().contains(event->pos())) { | - | ||||||||||||||||||
| 1312 | index = q->indexAt(event->pos()); | - | ||||||||||||||||||
| 1313 | if (!index.isValid() || !q->visualRect(index).contains(event->pos())) | - | ||||||||||||||||||
| 1314 | index = root; | - | ||||||||||||||||||
| 1315 | } | - | ||||||||||||||||||
| 1316 | - | |||||||||||||||||||
| 1317 | - | |||||||||||||||||||
| 1318 | if (model->supportedDropActions() & event->dropAction()) { | - | ||||||||||||||||||
| 1319 | int row = -1; | - | ||||||||||||||||||
| 1320 | int col = -1; | - | ||||||||||||||||||
| 1321 | if (index != root) { | - | ||||||||||||||||||
| 1322 | dropIndicatorPosition = position(event->pos(), q->visualRect(index), index); | - | ||||||||||||||||||
| 1323 | switch (dropIndicatorPosition) { | - | ||||||||||||||||||
| 1324 | case QAbstractItemView::AboveItem: | - | ||||||||||||||||||
| 1325 | row = index.row(); | - | ||||||||||||||||||
| 1326 | col = index.column(); | - | ||||||||||||||||||
| 1327 | index = index.parent(); | - | ||||||||||||||||||
| 1328 | break; | - | ||||||||||||||||||
| 1329 | case QAbstractItemView::BelowItem: | - | ||||||||||||||||||
| 1330 | row = index.row() + 1; | - | ||||||||||||||||||
| 1331 | col = index.column(); | - | ||||||||||||||||||
| 1332 | index = index.parent(); | - | ||||||||||||||||||
| 1333 | break; | - | ||||||||||||||||||
| 1334 | case QAbstractItemView::OnItem: | - | ||||||||||||||||||
| 1335 | case QAbstractItemView::OnViewport: | - | ||||||||||||||||||
| 1336 | break; | - | ||||||||||||||||||
| 1337 | } | - | ||||||||||||||||||
| 1338 | } else { | - | ||||||||||||||||||
| 1339 | dropIndicatorPosition = QAbstractItemView::OnViewport; | - | ||||||||||||||||||
| 1340 | } | - | ||||||||||||||||||
| 1341 | *dropIndex = index; | - | ||||||||||||||||||
| 1342 | *dropRow = row; | - | ||||||||||||||||||
| 1343 | *dropCol = col; | - | ||||||||||||||||||
| 1344 | if (!droppingOnItself(event, index)) | - | ||||||||||||||||||
| 1345 | return true; | - | ||||||||||||||||||
| 1346 | } | - | ||||||||||||||||||
| 1347 | return false; | - | ||||||||||||||||||
| 1348 | } | - | ||||||||||||||||||
| 1349 | - | |||||||||||||||||||
| 1350 | QAbstractItemView::DropIndicatorPosition | - | ||||||||||||||||||
| 1351 | QAbstractItemViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const | - | ||||||||||||||||||
| 1352 | { | - | ||||||||||||||||||
| 1353 | QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport; | - | ||||||||||||||||||
| 1354 | if (!overwrite) { | - | ||||||||||||||||||
| 1355 | const int margin = 2; | - | ||||||||||||||||||
| 1356 | if (pos.y() - rect.top() < margin) { | - | ||||||||||||||||||
| 1357 | r = QAbstractItemView::AboveItem; | - | ||||||||||||||||||
| 1358 | } else if (rect.bottom() - pos.y() < margin) { | - | ||||||||||||||||||
| 1359 | r = QAbstractItemView::BelowItem; | - | ||||||||||||||||||
| 1360 | } else if (rect.contains(pos, true)) { | - | ||||||||||||||||||
| 1361 | r = QAbstractItemView::OnItem; | - | ||||||||||||||||||
| 1362 | } | - | ||||||||||||||||||
| 1363 | } else { | - | ||||||||||||||||||
| 1364 | QRect touchingRect = rect; | - | ||||||||||||||||||
| 1365 | touchingRect.adjust(-1, -1, 1, 1); | - | ||||||||||||||||||
| 1366 | if (touchingRect.contains(pos, false)) { | - | ||||||||||||||||||
| 1367 | r = QAbstractItemView::OnItem; | - | ||||||||||||||||||
| 1368 | } | - | ||||||||||||||||||
| 1369 | } | - | ||||||||||||||||||
| 1370 | - | |||||||||||||||||||
| 1371 | if (r == QAbstractItemView::OnItem && (!(model->flags(index) & Qt::ItemIsDropEnabled))) | - | ||||||||||||||||||
| 1372 | r = pos.y() < rect.center().y() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem; | - | ||||||||||||||||||
| 1373 | - | |||||||||||||||||||
| 1374 | return r; | - | ||||||||||||||||||
| 1375 | } | - | ||||||||||||||||||
| 1376 | void QAbstractItemView::focusInEvent(QFocusEvent *event) | - | ||||||||||||||||||
| 1377 | { | - | ||||||||||||||||||
| 1378 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1379 | QAbstractScrollArea::focusInEvent(event); | - | ||||||||||||||||||
| 1380 | - | |||||||||||||||||||
| 1381 | const QItemSelectionModel* model = selectionModel(); | - | ||||||||||||||||||
| 1382 | const bool currentIndexValid = currentIndex().isValid(); | - | ||||||||||||||||||
| 1383 | - | |||||||||||||||||||
| 1384 | if (model | - | ||||||||||||||||||
| 1385 | && !d->currentIndexSet | - | ||||||||||||||||||
| 1386 | && !currentIndexValid) { | - | ||||||||||||||||||
| 1387 | bool autoScroll = d->autoScroll; | - | ||||||||||||||||||
| 1388 | d->autoScroll = false; | - | ||||||||||||||||||
| 1389 | QModelIndex index = moveCursor(MoveNext, Qt::NoModifier); | - | ||||||||||||||||||
| 1390 | if (index.isValid() && d->isIndexEnabled(index) && event->reason() != Qt::MouseFocusReason) | - | ||||||||||||||||||
| 1391 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | - | ||||||||||||||||||
| 1392 | d->autoScroll = autoScroll; | - | ||||||||||||||||||
| 1393 | } | - | ||||||||||||||||||
| 1394 | - | |||||||||||||||||||
| 1395 | if (model && currentIndexValid) { | - | ||||||||||||||||||
| 1396 | if (currentIndex().flags() != Qt::ItemIsEditable) | - | ||||||||||||||||||
| 1397 | setAttribute(Qt::WA_InputMethodEnabled, false); | - | ||||||||||||||||||
| 1398 | else | - | ||||||||||||||||||
| 1399 | setAttribute(Qt::WA_InputMethodEnabled); | - | ||||||||||||||||||
| 1400 | } | - | ||||||||||||||||||
| 1401 | - | |||||||||||||||||||
| 1402 | if (!currentIndexValid) | - | ||||||||||||||||||
| 1403 | setAttribute(Qt::WA_InputMethodEnabled, false); | - | ||||||||||||||||||
| 1404 | - | |||||||||||||||||||
| 1405 | d->viewport->update(); | - | ||||||||||||||||||
| 1406 | } | - | ||||||||||||||||||
| 1407 | - | |||||||||||||||||||
| 1408 | - | |||||||||||||||||||
| 1409 | - | |||||||||||||||||||
| 1410 | - | |||||||||||||||||||
| 1411 | - | |||||||||||||||||||
| 1412 | - | |||||||||||||||||||
| 1413 | - | |||||||||||||||||||
| 1414 | void QAbstractItemView::focusOutEvent(QFocusEvent *event) | - | ||||||||||||||||||
| 1415 | { | - | ||||||||||||||||||
| 1416 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1417 | QAbstractScrollArea::focusOutEvent(event); | - | ||||||||||||||||||
| 1418 | d->viewport->update(); | - | ||||||||||||||||||
| 1419 | } | - | ||||||||||||||||||
| 1420 | void QAbstractItemView::keyPressEvent(QKeyEvent *event) | - | ||||||||||||||||||
| 1421 | { | - | ||||||||||||||||||
| 1422 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1423 | d->delayedAutoScroll.stop(); | - | ||||||||||||||||||
| 1424 | if (event == QKeySequence::Copy) { | - | ||||||||||||||||||
| 1425 | QVariant variant; | - | ||||||||||||||||||
| 1426 | if (d->model) | - | ||||||||||||||||||
| 1427 | variant = d->model->data(currentIndex(), Qt::DisplayRole); | - | ||||||||||||||||||
| 1428 | if (variant.type() == QVariant::String) | - | ||||||||||||||||||
| 1429 | QApplication::clipboard()->setText(variant.toString()); | - | ||||||||||||||||||
| 1430 | event->accept(); | - | ||||||||||||||||||
| 1431 | } | - | ||||||||||||||||||
| 1432 | - | |||||||||||||||||||
| 1433 | - | |||||||||||||||||||
| 1434 | QPersistentModelIndex newCurrent; | - | ||||||||||||||||||
| 1435 | d->moveCursorUpdatedView = false; | - | ||||||||||||||||||
| 1436 | switch (event->key()) { | - | ||||||||||||||||||
| 1437 | case Qt::Key_Down: | - | ||||||||||||||||||
| 1438 | newCurrent = moveCursor(MoveDown, event->modifiers()); | - | ||||||||||||||||||
| 1439 | break; | - | ||||||||||||||||||
| 1440 | case Qt::Key_Up: | - | ||||||||||||||||||
| 1441 | newCurrent = moveCursor(MoveUp, event->modifiers()); | - | ||||||||||||||||||
| 1442 | break; | - | ||||||||||||||||||
| 1443 | case Qt::Key_Left: | - | ||||||||||||||||||
| 1444 | newCurrent = moveCursor(MoveLeft, event->modifiers()); | - | ||||||||||||||||||
| 1445 | break; | - | ||||||||||||||||||
| 1446 | case Qt::Key_Right: | - | ||||||||||||||||||
| 1447 | newCurrent = moveCursor(MoveRight, event->modifiers()); | - | ||||||||||||||||||
| 1448 | break; | - | ||||||||||||||||||
| 1449 | case Qt::Key_Home: | - | ||||||||||||||||||
| 1450 | newCurrent = moveCursor(MoveHome, event->modifiers()); | - | ||||||||||||||||||
| 1451 | break; | - | ||||||||||||||||||
| 1452 | case Qt::Key_End: | - | ||||||||||||||||||
| 1453 | newCurrent = moveCursor(MoveEnd, event->modifiers()); | - | ||||||||||||||||||
| 1454 | break; | - | ||||||||||||||||||
| 1455 | case Qt::Key_PageUp: | - | ||||||||||||||||||
| 1456 | newCurrent = moveCursor(MovePageUp, event->modifiers()); | - | ||||||||||||||||||
| 1457 | break; | - | ||||||||||||||||||
| 1458 | case Qt::Key_PageDown: | - | ||||||||||||||||||
| 1459 | newCurrent = moveCursor(MovePageDown, event->modifiers()); | - | ||||||||||||||||||
| 1460 | break; | - | ||||||||||||||||||
| 1461 | case Qt::Key_Tab: | - | ||||||||||||||||||
| 1462 | if (d->tabKeyNavigation) | - | ||||||||||||||||||
| 1463 | newCurrent = moveCursor(MoveNext, event->modifiers()); | - | ||||||||||||||||||
| 1464 | break; | - | ||||||||||||||||||
| 1465 | case Qt::Key_Backtab: | - | ||||||||||||||||||
| 1466 | if (d->tabKeyNavigation) | - | ||||||||||||||||||
| 1467 | newCurrent = moveCursor(MovePrevious, event->modifiers()); | - | ||||||||||||||||||
| 1468 | break; | - | ||||||||||||||||||
| 1469 | } | - | ||||||||||||||||||
| 1470 | - | |||||||||||||||||||
| 1471 | QPersistentModelIndex oldCurrent = currentIndex(); | - | ||||||||||||||||||
| 1472 | if (newCurrent != oldCurrent && newCurrent.isValid() && d->isIndexEnabled(newCurrent)) { | - | ||||||||||||||||||
| 1473 | if (!hasFocus() && QApplication::focusWidget() == indexWidget(oldCurrent)) | - | ||||||||||||||||||
| 1474 | setFocus(); | - | ||||||||||||||||||
| 1475 | QItemSelectionModel::SelectionFlags command = selectionCommand(newCurrent, event); | - | ||||||||||||||||||
| 1476 | if (command != QItemSelectionModel::NoUpdate | - | ||||||||||||||||||
| 1477 | || style()->styleHint(QStyle::SH_ItemView_MovementWithoutUpdatingSelection, 0, this)) { | - | ||||||||||||||||||
| 1478 | - | |||||||||||||||||||
| 1479 | if (command & QItemSelectionModel::Current) { | - | ||||||||||||||||||
| 1480 | d->selectionModel->setCurrentIndex(newCurrent, QItemSelectionModel::NoUpdate); | - | ||||||||||||||||||
| 1481 | if (!d->currentSelectionStartIndex.isValid()) | - | ||||||||||||||||||
| 1482 | d->currentSelectionStartIndex = oldCurrent; | - | ||||||||||||||||||
| 1483 | QRect rect(visualRect(d->currentSelectionStartIndex).center(), visualRect(newCurrent).center()); | - | ||||||||||||||||||
| 1484 | setSelection(rect, command); | - | ||||||||||||||||||
| 1485 | } else { | - | ||||||||||||||||||
| 1486 | d->selectionModel->setCurrentIndex(newCurrent, command); | - | ||||||||||||||||||
| 1487 | d->currentSelectionStartIndex = newCurrent; | - | ||||||||||||||||||
| 1488 | if (newCurrent.isValid()) { | - | ||||||||||||||||||
| 1489 | - | |||||||||||||||||||
| 1490 | QRect rect(visualRect(newCurrent).center(), QSize(1, 1)); | - | ||||||||||||||||||
| 1491 | setSelection(rect, command); | - | ||||||||||||||||||
| 1492 | } | - | ||||||||||||||||||
| 1493 | } | - | ||||||||||||||||||
| 1494 | event->accept(); | - | ||||||||||||||||||
| 1495 | return; | - | ||||||||||||||||||
| 1496 | } | - | ||||||||||||||||||
| 1497 | } | - | ||||||||||||||||||
| 1498 | - | |||||||||||||||||||
| 1499 | switch (event->key()) { | - | ||||||||||||||||||
| 1500 | - | |||||||||||||||||||
| 1501 | case Qt::Key_Down: | - | ||||||||||||||||||
| 1502 | case Qt::Key_Up: | - | ||||||||||||||||||
| 1503 | - | |||||||||||||||||||
| 1504 | - | |||||||||||||||||||
| 1505 | - | |||||||||||||||||||
| 1506 | - | |||||||||||||||||||
| 1507 | - | |||||||||||||||||||
| 1508 | - | |||||||||||||||||||
| 1509 | case Qt::Key_Left: | - | ||||||||||||||||||
| 1510 | case Qt::Key_Right: | - | ||||||||||||||||||
| 1511 | case Qt::Key_Home: | - | ||||||||||||||||||
| 1512 | case Qt::Key_End: | - | ||||||||||||||||||
| 1513 | case Qt::Key_PageUp: | - | ||||||||||||||||||
| 1514 | case Qt::Key_PageDown: | - | ||||||||||||||||||
| 1515 | case Qt::Key_Escape: | - | ||||||||||||||||||
| 1516 | case Qt::Key_Shift: | - | ||||||||||||||||||
| 1517 | case Qt::Key_Control: | - | ||||||||||||||||||
| 1518 | case Qt::Key_Delete: | - | ||||||||||||||||||
| 1519 | case Qt::Key_Backspace: | - | ||||||||||||||||||
| 1520 | event->ignore(); | - | ||||||||||||||||||
| 1521 | break; | - | ||||||||||||||||||
| 1522 | case Qt::Key_Space: | - | ||||||||||||||||||
| 1523 | case Qt::Key_Select: | - | ||||||||||||||||||
| 1524 | if (!edit(currentIndex(), AnyKeyPressed, event) && d->selectionModel) | - | ||||||||||||||||||
| 1525 | d->selectionModel->select(currentIndex(), selectionCommand(currentIndex(), event)); | - | ||||||||||||||||||
| 1526 | break; | - | ||||||||||||||||||
| 1527 | case Qt::Key_F2: | - | ||||||||||||||||||
| 1528 | if (!edit(currentIndex(), EditKeyPressed, event)) | - | ||||||||||||||||||
| 1529 | event->ignore(); | - | ||||||||||||||||||
| 1530 | break; | - | ||||||||||||||||||
| 1531 | case Qt::Key_Enter: | - | ||||||||||||||||||
| 1532 | case Qt::Key_Return: | - | ||||||||||||||||||
| 1533 | - | |||||||||||||||||||
| 1534 | - | |||||||||||||||||||
| 1535 | - | |||||||||||||||||||
| 1536 | if (state() != EditingState || hasFocus()) { | - | ||||||||||||||||||
| 1537 | if (currentIndex().isValid()) | - | ||||||||||||||||||
| 1538 | activated(currentIndex()); | - | ||||||||||||||||||
| 1539 | event->ignore(); | - | ||||||||||||||||||
| 1540 | } | - | ||||||||||||||||||
| 1541 | break; | - | ||||||||||||||||||
| 1542 | - | |||||||||||||||||||
| 1543 | default: { | - | ||||||||||||||||||
| 1544 | if (event == QKeySequence::SelectAll && selectionMode() != NoSelection) { | - | ||||||||||||||||||
| 1545 | selectAll(); | - | ||||||||||||||||||
| 1546 | break; | - | ||||||||||||||||||
| 1547 | } | - | ||||||||||||||||||
| 1548 | - | |||||||||||||||||||
| 1549 | - | |||||||||||||||||||
| 1550 | - | |||||||||||||||||||
| 1551 | - | |||||||||||||||||||
| 1552 | - | |||||||||||||||||||
| 1553 | - | |||||||||||||||||||
| 1554 | bool modified = (event->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier)); | - | ||||||||||||||||||
| 1555 | if (!event->text().isEmpty() && !modified && !edit(currentIndex(), AnyKeyPressed, event)) { | - | ||||||||||||||||||
| 1556 | keyboardSearch(event->text()); | - | ||||||||||||||||||
| 1557 | event->accept(); | - | ||||||||||||||||||
| 1558 | } else { | - | ||||||||||||||||||
| 1559 | event->ignore(); | - | ||||||||||||||||||
| 1560 | } | - | ||||||||||||||||||
| 1561 | break; } | - | ||||||||||||||||||
| 1562 | } | - | ||||||||||||||||||
| 1563 | if (d->moveCursorUpdatedView) | - | ||||||||||||||||||
| 1564 | event->accept(); | - | ||||||||||||||||||
| 1565 | } | - | ||||||||||||||||||
| 1566 | - | |||||||||||||||||||
| 1567 | - | |||||||||||||||||||
| 1568 | - | |||||||||||||||||||
| 1569 | - | |||||||||||||||||||
| 1570 | - | |||||||||||||||||||
| 1571 | - | |||||||||||||||||||
| 1572 | - | |||||||||||||||||||
| 1573 | void QAbstractItemView::resizeEvent(QResizeEvent *event) | - | ||||||||||||||||||
| 1574 | { | - | ||||||||||||||||||
| 1575 | QAbstractScrollArea::resizeEvent(event); | - | ||||||||||||||||||
| 1576 | updateGeometries(); | - | ||||||||||||||||||
| 1577 | } | - | ||||||||||||||||||
| 1578 | - | |||||||||||||||||||
| 1579 | - | |||||||||||||||||||
| 1580 | - | |||||||||||||||||||
| 1581 | - | |||||||||||||||||||
| 1582 | - | |||||||||||||||||||
| 1583 | - | |||||||||||||||||||
| 1584 | - | |||||||||||||||||||
| 1585 | void QAbstractItemView::timerEvent(QTimerEvent *event) | - | ||||||||||||||||||
| 1586 | { | - | ||||||||||||||||||
| 1587 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1588 | if (event->timerId() == d->fetchMoreTimer.timerId()) | - | ||||||||||||||||||
| 1589 | d->fetchMore(); | - | ||||||||||||||||||
| 1590 | else if (event->timerId() == d->delayedReset.timerId()) | - | ||||||||||||||||||
| 1591 | reset(); | - | ||||||||||||||||||
| 1592 | else if (event->timerId() == d->autoScrollTimer.timerId()) | - | ||||||||||||||||||
| 1593 | doAutoScroll(); | - | ||||||||||||||||||
| 1594 | else if (event->timerId() == d->updateTimer.timerId()) | - | ||||||||||||||||||
| 1595 | d->updateDirtyRegion(); | - | ||||||||||||||||||
| 1596 | else if (event->timerId() == d->delayedEditing.timerId()) { | - | ||||||||||||||||||
| 1597 | d->delayedEditing.stop(); | - | ||||||||||||||||||
| 1598 | edit(currentIndex()); | - | ||||||||||||||||||
| 1599 | } else if (event->timerId() == d->delayedLayout.timerId()) { | - | ||||||||||||||||||
| 1600 | d->delayedLayout.stop(); | - | ||||||||||||||||||
| 1601 | if (isVisible()) { | - | ||||||||||||||||||
| 1602 | d->interruptDelayedItemsLayout(); | - | ||||||||||||||||||
| 1603 | doItemsLayout(); | - | ||||||||||||||||||
| 1604 | const QModelIndex current = currentIndex(); | - | ||||||||||||||||||
| 1605 | if (current.isValid() && d->state == QAbstractItemView::EditingState) | - | ||||||||||||||||||
| 1606 | scrollTo(current); | - | ||||||||||||||||||
| 1607 | } | - | ||||||||||||||||||
| 1608 | } else if (event->timerId() == d->delayedAutoScroll.timerId()) { | - | ||||||||||||||||||
| 1609 | d->delayedAutoScroll.stop(); | - | ||||||||||||||||||
| 1610 | - | |||||||||||||||||||
| 1611 | - | |||||||||||||||||||
| 1612 | if (d->pressedIndex.isValid() && d->pressedIndex == currentIndex()) | - | ||||||||||||||||||
| 1613 | scrollTo(d->pressedIndex); | - | ||||||||||||||||||
| 1614 | } | - | ||||||||||||||||||
| 1615 | } | - | ||||||||||||||||||
| 1616 | - | |||||||||||||||||||
| 1617 | - | |||||||||||||||||||
| 1618 | - | |||||||||||||||||||
| 1619 | - | |||||||||||||||||||
| 1620 | void QAbstractItemView::inputMethodEvent(QInputMethodEvent *event) | - | ||||||||||||||||||
| 1621 | { | - | ||||||||||||||||||
| 1622 | if (event->commitString().isEmpty() && event->preeditString().isEmpty()) { | - | ||||||||||||||||||
| 1623 | event->ignore(); | - | ||||||||||||||||||
| 1624 | return; | - | ||||||||||||||||||
| 1625 | } | - | ||||||||||||||||||
| 1626 | if (!edit(currentIndex(), AnyKeyPressed, event)) { | - | ||||||||||||||||||
| 1627 | if (!event->commitString().isEmpty()) | - | ||||||||||||||||||
| 1628 | keyboardSearch(event->commitString()); | - | ||||||||||||||||||
| 1629 | event->ignore(); | - | ||||||||||||||||||
| 1630 | } | - | ||||||||||||||||||
| 1631 | } | - | ||||||||||||||||||
| 1632 | QAbstractItemView::DropIndicatorPosition QAbstractItemView::dropIndicatorPosition() const | - | ||||||||||||||||||
| 1633 | { | - | ||||||||||||||||||
| 1634 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1635 | return d->dropIndicatorPosition; | - | ||||||||||||||||||
| 1636 | } | - | ||||||||||||||||||
| 1637 | QModelIndexList QAbstractItemView::selectedIndexes() const | - | ||||||||||||||||||
| 1638 | { | - | ||||||||||||||||||
| 1639 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1640 | QModelIndexList indexes; | - | ||||||||||||||||||
| 1641 | if (d->selectionModel
| 0 | ||||||||||||||||||
| 1642 | indexes = d->selectionModel->selectedIndexes(); | - | ||||||||||||||||||
| 1643 | QList<auto isHidden = [this](const QModelIndex >::iterator it&idx) { | - | ||||||||||||||||||
| 1644 | return never executed: isIndexHidden(idx);return isIndexHidden(idx);never executed: return isIndexHidden(idx); | 0 | ||||||||||||||||||
| 1645 | }; | - | ||||||||||||||||||
| 1646 | const auto end = indexes.beginend(); | - | ||||||||||||||||||
| 1647 | while (it !=indexes.end()) | - | ||||||||||||||||||
| iferase(isIndexHidden(*it)) | ||||||||||||||||||||
| it =std::remove_if(indexes.erase(itbegin(), end, isHidden), end); | ||||||||||||||||||||
| 1648 | else | 0 | ||||||||||||||||||
| ++it;} never executed: end of block | ||||||||||||||||||||
| 1649 | return never executed: indexes;return indexes;never executed: return indexes; | 0 | ||||||||||||||||||
| 1650 | } | - | ||||||||||||||||||
| 1651 | bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEvent *event) | - | ||||||||||||||||||
| 1652 | { | - | ||||||||||||||||||
| 1653 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1654 | - | |||||||||||||||||||
| 1655 | if (!d->isIndexValid(index)) | - | ||||||||||||||||||
| 1656 | return false; | - | ||||||||||||||||||
| 1657 | - | |||||||||||||||||||
| 1658 | if (QWidget *w = (d->persistent.isEmpty() ? static_cast<QWidget*>(0) : d->editorForIndex(index).widget.data())) { | - | ||||||||||||||||||
| 1659 | if (w->focusPolicy() == Qt::NoFocus) | - | ||||||||||||||||||
| 1660 | return false; | - | ||||||||||||||||||
| 1661 | w->setFocus(); | - | ||||||||||||||||||
| 1662 | return true; | - | ||||||||||||||||||
| 1663 | } | - | ||||||||||||||||||
| 1664 | - | |||||||||||||||||||
| 1665 | if (trigger == DoubleClicked) { | - | ||||||||||||||||||
| 1666 | d->delayedEditing.stop(); | - | ||||||||||||||||||
| 1667 | d->delayedAutoScroll.stop(); | - | ||||||||||||||||||
| 1668 | } else if (trigger == CurrentChanged) { | - | ||||||||||||||||||
| 1669 | d->delayedEditing.stop(); | - | ||||||||||||||||||
| 1670 | } | - | ||||||||||||||||||
| 1671 | - | |||||||||||||||||||
| 1672 | if (d->sendDelegateEvent(index, event)) { | - | ||||||||||||||||||
| 1673 | update(index); | - | ||||||||||||||||||
| 1674 | return true; | - | ||||||||||||||||||
| 1675 | } | - | ||||||||||||||||||
| 1676 | - | |||||||||||||||||||
| 1677 | - | |||||||||||||||||||
| 1678 | EditTriggers lastTrigger = d->lastTrigger; | - | ||||||||||||||||||
| 1679 | d->lastTrigger = trigger; | - | ||||||||||||||||||
| 1680 | - | |||||||||||||||||||
| 1681 | if (!d->shouldEdit(trigger, d->model->buddy(index))) | - | ||||||||||||||||||
| 1682 | return false; | - | ||||||||||||||||||
| 1683 | - | |||||||||||||||||||
| 1684 | if (d->delayedEditing.isActive()) | - | ||||||||||||||||||
| 1685 | return false; | - | ||||||||||||||||||
| 1686 | - | |||||||||||||||||||
| 1687 | - | |||||||||||||||||||
| 1688 | - | |||||||||||||||||||
| 1689 | if (lastTrigger == DoubleClicked && trigger == SelectedClicked) | - | ||||||||||||||||||
| 1690 | return false; | - | ||||||||||||||||||
| 1691 | - | |||||||||||||||||||
| 1692 | - | |||||||||||||||||||
| 1693 | if (trigger == SelectedClicked) | - | ||||||||||||||||||
| 1694 | d->delayedEditing.start(QApplication::doubleClickInterval(), this); | - | ||||||||||||||||||
| 1695 | else | - | ||||||||||||||||||
| 1696 | d->openEditor(index, d->shouldForwardEvent(trigger, event) ? event : 0); | - | ||||||||||||||||||
| 1697 | - | |||||||||||||||||||
| 1698 | return true; | - | ||||||||||||||||||
| 1699 | } | - | ||||||||||||||||||
| 1700 | - | |||||||||||||||||||
| 1701 | - | |||||||||||||||||||
| 1702 | - | |||||||||||||||||||
| 1703 | - | |||||||||||||||||||
| 1704 | - | |||||||||||||||||||
| 1705 | void QAbstractItemView::updateEditorData() | - | ||||||||||||||||||
| 1706 | { | - | ||||||||||||||||||
| 1707 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1708 | d->updateEditorData(QModelIndex(), QModelIndex()); | - | ||||||||||||||||||
| 1709 | } | - | ||||||||||||||||||
| 1710 | - | |||||||||||||||||||
| 1711 | - | |||||||||||||||||||
| 1712 | - | |||||||||||||||||||
| 1713 | - | |||||||||||||||||||
| 1714 | - | |||||||||||||||||||
| 1715 | void QAbstractItemView::updateEditorGeometries() | - | ||||||||||||||||||
| 1716 | { | - | ||||||||||||||||||
| 1717 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1718 | if(d->editorIndexHash.isEmpty()) | - | ||||||||||||||||||
| 1719 | return; | - | ||||||||||||||||||
| 1720 | if (d->delayedPendingLayout) { | - | ||||||||||||||||||
| 1721 | - | |||||||||||||||||||
| 1722 | d->executePostedLayout(); | - | ||||||||||||||||||
| 1723 | return; | - | ||||||||||||||||||
| 1724 | } | - | ||||||||||||||||||
| 1725 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||
| 1726 | QEditorIndexHash::iterator it = d->editorIndexHash.begin(); | - | ||||||||||||||||||
| 1727 | QWidgetList editorsToRelease; | - | ||||||||||||||||||
| 1728 | QWidgetList editorsToHide; | - | ||||||||||||||||||
| 1729 | while (it != d->editorIndexHash.end()) { | - | ||||||||||||||||||
| 1730 | QModelIndex index = it.value(); | - | ||||||||||||||||||
| 1731 | QWidget *editor = it.key(); | - | ||||||||||||||||||
| 1732 | if (index.isValid() && editor) { | - | ||||||||||||||||||
| 1733 | option.rect = visualRect(index); | - | ||||||||||||||||||
| 1734 | if (option.rect.isValid()) { | - | ||||||||||||||||||
| 1735 | editor->show(); | - | ||||||||||||||||||
| 1736 | QAbstractItemDelegate *delegate = d->delegateForIndex(index); | - | ||||||||||||||||||
| 1737 | if (delegate) | - | ||||||||||||||||||
| 1738 | delegate->updateEditorGeometry(editor, option, index); | - | ||||||||||||||||||
| 1739 | } else { | - | ||||||||||||||||||
| 1740 | editorsToHide << editor; | - | ||||||||||||||||||
| 1741 | } | - | ||||||||||||||||||
| 1742 | ++it; | - | ||||||||||||||||||
| 1743 | } else { | - | ||||||||||||||||||
| 1744 | d->indexEditorHash.remove(it.value()); | - | ||||||||||||||||||
| 1745 | it = d->editorIndexHash.erase(it); | - | ||||||||||||||||||
| 1746 | editorsToRelease << editor; | - | ||||||||||||||||||
| 1747 | } | - | ||||||||||||||||||
| 1748 | } | - | ||||||||||||||||||
| 1749 | - | |||||||||||||||||||
| 1750 | - | |||||||||||||||||||
| 1751 | - | |||||||||||||||||||
| 1752 | for (int i = 0; i < editorsToHide.count(); ++i) { | - | ||||||||||||||||||
| 1753 | editorsToHide.at(i)->hide(); | - | ||||||||||||||||||
| 1754 | } | - | ||||||||||||||||||
| 1755 | for (int i = 0; i < editorsToRelease.count(); ++i) { | - | ||||||||||||||||||
| 1756 | d->releaseEditor(editorsToRelease.at(i)); | - | ||||||||||||||||||
| 1757 | } | - | ||||||||||||||||||
| 1758 | } | - | ||||||||||||||||||
| 1759 | - | |||||||||||||||||||
| 1760 | - | |||||||||||||||||||
| 1761 | - | |||||||||||||||||||
| 1762 | - | |||||||||||||||||||
| 1763 | - | |||||||||||||||||||
| 1764 | - | |||||||||||||||||||
| 1765 | void QAbstractItemView::updateGeometries() | - | ||||||||||||||||||
| 1766 | { | - | ||||||||||||||||||
| 1767 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1768 | updateEditorGeometries(); | - | ||||||||||||||||||
| 1769 | d->fetchMoreTimer.start(0, this); | - | ||||||||||||||||||
| 1770 | d->updateGeometry(); | - | ||||||||||||||||||
| 1771 | } | - | ||||||||||||||||||
| 1772 | - | |||||||||||||||||||
| 1773 | - | |||||||||||||||||||
| 1774 | - | |||||||||||||||||||
| 1775 | - | |||||||||||||||||||
| 1776 | void QAbstractItemView::verticalScrollbarValueChanged(int value) | - | ||||||||||||||||||
| 1777 | { | - | ||||||||||||||||||
| 1778 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1779 | if (verticalScrollBar()->maximum() == value && d->model->canFetchMore(d->root)) | - | ||||||||||||||||||
| 1780 | d->model->fetchMore(d->root); | - | ||||||||||||||||||
| 1781 | QPoint posInVp = viewport()->mapFromGlobal(QCursor::pos()); | - | ||||||||||||||||||
| 1782 | if (viewport()->rect().contains(posInVp)) | - | ||||||||||||||||||
| 1783 | d->checkMouseMove(posInVp); | - | ||||||||||||||||||
| 1784 | } | - | ||||||||||||||||||
| 1785 | - | |||||||||||||||||||
| 1786 | - | |||||||||||||||||||
| 1787 | - | |||||||||||||||||||
| 1788 | - | |||||||||||||||||||
| 1789 | void QAbstractItemView::horizontalScrollbarValueChanged(int value) | - | ||||||||||||||||||
| 1790 | { | - | ||||||||||||||||||
| 1791 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1792 | if (horizontalScrollBar()->maximum() == value && d->model->canFetchMore(d->root)) | - | ||||||||||||||||||
| 1793 | d->model->fetchMore(d->root); | - | ||||||||||||||||||
| 1794 | QPoint posInVp = viewport()->mapFromGlobal(QCursor::pos()); | - | ||||||||||||||||||
| 1795 | if (viewport()->rect().contains(posInVp)) | - | ||||||||||||||||||
| 1796 | d->checkMouseMove(posInVp); | - | ||||||||||||||||||
| 1797 | } | - | ||||||||||||||||||
| 1798 | - | |||||||||||||||||||
| 1799 | - | |||||||||||||||||||
| 1800 | - | |||||||||||||||||||
| 1801 | - | |||||||||||||||||||
| 1802 | void QAbstractItemView::verticalScrollbarAction(int) | - | ||||||||||||||||||
| 1803 | { | - | ||||||||||||||||||
| 1804 | - | |||||||||||||||||||
| 1805 | } | - | ||||||||||||||||||
| 1806 | - | |||||||||||||||||||
| 1807 | - | |||||||||||||||||||
| 1808 | - | |||||||||||||||||||
| 1809 | - | |||||||||||||||||||
| 1810 | void QAbstractItemView::horizontalScrollbarAction(int) | - | ||||||||||||||||||
| 1811 | { | - | ||||||||||||||||||
| 1812 | - | |||||||||||||||||||
| 1813 | } | - | ||||||||||||||||||
| 1814 | void QAbstractItemView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint) | - | ||||||||||||||||||
| 1815 | { | - | ||||||||||||||||||
| 1816 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1817 | - | |||||||||||||||||||
| 1818 | - | |||||||||||||||||||
| 1819 | if (editor) { | - | ||||||||||||||||||
| 1820 | bool isPersistent = d->persistent.contains(editor); | - | ||||||||||||||||||
| 1821 | bool hadFocus = editor->hasFocus(); | - | ||||||||||||||||||
| 1822 | QModelIndex index = d->indexForEditor(editor); | - | ||||||||||||||||||
| 1823 | if (!index.isValid()) | - | ||||||||||||||||||
| 1824 | return; | - | ||||||||||||||||||
| 1825 | - | |||||||||||||||||||
| 1826 | if (!isPersistent) { | - | ||||||||||||||||||
| 1827 | setState(NoState); | - | ||||||||||||||||||
| 1828 | QModelIndex index = d->indexForEditor(editor); | - | ||||||||||||||||||
| 1829 | editor->removeEventFilter(d->delegateForIndex(index)); | - | ||||||||||||||||||
| 1830 | d->removeEditor(editor); | - | ||||||||||||||||||
| 1831 | } | - | ||||||||||||||||||
| 1832 | if (hadFocus) { | - | ||||||||||||||||||
| 1833 | if (focusPolicy() != Qt::NoFocus) | - | ||||||||||||||||||
| 1834 | setFocus(); | - | ||||||||||||||||||
| 1835 | else | - | ||||||||||||||||||
| 1836 | editor->clearFocus(); | - | ||||||||||||||||||
| 1837 | } else { | - | ||||||||||||||||||
| 1838 | d->checkPersistentEditorFocus(); | - | ||||||||||||||||||
| 1839 | } | - | ||||||||||||||||||
| 1840 | - | |||||||||||||||||||
| 1841 | QPointer<QWidget> ed = editor; | - | ||||||||||||||||||
| 1842 | QApplication::sendPostedEvents(editor, 0); | - | ||||||||||||||||||
| 1843 | editor = ed; | - | ||||||||||||||||||
| 1844 | - | |||||||||||||||||||
| 1845 | if (!isPersistent && editor) | - | ||||||||||||||||||
| 1846 | d->releaseEditor(editor, index); | - | ||||||||||||||||||
| 1847 | } | - | ||||||||||||||||||
| 1848 | - | |||||||||||||||||||
| 1849 | - | |||||||||||||||||||
| 1850 | QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 1851 | if (d->selectionMode != NoSelection) | - | ||||||||||||||||||
| 1852 | flags = QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags(); | - | ||||||||||||||||||
| 1853 | switch (hint) { | - | ||||||||||||||||||
| 1854 | case QAbstractItemDelegate::EditNextItem: { | - | ||||||||||||||||||
| 1855 | QModelIndex index = moveCursor(MoveNext, Qt::NoModifier); | - | ||||||||||||||||||
| 1856 | if (index.isValid()) { | - | ||||||||||||||||||
| 1857 | QPersistentModelIndex persistent(index); | - | ||||||||||||||||||
| 1858 | d->selectionModel->setCurrentIndex(persistent, flags); | - | ||||||||||||||||||
| 1859 | - | |||||||||||||||||||
| 1860 | if (index.flags() & Qt::ItemIsEditable | - | ||||||||||||||||||
| 1861 | && (!(editTriggers() & QAbstractItemView::CurrentChanged))) | - | ||||||||||||||||||
| 1862 | edit(persistent); | - | ||||||||||||||||||
| 1863 | } break; } | - | ||||||||||||||||||
| 1864 | case QAbstractItemDelegate::EditPreviousItem: { | - | ||||||||||||||||||
| 1865 | QModelIndex index = moveCursor(MovePrevious, Qt::NoModifier); | - | ||||||||||||||||||
| 1866 | if (index.isValid()) { | - | ||||||||||||||||||
| 1867 | QPersistentModelIndex persistent(index); | - | ||||||||||||||||||
| 1868 | d->selectionModel->setCurrentIndex(persistent, flags); | - | ||||||||||||||||||
| 1869 | - | |||||||||||||||||||
| 1870 | if (index.flags() & Qt::ItemIsEditable | - | ||||||||||||||||||
| 1871 | && (!(editTriggers() & QAbstractItemView::CurrentChanged))) | - | ||||||||||||||||||
| 1872 | edit(persistent); | - | ||||||||||||||||||
| 1873 | } break; } | - | ||||||||||||||||||
| 1874 | case QAbstractItemDelegate::SubmitModelCache: | - | ||||||||||||||||||
| 1875 | d->model->submit(); | - | ||||||||||||||||||
| 1876 | break; | - | ||||||||||||||||||
| 1877 | case QAbstractItemDelegate::RevertModelCache: | - | ||||||||||||||||||
| 1878 | d->model->revert(); | - | ||||||||||||||||||
| 1879 | break; | - | ||||||||||||||||||
| 1880 | default: | - | ||||||||||||||||||
| 1881 | break; | - | ||||||||||||||||||
| 1882 | } | - | ||||||||||||||||||
| 1883 | } | - | ||||||||||||||||||
| 1884 | - | |||||||||||||||||||
| 1885 | - | |||||||||||||||||||
| 1886 | - | |||||||||||||||||||
| 1887 | - | |||||||||||||||||||
| 1888 | - | |||||||||||||||||||
| 1889 | - | |||||||||||||||||||
| 1890 | void QAbstractItemView::commitData(QWidget *editor) | - | ||||||||||||||||||
| 1891 | { | - | ||||||||||||||||||
| 1892 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1893 | if (!editor || !d->itemDelegate || d->currentlyCommittingEditor) | - | ||||||||||||||||||
| 1894 | return; | - | ||||||||||||||||||
| 1895 | QModelIndex index = d->indexForEditor(editor); | - | ||||||||||||||||||
| 1896 | if (!index.isValid()) | - | ||||||||||||||||||
| 1897 | return; | - | ||||||||||||||||||
| 1898 | d->currentlyCommittingEditor = editor; | - | ||||||||||||||||||
| 1899 | QAbstractItemDelegate *delegate = d->delegateForIndex(index); | - | ||||||||||||||||||
| 1900 | editor->removeEventFilter(delegate); | - | ||||||||||||||||||
| 1901 | delegate->setModelData(editor, d->model, index); | - | ||||||||||||||||||
| 1902 | editor->installEventFilter(delegate); | - | ||||||||||||||||||
| 1903 | d->currentlyCommittingEditor = 0; | - | ||||||||||||||||||
| 1904 | } | - | ||||||||||||||||||
| 1905 | - | |||||||||||||||||||
| 1906 | - | |||||||||||||||||||
| 1907 | - | |||||||||||||||||||
| 1908 | - | |||||||||||||||||||
| 1909 | - | |||||||||||||||||||
| 1910 | - | |||||||||||||||||||
| 1911 | void QAbstractItemView::editorDestroyed(QObject *editor) | - | ||||||||||||||||||
| 1912 | { | - | ||||||||||||||||||
| 1913 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1914 | QWidget *w = qobject_cast<QWidget*>(editor); | - | ||||||||||||||||||
| 1915 | d->removeEditor(w); | - | ||||||||||||||||||
| 1916 | d->persistent.remove(w); | - | ||||||||||||||||||
| 1917 | if (state() == EditingState) | - | ||||||||||||||||||
| 1918 | setState(NoState); | - | ||||||||||||||||||
| 1919 | } | - | ||||||||||||||||||
| 1920 | void QAbstractItemView::setHorizontalStepsPerItem(int steps) | - | ||||||||||||||||||
| 1921 | { | - | ||||||||||||||||||
| 1922 | (void)steps; | - | ||||||||||||||||||
| 1923 | - | |||||||||||||||||||
| 1924 | } | - | ||||||||||||||||||
| 1925 | - | |||||||||||||||||||
| 1926 | - | |||||||||||||||||||
| 1927 | - | |||||||||||||||||||
| 1928 | - | |||||||||||||||||||
| 1929 | - | |||||||||||||||||||
| 1930 | - | |||||||||||||||||||
| 1931 | - | |||||||||||||||||||
| 1932 | int QAbstractItemView::horizontalStepsPerItem() const | - | ||||||||||||||||||
| 1933 | { | - | ||||||||||||||||||
| 1934 | return 1; | - | ||||||||||||||||||
| 1935 | } | - | ||||||||||||||||||
| 1936 | void QAbstractItemView::setVerticalStepsPerItem(int steps) | - | ||||||||||||||||||
| 1937 | { | - | ||||||||||||||||||
| 1938 | (void)steps; | - | ||||||||||||||||||
| 1939 | - | |||||||||||||||||||
| 1940 | } | - | ||||||||||||||||||
| 1941 | - | |||||||||||||||||||
| 1942 | - | |||||||||||||||||||
| 1943 | - | |||||||||||||||||||
| 1944 | - | |||||||||||||||||||
| 1945 | - | |||||||||||||||||||
| 1946 | - | |||||||||||||||||||
| 1947 | - | |||||||||||||||||||
| 1948 | int QAbstractItemView::verticalStepsPerItem() const | - | ||||||||||||||||||
| 1949 | { | - | ||||||||||||||||||
| 1950 | return 1; | - | ||||||||||||||||||
| 1951 | } | - | ||||||||||||||||||
| 1952 | void QAbstractItemView::keyboardSearch(const QString &search) | - | ||||||||||||||||||
| 1953 | { | - | ||||||||||||||||||
| 1954 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1955 | if (!d->model->rowCount(d->root) || !d->model->columnCount(d->root)) | - | ||||||||||||||||||
| 1956 | return; | - | ||||||||||||||||||
| 1957 | - | |||||||||||||||||||
| 1958 | QModelIndex start = currentIndex().isValid() ? currentIndex() | - | ||||||||||||||||||
| 1959 | : d->model->index(0, 0, d->root); | - | ||||||||||||||||||
| 1960 | bool skipRow = false; | - | ||||||||||||||||||
| 1961 | bool keyboardTimeWasValid = d->keyboardInputTime.isValid(); | - | ||||||||||||||||||
| 1962 | qint64 keyboardInputTimeElapsed; | - | ||||||||||||||||||
| 1963 | if (keyboardTimeWasValid) | - | ||||||||||||||||||
| 1964 | keyboardInputTimeElapsed = d->keyboardInputTime.restart(); | - | ||||||||||||||||||
| 1965 | else | - | ||||||||||||||||||
| 1966 | d->keyboardInputTime.start(); | - | ||||||||||||||||||
| 1967 | if (search.isEmpty() || !keyboardTimeWasValid | - | ||||||||||||||||||
| 1968 | || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) { | - | ||||||||||||||||||
| 1969 | d->keyboardInput = search; | - | ||||||||||||||||||
| 1970 | skipRow = currentIndex().isValid(); | - | ||||||||||||||||||
| 1971 | } else { | - | ||||||||||||||||||
| 1972 | d->keyboardInput += search; | - | ||||||||||||||||||
| 1973 | } | - | ||||||||||||||||||
| 1974 | - | |||||||||||||||||||
| 1975 | - | |||||||||||||||||||
| 1976 | bool sameKey = false; | - | ||||||||||||||||||
| 1977 | if (d->keyboardInput.length() > 1) { | - | ||||||||||||||||||
| 1978 | int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1)); | - | ||||||||||||||||||
| 1979 | sameKey = (c == d->keyboardInput.length()); | - | ||||||||||||||||||
| 1980 | if (sameKey) | - | ||||||||||||||||||
| 1981 | skipRow = true; | - | ||||||||||||||||||
| 1982 | } | - | ||||||||||||||||||
| 1983 | - | |||||||||||||||||||
| 1984 | - | |||||||||||||||||||
| 1985 | if (skipRow) { | - | ||||||||||||||||||
| 1986 | QModelIndex parent = start.parent(); | - | ||||||||||||||||||
| 1987 | int newRow = (start.row() < d->model->rowCount(parent) - 1) ? start.row() + 1 : 0; | - | ||||||||||||||||||
| 1988 | start = d->model->index(newRow, start.column(), parent); | - | ||||||||||||||||||
| 1989 | } | - | ||||||||||||||||||
| 1990 | - | |||||||||||||||||||
| 1991 | - | |||||||||||||||||||
| 1992 | QModelIndex current = start; | - | ||||||||||||||||||
| 1993 | QModelIndexList match; | - | ||||||||||||||||||
| 1994 | QModelIndex firstMatch; | - | ||||||||||||||||||
| 1995 | QModelIndex startMatch; | - | ||||||||||||||||||
| 1996 | QModelIndexList previous; | - | ||||||||||||||||||
| 1997 | do { | - | ||||||||||||||||||
| 1998 | match = d->model->match(current, Qt::DisplayRole, d->keyboardInput); | - | ||||||||||||||||||
| 1999 | if (match == previous) | - | ||||||||||||||||||
| 2000 | break; | - | ||||||||||||||||||
| 2001 | firstMatch = match.value(0); | - | ||||||||||||||||||
| 2002 | previous = match; | - | ||||||||||||||||||
| 2003 | if (firstMatch.isValid()) { | - | ||||||||||||||||||
| 2004 | if (d->isIndexEnabled(firstMatch)) { | - | ||||||||||||||||||
| 2005 | setCurrentIndex(firstMatch); | - | ||||||||||||||||||
| 2006 | break; | - | ||||||||||||||||||
| 2007 | } | - | ||||||||||||||||||
| 2008 | int row = firstMatch.row() + 1; | - | ||||||||||||||||||
| 2009 | if (row >= d->model->rowCount(firstMatch.parent())) | - | ||||||||||||||||||
| 2010 | row = 0; | - | ||||||||||||||||||
| 2011 | current = firstMatch.sibling(row, firstMatch.column()); | - | ||||||||||||||||||
| 2012 | - | |||||||||||||||||||
| 2013 | - | |||||||||||||||||||
| 2014 | if (!startMatch.isValid()) | - | ||||||||||||||||||
| 2015 | startMatch = firstMatch; | - | ||||||||||||||||||
| 2016 | else if (startMatch == firstMatch) | - | ||||||||||||||||||
| 2017 | break; | - | ||||||||||||||||||
| 2018 | } | - | ||||||||||||||||||
| 2019 | } while (current != start && firstMatch.isValid()); | - | ||||||||||||||||||
| 2020 | } | - | ||||||||||||||||||
| 2021 | - | |||||||||||||||||||
| 2022 | - | |||||||||||||||||||
| 2023 | - | |||||||||||||||||||
| 2024 | - | |||||||||||||||||||
| 2025 | - | |||||||||||||||||||
| 2026 | - | |||||||||||||||||||
| 2027 | - | |||||||||||||||||||
| 2028 | QSize QAbstractItemView::sizeHintForIndex(const QModelIndex &index) const | - | ||||||||||||||||||
| 2029 | { | - | ||||||||||||||||||
| 2030 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2031 | if (!d->isIndexValid(index) || !d->itemDelegate) | - | ||||||||||||||||||
| 2032 | return QSize(); | - | ||||||||||||||||||
| 2033 | return d->delegateForIndex(index)->sizeHint(d->viewOptionsV1(), index); | - | ||||||||||||||||||
| 2034 | } | - | ||||||||||||||||||
| 2035 | int QAbstractItemView::sizeHintForRow(int row) const | - | ||||||||||||||||||
| 2036 | { | - | ||||||||||||||||||
| 2037 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2038 | - | |||||||||||||||||||
| 2039 | if (row < 0 || row >= d->model->rowCount(d->root)) | - | ||||||||||||||||||
| 2040 | return -1; | - | ||||||||||||||||||
| 2041 | - | |||||||||||||||||||
| 2042 | ensurePolished(); | - | ||||||||||||||||||
| 2043 | - | |||||||||||||||||||
| 2044 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||
| 2045 | int height = 0; | - | ||||||||||||||||||
| 2046 | int colCount = d->model->columnCount(d->root); | - | ||||||||||||||||||
| 2047 | for (int c = 0; c < colCount; ++c) { | - | ||||||||||||||||||
| 2048 | const QModelIndex index = d->model->index(row, c, d->root); | - | ||||||||||||||||||
| 2049 | if (QWidget *editor = d->editorForIndex(index).widget.data()) | - | ||||||||||||||||||
| 2050 | height = qMax(height, editor->height()); | - | ||||||||||||||||||
| 2051 | if (const QAbstractItemDelegate *delegate = d->delegateForIndex(index)) | - | ||||||||||||||||||
| 2052 | height = qMax(height, delegate->sizeHint(option, index).height()); | - | ||||||||||||||||||
| 2053 | } | - | ||||||||||||||||||
| 2054 | return height; | - | ||||||||||||||||||
| 2055 | } | - | ||||||||||||||||||
| 2056 | int QAbstractItemView::sizeHintForColumn(int column) const | - | ||||||||||||||||||
| 2057 | { | - | ||||||||||||||||||
| 2058 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2059 | - | |||||||||||||||||||
| 2060 | if (column < 0 || column >= d->model->columnCount(d->root)) | - | ||||||||||||||||||
| 2061 | return -1; | - | ||||||||||||||||||
| 2062 | - | |||||||||||||||||||
| 2063 | ensurePolished(); | - | ||||||||||||||||||
| 2064 | - | |||||||||||||||||||
| 2065 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||
| 2066 | int width = 0; | - | ||||||||||||||||||
| 2067 | int rows = d->model->rowCount(d->root); | - | ||||||||||||||||||
| 2068 | for (int r = 0; r < rows; ++r) { | - | ||||||||||||||||||
| 2069 | const QModelIndex index = d->model->index(r, column, d->root); | - | ||||||||||||||||||
| 2070 | if (QWidget *editor = d->editorForIndex(index).widget.data()) | - | ||||||||||||||||||
| 2071 | width = qMax(width, editor->sizeHint().width()); | - | ||||||||||||||||||
| 2072 | if (const QAbstractItemDelegate *delegate = d->delegateForIndex(index)) | - | ||||||||||||||||||
| 2073 | width = qMax(width, delegate->sizeHint(option, index).width()); | - | ||||||||||||||||||
| 2074 | } | - | ||||||||||||||||||
| 2075 | return width; | - | ||||||||||||||||||
| 2076 | } | - | ||||||||||||||||||
| 2077 | - | |||||||||||||||||||
| 2078 | - | |||||||||||||||||||
| 2079 | - | |||||||||||||||||||
| 2080 | - | |||||||||||||||||||
| 2081 | - | |||||||||||||||||||
| 2082 | - | |||||||||||||||||||
| 2083 | - | |||||||||||||||||||
| 2084 | void QAbstractItemView::openPersistentEditor(const QModelIndex &index) | - | ||||||||||||||||||
| 2085 | { | - | ||||||||||||||||||
| 2086 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2087 | QStyleOptionViewItem options = d->viewOptionsV1(); | - | ||||||||||||||||||
| 2088 | options.rect = visualRect(index); | - | ||||||||||||||||||
| 2089 | options.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None); | - | ||||||||||||||||||
| 2090 | - | |||||||||||||||||||
| 2091 | QWidget *editor = d->editor(index, options); | - | ||||||||||||||||||
| 2092 | if (editor) { | - | ||||||||||||||||||
| 2093 | editor->show(); | - | ||||||||||||||||||
| 2094 | d->persistent.insert(editor); | - | ||||||||||||||||||
| 2095 | } | - | ||||||||||||||||||
| 2096 | } | - | ||||||||||||||||||
| 2097 | - | |||||||||||||||||||
| 2098 | - | |||||||||||||||||||
| 2099 | - | |||||||||||||||||||
| 2100 | - | |||||||||||||||||||
| 2101 | - | |||||||||||||||||||
| 2102 | - | |||||||||||||||||||
| 2103 | void QAbstractItemView::closePersistentEditor(const QModelIndex &index) | - | ||||||||||||||||||
| 2104 | { | - | ||||||||||||||||||
| 2105 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2106 | if (QWidget *editor = d->editorForIndex(index).widget.data()) { | - | ||||||||||||||||||
| 2107 | if (index == selectionModel()->currentIndex()) | - | ||||||||||||||||||
| 2108 | closeEditor(editor, QAbstractItemDelegate::RevertModelCache); | - | ||||||||||||||||||
| 2109 | d->persistent.remove(editor); | - | ||||||||||||||||||
| 2110 | d->removeEditor(editor); | - | ||||||||||||||||||
| 2111 | d->releaseEditor(editor, index); | - | ||||||||||||||||||
| 2112 | } | - | ||||||||||||||||||
| 2113 | } | - | ||||||||||||||||||
| 2114 | void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget) | - | ||||||||||||||||||
| 2115 | { | - | ||||||||||||||||||
| 2116 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2117 | if (!d->isIndexValid(index)) | - | ||||||||||||||||||
| 2118 | return; | - | ||||||||||||||||||
| 2119 | if (indexWidget(index) == widget) | - | ||||||||||||||||||
| 2120 | return; | - | ||||||||||||||||||
| 2121 | if (QWidget *oldWidget = indexWidget(index)) { | - | ||||||||||||||||||
| 2122 | d->persistent.remove(oldWidget); | - | ||||||||||||||||||
| 2123 | d->removeEditor(oldWidget); | - | ||||||||||||||||||
| 2124 | oldWidget->deleteLater(); | - | ||||||||||||||||||
| 2125 | } | - | ||||||||||||||||||
| 2126 | if (widget) { | - | ||||||||||||||||||
| 2127 | widget->setParent(viewport()); | - | ||||||||||||||||||
| 2128 | d->persistent.insert(widget); | - | ||||||||||||||||||
| 2129 | d->addEditor(index, widget, true); | - | ||||||||||||||||||
| 2130 | widget->show(); | - | ||||||||||||||||||
| 2131 | dataChanged(index, index); | - | ||||||||||||||||||
| 2132 | if (!d->delayedPendingLayout) | - | ||||||||||||||||||
| 2133 | widget->setGeometry(visualRect(index)); | - | ||||||||||||||||||
| 2134 | } | - | ||||||||||||||||||
| 2135 | } | - | ||||||||||||||||||
| 2136 | - | |||||||||||||||||||
| 2137 | - | |||||||||||||||||||
| 2138 | - | |||||||||||||||||||
| 2139 | - | |||||||||||||||||||
| 2140 | - | |||||||||||||||||||
| 2141 | - | |||||||||||||||||||
| 2142 | QWidget* QAbstractItemView::indexWidget(const QModelIndex &index) const | - | ||||||||||||||||||
| 2143 | { | - | ||||||||||||||||||
| 2144 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2145 | if (d->isIndexValid(index)) | - | ||||||||||||||||||
| 2146 | if (QWidget *editor = d->editorForIndex(index).widget.data()) | - | ||||||||||||||||||
| 2147 | return editor; | - | ||||||||||||||||||
| 2148 | - | |||||||||||||||||||
| 2149 | return 0; | - | ||||||||||||||||||
| 2150 | } | - | ||||||||||||||||||
| 2151 | void QAbstractItemView::scrollToTop() | - | ||||||||||||||||||
| 2152 | { | - | ||||||||||||||||||
| 2153 | verticalScrollBar()->setValue(verticalScrollBar()->minimum()); | - | ||||||||||||||||||
| 2154 | } | - | ||||||||||||||||||
| 2155 | void QAbstractItemView::scrollToBottom() | - | ||||||||||||||||||
| 2156 | { | - | ||||||||||||||||||
| 2157 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2158 | if (d->delayedPendingLayout) { | - | ||||||||||||||||||
| 2159 | d->executePostedLayout(); | - | ||||||||||||||||||
| 2160 | updateGeometries(); | - | ||||||||||||||||||
| 2161 | } | - | ||||||||||||||||||
| 2162 | verticalScrollBar()->setValue(verticalScrollBar()->maximum()); | - | ||||||||||||||||||
| 2163 | } | - | ||||||||||||||||||
| 2164 | - | |||||||||||||||||||
| 2165 | - | |||||||||||||||||||
| 2166 | - | |||||||||||||||||||
| 2167 | - | |||||||||||||||||||
| 2168 | - | |||||||||||||||||||
| 2169 | - | |||||||||||||||||||
| 2170 | - | |||||||||||||||||||
| 2171 | void QAbstractItemView::update(const QModelIndex &index) | - | ||||||||||||||||||
| 2172 | { | - | ||||||||||||||||||
| 2173 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2174 | if (index.isValid()) { | - | ||||||||||||||||||
| 2175 | const QRect rect = visualRect(index); | - | ||||||||||||||||||
| 2176 | - | |||||||||||||||||||
| 2177 | - | |||||||||||||||||||
| 2178 | - | |||||||||||||||||||
| 2179 | if (d->viewport->rect().intersects(rect)) | - | ||||||||||||||||||
| 2180 | d->viewport->update(rect); | - | ||||||||||||||||||
| 2181 | } | - | ||||||||||||||||||
| 2182 | } | - | ||||||||||||||||||
| 2183 | void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) | - | ||||||||||||||||||
| 2184 | { | - | ||||||||||||||||||
| 2185 | (void)roles;; | - | ||||||||||||||||||
| 2186 | - | |||||||||||||||||||
| 2187 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2188 | if (topLeft == bottomRight && topLeft.isValid()) { | - | ||||||||||||||||||
| 2189 | const QEditorInfo &editorInfo = d->editorForIndex(topLeft); | - | ||||||||||||||||||
| 2190 | - | |||||||||||||||||||
| 2191 | if (!editorInfo.isStatic && editorInfo.widget) { | - | ||||||||||||||||||
| 2192 | QAbstractItemDelegate *delegate = d->delegateForIndex(topLeft); | - | ||||||||||||||||||
| 2193 | if (delegate) { | - | ||||||||||||||||||
| 2194 | delegate->setEditorData(editorInfo.widget.data(), topLeft); | - | ||||||||||||||||||
| 2195 | } | - | ||||||||||||||||||
| 2196 | } | - | ||||||||||||||||||
| 2197 | if (isVisible() && !d->delayedPendingLayout) { | - | ||||||||||||||||||
| 2198 | - | |||||||||||||||||||
| 2199 | update(topLeft); | - | ||||||||||||||||||
| 2200 | } | - | ||||||||||||||||||
| 2201 | } else { | - | ||||||||||||||||||
| 2202 | d->updateEditorData(topLeft, bottomRight); | - | ||||||||||||||||||
| 2203 | if (isVisible() && !d->delayedPendingLayout) | - | ||||||||||||||||||
| 2204 | d->viewport->update(); | - | ||||||||||||||||||
| 2205 | } | - | ||||||||||||||||||
| 2206 | - | |||||||||||||||||||
| 2207 | - | |||||||||||||||||||
| 2208 | if (QAccessible::isActive()) { | - | ||||||||||||||||||
| 2209 | QAccessibleTableModelChangeEvent accessibleEvent(this, QAccessibleTableModelChangeEvent::DataChanged); | - | ||||||||||||||||||
| 2210 | accessibleEvent.setFirstRow(topLeft.row()); | - | ||||||||||||||||||
| 2211 | accessibleEvent.setFirstColumn(topLeft.column()); | - | ||||||||||||||||||
| 2212 | accessibleEvent.setLastRow(bottomRight.row()); | - | ||||||||||||||||||
| 2213 | accessibleEvent.setLastColumn(bottomRight.column()); | - | ||||||||||||||||||
| 2214 | QAccessible::updateAccessibility(&accessibleEvent); | - | ||||||||||||||||||
| 2215 | } | - | ||||||||||||||||||
| 2216 | - | |||||||||||||||||||
| 2217 | d->updateGeometry(); | - | ||||||||||||||||||
| 2218 | } | - | ||||||||||||||||||
| 2219 | void QAbstractItemView::rowsInserted(const QModelIndex &, int, int) | - | ||||||||||||||||||
| 2220 | { | - | ||||||||||||||||||
| 2221 | if (!isVisible()) | - | ||||||||||||||||||
| 2222 | d_func()->fetchMoreTimer.start(0, this); | - | ||||||||||||||||||
| 2223 | else | - | ||||||||||||||||||
| 2224 | updateEditorGeometries(); | - | ||||||||||||||||||
| 2225 | } | - | ||||||||||||||||||
| 2226 | - | |||||||||||||||||||
| 2227 | - | |||||||||||||||||||
| 2228 | - | |||||||||||||||||||
| 2229 | - | |||||||||||||||||||
| 2230 | - | |||||||||||||||||||
| 2231 | - | |||||||||||||||||||
| 2232 | - | |||||||||||||||||||
| 2233 | void QAbstractItemView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) | - | ||||||||||||||||||
| 2234 | { | - | ||||||||||||||||||
| 2235 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2236 | - | |||||||||||||||||||
| 2237 | setState(CollapsingState); | - | ||||||||||||||||||
| 2238 | - | |||||||||||||||||||
| 2239 | - | |||||||||||||||||||
| 2240 | QModelIndex current = currentIndex(); | - | ||||||||||||||||||
| 2241 | if (d->selectionMode == SingleSelection | - | ||||||||||||||||||
| 2242 | && current.isValid() | - | ||||||||||||||||||
| 2243 | && current.row() >= start | - | ||||||||||||||||||
| 2244 | && current.row() <= end | - | ||||||||||||||||||
| 2245 | && current.parent() == parent) { | - | ||||||||||||||||||
| 2246 | int totalToRemove = end - start + 1; | - | ||||||||||||||||||
| 2247 | if (d->model->rowCount(parent) <= totalToRemove) { | - | ||||||||||||||||||
| 2248 | QModelIndex index = parent; | - | ||||||||||||||||||
| 2249 | while (index != d->root && !d->isIndexEnabled(index)) | - | ||||||||||||||||||
| 2250 | index = index.parent(); | - | ||||||||||||||||||
| 2251 | if (index != d->root) | - | ||||||||||||||||||
| 2252 | setCurrentIndex(index); | - | ||||||||||||||||||
| 2253 | } else { | - | ||||||||||||||||||
| 2254 | int row = end + 1; | - | ||||||||||||||||||
| 2255 | QModelIndex next; | - | ||||||||||||||||||
| 2256 | do { | - | ||||||||||||||||||
| 2257 | next = d->model->index(row++, current.column(), current.parent()); | - | ||||||||||||||||||
| 2258 | } while (next.isValid() && (isIndexHidden(next) || !d->isIndexEnabled(next))); | - | ||||||||||||||||||
| 2259 | if (row > d->model->rowCount(parent)) { | - | ||||||||||||||||||
| 2260 | row = start - 1; | - | ||||||||||||||||||
| 2261 | do { | - | ||||||||||||||||||
| 2262 | next = d->model->index(row--, current.column(), current.parent()); | - | ||||||||||||||||||
| 2263 | } while (next.isValid() && (isIndexHidden(next) || !d->isIndexEnabled(next))); | - | ||||||||||||||||||
| 2264 | } | - | ||||||||||||||||||
| 2265 | setCurrentIndex(next); | - | ||||||||||||||||||
| 2266 | } | - | ||||||||||||||||||
| 2267 | } | - | ||||||||||||||||||
| 2268 | - | |||||||||||||||||||
| 2269 | - | |||||||||||||||||||
| 2270 | QEditorIndexHash::iterator i = d->editorIndexHash.begin(); | - | ||||||||||||||||||
| 2271 | while (i != d->editorIndexHash.end()) { | - | ||||||||||||||||||
| 2272 | const QModelIndex index = i.value(); | - | ||||||||||||||||||
| 2273 | if (index.row() >= start && index.row() <= end && d->model->parent(index) == parent) { | - | ||||||||||||||||||
| 2274 | QWidget *editor = i.key(); | - | ||||||||||||||||||
| 2275 | QEditorInfo info = d->indexEditorHash.take(index); | - | ||||||||||||||||||
| 2276 | i = d->editorIndexHash.erase(i); | - | ||||||||||||||||||
| 2277 | if (info.widget) | - | ||||||||||||||||||
| 2278 | d->releaseEditor(editor, index); | - | ||||||||||||||||||
| 2279 | } else { | - | ||||||||||||||||||
| 2280 | ++i; | - | ||||||||||||||||||
| 2281 | } | - | ||||||||||||||||||
| 2282 | } | - | ||||||||||||||||||
| 2283 | } | - | ||||||||||||||||||
| 2284 | void QAbstractItemViewPrivate::_q_rowsRemoved(const QModelIndex &index, int start, int end) | - | ||||||||||||||||||
| 2285 | { | - | ||||||||||||||||||
| 2286 | (void)index; | - | ||||||||||||||||||
| 2287 | (void)start; | - | ||||||||||||||||||
| 2288 | (void)end; | - | ||||||||||||||||||
| 2289 | - | |||||||||||||||||||
| 2290 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 2291 | if (q->isVisible()) | - | ||||||||||||||||||
| 2292 | q->updateEditorGeometries(); | - | ||||||||||||||||||
| 2293 | q->setState(QAbstractItemView::NoState); | - | ||||||||||||||||||
| 2294 | - | |||||||||||||||||||
| 2295 | if (QAccessible::isActive()) { | - | ||||||||||||||||||
| 2296 | QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::RowsRemoved); | - | ||||||||||||||||||
| 2297 | accessibleEvent.setFirstRow(start); | - | ||||||||||||||||||
| 2298 | accessibleEvent.setLastRow(end); | - | ||||||||||||||||||
| 2299 | QAccessible::updateAccessibility(&accessibleEvent); | - | ||||||||||||||||||
| 2300 | } | - | ||||||||||||||||||
| 2301 | - | |||||||||||||||||||
| 2302 | updateGeometry(); | - | ||||||||||||||||||
| 2303 | } | - | ||||||||||||||||||
| 2304 | void QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end) | - | ||||||||||||||||||
| 2305 | { | - | ||||||||||||||||||
| 2306 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 2307 | - | |||||||||||||||||||
| 2308 | q->setState(QAbstractItemView::CollapsingState); | - | ||||||||||||||||||
| 2309 | - | |||||||||||||||||||
| 2310 | - | |||||||||||||||||||
| 2311 | QModelIndex current = q->currentIndex(); | - | ||||||||||||||||||
| 2312 | if (current.isValid() | - | ||||||||||||||||||
| 2313 | && selectionMode == QAbstractItemView::SingleSelection | - | ||||||||||||||||||
| 2314 | && current.column() >= start | - | ||||||||||||||||||
| 2315 | && current.column() <= end) { | - | ||||||||||||||||||
| 2316 | int totalToRemove = end - start + 1; | - | ||||||||||||||||||
| 2317 | if (model->columnCount(parent) < totalToRemove) { | - | ||||||||||||||||||
| 2318 | QModelIndex index = parent; | - | ||||||||||||||||||
| 2319 | while (index.isValid() && !isIndexEnabled(index)) | - | ||||||||||||||||||
| 2320 | index = index.parent(); | - | ||||||||||||||||||
| 2321 | if (index.isValid()) | - | ||||||||||||||||||
| 2322 | q->setCurrentIndex(index); | - | ||||||||||||||||||
| 2323 | } else { | - | ||||||||||||||||||
| 2324 | int column = end; | - | ||||||||||||||||||
| 2325 | QModelIndex next; | - | ||||||||||||||||||
| 2326 | do { | - | ||||||||||||||||||
| 2327 | next = model->index(current.row(), column++, current.parent()); | - | ||||||||||||||||||
| 2328 | } while (next.isValid() && (q->isIndexHidden(next) || !isIndexEnabled(next))); | - | ||||||||||||||||||
| 2329 | q->setCurrentIndex(next); | - | ||||||||||||||||||
| 2330 | } | - | ||||||||||||||||||
| 2331 | } | - | ||||||||||||||||||
| 2332 | - | |||||||||||||||||||
| 2333 | - | |||||||||||||||||||
| 2334 | QEditorIndexHash::iterator it = editorIndexHash.begin(); | - | ||||||||||||||||||
| 2335 | while (it != editorIndexHash.end()) { | - | ||||||||||||||||||
| 2336 | QModelIndex index = it.value(); | - | ||||||||||||||||||
| 2337 | if (index.column() <= start && index.column() >= end && model->parent(index) == parent) { | - | ||||||||||||||||||
| 2338 | QWidget *editor = it.key(); | - | ||||||||||||||||||
| 2339 | QEditorInfo info = indexEditorHash.take(it.value()); | - | ||||||||||||||||||
| 2340 | it = editorIndexHash.erase(it); | - | ||||||||||||||||||
| 2341 | if (info.widget) | - | ||||||||||||||||||
| 2342 | releaseEditor(editor, index); | - | ||||||||||||||||||
| 2343 | } else { | - | ||||||||||||||||||
| 2344 | ++it; | - | ||||||||||||||||||
| 2345 | } | - | ||||||||||||||||||
| 2346 | } | - | ||||||||||||||||||
| 2347 | - | |||||||||||||||||||
| 2348 | } | - | ||||||||||||||||||
| 2349 | void QAbstractItemViewPrivate::_q_columnsRemoved(const QModelIndex &index, int start, int end) | - | ||||||||||||||||||
| 2350 | { | - | ||||||||||||||||||
| 2351 | (void)index; | - | ||||||||||||||||||
| 2352 | (void)start; | - | ||||||||||||||||||
| 2353 | (void)end; | - | ||||||||||||||||||
| 2354 | - | |||||||||||||||||||
| 2355 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 2356 | if (q->isVisible()) | - | ||||||||||||||||||
| 2357 | q->updateEditorGeometries(); | - | ||||||||||||||||||
| 2358 | q->setState(QAbstractItemView::NoState); | - | ||||||||||||||||||
| 2359 | - | |||||||||||||||||||
| 2360 | if (QAccessible::isActive()) { | - | ||||||||||||||||||
| 2361 | QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::ColumnsRemoved); | - | ||||||||||||||||||
| 2362 | accessibleEvent.setFirstColumn(start); | - | ||||||||||||||||||
| 2363 | accessibleEvent.setLastColumn(end); | - | ||||||||||||||||||
| 2364 | QAccessible::updateAccessibility(&accessibleEvent); | - | ||||||||||||||||||
| 2365 | } | - | ||||||||||||||||||
| 2366 | - | |||||||||||||||||||
| 2367 | updateGeometry(); | - | ||||||||||||||||||
| 2368 | } | - | ||||||||||||||||||
| 2369 | - | |||||||||||||||||||
| 2370 | - | |||||||||||||||||||
| 2371 | - | |||||||||||||||||||
| 2372 | - | |||||||||||||||||||
| 2373 | - | |||||||||||||||||||
| 2374 | - | |||||||||||||||||||
| 2375 | - | |||||||||||||||||||
| 2376 | void QAbstractItemViewPrivate::_q_rowsInserted(const QModelIndex &index, int start, int end) | - | ||||||||||||||||||
| 2377 | { | - | ||||||||||||||||||
| 2378 | (void)index; | - | ||||||||||||||||||
| 2379 | (void)start; | - | ||||||||||||||||||
| 2380 | (void)end; | - | ||||||||||||||||||
| 2381 | - | |||||||||||||||||||
| 2382 | - | |||||||||||||||||||
| 2383 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 2384 | if (QAccessible::isActive()) { | - | ||||||||||||||||||
| 2385 | QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::RowsInserted); | - | ||||||||||||||||||
| 2386 | accessibleEvent.setFirstRow(start); | - | ||||||||||||||||||
| 2387 | accessibleEvent.setLastRow(end); | - | ||||||||||||||||||
| 2388 | QAccessible::updateAccessibility(&accessibleEvent); | - | ||||||||||||||||||
| 2389 | } | - | ||||||||||||||||||
| 2390 | - | |||||||||||||||||||
| 2391 | updateGeometry(); | - | ||||||||||||||||||
| 2392 | } | - | ||||||||||||||||||
| 2393 | - | |||||||||||||||||||
| 2394 | - | |||||||||||||||||||
| 2395 | - | |||||||||||||||||||
| 2396 | - | |||||||||||||||||||
| 2397 | - | |||||||||||||||||||
| 2398 | - | |||||||||||||||||||
| 2399 | void QAbstractItemViewPrivate::_q_columnsInserted(const QModelIndex &index, int start, int end) | - | ||||||||||||||||||
| 2400 | { | - | ||||||||||||||||||
| 2401 | (void)index; | - | ||||||||||||||||||
| 2402 | (void)start; | - | ||||||||||||||||||
| 2403 | (void)end; | - | ||||||||||||||||||
| 2404 | - | |||||||||||||||||||
| 2405 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 2406 | if (q->isVisible()) | - | ||||||||||||||||||
| 2407 | q->updateEditorGeometries(); | - | ||||||||||||||||||
| 2408 | - | |||||||||||||||||||
| 2409 | if (QAccessible::isActive()) { | - | ||||||||||||||||||
| 2410 | QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::ColumnsInserted); | - | ||||||||||||||||||
| 2411 | accessibleEvent.setFirstColumn(start); | - | ||||||||||||||||||
| 2412 | accessibleEvent.setLastColumn(end); | - | ||||||||||||||||||
| 2413 | QAccessible::updateAccessibility(&accessibleEvent); | - | ||||||||||||||||||
| 2414 | } | - | ||||||||||||||||||
| 2415 | - | |||||||||||||||||||
| 2416 | updateGeometry(); | - | ||||||||||||||||||
| 2417 | } | - | ||||||||||||||||||
| 2418 | - | |||||||||||||||||||
| 2419 | - | |||||||||||||||||||
| 2420 | - | |||||||||||||||||||
| 2421 | - | |||||||||||||||||||
| 2422 | void QAbstractItemViewPrivate::_q_modelDestroyed() | - | ||||||||||||||||||
| 2423 | { | - | ||||||||||||||||||
| 2424 | model = QAbstractItemModelPrivate::staticEmptyModel(); | - | ||||||||||||||||||
| 2425 | doDelayedReset(); | - | ||||||||||||||||||
| 2426 | } | - | ||||||||||||||||||
| 2427 | - | |||||||||||||||||||
| 2428 | - | |||||||||||||||||||
| 2429 | - | |||||||||||||||||||
| 2430 | - | |||||||||||||||||||
| 2431 | - | |||||||||||||||||||
| 2432 | - | |||||||||||||||||||
| 2433 | void QAbstractItemViewPrivate::_q_layoutChanged() | - | ||||||||||||||||||
| 2434 | { | - | ||||||||||||||||||
| 2435 | doDelayedItemsLayout(); | - | ||||||||||||||||||
| 2436 | - | |||||||||||||||||||
| 2437 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 2438 | if (QAccessible::isActive()) { | - | ||||||||||||||||||
| 2439 | QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::ModelReset); | - | ||||||||||||||||||
| 2440 | QAccessible::updateAccessibility(&accessibleEvent); | - | ||||||||||||||||||
| 2441 | } | - | ||||||||||||||||||
| 2442 | - | |||||||||||||||||||
| 2443 | } | - | ||||||||||||||||||
| 2444 | - | |||||||||||||||||||
| 2445 | void QAbstractItemViewPrivate::_q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int) | - | ||||||||||||||||||
| 2446 | { | - | ||||||||||||||||||
| 2447 | _q_layoutChanged(); | - | ||||||||||||||||||
| 2448 | } | - | ||||||||||||||||||
| 2449 | - | |||||||||||||||||||
| 2450 | void QAbstractItemViewPrivate::_q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int) | - | ||||||||||||||||||
| 2451 | { | - | ||||||||||||||||||
| 2452 | _q_layoutChanged(); | - | ||||||||||||||||||
| 2453 | } | - | ||||||||||||||||||
| 2454 | void QAbstractItemView::selectionChanged(const QItemSelection &selected, | - | ||||||||||||||||||
| 2455 | const QItemSelection &deselected) | - | ||||||||||||||||||
| 2456 | { | - | ||||||||||||||||||
| 2457 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2458 | if (isVisible() && updatesEnabled()) { | - | ||||||||||||||||||
| 2459 | d->viewport->update(visualRegionForSelection(deselected) | visualRegionForSelection(selected)); | - | ||||||||||||||||||
| 2460 | } | - | ||||||||||||||||||
| 2461 | } | - | ||||||||||||||||||
| 2462 | void QAbstractItemView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | - | ||||||||||||||||||
| 2463 | { | - | ||||||||||||||||||
| 2464 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2465 | ((!(d->model)) ? qt_assert("d->model",__FILE__,35733623) : qt_noop()); | - | ||||||||||||||||||
| 2466 | - | |||||||||||||||||||
| 2467 | if (previous.isValid()) { | - | ||||||||||||||||||
| 2468 | QModelIndex buddy = d->model->buddy(previous); | - | ||||||||||||||||||
| 2469 | QWidget *editor = d->editorForIndex(buddy).widget.data(); | - | ||||||||||||||||||
| 2470 | if (editor && !d->persistent.contains(editor)) { | - | ||||||||||||||||||
| 2471 | commitData(editor); | - | ||||||||||||||||||
| 2472 | if (current.row() != previous.row()) | - | ||||||||||||||||||
| 2473 | closeEditor(editor, QAbstractItemDelegate::SubmitModelCache); | - | ||||||||||||||||||
| 2474 | else | - | ||||||||||||||||||
| 2475 | closeEditor(editor, QAbstractItemDelegate::NoHint); | - | ||||||||||||||||||
| 2476 | } | - | ||||||||||||||||||
| 2477 | if (isVisible()) { | - | ||||||||||||||||||
| 2478 | update(previous); | - | ||||||||||||||||||
| 2479 | } | - | ||||||||||||||||||
| 2480 | } | - | ||||||||||||||||||
| 2481 | - | |||||||||||||||||||
| 2482 | if (current.isValid() && !d->autoScrollTimer.isActive()) { | - | ||||||||||||||||||
| 2483 | if (isVisible()) { | - | ||||||||||||||||||
| 2484 | if (d->autoScroll) | - | ||||||||||||||||||
| 2485 | scrollTo(current); | - | ||||||||||||||||||
| 2486 | update(current); | - | ||||||||||||||||||
| 2487 | edit(current, CurrentChanged, 0); | - | ||||||||||||||||||
| 2488 | if (current.row() == (d->model->rowCount(d->root) - 1)) | - | ||||||||||||||||||
| 2489 | d->fetchMore(); | - | ||||||||||||||||||
| 2490 | } else { | - | ||||||||||||||||||
| 2491 | d->shouldScrollToCurrentOnShow = d->autoScroll; | - | ||||||||||||||||||
| 2492 | } | - | ||||||||||||||||||
| 2493 | } | - | ||||||||||||||||||
| 2494 | } | - | ||||||||||||||||||
| 2495 | - | |||||||||||||||||||
| 2496 | - | |||||||||||||||||||
| 2497 | - | |||||||||||||||||||
| 2498 | - | |||||||||||||||||||
| 2499 | - | |||||||||||||||||||
| 2500 | void QAbstractItemView::startDrag(Qt::DropActions supportedActions) | - | ||||||||||||||||||
| 2501 | { | - | ||||||||||||||||||
| 2502 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2503 | QModelIndexList indexes = d->selectedDraggableIndexes(); | - | ||||||||||||||||||
| 2504 | if (indexes.count() > 0) { | - | ||||||||||||||||||
| 2505 | QMimeData *data = d->model->mimeData(indexes); | - | ||||||||||||||||||
| 2506 | if (!data) | - | ||||||||||||||||||
| 2507 | return; | - | ||||||||||||||||||
| 2508 | QRect rect; | - | ||||||||||||||||||
| 2509 | QPixmap pixmap = d->renderToPixmap(indexes, &rect); | - | ||||||||||||||||||
| 2510 | rect.adjust(horizontalOffset(), verticalOffset(), 0, 0); | - | ||||||||||||||||||
| 2511 | QDrag *drag = new QDrag(this); | - | ||||||||||||||||||
| 2512 | drag->setPixmap(pixmap); | - | ||||||||||||||||||
| 2513 | drag->setMimeData(data); | - | ||||||||||||||||||
| 2514 | drag->setHotSpot(d->pressedPosition - rect.topLeft()); | - | ||||||||||||||||||
| 2515 | Qt::DropAction defaultDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||
| 2516 | if (d->defaultDropAction != Qt::IgnoreAction && (supportedActions & d->defaultDropAction)) | - | ||||||||||||||||||
| 2517 | defaultDropAction = d->defaultDropAction; | - | ||||||||||||||||||
| 2518 | else if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove) | - | ||||||||||||||||||
| 2519 | defaultDropAction = Qt::CopyAction; | - | ||||||||||||||||||
| 2520 | if (drag->exec(supportedActions, defaultDropAction) == Qt::MoveAction) | - | ||||||||||||||||||
| 2521 | d->clearOrRemove(); | - | ||||||||||||||||||
| 2522 | - | |||||||||||||||||||
| 2523 | d->dropIndicatorRect = QRect(); | - | ||||||||||||||||||
| 2524 | d->dropIndicatorPosition = OnItem; | - | ||||||||||||||||||
| 2525 | } | - | ||||||||||||||||||
| 2526 | } | - | ||||||||||||||||||
| 2527 | - | |||||||||||||||||||
| 2528 | - | |||||||||||||||||||
| 2529 | - | |||||||||||||||||||
| 2530 | - | |||||||||||||||||||
| 2531 | - | |||||||||||||||||||
| 2532 | - | |||||||||||||||||||
| 2533 | QStyleOptionViewItem QAbstractItemView::viewOptions() const | - | ||||||||||||||||||
| 2534 | { | - | ||||||||||||||||||
| 2535 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2536 | QStyleOptionViewItem option; | - | ||||||||||||||||||
| 2537 | option.init(this); | - | ||||||||||||||||||
| 2538 | option.state &= ~QStyle::State_MouseOver; | - | ||||||||||||||||||
| 2539 | option.font = font(); | - | ||||||||||||||||||
| 2540 | - | |||||||||||||||||||
| 2541 | - | |||||||||||||||||||
| 2542 | - | |||||||||||||||||||
| 2543 | - | |||||||||||||||||||
| 2544 | if (!hasFocus()) | - | ||||||||||||||||||
| 2545 | option.state &= ~QStyle::State_Active; | - | ||||||||||||||||||
| 2546 | - | |||||||||||||||||||
| 2547 | - | |||||||||||||||||||
| 2548 | option.state &= ~QStyle::State_HasFocus; | - | ||||||||||||||||||
| 2549 | if (d->iconSize.isValid()) { | - | ||||||||||||||||||
| 2550 | option.decorationSize = d->iconSize; | - | ||||||||||||||||||
| 2551 | } else { | - | ||||||||||||||||||
| 2552 | int pm = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); | - | ||||||||||||||||||
| 2553 | option.decorationSize = QSize(pm, pm); | - | ||||||||||||||||||
| 2554 | } | - | ||||||||||||||||||
| 2555 | option.decorationPosition = QStyleOptionViewItem::Left; | - | ||||||||||||||||||
| 2556 | option.decorationAlignment = Qt::AlignCenter; | - | ||||||||||||||||||
| 2557 | option.displayAlignment = Qt::AlignLeft|Qt::AlignVCenter; | - | ||||||||||||||||||
| 2558 | option.textElideMode = d->textElideMode; | - | ||||||||||||||||||
| 2559 | option.rect = QRect(); | - | ||||||||||||||||||
| 2560 | option.showDecorationSelected = style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, this); | - | ||||||||||||||||||
| 2561 | if (d->wrapItemText) | - | ||||||||||||||||||
| 2562 | option.features = QStyleOptionViewItem::WrapText; | - | ||||||||||||||||||
| 2563 | option.locale = locale(); | - | ||||||||||||||||||
| 2564 | option.locale.setNumberOptions(QLocale::OmitGroupSeparator); | - | ||||||||||||||||||
| 2565 | option.widget = this; | - | ||||||||||||||||||
| 2566 | return option; | - | ||||||||||||||||||
| 2567 | } | - | ||||||||||||||||||
| 2568 | - | |||||||||||||||||||
| 2569 | QStyleOptionViewItem QAbstractItemViewPrivate::viewOptionsV1() const | - | ||||||||||||||||||
| 2570 | { | - | ||||||||||||||||||
| 2571 | const QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 2572 | return q->viewOptions(); | - | ||||||||||||||||||
| 2573 | } | - | ||||||||||||||||||
| 2574 | - | |||||||||||||||||||
| 2575 | - | |||||||||||||||||||
| 2576 | - | |||||||||||||||||||
| 2577 | - | |||||||||||||||||||
| 2578 | - | |||||||||||||||||||
| 2579 | - | |||||||||||||||||||
| 2580 | QAbstractItemView::State QAbstractItemView::state() const | - | ||||||||||||||||||
| 2581 | { | - | ||||||||||||||||||
| 2582 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2583 | return d->state; | - | ||||||||||||||||||
| 2584 | } | - | ||||||||||||||||||
| 2585 | - | |||||||||||||||||||
| 2586 | - | |||||||||||||||||||
| 2587 | - | |||||||||||||||||||
| 2588 | - | |||||||||||||||||||
| 2589 | - | |||||||||||||||||||
| 2590 | - | |||||||||||||||||||
| 2591 | void QAbstractItemView::setState(State state) | - | ||||||||||||||||||
| 2592 | { | - | ||||||||||||||||||
| 2593 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2594 | d->state = state; | - | ||||||||||||||||||
| 2595 | } | - | ||||||||||||||||||
| 2596 | void QAbstractItemView::scheduleDelayedItemsLayout() | - | ||||||||||||||||||
| 2597 | { | - | ||||||||||||||||||
| 2598 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2599 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||
| 2600 | } | - | ||||||||||||||||||
| 2601 | - | |||||||||||||||||||
| 2602 | - | |||||||||||||||||||
| 2603 | - | |||||||||||||||||||
| 2604 | - | |||||||||||||||||||
| 2605 | - | |||||||||||||||||||
| 2606 | - | |||||||||||||||||||
| 2607 | - | |||||||||||||||||||
| 2608 | void QAbstractItemView::executeDelayedItemsLayout() | - | ||||||||||||||||||
| 2609 | { | - | ||||||||||||||||||
| 2610 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2611 | d->executePostedLayout(); | - | ||||||||||||||||||
| 2612 | } | - | ||||||||||||||||||
| 2613 | void QAbstractItemView::setDirtyRegion(const QRegion ®ion) | - | ||||||||||||||||||
| 2614 | { | - | ||||||||||||||||||
| 2615 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2616 | d->setDirtyRegion(region); | - | ||||||||||||||||||
| 2617 | } | - | ||||||||||||||||||
| 2618 | void QAbstractItemView::scrollDirtyRegion(int dx, int dy) | - | ||||||||||||||||||
| 2619 | { | - | ||||||||||||||||||
| 2620 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2621 | d->scrollDirtyRegion(dx, dy); | - | ||||||||||||||||||
| 2622 | } | - | ||||||||||||||||||
| 2623 | QPoint QAbstractItemView::dirtyRegionOffset() const | - | ||||||||||||||||||
| 2624 | { | - | ||||||||||||||||||
| 2625 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2626 | return d->scrollDelayOffset; | - | ||||||||||||||||||
| 2627 | } | - | ||||||||||||||||||
| 2628 | - | |||||||||||||||||||
| 2629 | - | |||||||||||||||||||
| 2630 | - | |||||||||||||||||||
| 2631 | - | |||||||||||||||||||
| 2632 | void QAbstractItemView::startAutoScroll() | - | ||||||||||||||||||
| 2633 | { | - | ||||||||||||||||||
| 2634 | d_func()->startAutoScroll(); | - | ||||||||||||||||||
| 2635 | } | - | ||||||||||||||||||
| 2636 | - | |||||||||||||||||||
| 2637 | - | |||||||||||||||||||
| 2638 | - | |||||||||||||||||||
| 2639 | - | |||||||||||||||||||
| 2640 | void QAbstractItemView::stopAutoScroll() | - | ||||||||||||||||||
| 2641 | { | - | ||||||||||||||||||
| 2642 | d_func()->stopAutoScroll(); | - | ||||||||||||||||||
| 2643 | } | - | ||||||||||||||||||
| 2644 | - | |||||||||||||||||||
| 2645 | - | |||||||||||||||||||
| 2646 | - | |||||||||||||||||||
| 2647 | - | |||||||||||||||||||
| 2648 | void QAbstractItemView::doAutoScroll() | - | ||||||||||||||||||
| 2649 | { | - | ||||||||||||||||||
| 2650 | - | |||||||||||||||||||
| 2651 | QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2652 | QScrollBar *verticalScroll = verticalScrollBar(); | - | ||||||||||||||||||
| 2653 | QScrollBar *horizontalScroll = horizontalScrollBar(); | - | ||||||||||||||||||
| 2654 | - | |||||||||||||||||||
| 2655 | - | |||||||||||||||||||
| 2656 | - | |||||||||||||||||||
| 2657 | QHeaderView *hv = qobject_cast<QHeaderView*>(this); | - | ||||||||||||||||||
| 2658 | if (hv) { | - | ||||||||||||||||||
| 2659 | QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea*>(parentWidget()); | - | ||||||||||||||||||
| 2660 | if (parent) { | - | ||||||||||||||||||
| 2661 | if (hv->orientation() == Qt::Horizontal) { | - | ||||||||||||||||||
| 2662 | if (!hv->horizontalScrollBar() || !hv->horizontalScrollBar()->isVisible()) | - | ||||||||||||||||||
| 2663 | horizontalScroll = parent->horizontalScrollBar(); | - | ||||||||||||||||||
| 2664 | } else { | - | ||||||||||||||||||
| 2665 | if (!hv->verticalScrollBar() || !hv->verticalScrollBar()->isVisible()) | - | ||||||||||||||||||
| 2666 | verticalScroll = parent->verticalScrollBar(); | - | ||||||||||||||||||
| 2667 | } | - | ||||||||||||||||||
| 2668 | } | - | ||||||||||||||||||
| 2669 | } | - | ||||||||||||||||||
| 2670 | - | |||||||||||||||||||
| 2671 | int verticalStep = verticalScroll->pageStep(); | - | ||||||||||||||||||
| 2672 | int horizontalStep = horizontalScroll->pageStep(); | - | ||||||||||||||||||
| 2673 | if (d->autoScrollCount < qMax(verticalStep, horizontalStep)) | - | ||||||||||||||||||
| 2674 | ++d->autoScrollCount; | - | ||||||||||||||||||
| 2675 | - | |||||||||||||||||||
| 2676 | int margin = d->autoScrollMargin; | - | ||||||||||||||||||
| 2677 | int verticalValue = verticalScroll->value(); | - | ||||||||||||||||||
| 2678 | int horizontalValue = horizontalScroll->value(); | - | ||||||||||||||||||
| 2679 | - | |||||||||||||||||||
| 2680 | QPoint pos = d->viewport->mapFromGlobal(QCursor::pos()); | - | ||||||||||||||||||
| 2681 | QRect area = QWidgetPrivate::get(d->viewport)->clipRect(); | - | ||||||||||||||||||
| 2682 | - | |||||||||||||||||||
| 2683 | - | |||||||||||||||||||
| 2684 | if (pos.y() - area.top() < margin) | - | ||||||||||||||||||
| 2685 | verticalScroll->setValue(verticalValue - d->autoScrollCount); | - | ||||||||||||||||||
| 2686 | else if (area.bottom() - pos.y() < margin) | - | ||||||||||||||||||
| 2687 | verticalScroll->setValue(verticalValue + d->autoScrollCount); | - | ||||||||||||||||||
| 2688 | if (pos.x() - area.left() < margin) | - | ||||||||||||||||||
| 2689 | horizontalScroll->setValue(horizontalValue - d->autoScrollCount); | - | ||||||||||||||||||
| 2690 | else if (area.right() - pos.x() < margin) | - | ||||||||||||||||||
| 2691 | horizontalScroll->setValue(horizontalValue + d->autoScrollCount); | - | ||||||||||||||||||
| 2692 | - | |||||||||||||||||||
| 2693 | bool verticalUnchanged = (verticalValue == verticalScroll->value()); | - | ||||||||||||||||||
| 2694 | bool horizontalUnchanged = (horizontalValue == horizontalScroll->value()); | - | ||||||||||||||||||
| 2695 | if (verticalUnchanged && horizontalUnchanged) { | - | ||||||||||||||||||
| 2696 | stopAutoScroll(); | - | ||||||||||||||||||
| 2697 | } else { | - | ||||||||||||||||||
| 2698 | - | |||||||||||||||||||
| 2699 | d->dropIndicatorRect = QRect(); | - | ||||||||||||||||||
| 2700 | d->dropIndicatorPosition = QAbstractItemView::OnViewport; | - | ||||||||||||||||||
| 2701 | - | |||||||||||||||||||
| 2702 | d->viewport->update(); | - | ||||||||||||||||||
| 2703 | } | - | ||||||||||||||||||
| 2704 | } | - | ||||||||||||||||||
| 2705 | QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QModelIndex &index, | - | ||||||||||||||||||
| 2706 | const QEvent *event) const | - | ||||||||||||||||||
| 2707 | { | - | ||||||||||||||||||
| 2708 | const QAbstractItemViewPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2709 | Qt::KeyboardModifiers keyModifiers = Qt::NoModifier; | - | ||||||||||||||||||
| 2710 | if (event) { | - | ||||||||||||||||||
| 2711 | switch (event->type()) { | - | ||||||||||||||||||
| 2712 | case QEvent::MouseButtonDblClick: | - | ||||||||||||||||||
| 2713 | case QEvent::MouseButtonPress: | - | ||||||||||||||||||
| 2714 | case QEvent::MouseButtonRelease: | - | ||||||||||||||||||
| 2715 | case QEvent::MouseMove: | - | ||||||||||||||||||
| 2716 | case QEvent::KeyPress: | - | ||||||||||||||||||
| 2717 | case QEvent::KeyRelease: | - | ||||||||||||||||||
| 2718 | keyModifiers = (static_cast<const QInputEvent*>(event))->modifiers(); | - | ||||||||||||||||||
| 2719 | break; | - | ||||||||||||||||||
| 2720 | default: | - | ||||||||||||||||||
| 2721 | keyModifiers = QApplication::keyboardModifiers(); | - | ||||||||||||||||||
| 2722 | } | - | ||||||||||||||||||
| 2723 | } | - | ||||||||||||||||||
| 2724 | switch (d->selectionMode) { | - | ||||||||||||||||||
| 2725 | case NoSelection: | - | ||||||||||||||||||
| 2726 | return QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 2727 | case SingleSelection: | - | ||||||||||||||||||
| 2728 | if (event && event->type() == QEvent::MouseButtonRelease) | - | ||||||||||||||||||
| 2729 | return QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 2730 | if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index)) | - | ||||||||||||||||||
| 2731 | return QItemSelectionModel::Deselect | d->selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2732 | else | - | ||||||||||||||||||
| 2733 | return QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2734 | case MultiSelection: | - | ||||||||||||||||||
| 2735 | return d->multiSelectionCommand(index, event); | - | ||||||||||||||||||
| 2736 | case ExtendedSelection: | - | ||||||||||||||||||
| 2737 | return d->extendedSelectionCommand(index, event); | - | ||||||||||||||||||
| 2738 | case ContiguousSelection: | - | ||||||||||||||||||
| 2739 | return d->contiguousSelectionCommand(index, event); | - | ||||||||||||||||||
| 2740 | } | - | ||||||||||||||||||
| 2741 | return QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 2742 | } | - | ||||||||||||||||||
| 2743 | - | |||||||||||||||||||
| 2744 | QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::multiSelectionCommand( | - | ||||||||||||||||||
| 2745 | const QModelIndex &index, const QEvent *event) const | - | ||||||||||||||||||
| 2746 | { | - | ||||||||||||||||||
| 2747 | (void)index; | - | ||||||||||||||||||
| 2748 | - | |||||||||||||||||||
| 2749 | if (event) { | - | ||||||||||||||||||
| 2750 | switch (event->type()) { | - | ||||||||||||||||||
| 2751 | case QEvent::KeyPress: | - | ||||||||||||||||||
| 2752 | if (static_cast<const QKeyEvent*>(event)->key() == Qt::Key_Space | - | ||||||||||||||||||
| 2753 | || static_cast<const QKeyEvent*>(event)->key() == Qt::Key_Select) | - | ||||||||||||||||||
| 2754 | return QItemSelectionModel::Toggle|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2755 | break; | - | ||||||||||||||||||
| 2756 | case QEvent::MouseButtonPress: | - | ||||||||||||||||||
| 2757 | if (static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton) | - | ||||||||||||||||||
| 2758 | return QItemSelectionModel::Toggle|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2759 | break; | - | ||||||||||||||||||
| 2760 | case QEvent::MouseButtonRelease: | - | ||||||||||||||||||
| 2761 | if (static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton) | - | ||||||||||||||||||
| 2762 | return QItemSelectionModel::NoUpdate|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2763 | break; | - | ||||||||||||||||||
| 2764 | case QEvent::MouseMove: | - | ||||||||||||||||||
| 2765 | if (static_cast<const QMouseEvent*>(event)->buttons() & Qt::LeftButton) | - | ||||||||||||||||||
| 2766 | return QItemSelectionModel::ToggleCurrent|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2767 | default: | - | ||||||||||||||||||
| 2768 | break; | - | ||||||||||||||||||
| 2769 | } | - | ||||||||||||||||||
| 2770 | return QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 2771 | } | - | ||||||||||||||||||
| 2772 | - | |||||||||||||||||||
| 2773 | return QItemSelectionModel::Toggle|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2774 | } | - | ||||||||||||||||||
| 2775 | - | |||||||||||||||||||
| 2776 | QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionCommand( | - | ||||||||||||||||||
| 2777 | const QModelIndex &index, const QEvent *event) const | - | ||||||||||||||||||
| 2778 | { | - | ||||||||||||||||||
| 2779 | Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers(); | - | ||||||||||||||||||
| 2780 | if (event) { | - | ||||||||||||||||||
| 2781 | switch (event->type()) { | - | ||||||||||||||||||
| 2782 | case QEvent::MouseMove: { | - | ||||||||||||||||||
| 2783 | - | |||||||||||||||||||
| 2784 | modifiers = static_cast<const QMouseEvent*>(event)->modifiers(); | - | ||||||||||||||||||
| 2785 | if (modifiers & Qt::ControlModifier) | - | ||||||||||||||||||
| 2786 | return QItemSelectionModel::ToggleCurrent|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2787 | break; | - | ||||||||||||||||||
| 2788 | } | - | ||||||||||||||||||
| 2789 | case QEvent::MouseButtonPress: { | - | ||||||||||||||||||
| 2790 | modifiers = static_cast<const QMouseEvent*>(event)->modifiers(); | - | ||||||||||||||||||
| 2791 | const Qt::MouseButton button = static_cast<const QMouseEvent*>(event)->button(); | - | ||||||||||||||||||
| 2792 | const bool rightButtonPressed = button & Qt::RightButton; | - | ||||||||||||||||||
| 2793 | const bool shiftKeyPressed = modifiers & Qt::ShiftModifier; | - | ||||||||||||||||||
| 2794 | const bool controlKeyPressed = modifiers & Qt::ControlModifier; | - | ||||||||||||||||||
| 2795 | const bool indexIsSelected = selectionModel->isSelected(index); | - | ||||||||||||||||||
| 2796 | if ((shiftKeyPressed || controlKeyPressed) && rightButtonPressed) | - | ||||||||||||||||||
| 2797 | return QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 2798 | if (!shiftKeyPressed && !controlKeyPressed && indexIsSelected) | - | ||||||||||||||||||
| 2799 | return QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 2800 | if (!index.isValid() && !rightButtonPressed && !shiftKeyPressed && !controlKeyPressed) | - | ||||||||||||||||||
| 2801 | return QItemSelectionModel::Clear; | - | ||||||||||||||||||
| 2802 | if (!index.isValid()) | - | ||||||||||||||||||
| 2803 | return QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 2804 | break; | - | ||||||||||||||||||
| 2805 | } | - | ||||||||||||||||||
| 2806 | case QEvent::MouseButtonRelease: { | - | ||||||||||||||||||
| 2807 | - | |||||||||||||||||||
| 2808 | modifiers = static_cast<const QMouseEvent*>(event)->modifiers(); | - | ||||||||||||||||||
| 2809 | const Qt::MouseButton button = static_cast<const QMouseEvent*>(event)->button(); | - | ||||||||||||||||||
| 2810 | const bool rightButtonPressed = button & Qt::RightButton; | - | ||||||||||||||||||
| 2811 | const bool shiftKeyPressed = modifiers & Qt::ShiftModifier; | - | ||||||||||||||||||
| 2812 | const bool controlKeyPressed = modifiers & Qt::ControlModifier; | - | ||||||||||||||||||
| 2813 | if (((index == pressedIndex && selectionModel->isSelected(index)) | - | ||||||||||||||||||
| 2814 | || !index.isValid()) && state != QAbstractItemView::DragSelectingState | - | ||||||||||||||||||
| 2815 | && !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !index.isValid())) | - | ||||||||||||||||||
| 2816 | return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2817 | return QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 2818 | } | - | ||||||||||||||||||
| 2819 | case QEvent::KeyPress: { | - | ||||||||||||||||||
| 2820 | - | |||||||||||||||||||
| 2821 | modifiers = static_cast<const QKeyEvent*>(event)->modifiers(); | - | ||||||||||||||||||
| 2822 | switch (static_cast<const QKeyEvent*>(event)->key()) { | - | ||||||||||||||||||
| 2823 | case Qt::Key_Backtab: | - | ||||||||||||||||||
| 2824 | modifiers = modifiers & ~Qt::ShiftModifier; | - | ||||||||||||||||||
| 2825 | case Qt::Key_Down: | - | ||||||||||||||||||
| 2826 | case Qt::Key_Up: | - | ||||||||||||||||||
| 2827 | case Qt::Key_Left: | - | ||||||||||||||||||
| 2828 | case Qt::Key_Right: | - | ||||||||||||||||||
| 2829 | case Qt::Key_Home: | - | ||||||||||||||||||
| 2830 | case Qt::Key_End: | - | ||||||||||||||||||
| 2831 | case Qt::Key_PageUp: | - | ||||||||||||||||||
| 2832 | case Qt::Key_PageDown: | - | ||||||||||||||||||
| 2833 | case Qt::Key_Tab: | - | ||||||||||||||||||
| 2834 | if (modifiers & Qt::ControlModifier | - | ||||||||||||||||||
| 2835 | - | |||||||||||||||||||
| 2836 | - | |||||||||||||||||||
| 2837 | - | |||||||||||||||||||
| 2838 | - | |||||||||||||||||||
| 2839 | ) | - | ||||||||||||||||||
| 2840 | return QItemSelectionModel::NoUpdate; | - | ||||||||||||||||||
| 2841 | break; | - | ||||||||||||||||||
| 2842 | case Qt::Key_Select: | - | ||||||||||||||||||
| 2843 | return QItemSelectionModel::Toggle|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2844 | case Qt::Key_Space: | - | ||||||||||||||||||
| 2845 | if (modifiers & Qt::ControlModifier) | - | ||||||||||||||||||
| 2846 | return QItemSelectionModel::Toggle|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2847 | return QItemSelectionModel::Select|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2848 | default: | - | ||||||||||||||||||
| 2849 | break; | - | ||||||||||||||||||
| 2850 | } | - | ||||||||||||||||||
| 2851 | } | - | ||||||||||||||||||
| 2852 | default: | - | ||||||||||||||||||
| 2853 | break; | - | ||||||||||||||||||
| 2854 | } | - | ||||||||||||||||||
| 2855 | } | - | ||||||||||||||||||
| 2856 | - | |||||||||||||||||||
| 2857 | if (modifiers & Qt::ShiftModifier) | - | ||||||||||||||||||
| 2858 | return QItemSelectionModel::SelectCurrent|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2859 | if (modifiers & Qt::ControlModifier) | - | ||||||||||||||||||
| 2860 | return QItemSelectionModel::Toggle|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2861 | if (state == QAbstractItemView::DragSelectingState) { | - | ||||||||||||||||||
| 2862 | - | |||||||||||||||||||
| 2863 | return QItemSelectionModel::Clear|QItemSelectionModel::SelectCurrent|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2864 | } | - | ||||||||||||||||||
| 2865 | - | |||||||||||||||||||
| 2866 | return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2867 | } | - | ||||||||||||||||||
| 2868 | - | |||||||||||||||||||
| 2869 | QItemSelectionModel::SelectionFlags | - | ||||||||||||||||||
| 2870 | QAbstractItemViewPrivate::contiguousSelectionCommand(const QModelIndex &index, | - | ||||||||||||||||||
| 2871 | const QEvent *event) const | - | ||||||||||||||||||
| 2872 | { | - | ||||||||||||||||||
| 2873 | QItemSelectionModel::SelectionFlags flags = extendedSelectionCommand(index, event); | - | ||||||||||||||||||
| 2874 | const int Mask = QItemSelectionModel::Clear | QItemSelectionModel::Select | - | ||||||||||||||||||
| 2875 | | QItemSelectionModel::Deselect | QItemSelectionModel::Toggle | - | ||||||||||||||||||
| 2876 | | QItemSelectionModel::Current; | - | ||||||||||||||||||
| 2877 | - | |||||||||||||||||||
| 2878 | switch (flags & Mask) { | - | ||||||||||||||||||
| 2879 | case QItemSelectionModel::Clear: | - | ||||||||||||||||||
| 2880 | case QItemSelectionModel::ClearAndSelect: | - | ||||||||||||||||||
| 2881 | case QItemSelectionModel::SelectCurrent: | - | ||||||||||||||||||
| 2882 | return flags; | - | ||||||||||||||||||
| 2883 | case QItemSelectionModel::NoUpdate: | - | ||||||||||||||||||
| 2884 | if (event && | - | ||||||||||||||||||
| 2885 | (event->type() == QEvent::MouseButtonPress | - | ||||||||||||||||||
| 2886 | || event->type() == QEvent::MouseButtonRelease)) | - | ||||||||||||||||||
| 2887 | return flags; | - | ||||||||||||||||||
| 2888 | return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2889 | default: | - | ||||||||||||||||||
| 2890 | return QItemSelectionModel::SelectCurrent|selectionBehaviorFlags(); | - | ||||||||||||||||||
| 2891 | } | - | ||||||||||||||||||
| 2892 | } | - | ||||||||||||||||||
| 2893 | - | |||||||||||||||||||
| 2894 | void QAbstractItemViewPrivate::fetchMore() | - | ||||||||||||||||||
| 2895 | { | - | ||||||||||||||||||
| 2896 | fetchMoreTimer.stop(); | - | ||||||||||||||||||
| 2897 | if (!model->canFetchMore(root)) | - | ||||||||||||||||||
| 2898 | return; | - | ||||||||||||||||||
| 2899 | int last = model->rowCount(root) - 1; | - | ||||||||||||||||||
| 2900 | if (last < 0) { | - | ||||||||||||||||||
| 2901 | model->fetchMore(root); | - | ||||||||||||||||||
| 2902 | return; | - | ||||||||||||||||||
| 2903 | } | - | ||||||||||||||||||
| 2904 | - | |||||||||||||||||||
| 2905 | QModelIndex index = model->index(last, 0, root); | - | ||||||||||||||||||
| 2906 | QRect rect = q_func()->visualRect(index); | - | ||||||||||||||||||
| 2907 | if (viewport->rect().intersects(rect)) | - | ||||||||||||||||||
| 2908 | model->fetchMore(root); | - | ||||||||||||||||||
| 2909 | } | - | ||||||||||||||||||
| 2910 | - | |||||||||||||||||||
| 2911 | bool QAbstractItemViewPrivate::shouldEdit(QAbstractItemView::EditTrigger trigger, | - | ||||||||||||||||||
| 2912 | const QModelIndex &index) const | - | ||||||||||||||||||
| 2913 | { | - | ||||||||||||||||||
| 2914 | if (!index.isValid()) | - | ||||||||||||||||||
| 2915 | return false; | - | ||||||||||||||||||
| 2916 | Qt::ItemFlags flags = model->flags(index); | - | ||||||||||||||||||
| 2917 | if (((flags & Qt::ItemIsEditable) == 0) || ((flags & Qt::ItemIsEnabled) == 0)) | - | ||||||||||||||||||
| 2918 | return false; | - | ||||||||||||||||||
| 2919 | if (state == QAbstractItemView::EditingState) | - | ||||||||||||||||||
| 2920 | return false; | - | ||||||||||||||||||
| 2921 | if (hasEditor(index)) | - | ||||||||||||||||||
| 2922 | return false; | - | ||||||||||||||||||
| 2923 | if (trigger == QAbstractItemView::AllEditTriggers) | - | ||||||||||||||||||
| 2924 | return true; | - | ||||||||||||||||||
| 2925 | if ((trigger & editTriggers) == QAbstractItemView::SelectedClicked | - | ||||||||||||||||||
| 2926 | && !selectionModel->isSelected(index)) | - | ||||||||||||||||||
| 2927 | return false; | - | ||||||||||||||||||
| 2928 | return (trigger & editTriggers); | - | ||||||||||||||||||
| 2929 | } | - | ||||||||||||||||||
| 2930 | - | |||||||||||||||||||
| 2931 | bool QAbstractItemViewPrivate::shouldForwardEvent(QAbstractItemView::EditTrigger trigger, | - | ||||||||||||||||||
| 2932 | const QEvent *event) const | - | ||||||||||||||||||
| 2933 | { | - | ||||||||||||||||||
| 2934 | if (!event || (trigger & editTriggers) != QAbstractItemView::AnyKeyPressed) | - | ||||||||||||||||||
| 2935 | return false; | - | ||||||||||||||||||
| 2936 | - | |||||||||||||||||||
| 2937 | switch (event->type()) { | - | ||||||||||||||||||
| 2938 | case QEvent::KeyPress: | - | ||||||||||||||||||
| 2939 | case QEvent::MouseButtonDblClick: | - | ||||||||||||||||||
| 2940 | case QEvent::MouseButtonPress: | - | ||||||||||||||||||
| 2941 | case QEvent::MouseButtonRelease: | - | ||||||||||||||||||
| 2942 | case QEvent::MouseMove: | - | ||||||||||||||||||
| 2943 | return true; | - | ||||||||||||||||||
| 2944 | default: | - | ||||||||||||||||||
| 2945 | break; | - | ||||||||||||||||||
| 2946 | }; | - | ||||||||||||||||||
| 2947 | - | |||||||||||||||||||
| 2948 | return false; | - | ||||||||||||||||||
| 2949 | } | - | ||||||||||||||||||
| 2950 | - | |||||||||||||||||||
| 2951 | bool QAbstractItemViewPrivate::shouldAutoScroll(const QPoint &pos) const | - | ||||||||||||||||||
| 2952 | { | - | ||||||||||||||||||
| 2953 | if (!autoScroll) | - | ||||||||||||||||||
| 2954 | return false; | - | ||||||||||||||||||
| 2955 | QRect area = static_cast<QAbstractItemView*>(viewport)->d_func()->clipRect(); | - | ||||||||||||||||||
| 2956 | return (pos.y() - area.top() < autoScrollMargin) | - | ||||||||||||||||||
| 2957 | || (area.bottom() - pos.y() < autoScrollMargin) | - | ||||||||||||||||||
| 2958 | || (pos.x() - area.left() < autoScrollMargin) | - | ||||||||||||||||||
| 2959 | || (area.right() - pos.x() < autoScrollMargin); | - | ||||||||||||||||||
| 2960 | } | - | ||||||||||||||||||
| 2961 | - | |||||||||||||||||||
| 2962 | void QAbstractItemViewPrivate::doDelayedItemsLayout(int delay) | - | ||||||||||||||||||
| 2963 | { | - | ||||||||||||||||||
| 2964 | if (!delayedPendingLayout) { | - | ||||||||||||||||||
| 2965 | delayedPendingLayout = true; | - | ||||||||||||||||||
| 2966 | delayedLayout.start(delay, q_func()); | - | ||||||||||||||||||
| 2967 | } | - | ||||||||||||||||||
| 2968 | } | - | ||||||||||||||||||
| 2969 | - | |||||||||||||||||||
| 2970 | void QAbstractItemViewPrivate::interruptDelayedItemsLayout() const | - | ||||||||||||||||||
| 2971 | { | - | ||||||||||||||||||
| 2972 | delayedLayout.stop(); | - | ||||||||||||||||||
| 2973 | delayedPendingLayout = false; | - | ||||||||||||||||||
| 2974 | } | - | ||||||||||||||||||
| 2975 | - | |||||||||||||||||||
| 2976 | void QAbstractItemViewPrivate::updateGeometry() | - | ||||||||||||||||||
| 2977 | { | - | ||||||||||||||||||
| 2978 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 2979 | if (sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored) | - | ||||||||||||||||||
| 2980 | return; | - | ||||||||||||||||||
| 2981 | if (sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents || !shownOnce) | - | ||||||||||||||||||
| 2982 | q->updateGeometry(); | - | ||||||||||||||||||
| 2983 | } | - | ||||||||||||||||||
| 2984 | - | |||||||||||||||||||
| 2985 | QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index, | - | ||||||||||||||||||
| 2986 | const QStyleOptionViewItem &options) | - | ||||||||||||||||||
| 2987 | { | - | ||||||||||||||||||
| 2988 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 2989 | QWidget *w = editorForIndex(index).widget.data(); | - | ||||||||||||||||||
| 2990 | if (!w) { | - | ||||||||||||||||||
| 2991 | QAbstractItemDelegate *delegate = delegateForIndex(index); | - | ||||||||||||||||||
| 2992 | if (!delegate) | - | ||||||||||||||||||
| 2993 | return 0; | - | ||||||||||||||||||
| 2994 | w = delegate->createEditor(viewport, options, index); | - | ||||||||||||||||||
| 2995 | if (w) { | - | ||||||||||||||||||
| 2996 | w->installEventFilter(delegate); | - | ||||||||||||||||||
| 2997 | QObject::connect(w, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "4157""4207"), q, qFlagLocation("1""editorDestroyed(QObject*)" "\0" __FILE__ ":" "4157""4207")); | - | ||||||||||||||||||
| 2998 | delegate->updateEditorGeometry(w, options, index); | - | ||||||||||||||||||
| 2999 | delegate->setEditorData(w, index); | - | ||||||||||||||||||
| 3000 | addEditor(index, w, false); | - | ||||||||||||||||||
| 3001 | if (w->parent() == viewport) | - | ||||||||||||||||||
| 3002 | QWidget::setTabOrder(q, w); | - | ||||||||||||||||||
| 3003 | - | |||||||||||||||||||
| 3004 | - | |||||||||||||||||||
| 3005 | QWidget *focusWidget = w; | - | ||||||||||||||||||
| 3006 | while (QWidget *fp = focusWidget->focusProxy()) | - | ||||||||||||||||||
| 3007 | focusWidget = fp; | - | ||||||||||||||||||
| 3008 | - | |||||||||||||||||||
| 3009 | if (QLineEdit *le = qobject_cast<QLineEdit*>(focusWidget)) | - | ||||||||||||||||||
| 3010 | le->selectAll(); | - | ||||||||||||||||||
| 3011 | - | |||||||||||||||||||
| 3012 | - | |||||||||||||||||||
| 3013 | if (QSpinBox *sb = qobject_cast<QSpinBox*>(focusWidget)) | - | ||||||||||||||||||
| 3014 | sb->selectAll(); | - | ||||||||||||||||||
| 3015 | else if (QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(focusWidget)) | - | ||||||||||||||||||
| 3016 | dsb->selectAll(); | - | ||||||||||||||||||
| 3017 | - | |||||||||||||||||||
| 3018 | } | - | ||||||||||||||||||
| 3019 | } | - | ||||||||||||||||||
| 3020 | - | |||||||||||||||||||
| 3021 | return w; | - | ||||||||||||||||||
| 3022 | } | - | ||||||||||||||||||
| 3023 | - | |||||||||||||||||||
| 3024 | void QAbstractItemViewPrivate::updateEditorData(const QModelIndex &tl, const QModelIndex &br) | - | ||||||||||||||||||
| 3025 | { | - | ||||||||||||||||||
| 3026 | - | |||||||||||||||||||
| 3027 | const bool checkIndexes = tl.isValid() && br.isValid(); | - | ||||||||||||||||||
| 3028 | const QModelIndex parent = tl.parent(); | - | ||||||||||||||||||
| 3029 | - | |||||||||||||||||||
| 3030 | - | |||||||||||||||||||
| 3031 | - | |||||||||||||||||||
| 3032 | const QIndexEditorHash indexEditorHashCopy = indexEditorHash; | - | ||||||||||||||||||
| 3033 | QIndexEditorHash::const_iterator it = indexEditorHashCopy.constBegin(); | - | ||||||||||||||||||
| 3034 | for (; it != indexEditorHashCopy.constEnd(); ++it) { | - | ||||||||||||||||||
| 3035 | QWidget *editor = it.value().widget.data(); | - | ||||||||||||||||||
| 3036 | const QModelIndex index = it.key(); | - | ||||||||||||||||||
| 3037 | if (it.value().isStatic || !editor || !index.isValid() || | - | ||||||||||||||||||
| 3038 | (checkIndexes | - | ||||||||||||||||||
| 3039 | && (index.row() < tl.row() || index.row() > br.row() | - | ||||||||||||||||||
| 3040 | || index.column() < tl.column() || index.column() > br.column() | - | ||||||||||||||||||
| 3041 | || index.parent() != parent))) | - | ||||||||||||||||||
| 3042 | continue; | - | ||||||||||||||||||
| 3043 | - | |||||||||||||||||||
| 3044 | QAbstractItemDelegate *delegate = delegateForIndex(index); | - | ||||||||||||||||||
| 3045 | if (delegate) { | - | ||||||||||||||||||
| 3046 | delegate->setEditorData(editor, index); | - | ||||||||||||||||||
| 3047 | } | - | ||||||||||||||||||
| 3048 | } | - | ||||||||||||||||||
| 3049 | } | - | ||||||||||||||||||
| 3050 | void QAbstractItemViewPrivate::clearOrRemove() | - | ||||||||||||||||||
| 3051 | { | - | ||||||||||||||||||
| 3052 | - | |||||||||||||||||||
| 3053 | const QItemSelection selection = selectionModel->selection(); | - | ||||||||||||||||||
| 3054 | QList<QItemSelectionRange>::const_iterator it = selection.constBegin(); | - | ||||||||||||||||||
| 3055 | - | |||||||||||||||||||
| 3056 | if (!overwrite) { | - | ||||||||||||||||||
| 3057 | for (; it != selection.constEnd(); ++it) { | - | ||||||||||||||||||
| 3058 | QModelIndex parent = (*it).parent(); | - | ||||||||||||||||||
| 3059 | if ((*it).left() != 0) | - | ||||||||||||||||||
| 3060 | continue; | - | ||||||||||||||||||
| 3061 | if ((*it).right() != (model->columnCount(parent) - 1)) | - | ||||||||||||||||||
| 3062 | continue; | - | ||||||||||||||||||
| 3063 | int count = (*it).bottom() - (*it).top() + 1; | - | ||||||||||||||||||
| 3064 | model->removeRows((*it).top(), count, parent); | - | ||||||||||||||||||
| 3065 | } | - | ||||||||||||||||||
| 3066 | } else { | - | ||||||||||||||||||
| 3067 | - | |||||||||||||||||||
| 3068 | QModelIndexList list = selection.indexes(); | - | ||||||||||||||||||
| 3069 | for (int i=0; i < list.size(); ++i) { | - | ||||||||||||||||||
| 3070 | QModelIndex index = list.at(i); | - | ||||||||||||||||||
| 3071 | QMap<int, QVariant> roles = model->itemData(index); | - | ||||||||||||||||||
| 3072 | for (QMap<int, QVariant>::Iterator it = roles.begin(); it != roles.end(); ++it) | - | ||||||||||||||||||
| 3073 | it.value() = QVariant(); | - | ||||||||||||||||||
| 3074 | model->setItemData(index, roles); | - | ||||||||||||||||||
| 3075 | } | - | ||||||||||||||||||
| 3076 | } | - | ||||||||||||||||||
| 3077 | - | |||||||||||||||||||
| 3078 | } | - | ||||||||||||||||||
| 3079 | - | |||||||||||||||||||
| 3080 | - | |||||||||||||||||||
| 3081 | - | |||||||||||||||||||
| 3082 | - | |||||||||||||||||||
| 3083 | - | |||||||||||||||||||
| 3084 | - | |||||||||||||||||||
| 3085 | - | |||||||||||||||||||
| 3086 | void QAbstractItemViewPrivate::checkPersistentEditorFocus() | - | ||||||||||||||||||
| 3087 | { | - | ||||||||||||||||||
| 3088 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 3089 | if (QWidget *widget = QApplication::focusWidget()) { | - | ||||||||||||||||||
| 3090 | if (persistent.contains(widget)) { | - | ||||||||||||||||||
| 3091 | - | |||||||||||||||||||
| 3092 | QModelIndex index = indexForEditor(widget); | - | ||||||||||||||||||
| 3093 | if (selectionModel->currentIndex() != index) | - | ||||||||||||||||||
| 3094 | q->setCurrentIndex(index); | - | ||||||||||||||||||
| 3095 | } | - | ||||||||||||||||||
| 3096 | } | - | ||||||||||||||||||
| 3097 | } | - | ||||||||||||||||||
| 3098 | - | |||||||||||||||||||
| 3099 | - | |||||||||||||||||||
| 3100 | const QEditorInfo & QAbstractItemViewPrivate::editorForIndex(const QModelIndex &index) const | - | ||||||||||||||||||
| 3101 | { | - | ||||||||||||||||||
| 3102 | static QEditorInfo nullInfo; | - | ||||||||||||||||||
| 3103 | - | |||||||||||||||||||
| 3104 | - | |||||||||||||||||||
| 3105 | if (indexEditorHash.isEmpty()) | - | ||||||||||||||||||
| 3106 | return nullInfo; | - | ||||||||||||||||||
| 3107 | - | |||||||||||||||||||
| 3108 | QIndexEditorHash::const_iterator it = indexEditorHash.find(index); | - | ||||||||||||||||||
| 3109 | if (it == indexEditorHash.end()) | - | ||||||||||||||||||
| 3110 | return nullInfo; | - | ||||||||||||||||||
| 3111 | - | |||||||||||||||||||
| 3112 | return it.value(); | - | ||||||||||||||||||
| 3113 | } | - | ||||||||||||||||||
| 3114 | - | |||||||||||||||||||
| 3115 | bool QAbstractItemViewPrivate::hasEditor(const QModelIndex &index) const | - | ||||||||||||||||||
| 3116 | { | - | ||||||||||||||||||
| 3117 | - | |||||||||||||||||||
| 3118 | return never executed: !indexEditorHash.find(index) !=isEmpty() && indexEditorHash.constEnd();contains(index);return !indexEditorHash.isEmpty() && indexEditorHash.contains(index);never executed: return !indexEditorHash.isEmpty() && indexEditorHash.contains(index); | 0 | ||||||||||||||||||
| 3119 | } | - | ||||||||||||||||||
| 3120 | - | |||||||||||||||||||
| 3121 | QModelIndex QAbstractItemViewPrivate::indexForEditor(QWidget *editor) const | - | ||||||||||||||||||
| 3122 | { | - | ||||||||||||||||||
| 3123 | - | |||||||||||||||||||
| 3124 | if (indexEditorHash.isEmpty()) | - | ||||||||||||||||||
| 3125 | return QModelIndex(); | - | ||||||||||||||||||
| 3126 | - | |||||||||||||||||||
| 3127 | QEditorIndexHash::const_iterator it = editorIndexHash.find(editor); | - | ||||||||||||||||||
| 3128 | if (it == editorIndexHash.end()) | - | ||||||||||||||||||
| 3129 | return QModelIndex(); | - | ||||||||||||||||||
| 3130 | - | |||||||||||||||||||
| 3131 | return it.value(); | - | ||||||||||||||||||
| 3132 | } | - | ||||||||||||||||||
| 3133 | - | |||||||||||||||||||
| 3134 | void QAbstractItemViewPrivate::removeEditor(QWidget *editor) | - | ||||||||||||||||||
| 3135 | { | - | ||||||||||||||||||
| 3136 | QEditorIndexHash::iteratorconst auto it = editorIndexHash.findconstFind(editor); | - | ||||||||||||||||||
| 3137 | if (it != editorIndexHash.endcend()
| 0 | ||||||||||||||||||
| 3138 | indexEditorHash.remove(it.value()); | - | ||||||||||||||||||
| 3139 | editorIndexHash.erase(it); | - | ||||||||||||||||||
| 3140 | } never executed: end of block | 0 | ||||||||||||||||||
| 3141 | } never executed: end of block | 0 | ||||||||||||||||||
| 3142 | - | |||||||||||||||||||
| 3143 | void QAbstractItemViewPrivate::addEditor(const QModelIndex &index, QWidget *editor, bool isStatic) | - | ||||||||||||||||||
| 3144 | { | - | ||||||||||||||||||
| 3145 | editorIndexHash.insert(editor, index); | - | ||||||||||||||||||
| 3146 | indexEditorHash.insert(index, QEditorInfo(editor, isStatic)); | - | ||||||||||||||||||
| 3147 | } | - | ||||||||||||||||||
| 3148 | - | |||||||||||||||||||
| 3149 | bool QAbstractItemViewPrivate::sendDelegateEvent(const QModelIndex &index, QEvent *event) const | - | ||||||||||||||||||
| 3150 | { | - | ||||||||||||||||||
| 3151 | const QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 3152 | QModelIndex buddy = model->buddy(index); | - | ||||||||||||||||||
| 3153 | QStyleOptionViewItem options = viewOptionsV1(); | - | ||||||||||||||||||
| 3154 | options.rect = q->visualRect(buddy); | - | ||||||||||||||||||
| 3155 | options.state |= (buddy == q->currentIndex() ? QStyle::State_HasFocus : QStyle::State_None); | - | ||||||||||||||||||
| 3156 | QAbstractItemDelegate *delegate = delegateForIndex(index); | - | ||||||||||||||||||
| 3157 | return (event && delegate && delegate->editorEvent(event, model, options, buddy)); | - | ||||||||||||||||||
| 3158 | } | - | ||||||||||||||||||
| 3159 | - | |||||||||||||||||||
| 3160 | bool QAbstractItemViewPrivate::openEditor(const QModelIndex &index, QEvent *event) | - | ||||||||||||||||||
| 3161 | { | - | ||||||||||||||||||
| 3162 | QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 3163 | - | |||||||||||||||||||
| 3164 | QModelIndex buddy = model->buddy(index); | - | ||||||||||||||||||
| 3165 | QStyleOptionViewItem options = viewOptionsV1(); | - | ||||||||||||||||||
| 3166 | options.rect = q->visualRect(buddy); | - | ||||||||||||||||||
| 3167 | options.state |= (buddy == q->currentIndex() ? QStyle::State_HasFocus : QStyle::State_None); | - | ||||||||||||||||||
| 3168 | - | |||||||||||||||||||
| 3169 | QWidget *w = editor(buddy, options); | - | ||||||||||||||||||
| 3170 | if (!w) | - | ||||||||||||||||||
| 3171 | return false; | - | ||||||||||||||||||
| 3172 | - | |||||||||||||||||||
| 3173 | q->setState(QAbstractItemView::EditingState); | - | ||||||||||||||||||
| 3174 | w->show(); | - | ||||||||||||||||||
| 3175 | w->setFocus(); | - | ||||||||||||||||||
| 3176 | - | |||||||||||||||||||
| 3177 | if (event) | - | ||||||||||||||||||
| 3178 | QApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event); | - | ||||||||||||||||||
| 3179 | - | |||||||||||||||||||
| 3180 | return true; | - | ||||||||||||||||||
| 3181 | } | - | ||||||||||||||||||
| 3182 | - | |||||||||||||||||||
| 3183 | - | |||||||||||||||||||
| 3184 | - | |||||||||||||||||||
| 3185 | - | |||||||||||||||||||
| 3186 | - | |||||||||||||||||||
| 3187 | - | |||||||||||||||||||
| 3188 | - | |||||||||||||||||||
| 3189 | QItemViewPaintPairs QAbstractItemViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const | - | ||||||||||||||||||
| 3190 | { | - | ||||||||||||||||||
| 3191 | ((!(r)) ? qt_assert("r",__FILE__,43614411) : qt_noop()); | - | ||||||||||||||||||
| 3192 | const QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 3193 | QRect &rect = *r; | - | ||||||||||||||||||
| 3194 | const QRect viewportRect = viewport->rect(); | - | ||||||||||||||||||
| 3195 | QItemViewPaintPairs ret; | - | ||||||||||||||||||
| 3196 | for (int i = 0; i < indexes.count(); ++i) {const QModelIndexauto &index =: indexes.at(i);) { | - | ||||||||||||||||||
| 3197 | const QRect current = q->visualRect(index); | - | ||||||||||||||||||
| 3198 | if (current.intersects(viewportRect)
| 0 | ||||||||||||||||||
| 3199 | ret += qMakePair(QItemViewPaintPair p = { current, index );}; | - | ||||||||||||||||||
| 3200 | ret += p; | - | ||||||||||||||||||
| 3201 | rect |= current; | - | ||||||||||||||||||
| 3202 | } never executed: end of block | 0 | ||||||||||||||||||
| 3203 | } never executed: end of block | 0 | ||||||||||||||||||
| 3204 | rect &= viewportRect; | - | ||||||||||||||||||
| 3205 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 3206 | } | - | ||||||||||||||||||
| 3207 | - | |||||||||||||||||||
| 3208 | QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes, QRect *r) const | - | ||||||||||||||||||
| 3209 | { | - | ||||||||||||||||||
| 3210 | ((!(r)) ? qt_assert("r",__FILE__,43804430) : qt_noop()); | - | ||||||||||||||||||
| 3211 | QItemViewPaintPairs paintPairs = draggablePaintPairs(indexes, r); | - | ||||||||||||||||||
| 3212 | if (paintPairs.isEmpty()
| 0 | ||||||||||||||||||
| 3213 | return never executed: QPixmap();return QPixmap();never executed: return QPixmap(); | 0 | ||||||||||||||||||
| 3214 | - | |||||||||||||||||||
| 3215 | qreal scale = 1.0f; | - | ||||||||||||||||||
| 3216 | - | |||||||||||||||||||
| 3217 | const QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 3218 | QWidget *window = q->window(); | - | ||||||||||||||||||
| 3219 | if (window
| 0 | ||||||||||||||||||
| 3220 | QWindow *windowHandle = window->windowHandle(); | - | ||||||||||||||||||
| 3221 | if (windowHandle
| 0 | ||||||||||||||||||
| 3222 | scale = windowHandle->devicePixelRatio(); never executed: scale = windowHandle->devicePixelRatio(); | 0 | ||||||||||||||||||
| 3223 | } never executed: end of block | 0 | ||||||||||||||||||
| 3224 | - | |||||||||||||||||||
| 3225 | QPixmap pixmap(r->size() * scale); | - | ||||||||||||||||||
| 3226 | pixmap.setDevicePixelRatio(scale); | - | ||||||||||||||||||
| 3227 | - | |||||||||||||||||||
| 3228 | pixmap.fill(Qt::transparent); | - | ||||||||||||||||||
| 3229 | QPainter painter(&pixmap); | - | ||||||||||||||||||
| 3230 | QStyleOptionViewItem option = viewOptionsV1(); | - | ||||||||||||||||||
| 3231 | option.state |= QStyle::State_Selected; | - | ||||||||||||||||||
| 3232 | for (int j = 0; j < paintPairs.count()
| 0 | ||||||||||||||||||
| 3233 | option.rect = paintPairs.at(j).firstrect.translated(-r->topLeft()); | - | ||||||||||||||||||
| 3234 | const QModelIndex ¤t = paintPairs.at(j).secondindex; | - | ||||||||||||||||||
| 3235 | adjustViewOptionsForIndex(&option, current); | - | ||||||||||||||||||
| 3236 | delegateForIndex(current)->paint(&painter, option, current); | - | ||||||||||||||||||
| 3237 | } never executed: end of block | 0 | ||||||||||||||||||
| 3238 | return never executed: pixmap;return pixmap;never executed: return pixmap; | 0 | ||||||||||||||||||
| 3239 | } | - | ||||||||||||||||||
| 3240 | - | |||||||||||||||||||
| 3241 | void QAbstractItemViewPrivate::selectAll(QItemSelectionModel::SelectionFlags command) | - | ||||||||||||||||||
| 3242 | { | - | ||||||||||||||||||
| 3243 | if (!selectionModel) | - | ||||||||||||||||||
| 3244 | return; | - | ||||||||||||||||||
| 3245 | - | |||||||||||||||||||
| 3246 | QItemSelection selection; | - | ||||||||||||||||||
| 3247 | QModelIndex tl = model->index(0, 0, root); | - | ||||||||||||||||||
| 3248 | QModelIndex br = model->index(model->rowCount(root) - 1, | - | ||||||||||||||||||
| 3249 | model->columnCount(root) - 1, | - | ||||||||||||||||||
| 3250 | root); | - | ||||||||||||||||||
| 3251 | selection.append(QItemSelectionRange(tl, br)); | - | ||||||||||||||||||
| 3252 | selectionModel->select(selection, command); | - | ||||||||||||||||||
| 3253 | } | - | ||||||||||||||||||
| 3254 | - | |||||||||||||||||||
| 3255 | QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const | - | ||||||||||||||||||
| 3256 | { | - | ||||||||||||||||||
| 3257 | const QAbstractItemView * const q = q_func(); | - | ||||||||||||||||||
| 3258 | QModelIndexList indexes = q->selectedIndexes(); | - | ||||||||||||||||||
| 3259 | for(int iauto isNotDragEnabled = indexes.count() - 1 ; i >= 0; --i[this](const QModelIndex &index) { | - | ||||||||||||||||||
| 3260 | if (!return never executed: return !isIndexDragEnabled(index);never executed: !isIndexDragEnabled(index);return !isIndexDragEnabled(index);never executed: return !isIndexDragEnabled(index); | 0 | ||||||||||||||||||
| 3261 | }; | - | ||||||||||||||||||
| 3262 | indexes.aterase(i)))std::remove_if(indexes.removeAt(i); | - | ||||||||||||||||||
| }begin(), indexes.end(), | ||||||||||||||||||||
| 3263 | isNotDragEnabled), | - | ||||||||||||||||||
| 3264 | indexes.end()); | - | ||||||||||||||||||
| 3265 | return never executed: indexes;return indexes;never executed: return indexes; | 0 | ||||||||||||||||||
| 3266 | } | - | ||||||||||||||||||
| 3267 | - | |||||||||||||||||||
| 3268 | - | |||||||||||||||||||
| 3269 | - | |||||||||||||||||||
| 3270 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |