Introduce interface for exporter.

This commit is contained in:
Florian Geyer 2014-05-16 12:30:47 +02:00
parent 204cd8d971
commit ea3375490c
4 changed files with 20 additions and 4 deletions

14
src/core/Exporter.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef KEEPASSX_EXPORTER_H
#define KEEPASSX_EXPORTER_H
class Database;
class Group;
class Exporter
{
public:
virtual Database* exportGroup(Group* group) = 0;
virtual ~Exporter() {}
};
#endif // KEEPASSX_EXPORTER_H

View File

@ -21,7 +21,7 @@
#include "core/Group.h" #include "core/Group.h"
#include "core/Metadata.h" #include "core/Metadata.h"
Database* ToDbExporter::exportToDb(Group* group) Database* ToDbExporter::exportGroup(Group* group)
{ {
Database* oldDb = group->database(); Database* oldDb = group->database();
Q_ASSERT(oldDb); Q_ASSERT(oldDb);

View File

@ -19,13 +19,15 @@
#ifndef KEEPASSX_TODBEXPORTER_H #ifndef KEEPASSX_TODBEXPORTER_H
#define KEEPASSX_TODBEXPORTER_H #define KEEPASSX_TODBEXPORTER_H
#include "core/Exporter.h"
class Database; class Database;
class Group; class Group;
class ToDbExporter class ToDbExporter : Exporter
{ {
public: public:
Database* exportToDb(Group* group); Database* exportGroup(Group* group);
}; };
#endif // KEEPASSX_TODBEXPORTER_H #endif // KEEPASSX_TODBEXPORTER_H

View File

@ -57,7 +57,7 @@ void TestExporter::testToDbExporter()
entryOrg->setIcon(Entry::DefaultIconNumber); entryOrg->setIcon(Entry::DefaultIconNumber);
entryOrg->endUpdate(); entryOrg->endUpdate();
Database* dbExp = ToDbExporter().exportToDb(groupOrg); Database* dbExp = ToDbExporter().exportGroup(groupOrg);
QCOMPARE(dbExp->rootGroup()->children().size(), 1); QCOMPARE(dbExp->rootGroup()->children().size(), 1);
Group* groupExp = dbExp->rootGroup()->children().first(); Group* groupExp = dbExp->rootGroup()->children().first();