summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp14
-rw-r--r--src/widgets/itemviews/qtablewidget.h8
-rw-r--r--tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp14
3 files changed, 36 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 5072cc9240..5c3d3385da 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -919,6 +919,20 @@ Qt::DropActions QTableModel::supportedDropActions() const
*/
/*!
+ \fn bool QTableWidgetSelectionRange::operator==(const QTableWidgetSelectionRange &lhs, const QTableWidgetSelectionRange &rhs)
+ \since 6.3
+
+ Returns true if \a lhs and \a rhs are equal, otherwise returns false.
+*/
+
+/*!
+ \fn bool QTableWidgetSelectionRange::operator!=(const QTableWidgetSelectionRange &lhs, const QTableWidgetSelectionRange &rhs)
+ \since 6.3
+
+ Returns true if \a lhs and \a rhs are not equal, otherwise returns false.
+*/
+
+/*!
\fn int QTableWidgetSelectionRange::topRow() const
Returns the top row of the range.
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
index 8f3a36daf1..3978bc23d6 100644
--- a/src/widgets/itemviews/qtablewidget.h
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -57,6 +57,14 @@ public:
: m_top(top), m_left(left), m_bottom(bottom), m_right(right)
{}
+ friend inline bool operator==(const QTableWidgetSelectionRange &lhs,
+ const QTableWidgetSelectionRange &rhs)
+ { return lhs.m_top == rhs.m_top && lhs.m_left == rhs.m_left
+ && lhs.m_bottom == rhs.m_bottom && lhs.m_right == rhs.m_right; };
+ friend inline bool operator!=(const QTableWidgetSelectionRange &lhs,
+ const QTableWidgetSelectionRange &rhs)
+ { return !(lhs == rhs); }
+
inline int topRow() const { return m_top; }
inline int bottomRow() const { return m_bottom; }
inline int leftColumn() const { return m_left; }
diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
index b827d87910..23e69b2190 100644
--- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
@@ -49,6 +49,7 @@ private slots:
void initTestCase();
void init();
void getSetCheck();
+ void selectionRange();
void clear();
void clearContents();
void rowCount();
@@ -155,6 +156,19 @@ void tst_QTableWidget::getSetCheck()
QCOMPARE(obj1.itemPrototype(), nullptr);
}
+void tst_QTableWidget::selectionRange()
+{
+ QTableWidgetSelectionRange defaultSelection;
+ QTableWidgetSelectionRange selection(1, 2, 3, 4);
+
+ QTableWidgetSelectionRange copy(selection);
+ QCOMPARE(copy, selection);
+ QVERIFY(copy != defaultSelection);
+
+ defaultSelection = copy;
+ QCOMPARE(defaultSelection, copy);
+}
+
void tst_QTableWidget::initTestCase()
{
testWidget.reset(new QTableWidget);