summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2020-05-11 21:13:19 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2020-05-28 06:13:56 +0200
commit33fc6226865ab4b36a452e733e4519e45fea691d (patch)
treea9301ce7d8b3a0f1b2474d9cc0a87c3d2f25185a
parentfa98adbd04de9d44ce921436b92589a41f285dcd (diff)
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>
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp34
-rw-r--r--src/widgets/itemviews/qtablewidget.h30
2 files changed, 17 insertions, 47 deletions
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 4b2554d5c0..c051039cb0 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -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;
}
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
index f53a55a8e2..65f9f60b37 100644
--- a/src/widgets/itemviews/qtablewidget.h
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -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;