From kde-commits Fri Feb 28 21:19:56 2014 From: =?utf-8?q?Dennis_Nienh=C3=BCser?= Date: Fri, 28 Feb 2014 21:19:56 +0000 To: kde-commits Subject: [marble] /: Equality operators for FlyTo, HotSpot, ImagePyramid, ItemIcon, Link. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=139362240506430 Git commit 0c84eb2defc38a04effdc16ee744d70d358752b5 by Dennis Nienh=C3=BCse= r, on behalf of Sanjiban Bairagya. Committed on 28/02/2014 at 21:18. Pushed by nienhueser into branch 'master'. Equality operators for FlyTo, HotSpot, ImagePyramid, ItemIcon, Link. REVIEW: 116485 BUG: 331587 M +10 -0 src/lib/marble/geodata/data/GeoDataFlyTo.cpp M +3 -1 src/lib/marble/geodata/data/GeoDataFlyTo.h M +10 -0 src/lib/marble/geodata/data/GeoDataHotSpot.cpp M +2 -0 src/lib/marble/geodata/data/GeoDataHotSpot.h M +10 -0 src/lib/marble/geodata/data/GeoDataImagePyramid.cpp M +2 -0 src/lib/marble/geodata/data/GeoDataImagePyramid.h M +10 -0 src/lib/marble/geodata/data/GeoDataItemIcon.cpp M +2 -0 src/lib/marble/geodata/data/GeoDataItemIcon.h M +11 -7 src/lib/marble/geodata/data/GeoDataLink.cpp M +2 -0 src/lib/marble/geodata/data/GeoDataLink.h M +107 -0 tests/TestEquality.cpp http://commits.kde.org/marble/0c84eb2defc38a04effdc16ee744d70d358752b5 diff --git a/src/lib/marble/geodata/data/GeoDataFlyTo.cpp b/src/lib/marble/= geodata/data/GeoDataFlyTo.cpp index a0a5085..245c1d9 100644 --- a/src/lib/marble/geodata/data/GeoDataFlyTo.cpp +++ b/src/lib/marble/geodata/data/GeoDataFlyTo.cpp @@ -50,6 +50,16 @@ GeoDataFlyTo &GeoDataFlyTo::operator=3D( const GeoDataFl= yTo &other ) return *this; } = +bool GeoDataFlyTo::operator=3D=3D( const GeoDataFlyTo& other ) const +{ + return ( d->m_duration =3D=3D other.d->m_duration ) && ( d->m_flyToMod= e =3D=3D other.d->m_flyToMode ) && ( d->m_view =3D=3D other.d->m_view ); +} + +bool GeoDataFlyTo::operator!=3D( const GeoDataFlyTo& other ) const +{ + return !this->operator=3D=3D(other); +} + GeoDataFlyTo::~GeoDataFlyTo() { delete d; diff --git a/src/lib/marble/geodata/data/GeoDataFlyTo.h b/src/lib/marble/ge= odata/data/GeoDataFlyTo.h index 6625524..82dbf60 100644 --- a/src/lib/marble/geodata/data/GeoDataFlyTo.h +++ b/src/lib/marble/geodata/data/GeoDataFlyTo.h @@ -20,7 +20,7 @@ namespace Marble { = class GeoDataFlyToPrivate; = -class GeoDataFlyTo: public GeoDataTourPrimitive +class MARBLE_EXPORT GeoDataFlyTo: public GeoDataTourPrimitive { public: enum FlyToMode { @@ -33,6 +33,8 @@ public: GeoDataFlyTo( const GeoDataFlyTo &other ); = GeoDataFlyTo& operator=3D( const GeoDataFlyTo &other ); + bool operator=3D=3D( const GeoDataFlyTo& other ) const; + bool operator!=3D( const GeoDataFlyTo& other ) const; = ~GeoDataFlyTo(); = diff --git a/src/lib/marble/geodata/data/GeoDataHotSpot.cpp b/src/lib/marbl= e/geodata/data/GeoDataHotSpot.cpp index 3374548..411aaa7 100644 --- a/src/lib/marble/geodata/data/GeoDataHotSpot.cpp +++ b/src/lib/marble/geodata/data/GeoDataHotSpot.cpp @@ -66,6 +66,16 @@ GeoDataHotSpot& GeoDataHotSpot::operator=3D( const GeoDa= taHotSpot& other ) return *this; } = +bool GeoDataHotSpot::operator=3D=3D( const GeoDataHotSpot& other ) +{ + return ( d->m_hotSpot =3D=3D other.d->m_hotSpot ) && ( d->m_xunits =3D= =3D other.d->m_xunits ) && ( d->m_yunits =3D=3D other.d->m_yunits ); +} + +bool GeoDataHotSpot::operator!=3D( const GeoDataHotSpot& other ) +{ + return !this->operator=3D=3D(other); +} + const QPointF& GeoDataHotSpot::hotSpot( Units& xunits, Units& yunits ) con= st { xunits =3D d->m_xunits; diff --git a/src/lib/marble/geodata/data/GeoDataHotSpot.h b/src/lib/marble/= geodata/data/GeoDataHotSpot.h index 43352c7..8691e16 100644 --- a/src/lib/marble/geodata/data/GeoDataHotSpot.h +++ b/src/lib/marble/geodata/data/GeoDataHotSpot.h @@ -35,6 +35,8 @@ class GEODATA_EXPORT GeoDataHotSpot : public GeoDataObject ~GeoDataHotSpot(); = GeoDataHotSpot& operator=3D( const GeoDataHotSpot& other ); + bool operator=3D=3D( const GeoDataHotSpot& other ); + bool operator!=3D( const GeoDataHotSpot& other ); = /// Provides type information for downcasting a GeoData virtual const char* nodeType() const; diff --git a/src/lib/marble/geodata/data/GeoDataImagePyramid.cpp b/src/lib/= marble/geodata/data/GeoDataImagePyramid.cpp index e8ada51..38043b2 100644 --- a/src/lib/marble/geodata/data/GeoDataImagePyramid.cpp +++ b/src/lib/marble/geodata/data/GeoDataImagePyramid.cpp @@ -53,6 +53,16 @@ GeoDataImagePyramid &GeoDataImagePyramid::operator=3D( c= onst GeoDataImagePyramid & return *this; } = +bool GeoDataImagePyramid::operator=3D=3D( const GeoDataImagePyramid& other= ) +{ + return ( d->m_tileSize =3D=3D other.d->m_tileSize ) && ( d->m_maxWidth= =3D=3D other.d->m_maxWidth ) && ( d->m_maxHeight =3D=3D other.d->m_maxHeig= ht ) && ( d->m_gridOrigin =3D=3D other.d->m_gridOrigin ); +} + +bool GeoDataImagePyramid::operator!=3D( const GeoDataImagePyramid& other ) +{ + return !this->operator=3D=3D(other); +} + GeoDataImagePyramid::~GeoDataImagePyramid() { delete d; diff --git a/src/lib/marble/geodata/data/GeoDataImagePyramid.h b/src/lib/ma= rble/geodata/data/GeoDataImagePyramid.h index cd92670..b155f10 100644 --- a/src/lib/marble/geodata/data/GeoDataImagePyramid.h +++ b/src/lib/marble/geodata/data/GeoDataImagePyramid.h @@ -27,6 +27,8 @@ public: GeoDataImagePyramid( const GeoDataImagePyramid &other ); = GeoDataImagePyramid& operator=3D( const GeoDataImagePyramid &other ); + bool operator=3D=3D( const GeoDataImagePyramid &other ); + bool operator!=3D( const GeoDataImagePyramid &other ); = ~GeoDataImagePyramid(); = diff --git a/src/lib/marble/geodata/data/GeoDataItemIcon.cpp b/src/lib/marb= le/geodata/data/GeoDataItemIcon.cpp index b8280b7..57c23ff 100644 --- a/src/lib/marble/geodata/data/GeoDataItemIcon.cpp +++ b/src/lib/marble/geodata/data/GeoDataItemIcon.cpp @@ -48,6 +48,16 @@ GeoDataItemIcon &GeoDataItemIcon::operator=3D( const Geo= DataItemIcon &other ) return *this; } = +bool GeoDataItemIcon::operator=3D=3D( const GeoDataItemIcon& other ) +{ + return ( d->m_state =3D=3D other.d->m_state ) && ( d->m_iconPath =3D= =3D other.d->m_iconPath ) && ( d->m_icon =3D=3D other.d->m_icon ); +} + +bool GeoDataItemIcon::operator!=3D( const GeoDataItemIcon& other ) +{ + return !this->operator=3D=3D(other); +} + GeoDataItemIcon::~GeoDataItemIcon() { delete d; diff --git a/src/lib/marble/geodata/data/GeoDataItemIcon.h b/src/lib/marble= /geodata/data/GeoDataItemIcon.h index 85b50b4..43dae7e 100644 --- a/src/lib/marble/geodata/data/GeoDataItemIcon.h +++ b/src/lib/marble/geodata/data/GeoDataItemIcon.h @@ -30,6 +30,8 @@ public: GeoDataItemIcon( const GeoDataItemIcon &other ); = GeoDataItemIcon& operator=3D( const GeoDataItemIcon &other ); + bool operator=3D=3D( const GeoDataItemIcon &other ); + bool operator!=3D( const GeoDataItemIcon &other ); = ~GeoDataItemIcon(); = diff --git a/src/lib/marble/geodata/data/GeoDataLink.cpp b/src/lib/marble/g= eodata/data/GeoDataLink.cpp index e6a33b7..57c4502 100644 --- a/src/lib/marble/geodata/data/GeoDataLink.cpp +++ b/src/lib/marble/geodata/data/GeoDataLink.cpp @@ -18,19 +18,12 @@ class GeoDataLinkPrivate { public: QString m_href; - GeoDataLink::RefreshMode m_refreshMode; - qreal m_refreshInterval; - GeoDataLink::ViewRefreshMode m_viewRefreshMode; - qreal m_viewRefreshTime; - qreal m_viewBoundScale; - QString m_viewFormat; - QString m_httpQuery; = GeoDataLinkPrivate(); @@ -67,6 +60,17 @@ GeoDataLink &GeoDataLink::operator=3D( const GeoDataLink= &other ) return *this; } = +bool GeoDataLink::operator=3D=3D( const GeoDataLink& other ) +{ + return ( d->m_href =3D=3D other.d->m_href ) && ( d->m_refreshMode =3D= =3D other.d->m_refreshMode ) && ( d->m_refreshInterval =3D=3D other.d->m_re= freshInterval ) && ( d->m_viewRefreshMode =3D=3D other.d->m_viewRefreshMode= ) + && ( d->m_viewRefreshTime =3D=3D other.d->m_viewRefreshTime ) && (= d->m_viewBoundScale =3D=3D other.d->m_viewBoundScale ) && ( d->m_viewForma= t =3D=3D other.d->m_viewFormat ) && ( d->m_httpQuery =3D=3D other.d->m_http= Query ); +} + +bool GeoDataLink::operator!=3D( const GeoDataLink& other ) +{ + return !this->operator=3D=3D(other); +} + GeoDataLink::~GeoDataLink() { delete d; diff --git a/src/lib/marble/geodata/data/GeoDataLink.h b/src/lib/marble/geo= data/data/GeoDataLink.h index 52c80d2..42db730 100644 --- a/src/lib/marble/geodata/data/GeoDataLink.h +++ b/src/lib/marble/geodata/data/GeoDataLink.h @@ -40,6 +40,8 @@ public: GeoDataLink( const GeoDataLink &other ); = GeoDataLink& operator=3D( const GeoDataLink &other ); + bool operator=3D=3D( const GeoDataLink &other ); + bool operator!=3D( const GeoDataLink &other ); = ~GeoDataLink(); = diff --git a/tests/TestEquality.cpp b/tests/TestEquality.cpp index 12f3f03..7a37b02 100644 --- a/tests/TestEquality.cpp +++ b/tests/TestEquality.cpp @@ -19,6 +19,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "TestUtils.h" = using namespace Marble; @@ -36,6 +41,11 @@ private slots: void balloonTest(); void colorTest(); void cameraTest(); + void flyToTest(); + void hotSpotTest(); + void imagePyramidTest(); + void itemIconTest(); + void linkTest(); }; = = @@ -247,6 +257,103 @@ void TestEquality::cameraTest() QVERIFY( camera1 !=3D camera2 ); } = +void TestEquality::flyToTest() +{ + GeoDataFlyTo flyTo1, flyTo2; + + flyTo1.setDuration(7.6); + flyTo1.setFlyToMode(GeoDataFlyTo::Bounce); + + flyTo2.setDuration( 5.8 ); + flyTo1.setFlyToMode( GeoDataFlyTo::Smooth ); + + QCOMPARE( flyTo1, flyTo1 ); + QCOMPARE( flyTo2, flyTo2 ); + QCOMPARE( flyTo1 =3D=3D flyTo2, false ); + QVERIFY( flyTo1 !=3D flyTo2 ); +} + +void TestEquality::hotSpotTest() +{ + QPointF point1, point2; + point1.setX( 5 ); + point1.setY( 4 ); + point2.setX( 6 ); + point2.setY( 2 ); + + GeoDataHotSpot hotSpot1, hotSpot2; + hotSpot1.setHotSpot( point1, GeoDataHotSpot::Fraction, GeoDataHotSpot:= :Fraction ); + hotSpot2.setHotSpot( point2, GeoDataHotSpot::Pixels, GeoDataHotSpot::P= ixels ); + + QCOMPARE( &hotSpot1, &hotSpot1 ); + QCOMPARE( &hotSpot2, &hotSpot2 ); + QCOMPARE( hotSpot1 =3D=3D hotSpot2, false ); + QVERIFY( hotSpot1 !=3D hotSpot2 ); +} + +void TestEquality::imagePyramidTest() +{ + GeoDataImagePyramid pyramid1, pyramid2; + pyramid1.setGridOrigin( GeoDataImagePyramid::LowerLeft ); + pyramid1.setMaxHeight( 40 ); + pyramid1.setMaxWidth( 30 ); + pyramid1.setTileSize( 20 ); + + pyramid2.setGridOrigin( GeoDataImagePyramid::UpperLeft ); + pyramid2.setMaxHeight( 50 ); + pyramid2.setMaxWidth( 80 ); + pyramid2.setTileSize( 30 ); + + QCOMPARE( &pyramid1, &pyramid1 ); + QCOMPARE( &pyramid2, &pyramid2 ); + QCOMPARE( pyramid1 =3D=3D pyramid2, false ); + QVERIFY( pyramid1 !=3D pyramid2 ); +} + +void TestEquality::itemIconTest() +{ + GeoDataItemIcon icon1, icon2; + QImage img1( 10, 20, QImage::Format_Mono ); + QImage img2( 30, 50, QImage::Format_Mono ); + + icon1.setIcon( img1 ); + icon1.setIconPath( "some/path" ); + icon1.setState( GeoDataItemIcon::Open ); + + icon2.setIcon( img2 ); + icon2.setIconPath( "some/other/path" ); + icon2.setState( GeoDataItemIcon::Closed ); + + QCOMPARE( &icon1, &icon1 ); + QCOMPARE( &icon2, &icon2 ); + QCOMPARE( &icon1 =3D=3D &icon2, false ); + QVERIFY( &icon1 !=3D &icon2 ); + +} + +void TestEquality::linkTest() +{ + GeoDataLink link1, link2; + + link1.setHref("some/example/href.something"); + link1.setRefreshInterval( 23 ); + link1.setRefreshMode( GeoDataLink::OnChange ); + link1.setViewBoundScale( 50 ); + link1.setViewRefreshTime( 30 ); + + link2.setHref("some/other/example/href.something"); + link1.setRefreshInterval( 32 ); + link1.setRefreshMode(GeoDataLink::OnChange); + link1.setViewBoundScale( 60 ); + link1.setViewRefreshTime( 40 ); + + QCOMPARE( &link1, &link1 ); + QCOMPARE( &link2, &link2 ); + QCOMPARE( &link1 =3D=3D &link2, false ); + QVERIFY( &link1 !=3D &link2 ); +} + + QTEST_MAIN( TestEquality ) = #include "TestEquality.moc"