0
0
mirror of https://github.com/keepassxreboot/keepassxc.git synced 2024-09-20 04:12:15 +02:00

Make some Group methods private.

This commit is contained in:
Felix Geyer 2011-07-08 13:57:02 +02:00
parent b4367a7ea1
commit 4dbdc4d847
13 changed files with 43 additions and 20 deletions

View File

@ -20,7 +20,8 @@
#include <QtCore/QFile>
#include <QtCore/QXmlStreamReader>
#include "Metadata.h"
#include "core/Group.h"
#include "core/Metadata.h"
#include "crypto/Random.h"
#include "format/KeePass2.h"
@ -46,7 +47,10 @@ const Group* Database::rootGroup() const
void Database::setRootGroup(Group* group)
{
Q_ASSERT(group == 0 || group->database() == this);
if (group != 0) {
group->setParent(this);
}
m_rootGroup = group;
}

View File

@ -18,13 +18,15 @@
#ifndef KEEPASSX_DATABASE_H
#define KEEPASSX_DATABASE_H
#include "Group.h"
#include <QtCore/QDateTime>
#include <QtCore/QHash>
#include <QtGui/QIcon>
#include "core/Uuid.h"
#include "keys/CompositeKey.h"
class Entry;
class Group;
class Metadata;
struct DeletedObject
@ -48,7 +50,12 @@ public:
Database();
Group* rootGroup();
const Group* rootGroup() const;
/**
* Sets group as the root group and takes ownership of it.
*/
void setRootGroup(Group* group);
Metadata* metadata();
const Metadata* metadata() const;
Entry* resolveEntry(const Uuid& uuid);
@ -66,6 +73,10 @@ public:
void setCompressionAlgo(Database::CompressionAlgorithm algo);
void setTransformRounds(quint64 rounds);
void setKey(const CompositeKey& key, const QByteArray& transformSeed);
/**
* Sets the database key and generates a random transform seed.
*/
void setKey(const CompositeKey& key);
Q_SIGNALS:

View File

@ -55,6 +55,7 @@ QIcon Entry::icon() const
return DatabaseIcons::icon(m_iconNumber);
}
else {
// TODO check if m_db is 0
return m_db->metadata()->customIcon(m_customIcon);
}
}

View File

@ -98,6 +98,9 @@ public:
static bool isDefaultAttributue(const QString& key);
Q_SIGNALS:
/**
* Emitted when a default attribute has been changed.
*/
void dataChanged(Entry* entry);
private:

View File

@ -20,7 +20,6 @@
#include "Group.h"
#include "Database.h"
#include "DatabaseIcons.h"
#include "Metadata.h"
@ -238,8 +237,6 @@ void Group::setParent(Database* db)
recSetDatabase(db);
QObject::setParent(db);
db->setRootGroup(this);
}
const Database* Group::database() const

View File

@ -20,12 +20,11 @@
#include <QtGui/QIcon>
#include "Database.h"
#include "Entry.h"
#include "TimeInfo.h"
#include "Uuid.h"
class Database;
class Group : public QObject
{
Q_OBJECT
@ -63,15 +62,12 @@ public:
Group* parentGroup();
const Group* parentGroup() const;
void setParent(Group* parent, int index = -1);
void setParent(Database* db);
const Database* database() const;
QList<Group*> children();
const QList<Group*>& children() const;
QList<Entry*> entries();
const QList<Entry*>& entries() const;
void addEntry(Entry* entry);
void removeEntry(Entry* entry);
Q_SIGNALS:
void dataChanged(Group* group);
@ -89,6 +85,10 @@ Q_SIGNALS:
void entryDataChanged(Entry* entry);
private:
void addEntry(Entry* entry);
void removeEntry(Entry* entry);
void setParent(Database* db);
void recSetDatabase(Database* db);
Database* m_db;
@ -107,6 +107,9 @@ private:
QList<Entry*> m_entries;
Group* m_parent;
friend void Database::setRootGroup(Group* group);
friend void Entry::setGroup(Group *group);
};
#endif // KEEPASSX_GROUP_H

