Notify entry/group parent on deletion.

Also make the root group pseudo static, i.e. it shouldn't be changed
after the database has been fully constructed.
This commit is contained in:
Felix Geyer
2011-07-09 21:54:01 +02:00
parent d4f02a78a7
commit 027362be76
11 changed files with 90 additions and 41 deletions

View File

@@ -41,7 +41,6 @@ void KeePass2XmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Ra
m_randomStream = randomStream;
m_tmpParent = new Group();
m_db->setRootGroup(m_tmpParent);
if (!m_xml.error() && m_xml.readNextStartElement()) {
if (m_xml.name() == "KeePassFile") {
@@ -49,6 +48,7 @@ void KeePass2XmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Ra
}
}
// TODO check if m_tmpParent doesn't have entries
if (!m_xml.error() && !m_tmpParent->children().isEmpty()) {
raiseError();
}
@@ -277,7 +277,9 @@ void KeePass2XmlReader::parseRoot()
if (m_xml.name() == "Group") {
Group* rootGroup = parseGroup();
if (rootGroup) {
Group* oldRoot = m_db->rootGroup();
m_db->setRootGroup(rootGroup);
delete oldRoot;
}
}
else if (m_xml.name() == "DeletedObjects") {
@@ -302,7 +304,7 @@ Group* KeePass2XmlReader::parseGroup()
}
else {
group = getGroup(uuid);
}
}
}
else if (m_xml.name() == "Name") {
group->setName(readString());