Added support for import data from file.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "context.h"
|
||||
#include "iservice.h"
|
||||
#include "permissionevaluator.h"
|
||||
#include "iimporter.h"
|
||||
|
||||
#include "transaction.h"
|
||||
|
||||
@@ -178,6 +179,33 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool importData(IImporter *importer) {
|
||||
int count = importer->recordCount();
|
||||
|
||||
if (importer->isError()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
QSharedPointer<QObject> qentity = importer->nextRecord();
|
||||
|
||||
if (importer->isError() || qentity.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QSharedPointer<T> entity = qentity.dynamicCast<T>();
|
||||
if (!entity.isNull()) {
|
||||
this->save(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool checkPermission(const QString &permission) {
|
||||
if (!m_pluginId.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user