View File

@ -21,6 +21,7 @@
#include "core/Database.h"
#include "core/DatabaseIcons.h"
#include "core/Group.h"
#include "core/Metadata.h"
#include "format/KeePass2RandomStream.h"
@ -40,7 +41,7 @@ void KeePass2XmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Ra
m_randomStream = randomStream;
m_tmpParent = new Group();
m_tmpParent->setParent(m_db);
m_db->setRootGroup(m_tmpParent);
if (!m_xml.error() && m_xml.readNextStartElement()) {
if (m_xml.name() == "KeePassFile") {
@ -276,7 +277,7 @@ void KeePass2XmlReader::parseRoot()
if (m_xml.name() == "Group") {
Group* rootGroup = parseGroup();
if (rootGroup) {
rootGroup->setParent(m_db);
m_db->setRootGroup(rootGroup);
}
}
else if (m_xml.name() == "DeletedObjects") {

View File

@ -25,6 +25,7 @@
#include "core/Database.h"
#include "core/Entry.h"
#include "core/Group.h"
#include "core/TimeInfo.h"
#include "core/Uuid.h"

View File

@ -22,6 +22,7 @@
#include <QtTest/QTest>
#include "core/Database.h"
#include "core/Group.h"
void TestGroup::initTestCase()
{
@ -46,7 +47,7 @@ void TestGroup::testParenting()
g2->setParent(g1);
g4->setParent(g3);
g3->setParent(g1);
g1->setParent(db);
db->setRootGroup(g1);
QVERIFY(g1->parent() == db);
QVERIFY(g2->parent() == g1);
@ -91,7 +92,7 @@ void TestGroup::testSignals()
{
Database* db = new Database();
QPointer<Group> root = new Group();
root->setParent(db);
db->setRootGroup(root);
Group* g1 = new Group();
Group* g2 = new Group();

View File

@ -35,7 +35,7 @@ void TestGroupModel::test()
Database* db = new Database();
Group* groupRoot = new Group();
groupRoot->setParent(db);
db->setRootGroup(groupRoot);
groupRoot->setName("groupRoot");
Group* group1 = new Group();

View File

@ -21,6 +21,7 @@
#include "config-keepassx-tests.h"
#include "core/Database.h"
#include "core/Group.h"
#include "core/Metadata.h"
#include "crypto/Crypto.h"
#include "format/KeePass2Reader.h"

View File

@ -21,13 +21,13 @@
#include <QtTest/QTest>
#include "core/Database.h"
#include "core/Group.h"
#include "core/Metadata.h"
#include "crypto/Crypto.h"
#include "format/KeePass2Reader.h"
#include "format/KeePass2Writer.h"
#include "keys/PasswordKey.h"
#include "format/KeePass2XmlWriter.h"
void TestKeePass2Writer::initTestCase()
{
Crypto::init();
@ -40,13 +40,12 @@ void TestKeePass2Writer::initTestCase()
m_dbOrg->metadata()->setName("TESTDB");
Group* group = new Group();
group->setUuid(Uuid::random());
group->setParent(m_dbOrg);
m_dbOrg->setRootGroup(group);
Entry* entry = new Entry();
entry->setUuid(Uuid::random());
entry->addAttribute("test", "protectedTest", true);
QVERIFY(entry->isAttributeProtected("test"));
group->addEntry(entry);
entry->setGroup(group);
QBuffer buffer;
buffer.open(QBuffer::ReadWrite);

View File

@ -20,6 +20,7 @@
#include <QtTest/QTest>
#include "core/Database.h"
#include "core/Group.h"
#include "core/Metadata.h"
#include "format/KeePass2XmlReader.h"
#include "config-keepassx-tests.h"