mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-03-25 15:38:11 -04:00
Fix group signals (#2670)
* Fix group not emitting signals when modified through copyDataFrom * Fix Group::GroupData equals wrongly compares timeInfo
This commit is contained in:
parent
42cfe01ad2
commit
e60f4278f7
@ -865,7 +865,9 @@ Group* Group::clone(Entry::CloneFlags entryFlags, Group::CloneFlags groupFlags)
|
||||
|
||||
void Group::copyDataFrom(const Group* other)
|
||||
{
|
||||
m_data = other->m_data;
|
||||
if (set(m_data, other->m_data)) {
|
||||
emit groupDataChanged(this);
|
||||
}
|
||||
m_customData->copyDataFrom(other->m_customData);
|
||||
m_lastTopVisibleEntry = other->m_lastTopVisibleEntry;
|
||||
}
|
||||
@ -1079,7 +1081,7 @@ bool Group::GroupData::equals(const Group::GroupData& other, CompareItemOptions
|
||||
if (::compare(customIcon, other.customIcon) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (timeInfo.equals(other.timeInfo, options) != 0) {
|
||||
if (!timeInfo.equals(other.timeInfo, options)) {
|
||||
return false;
|
||||
}
|
||||
// TODO HNH: Some properties are configurable - should they be ignored?
|
||||
|
@ -798,3 +798,46 @@ void TestGroup::testIsRecycled()
|
||||
db->recycleGroup(group4);
|
||||
QVERIFY(group4->isRecycled());
|
||||
}
|
||||
|
||||
void TestGroup::testCopyDataFrom()
|
||||
{
|
||||
QScopedPointer<Group> group(new Group());
|
||||
group->setName("TestGroup");
|
||||
|
||||
QScopedPointer<Group> group2(new Group());
|
||||
group2->setName("TestGroup2");
|
||||
|
||||
QScopedPointer<Group> group3(new Group());
|
||||
group3->setName("TestGroup3");
|
||||
group3->customData()->set("testKey", "value");
|
||||
|
||||
|
||||
QSignalSpy spyGroupModified(group.data(), SIGNAL(groupModified()));
|
||||
QSignalSpy spyGroupDataChanged(group.data(), SIGNAL(groupDataChanged(Group*)));
|
||||
|
||||
group->copyDataFrom(group2.data());
|
||||
QCOMPARE(spyGroupModified.count(), 1);
|
||||
QCOMPARE(spyGroupDataChanged.count(), 1);
|
||||
|
||||
// if no change, no signals
|
||||
spyGroupModified.clear();
|
||||
spyGroupDataChanged.clear();
|
||||
group->copyDataFrom(group2.data());
|
||||
QCOMPARE(spyGroupModified.count(), 0);
|
||||
QCOMPARE(spyGroupDataChanged.count(), 0);
|
||||
|
||||
// custom data change triggers a separate modified signal
|
||||
spyGroupModified.clear();
|
||||
spyGroupDataChanged.clear();
|
||||
group->copyDataFrom(group3.data());
|
||||
QCOMPARE(spyGroupDataChanged.count(), 1);
|
||||
QCOMPARE(spyGroupModified.count(), 2);
|
||||
}
|
||||
|
||||
void TestGroup::testEquals()
|
||||
{
|
||||
QScopedPointer<Group> group(new Group());
|
||||
group->setName("TestGroup");
|
||||
|
||||
QVERIFY(group->equals(group.data(), CompareItemDefault));
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ private slots:
|
||||
void testLocate();
|
||||
void testAddEntryWithPath();
|
||||
void testIsRecycled();
|
||||
void testCopyDataFrom();
|
||||
void testEquals();
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_TESTGROUP_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user