summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp42
-rw-r--r--src/widgets/itemviews/qdirmodel.cpp6
-rw-r--r--src/widgets/itemviews/qdirmodel.h11
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp6
-rw-r--r--src/widgets/itemviews/qtablewidget.h5
5 files changed, 41 insertions, 29 deletions
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index 31dde8832b..eecc18e5c7 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -387,44 +387,46 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
const QStyleOptionViewItem &option,
const QModelIndex &index)
{
- Q_D(QAbstractItemDelegate);
- Q_UNUSED(d);
- Q_UNUSED(index);
- Q_UNUSED(option);
-
if (!event || !view)
return false;
+ Q_D(QAbstractItemDelegate);
switch (event->type()) {
#ifndef QT_NO_TOOLTIP
case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(event);
const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp
- const QString tooltip = d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision);
- if (!tooltip.isEmpty()) {
- QToolTip::showText(he->globalPos(), tooltip, view);
- return true;
+ const QString tooltip = index.isValid() ?
+ d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+ QString();
+ QRect rect;
+ if (index.isValid()) {
+ const QRect r = view->visualRect(index);
+ rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+ }
+ QToolTip::showText(he->globalPos(), tooltip, view, rect);
+ event->setAccepted(!tooltip.isEmpty());
+ break;
}
- break;}
#endif
#if QT_CONFIG(whatsthis)
- case QEvent::QueryWhatsThis: {
- if (index.data(Qt::WhatsThisRole).isValid())
- return true;
- break; }
+ case QEvent::QueryWhatsThis:
+ event->setAccepted(index.data(Qt::WhatsThisRole).isValid());
+ break;
case QEvent::WhatsThis: {
QHelpEvent *he = static_cast<QHelpEvent*>(event);
const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp
- const QString whatsthis = d->textForRole(Qt::WhatsThisRole, index.data(Qt::WhatsThisRole), option.locale, precision);
- if (!whatsthis.isEmpty()) {
- QWhatsThis::showText(he->globalPos(), whatsthis, view);
- return true;
+ const QString whatsthis = index.isValid() ?
+ d->textForRole(Qt::WhatsThisRole, index.data(Qt::WhatsThisRole), option.locale, precision) :
+ QString();
+ QWhatsThis::showText(he->globalPos(), whatsthis, view);
+ event->setAccepted(!whatsthis.isEmpty());
+ break;
}
- break ; }
#endif
default:
break;
}
- return false;
+ return event->isAccepted();
}
/*!
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp
index 13a1bbd8eb..c9e7c7b7a6 100644
--- a/src/widgets/itemviews/qdirmodel.cpp
+++ b/src/widgets/itemviews/qdirmodel.cpp
@@ -39,6 +39,8 @@
#include "qdirmodel.h"
+#if QT_DEPRECATED_SINCE(5, 15)
+
#include <qfile.h>
#include <qfilesystemmodel.h>
#include <qurl.h>
@@ -1160,7 +1162,7 @@ void QDirModelPrivate::init()
root.parent = 0;
root.info = QFileInfo();
clear(&root);
- roleNames.insertMulti(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
+ roleNames.insert(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
roleNames.insert(QDirModel::FilePathRole, QByteArrayLiteral("filePath"));
roleNames.insert(QDirModel::FileNameRole, QByteArrayLiteral("fileName"));
}
@@ -1372,3 +1374,5 @@ QFileInfo QDirModelPrivate::resolvedInfo(QFileInfo info)
QT_END_NAMESPACE
#include "moc_qdirmodel.cpp"
+
+#endif // QT_DEPRECATED_SINCE(5, 15)
diff --git a/src/widgets/itemviews/qdirmodel.h b/src/widgets/itemviews/qdirmodel.h
index ab91bbd763..665a622dbe 100644
--- a/src/widgets/itemviews/qdirmodel.h
+++ b/src/widgets/itemviews/qdirmodel.h
@@ -45,6 +45,8 @@
#include <QtCore/qdir.h>
#include <QtWidgets/qfileiconprovider.h>
+#if QT_DEPRECATED_SINCE(5, 15)
+
QT_REQUIRE_CONFIG(dirmodel);
QT_BEGIN_NAMESPACE
@@ -65,9 +67,10 @@ public:
FileNameRole
};
- QDirModel(const QStringList &nameFilters, QDir::Filters filters,
- QDir::SortFlags sort, QObject *parent = nullptr);
- explicit QDirModel(QObject *parent = nullptr);
+ QT_DEPRECATED_VERSION_X_5_15("Use QFileSystemModel") QDirModel(const QStringList &nameFilters,
+ QDir::Filters filters, QDir::SortFlags sort,
+ QObject *parent = nullptr);
+ QT_DEPRECATED_VERSION_X_5_15("Use QFileSystemModel") explicit QDirModel(QObject *parent = nullptr);
~QDirModel();
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
@@ -144,4 +147,6 @@ private:
QT_END_NAMESPACE
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
#endif // QDIRMODEL_H
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index a25a582881..b1dbafa997 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -923,10 +923,8 @@ QTableWidgetSelectionRange::QTableWidgetSelectionRange(int top, int left, int bo
Constructs a the table selection range by copying the given \a
other table selection range.
*/
-QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other)
- : top(other.top), left(other.left), bottom(other.bottom), right(other.right)
-{
-}
+QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) = default;
+QTableWidgetSelectionRange &QTableWidgetSelectionRange::operator=(const QTableWidgetSelectionRange &other) = default;
/*!
Destroys the table selection range.
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
index d93032f3f0..0d93a0a075 100644
--- a/src/widgets/itemviews/qtablewidget.h
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -49,14 +49,17 @@ QT_REQUIRE_CONFIG(tablewidget);
QT_BEGIN_NAMESPACE
+// ### Qt6 unexport the class, remove the user-defined special 3 and make it a literal type.
class Q_WIDGETS_EXPORT QTableWidgetSelectionRange
{
public:
QTableWidgetSelectionRange();
QTableWidgetSelectionRange(int top, int left, int bottom, int right);
- QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other);
~QTableWidgetSelectionRange();
+ QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other);
+ QTableWidgetSelectionRange &operator=(const QTableWidgetSelectionRange &other);
+
inline int topRow() const { return top; }
inline int bottomRow() const { return bottom; }
inline int leftColumn() const { return left; }