diff options
| author | Ivan Solovev <ivan.solovev@qt.io> | 2025-07-25 17:43:37 +0200 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2025-07-26 19:45:22 +0000 |
| commit | a054870f35342f17a54f5ce6555b56cf386ac6bd (patch) | |
| tree | 841a570798bca92b13c89aebd2ceb3516cf51c4b /src | |
| parent | e13717cbde95d3802e32e2863b570d50555a8b18 (diff) | |
Properly guard supportedDragActions in QTreeWidget and QTableWidget
Guard Q_PROPERTY, the declarations and the definitions of the getters
and the setters with QT_CONFIG(draganddrop).
Both widgets use underlying models (QTreeModel and QTableModel) that
are based on QAbstractItemModel. The latter has a virtual method
supportedDragActions(), which is not guarded by any config.
As a result, this patch also has to provide fallback implementations
for the overrides of this method. The implementations simply return
Qt::IgnoreAction.
Amends 7d0017cda8fde28a1130feaeecf41010b40e3cb3 and
760579204e314cc4e0fdc7b8b8bd8d8706095a38.
Also provide fallback implementations for QTreeModel
Pick-to: 6.10
Change-Id: I9ff2c7112d1b3b7ad23347a03c5e29cf0d115935
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/widgets/itemviews/qtablewidget.cpp | 6 | ||||
| -rw-r--r-- | src/widgets/itemviews/qtablewidget.h | 2 | ||||
| -rw-r--r-- | src/widgets/itemviews/qtreewidget.cpp | 6 | ||||
| -rw-r--r-- | src/widgets/itemviews/qtreewidget.h | 2 |
4 files changed, 16 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 3e027920c67..8ba409191e4 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -871,8 +871,12 @@ Qt::DropActions QTableModel::supportedDropActions() const Qt::DropActions QTableModel::supportedDragActions() const { +#if QT_CONFIG(draganddrop) const QTableWidget *view = this->view(); return (view ? view->supportedDragActions() : Qt::DropActions(Qt::IgnoreAction)); +#else + return Qt::DropActions(Qt::IgnoreAction); +#endif } /*! @@ -2637,6 +2641,7 @@ Qt::DropActions QTableWidget::supportedDropActions() const return d_func()->tableModel()->QAbstractTableModel::supportedDropActions() | Qt::MoveAction; } +#if QT_CONFIG(draganddrop) /*! \property QTableWidget::supportedDragActions \brief the drag actions supported by this view @@ -2655,6 +2660,7 @@ void QTableWidget::setSupportedDragActions(Qt::DropActions actions) Q_D(QTableWidget); d->supportedDragActions = actions; } +#endif // QT_CONFIG(draganddrop) /*! Returns a list of pointers to the items contained in the \a data object. diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h index c7524101216..059a7a6a10a 100644 --- a/src/widgets/itemviews/qtablewidget.h +++ b/src/widgets/itemviews/qtablewidget.h @@ -194,7 +194,9 @@ class Q_WIDGETS_EXPORT QTableWidget : public QTableView Q_OBJECT Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount) Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount) +#if QT_CONFIG(draganddrop) Q_PROPERTY(Qt::DropActions supportedDragActions READ supportedDragActions WRITE setSupportedDragActions) +#endif friend class QTableModel; public: diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 759aee51ef8..d9f23b7c9db 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -739,7 +739,11 @@ Qt::DropActions QTreeModel::supportedDropActions() const Qt::DropActions QTreeModel::supportedDragActions() const { +#if QT_CONFIG(draganddrop) return view()->supportedDragActions(); +#else + return Qt::DropActions(Qt::IgnoreAction); +#endif } void QTreeModel::itemChanged(QTreeWidgetItem *item) @@ -3218,6 +3222,7 @@ Qt::DropActions QTreeWidget::supportedDropActions() const return model()->QAbstractItemModel::supportedDropActions() | Qt::MoveAction; } +#if QT_CONFIG(draganddrop) /*! \property QTreeWidget::supportedDragActions \brief the drag actions supported by this view @@ -3236,6 +3241,7 @@ void QTreeWidget::setSupportedDragActions(Qt::DropActions actions) Q_D(QTreeWidget); d->supportedDragActions = actions; } +#endif // QT_CONFIG(draganddrop) /*! Returns the QModelIndex associated with the given \a item in the given \a column. diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h index fadd9e09a58..bfeaa3ad669 100644 --- a/src/widgets/itemviews/qtreewidget.h +++ b/src/widgets/itemviews/qtreewidget.h @@ -227,7 +227,9 @@ class Q_WIDGETS_EXPORT QTreeWidget : public QTreeView Q_OBJECT Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount) Q_PROPERTY(int topLevelItemCount READ topLevelItemCount) +#if QT_CONFIG(draganddrop) Q_PROPERTY(Qt::DropActions supportedDragActions READ supportedDragActions WRITE setSupportedDragActions) +#endif friend class QTreeModel; friend class QTreeWidgetItem; |
