diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 7a7b5c4753..1619635dbf 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1793,9 +1793,11 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event) QPoint offset = d->offset(); d->draggedPosition = pos + offset; +#if QT_CONFIG(draganddrop) // update the pressed position when drag was enable if (d->dragEnabled) d->pressedPosition = d->draggedPosition; +#endif if (!(command & QItemSelectionModel::Current)) { d->pressedPosition = pos + offset; @@ -4127,13 +4129,21 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::multiSelectionComm case QEvent::MouseButtonPress: if (static_cast(event)->button() == Qt::LeftButton) { // since the press might start a drag, deselect only on release - if (!pressedAlreadySelected || !dragEnabled || !isIndexDragEnabled(index)) + if (!pressedAlreadySelected +#if QT_CONFIG(draganddrop) + || !dragEnabled || !isIndexDragEnabled(index) +#endif + ) return QItemSelectionModel::Toggle|selectionBehaviorFlags(); // toggle } break; case QEvent::MouseButtonRelease: if (static_cast(event)->button() == Qt::LeftButton) { - if (pressedAlreadySelected && dragEnabled && isIndexDragEnabled(index) && index == pressedIndex) + if (pressedAlreadySelected +#if QT_CONFIG(draganddrop) + && dragEnabled && isIndexDragEnabled(index) +#endif + && index == pressedIndex) return QItemSelectionModel::Toggle|selectionBehaviorFlags(); return QItemSelectionModel::NoUpdate|selectionBehaviorFlags(); // finalize } @@ -4181,7 +4191,10 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC return QItemSelectionModel::NoUpdate; // since the press might start a drag, deselect only on release if (controlKeyPressed && !rightButtonPressed && pressedAlreadySelected - && dragEnabled && isIndexDragEnabled(index)) { +#if QT_CONFIG(draganddrop) + && dragEnabled && isIndexDragEnabled(index) +#endif + ) { return QItemSelectionModel::NoUpdate; } break; @@ -4197,7 +4210,10 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC && !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !index.isValid())) return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags(); if (index == pressedIndex && controlKeyPressed && !rightButtonPressed - && dragEnabled && isIndexDragEnabled(index)) { +#if QT_CONFIG(draganddrop) + && dragEnabled && isIndexDragEnabled(index) +#endif + ) { break; } return QItemSelectionModel::NoUpdate; @@ -4661,6 +4677,7 @@ void QAbstractItemViewPrivate::selectAll(QItemSelectionModel::SelectionFlags com selectionModel->select(selection, command); } +#if QT_CONFIG(draganddrop) QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const { Q_Q(const QAbstractItemView); @@ -4671,6 +4688,7 @@ QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const indexes.removeIf(isNotDragEnabled); return indexes; } +#endif /*! \reimp diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index 257e368175..5475db2971 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -252,12 +252,14 @@ public: inline bool isIndexEnabled(const QModelIndex &index) const { return (model->flags(index) & Qt::ItemIsEnabled); } +#if QT_CONFIG(draganddrop) inline bool isIndexDropEnabled(const QModelIndex &index) const { return (model->flags(index) & Qt::ItemIsDropEnabled); } inline bool isIndexDragEnabled(const QModelIndex &index) const { return (model->flags(index) & Qt::ItemIsDragEnabled); } +#endif virtual bool selectionAllowed(const QModelIndex &index) const { // in some views we want to go ahead with selections, even if the index is invalid @@ -304,7 +306,9 @@ public: return static_cast(model->d_ptr.data())->persistent.indexes.contains(index); } +#if QT_CONFIG(draganddrop) QModelIndexList selectedDraggableIndexes() const; +#endif void doDelayedReset() { diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 5fa11e4a99..fd71cdb0aa 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3045,8 +3045,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e) ) QDragManager::self()->setCurrentTarget(nullptr, e->type() == QEvent::Drop); break; -#endif } +#endif // QT_CONFIG(draganddrop) case QEvent::TouchBegin: { // Note: TouchUpdate and TouchEnd events are never propagated QMutableTouchEvent *touchEvent = QMutableTouchEvent::from(static_cast(e));