QTableWidget: simplify QTableWidgetSelectionRange

Simplify QTableWidgetSelectionRange by removing the unneeded
user-defined functions - the compiler can generate them by it's own.

Change-Id: Ia96ea29f595851e58c5b714bb316174406d42b8e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Christian Ehrlicher 2020-05-11 21:13:19 +02:00
parent fa98adbd04
commit 33fc622686
2 changed files with 16 additions and 46 deletions

View File

@ -897,14 +897,6 @@ Qt::DropActions QTableModel::supportedDropActions() const
\sa QTableWidget
*/
/*!
Constructs an table selection range, i.e. a range
whose rowCount() and columnCount() are 0.
*/
QTableWidgetSelectionRange::QTableWidgetSelectionRange()
: top(-1), left(-1), bottom(-2), right(-2)
{
}
/*!
Constructs the table selection range from the given \a top, \a
@ -912,24 +904,6 @@ QTableWidgetSelectionRange::QTableWidgetSelectionRange()
\sa topRow(), leftColumn(), bottomRow(), rightColumn()
*/
QTableWidgetSelectionRange::QTableWidgetSelectionRange(int top, int left, int bottom, int right)
: top(top), left(left), bottom(bottom), right(right)
{
}
/*!
Constructs a the table selection range by copying the given \a
other table selection range.
*/
QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &) = default;
QTableWidgetSelectionRange &QTableWidgetSelectionRange::operator=(const QTableWidgetSelectionRange &) = default;
/*!
Destroys the table selection range.
*/
QTableWidgetSelectionRange::~QTableWidgetSelectionRange()
{
}
/*!
\fn int QTableWidgetSelectionRange::topRow() const
@ -2353,10 +2327,10 @@ QList<QTableWidgetSelectionRange> QTableWidget::selectedRanges() const
const int rangesCount = ranges.count();
result.reserve(rangesCount);
for (int i = 0; i < rangesCount; ++i)
result.append(QTableWidgetSelectionRange(ranges.at(i).top(),
ranges.at(i).left(),
ranges.at(i).bottom(),
ranges.at(i).right()));
result.append({ranges.at(i).top(),
ranges.at(i).left(),
ranges.at(i).bottom(),
ranges.at(i).right()});
return result;
}

View File

@ -49,26 +49,22 @@ 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
class QTableWidgetSelectionRange
{
public:
QTableWidgetSelectionRange();
QTableWidgetSelectionRange(int top, int left, int bottom, int right);
~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; }
inline int rightColumn() const { return right; }
inline int rowCount() const { return bottom - top + 1; }
inline int columnCount() const { return right - left + 1; }
QTableWidgetSelectionRange() = default;
QTableWidgetSelectionRange(int top, int left, int bottom, int right)
: m_top(top), m_left(left), m_bottom(bottom), m_right(right)
{}
inline int topRow() const { return m_top; }
inline int bottomRow() const { return m_bottom; }
inline int leftColumn() const { return m_left; }
inline int rightColumn() const { return m_right; }
inline int rowCount() const { return m_bottom - m_top + 1; }
inline int columnCount() const { return m_right - m_left + 1; }
private:
int top, left, bottom, right;
int m_top = -1, m_left = -1, m_bottom = -2, m_right = -2;
};
class QTableWidget;