QPageLayout: provide op!=

For consistency.

Change-Id: I20fb70999785e2c1947f033d63367a2f6746990a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: John Layt <jlayt@kde.org>
This commit is contained in:
Marc Mutz 2014-04-05 00:00:15 +02:00 committed by The Qt Project
parent 4bed03eb85
commit c7dd6006b9
3 changed files with 20 additions and 0 deletions

View File

@ -443,6 +443,20 @@ bool operator==(const QPageLayout &lhs, const QPageLayout &rhs)
return (lhs.d == rhs.d); return (lhs.d == rhs.d);
} }
/*!
\fn bool operator!=(const QPageLayout &lhs, const QPageLayout &rhs)
\relates QPageLayout
Returns \c true if page layout \a lhs is not equal to page layout \a rhs,
i.e. if any of the attributes differ.
Note that this is a strict equality, especially for page size where the
QPageSize ID, name and size must exactly match, and the margins where the
units must match.
\sa QPageLayout::isEquivalentTo()
*/
/*! /*!
Returns \c true if this page layout is equivalent to the \a other page layout, Returns \c true if this page layout is equivalent to the \a other page layout,
i.e. if the page has the same size, margins and orientation. i.e. if the page has the same size, margins and orientation.

View File

@ -143,6 +143,8 @@ private:
Q_DECLARE_SHARED(QPageLayout) Q_DECLARE_SHARED(QPageLayout)
Q_GUI_EXPORT bool operator==(const QPageLayout &lhs, const QPageLayout &rhs); Q_GUI_EXPORT bool operator==(const QPageLayout &lhs, const QPageLayout &rhs);
inline bool operator!=(const QPageLayout &lhs, const QPageLayout &rhs)
{ return !operator==(lhs, rhs); }
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageLayout &pageLayout); Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageLayout &pageLayout);

View File

@ -83,8 +83,12 @@ void tst_QPageLayout::basics()
QCOMPARE(simple.paintRectPoints(), QRect(0, 0, 595, 842)); QCOMPARE(simple.paintRectPoints(), QRect(0, 0, 595, 842));
QCOMPARE(simple.paintRectPixels(72), QRect(0, 0, 595, 842)); QCOMPARE(simple.paintRectPixels(72), QRect(0, 0, 595, 842));
const QPageLayout a4portrait = simple;
QVERIFY(a4portrait == simple);
// Change orientation // Change orientation
simple.setOrientation(QPageLayout::Landscape); simple.setOrientation(QPageLayout::Landscape);
QVERIFY(simple != a4portrait);
QCOMPARE(simple.orientation(), QPageLayout::Landscape); QCOMPARE(simple.orientation(), QPageLayout::Landscape);
QCOMPARE(simple.margins(), QMarginsF(0, 0, 0, 0)); QCOMPARE(simple.margins(), QMarginsF(0, 0, 0, 0));
QCOMPARE(simple.minimumMargins(), QMarginsF(0, 0, 0, 0)); QCOMPARE(simple.minimumMargins(), QMarginsF(0, 0, 0, 0));