summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-21 06:59:20 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-21 06:59:20 (GMT)
commit1f37580aa509d6eaddea6f2e638366cf09b5517a (patch)
tree81ceb3f73bd2cdfcc79ff9a59c12b54dece0f4c3
parent5517f37b0df2adec45038f8edb7e8884b0027523 (diff)
Fix relation copy and valid method
REVIEW: 129515
-rw-r--r--autotests/libs/relationtest.cpp15
-rw-r--r--src/core/relation.cpp6
2 files changed, 19 insertions, 2 deletions
diff --git a/autotests/libs/relationtest.cpp b/autotests/libs/relationtest.cpp
index c00af49..8079478 100644
--- a/autotests/libs/relationtest.cpp
+++ b/autotests/libs/relationtest.cpp
@@ -47,6 +47,7 @@ private Q_SLOTS:
void testCreateFetch();
void testMonitor();
+ void testEqualRelation();
};
void RelationTest::initTestCase()
@@ -159,6 +160,20 @@ void RelationTest::testMonitor()
}
}
+void RelationTest::testEqualRelation()
+{
+ Relation r1;
+ Item it1(45);
+ Item it2(46);
+ r1.setLeft(it1);
+ r1.setRight(it2);
+ r1.setRemoteId(QByteArrayLiteral("foo"));
+ r1.setType(QByteArrayLiteral("foo1"));
+
+ Relation r2 = r1;
+ QCOMPARE(r1, r2);
+}
+
QTEST_AKONADIMAIN(RelationTest)
#include "relationtest.moc"
diff --git a/src/core/relation.cpp b/src/core/relation.cpp
index 45e1558..4dacf2e 100644
--- a/src/core/relation.cpp
+++ b/src/core/relation.cpp
@@ -61,6 +61,7 @@ Relation &Relation::operator=(const Relation &other)
d->left = other.d->left;
d->right = other.d->right;
d->type = other.d->type;
+ d->remoteId = other.d->remoteId;
return *this;
}
@@ -69,7 +70,8 @@ bool Relation::operator==(const Relation &other) const
if (isValid() && other.isValid()) {
return d->left == other.d->left
&& d->right == other.d->right
- && d->type == other.d->type;
+ && d->type == other.d->type
+ && d->remoteId == other.d->remoteId;
}
return false;
}
@@ -121,7 +123,7 @@ QByteArray Relation::remoteId() const
bool Relation::isValid() const
{
- return (d->left.isValid() || !d->left.remoteId().isEmpty()) && (d->right.isValid() || !d->left.remoteId().isEmpty()) && !d->type.isEmpty();
+ return (d->left.isValid() || !d->left.remoteId().isEmpty()) && (d->right.isValid() || !d->right.remoteId().isEmpty()) && !d->type.isEmpty();
}
uint qHash(const Relation &relation)