QPolygon: streamline constructors and special member functions
Employ RO0; inherit the constructors from the base class; and do some code tidies as a drive by. The inherited constructors bring in goodies like initializer_list support. Change-Id: Ia00a3f9b0ccbf182bf837bc65ba2305110c8dc60 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
096e268764
commit
3f6afac6b1
@ -56,17 +56,12 @@ class QVariant;
|
||||
class QPolygon : public QList<QPoint>
|
||||
{
|
||||
public:
|
||||
inline QPolygon() {}
|
||||
inline ~QPolygon() {}
|
||||
inline explicit QPolygon(int size);
|
||||
inline /*implicit*/ QPolygon(const QList<QPoint> &v) : QList<QPoint>(v) { }
|
||||
/*implicit*/ QPolygon(QList<QPoint> &&v) noexcept : QList<QPoint>(std::move(v)) { }
|
||||
Q_GUI_EXPORT QPolygon(const QRect &r, bool closed=false);
|
||||
using QList<QPoint>::QList;
|
||||
QPolygon() = default;
|
||||
/* implicit */ QPolygon(const QList<QPoint> &v) : QList<QPoint>(v) { }
|
||||
/* implicit */ QPolygon(QList<QPoint> &&v) noexcept : QList<QPoint>(std::move(v)) { }
|
||||
/* implicit */ Q_GUI_EXPORT QPolygon(const QRect &r, bool closed=false);
|
||||
Q_GUI_EXPORT QPolygon(int nPoints, const int *points);
|
||||
QPolygon(const QPolygon &other) : QList<QPoint>(other) { }
|
||||
QPolygon(QPolygon &&other) noexcept : QList<QPoint>(std::move(other)) { }
|
||||
QPolygon &operator=(QPolygon &&other) noexcept { swap(other); return *this; }
|
||||
QPolygon &operator=(const QPolygon &other) { QList<QPoint>::operator=(other); return *this; }
|
||||
void swap(QPolygon &other) noexcept { QList<QPoint>::swap(other); } // prevent QList<QPoint><->QPolygon swaps
|
||||
|
||||
Q_GUI_EXPORT operator QVariant() const;
|
||||
@ -99,8 +94,6 @@ public:
|
||||
};
|
||||
Q_DECLARE_SHARED(QPolygon)
|
||||
|
||||
inline QPolygon::QPolygon(int size) : QList<QPoint>(size) { }
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygon &);
|
||||
#endif
|
||||
@ -137,17 +130,12 @@ class QRectF;
|
||||
class QPolygonF : public QList<QPointF>
|
||||
{
|
||||
public:
|
||||
inline QPolygonF() {}
|
||||
inline ~QPolygonF() {}
|
||||
inline explicit QPolygonF(int size);
|
||||
inline /*implicit*/ QPolygonF(const QList<QPointF> &v) : QList<QPointF>(v) { }
|
||||
using QList<QPointF>::QList;
|
||||
QPolygonF() = default;
|
||||
/* implicit */ QPolygonF(const QList<QPointF> &v) : QList<QPointF>(v) { }
|
||||
/* implicit */ QPolygonF(QList<QPointF> &&v) noexcept : QList<QPointF>(std::move(v)) { }
|
||||
Q_GUI_EXPORT QPolygonF(const QRectF &r);
|
||||
/*implicit*/ Q_GUI_EXPORT QPolygonF(const QPolygon &a);
|
||||
inline QPolygonF(const QPolygonF &a) : QList<QPointF>(a) { }
|
||||
QPolygonF(QPolygonF &&other) noexcept : QList<QPointF>(std::move(other)) { }
|
||||
QPolygonF &operator=(QPolygonF &&other) noexcept { swap(other); return *this; }
|
||||
QPolygonF &operator=(const QPolygonF &other) { QList<QPointF>::operator=(other); return *this; }
|
||||
/* implicit */ Q_GUI_EXPORT QPolygonF(const QRectF &r);
|
||||
/* implicit */ Q_GUI_EXPORT QPolygonF(const QPolygon &a);
|
||||
inline void swap(QPolygonF &other) { QList<QPointF>::swap(other); } // prevent QList<QPointF><->QPolygonF swaps
|
||||
|
||||
Q_GUI_EXPORT operator QVariant() const;
|
||||
@ -174,8 +162,6 @@ public:
|
||||
};
|
||||
Q_DECLARE_SHARED(QPolygonF)
|
||||
|
||||
inline QPolygonF::QPolygonF(int size) : QList<QPointF>(size) { }
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygonF &);
|
||||
#endif
|
||||
|
@ -39,10 +39,8 @@ class tst_QPolygon : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QPolygon();
|
||||
|
||||
private slots:
|
||||
void constructors();
|
||||
void boundingRect_data();
|
||||
void boundingRect();
|
||||
void boundingRectF_data();
|
||||
@ -53,8 +51,33 @@ private slots:
|
||||
void intersections();
|
||||
};
|
||||
|
||||
tst_QPolygon::tst_QPolygon()
|
||||
void constructors_helper(QPolygon) {}
|
||||
void constructors_helperF(QPolygonF) {}
|
||||
|
||||
void tst_QPolygon::constructors()
|
||||
{
|
||||
constructors_helper(QPolygon());
|
||||
constructors_helper({});
|
||||
constructors_helper({ QPoint(1, 2), QPoint(3, 4)});
|
||||
constructors_helper({ {1, 2}, {3, 4} });
|
||||
constructors_helper(QPolygon(12));
|
||||
QList<QPoint> pointList;
|
||||
constructors_helper(pointList);
|
||||
constructors_helper(std::move(pointList));
|
||||
constructors_helper(QRect(1, 2, 3, 4));
|
||||
const int points[2] = { 10, 20 };
|
||||
constructors_helper(QPolygon(1, points));
|
||||
|
||||
constructors_helperF(QPolygonF());
|
||||
constructors_helperF({});
|
||||
constructors_helperF({ QPointF(1, 2), QPointF(3, 4)});
|
||||
constructors_helperF({ {1, 2}, {3, 4} });
|
||||
constructors_helperF(QPolygonF(12));
|
||||
constructors_helperF(QPolygon());
|
||||
QList<QPointF> pointFList;
|
||||
constructors_helperF(pointFList);
|
||||
constructors_helperF(std::move(pointFList));
|
||||
constructors_helperF(QRectF(1, 2, 3, 4));
|
||||
}
|
||||
|
||||
void tst_QPolygon::boundingRect_data()
|
||||
|
Loading…
Reference in New Issue
Block a user