Update connection of modified signals of entries when a parent group changes database.

This commit is contained in:
Florian Geyer 2012-04-18 15:16:38 +02:00 committed by Felix Geyer
parent ec3cca1f77
commit d85e5d7560
2 changed files with 13 additions and 1 deletions

View File

@ -310,7 +310,9 @@ void Group::addEntry(Entry *entry)
m_entries << entry;
connect(entry, SIGNAL(dataChanged(Entry*)), SIGNAL(entryDataChanged(Entry*)));
connect(entry, SIGNAL(modified()), m_db, SIGNAL(modified()));
if (m_db) {
connect(entry, SIGNAL(modified()), m_db, SIGNAL(modified()));
}
Q_EMIT modified();
Q_EMIT entryAdded();
@ -335,6 +337,11 @@ void Group::recSetDatabase(Database* db)
disconnect(SIGNAL(added()), m_db);
disconnect(SIGNAL(modified()), m_db);
Q_FOREACH (Entry* entry, m_entries) {
entry->disconnect(m_db);
connect(entry, SIGNAL(modified()), db, SIGNAL(modified()));
}
connect(this, SIGNAL(dataChanged(Group*)), db, SIGNAL(groupDataChanged(Group*)));
connect(this, SIGNAL(aboutToRemove(Group*)), db, SIGNAL(groupAboutToRemove(Group*)));
connect(this, SIGNAL(removed()), db, SIGNAL(groupRemoved()));

View File

@ -71,6 +71,11 @@ void TestModified::testSignals()
QCOMPARE(spyModified.count(), spyCount);
QCOMPARE(spyModified2.count(), spyCount2);
entry1->setTitle("test");
spyCount2++;
QCOMPARE(spyModified.count(), spyCount);
QCOMPARE(spyModified2.count(), spyCount2);
QPointer<Entry> entry2 = new Entry();
entry2->setGroup(g2);
spyCount++;