Fix build with -no-feature-draganddrop
Change-Id: I88ecd9a84d7fb9f6cb78027cc51e34089e211ff2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 010a8987710f4aafcd34ce2359464cfab10dad46) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
79fac7527c
commit
27fa63a430
@ -1793,9 +1793,11 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event)
|
|||||||
QPoint offset = d->offset();
|
QPoint offset = d->offset();
|
||||||
d->draggedPosition = pos + offset;
|
d->draggedPosition = pos + offset;
|
||||||
|
|
||||||
|
#if QT_CONFIG(draganddrop)
|
||||||
// update the pressed position when drag was enable
|
// update the pressed position when drag was enable
|
||||||
if (d->dragEnabled)
|
if (d->dragEnabled)
|
||||||
d->pressedPosition = d->draggedPosition;
|
d->pressedPosition = d->draggedPosition;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!(command & QItemSelectionModel::Current)) {
|
if (!(command & QItemSelectionModel::Current)) {
|
||||||
d->pressedPosition = pos + offset;
|
d->pressedPosition = pos + offset;
|
||||||
@ -4127,13 +4129,21 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::multiSelectionComm
|
|||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
if (static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton) {
|
if (static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton) {
|
||||||
// since the press might start a drag, deselect only on release
|
// 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
|
return QItemSelectionModel::Toggle|selectionBehaviorFlags(); // toggle
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
if (static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton) {
|
if (static_cast<const QMouseEvent*>(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::Toggle|selectionBehaviorFlags();
|
||||||
return QItemSelectionModel::NoUpdate|selectionBehaviorFlags(); // finalize
|
return QItemSelectionModel::NoUpdate|selectionBehaviorFlags(); // finalize
|
||||||
}
|
}
|
||||||
@ -4181,7 +4191,10 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC
|
|||||||
return QItemSelectionModel::NoUpdate;
|
return QItemSelectionModel::NoUpdate;
|
||||||
// since the press might start a drag, deselect only on release
|
// since the press might start a drag, deselect only on release
|
||||||
if (controlKeyPressed && !rightButtonPressed && pressedAlreadySelected
|
if (controlKeyPressed && !rightButtonPressed && pressedAlreadySelected
|
||||||
&& dragEnabled && isIndexDragEnabled(index)) {
|
#if QT_CONFIG(draganddrop)
|
||||||
|
&& dragEnabled && isIndexDragEnabled(index)
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
return QItemSelectionModel::NoUpdate;
|
return QItemSelectionModel::NoUpdate;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4197,7 +4210,10 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC
|
|||||||
&& !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !index.isValid()))
|
&& !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !index.isValid()))
|
||||||
return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
|
return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
|
||||||
if (index == pressedIndex && controlKeyPressed && !rightButtonPressed
|
if (index == pressedIndex && controlKeyPressed && !rightButtonPressed
|
||||||
&& dragEnabled && isIndexDragEnabled(index)) {
|
#if QT_CONFIG(draganddrop)
|
||||||
|
&& dragEnabled && isIndexDragEnabled(index)
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return QItemSelectionModel::NoUpdate;
|
return QItemSelectionModel::NoUpdate;
|
||||||
@ -4661,6 +4677,7 @@ void QAbstractItemViewPrivate::selectAll(QItemSelectionModel::SelectionFlags com
|
|||||||
selectionModel->select(selection, command);
|
selectionModel->select(selection, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_CONFIG(draganddrop)
|
||||||
QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const
|
QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const
|
||||||
{
|
{
|
||||||
Q_Q(const QAbstractItemView);
|
Q_Q(const QAbstractItemView);
|
||||||
@ -4671,6 +4688,7 @@ QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const
|
|||||||
indexes.removeIf(isNotDragEnabled);
|
indexes.removeIf(isNotDragEnabled);
|
||||||
return indexes;
|
return indexes;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\reimp
|
\reimp
|
||||||
|
@ -252,12 +252,14 @@ public:
|
|||||||
inline bool isIndexEnabled(const QModelIndex &index) const {
|
inline bool isIndexEnabled(const QModelIndex &index) const {
|
||||||
return (model->flags(index) & Qt::ItemIsEnabled);
|
return (model->flags(index) & Qt::ItemIsEnabled);
|
||||||
}
|
}
|
||||||
|
#if QT_CONFIG(draganddrop)
|
||||||
inline bool isIndexDropEnabled(const QModelIndex &index) const {
|
inline bool isIndexDropEnabled(const QModelIndex &index) const {
|
||||||
return (model->flags(index) & Qt::ItemIsDropEnabled);
|
return (model->flags(index) & Qt::ItemIsDropEnabled);
|
||||||
}
|
}
|
||||||
inline bool isIndexDragEnabled(const QModelIndex &index) const {
|
inline bool isIndexDragEnabled(const QModelIndex &index) const {
|
||||||
return (model->flags(index) & Qt::ItemIsDragEnabled);
|
return (model->flags(index) & Qt::ItemIsDragEnabled);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual bool selectionAllowed(const QModelIndex &index) const {
|
virtual bool selectionAllowed(const QModelIndex &index) const {
|
||||||
// in some views we want to go ahead with selections, even if the index is invalid
|
// in some views we want to go ahead with selections, even if the index is invalid
|
||||||
@ -304,7 +306,9 @@ public:
|
|||||||
return static_cast<QAbstractItemModelPrivate *>(model->d_ptr.data())->persistent.indexes.contains(index);
|
return static_cast<QAbstractItemModelPrivate *>(model->d_ptr.data())->persistent.indexes.contains(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_CONFIG(draganddrop)
|
||||||
QModelIndexList selectedDraggableIndexes() const;
|
QModelIndexList selectedDraggableIndexes() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
void doDelayedReset()
|
void doDelayedReset()
|
||||||
{
|
{
|
||||||
|
@ -3045,8 +3045,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
|||||||
)
|
)
|
||||||
QDragManager::self()->setCurrentTarget(nullptr, e->type() == QEvent::Drop);
|
QDragManager::self()->setCurrentTarget(nullptr, e->type() == QEvent::Drop);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif // QT_CONFIG(draganddrop)
|
||||||
case QEvent::TouchBegin: {
|
case QEvent::TouchBegin: {
|
||||||
// Note: TouchUpdate and TouchEnd events are never propagated
|
// Note: TouchUpdate and TouchEnd events are never propagated
|
||||||
QMutableTouchEvent *touchEvent = QMutableTouchEvent::from(static_cast<QTouchEvent *>(e));
|
QMutableTouchEvent *touchEvent = QMutableTouchEvent::from(static_cast<QTouchEvent *>(e));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user