mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-17 18:50:56 -04:00
Implement support for group tree changes in GroupModel.
This commit is contained in:
parent
e28ed4891b
commit
623b325fa1
8 changed files with 134 additions and 21 deletions
|
@ -26,6 +26,7 @@ class TestGroup : public QObject
|
|||
|
||||
private Q_SLOTS:
|
||||
void testParenting();
|
||||
void testSignals();
|
||||
};
|
||||
|
||||
void TestGroup::testParenting()
|
||||
|
@ -67,7 +68,7 @@ void TestGroup::testParenting()
|
|||
QVERIFY(g1->children().at(1) == g3);
|
||||
QVERIFY(g3->children().contains(g4));
|
||||
|
||||
QSignalSpy spy(db, SIGNAL(groupChanged(const Group*)));
|
||||
QSignalSpy spy(db, SIGNAL(groupDataChanged(const Group*)));
|
||||
g2->setName("test");
|
||||
g4->setName("test");
|
||||
g3->setName("test");
|
||||
|
@ -77,6 +78,30 @@ void TestGroup::testParenting()
|
|||
QVERIFY(spy.count() == 6);
|
||||
}
|
||||
|
||||
void TestGroup::testSignals()
|
||||
{
|
||||
Database* db = new Database();
|
||||
Group* root = new Group();
|
||||
root->setParent(db);
|
||||
|
||||
Group* g1 = new Group();
|
||||
Group* g2 = new Group();
|
||||
g1->setParent(root);
|
||||
g2->setParent(root);
|
||||
|
||||
QSignalSpy spyAboutToAdd(db, SIGNAL(groupAboutToAdd(const Group*,int)));
|
||||
QSignalSpy spyAdded(db, SIGNAL(groupAdded()));
|
||||
QSignalSpy spyAboutToRemove(db, SIGNAL(groupAboutToRemove(const Group*)));
|
||||
QSignalSpy spyRemoved(db, SIGNAL(groupRemoved()));
|
||||
|
||||
g2->setParent(root, 0);
|
||||
|
||||
QCOMPARE(spyAboutToAdd.count(), 1);
|
||||
QCOMPARE(spyAdded.count(), 1);
|
||||
QCOMPARE(spyAboutToRemove.count(), 1);
|
||||
QCOMPARE(spyRemoved.count(), 1);
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestGroup);
|
||||
|
||||
#include "TestGroup.moc"
|
||||
|
|
|
@ -77,10 +77,22 @@ void TestGroupModel::test()
|
|||
QVERIFY(model->data(index121) == "group121");
|
||||
QVERIFY(model->data(index2) == "group2");
|
||||
|
||||
QSignalSpy spy(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)));
|
||||
QSignalSpy spy1(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)));
|
||||
group11->setName("test");
|
||||
group121->setIcon(4);
|
||||
QVERIFY(spy.count() == 2);
|
||||
QCOMPARE(spy1.count(), 2);
|
||||
|
||||
QSignalSpy spyAboutToAdd(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex&,int,int)));
|
||||
QSignalSpy spyAdded(model, SIGNAL(rowsInserted(const QModelIndex&,int,int)));
|
||||
QSignalSpy spyAboutToRemove(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&,int,int)));
|
||||
QSignalSpy spyRemoved(model, SIGNAL(rowsRemoved(const QModelIndex&,int,int)));
|
||||
|
||||
group12->setParent(group1, 0);
|
||||
|
||||
QCOMPARE(spyAboutToAdd.count(), 1);
|
||||
QCOMPARE(spyAdded.count(), 1);
|
||||
QCOMPARE(spyAboutToRemove.count(), 1);
|
||||
QCOMPARE(spyRemoved.count(), 1);
|
||||
|
||||
delete groupRoot;
|
||||
delete db;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue