QTableWidgetSelectionRange: Make it possible to compare for equality
Add operators as hidden friends, add test case to make sure that basic value-type operations are possible with this type. Task-number: QTBUG-255 Change-Id: I7fbf453aa16084c0b2a0079487cacb4e092ff664 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
9684764bda
commit
9a77230685
@ -918,6 +918,20 @@ Qt::DropActions QTableModel::supportedDropActions() const
|
||||
\sa topRow(), leftColumn(), bottomRow(), rightColumn()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\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
|
||||
|
||||
|
@ -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; }
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user