Zdenek Jonak 8 years ago
commit 6e2ee642ce

@ -0,0 +1,19 @@
#include "camp.h"
#include "campgrid.h"
#include "campform.h"
Camp::Camp()
{
}
void Camp::initServiceUi()
{
m_ui = new CampGrid();
((CampGrid*)m_ui)->setForm(new CampForm());
}
QIcon Camp::pluginIcon()
{
return QIcon(":/icons/campPlugin.svg");
}

@ -0,0 +1,27 @@
#ifndef CAMP_H
#define CAMP_H
#include "camp_global.h"
#include <core.h>
#include <QObject>
#include <QtPlugin>
class CAMPSHARED_EXPORT Camp : public QObject, IMetaDataPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID PluginInterface_iid FILE "camp.json")
Q_INTERFACES(IPlugin)
public:
Camp();
protected:
void initServiceUi() Q_DECL_OVERRIDE;
// IPlugin interface
public:
virtual QIcon pluginIcon();
};
#endif // CAMP_H

@ -0,0 +1,65 @@
{
"id" : "CAMP",
"name" : {
"default" : "Camp",
"CZ" : "Kemp"
},
"descriptoin" : {
"default" : "",
"CZ" : ""
},
"schemaVersion" : 1,
"sql" : [
"CREATE TABLE \"CampData\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
\"start\" TEXT NULL,
\"end\" TEXT NULL,
\"ownerFirstame\" TEXT NULL,
\"ownerLastname\" TEXT NULL,
\"ownerAddress\" TEXT NULL,
\"totalPrice\" INTEGER NOT NULL,
\"season\" INTEGER NULL,
CONSTRAINT \"season_fk\"
FOREIGN KEY (\"season\")
REFERENCES \"Season\" (\"id\")
DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE \"AddressItem\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
\"firstName\" TEXT NULL,
\"lastName\" TEXT NULL,
\"address\" TEXT NULL,
\"price\" INTEGER NOT NULL,
\"campData\" INTEGER NOT NULL,
CONSTRAINT \"campData_fk\"
FOREIGN KEY (\"campData\")
REFERENCES \"CampData\" (\"id\")
DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE \"ServiceItem\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
\"name\" TEXT NULL,
\"code\" TEXT NULL,
\"price\" INTEGER NOT NULL,
\"salePossible\" INTEGER NOT NULL,
\"type\" INTEGER NOT NULL,
\"campData\" INTEGER NOT NULL,
CONSTRAINT \"campData_fk\"
FOREIGN KEY (\"campData\")
REFERENCES \"CampData\" (\"id\")
DEFERRABLE INITIALLY DEFERRED);
"
],
"dependencies" : [ "ADDRESSBOOK", "SHOP", "SERVICES" ],
"translations" : {
"CZ" : {
"name" : "Název",
"shortName" : "Zobrazit na účtence",
"code" : "Kód",
"type" : "Druh",
"price" : "Cena",
"vat" : "DPH",
"count" : "Počet"
}
}
}

@ -0,0 +1,82 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-04-19T09:20:32
#
#-------------------------------------------------
QT += widgets sql
TARGET = camp
TEMPLATE = lib
DEFINES += CAMP_LIBRARY
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += camp.cpp \
data/campdata.cpp \
data/addressitem.cpp \
data/serviceitem.cpp \
campgrid.cpp \
campform.cpp
HEADERS += camp.h\
camp_global.h \
data/campdata.h \
data/addressitem.h \
data/serviceitem.h \
data/camp-data.h \
campgrid.h \
campform.h
include(../config_plugin.pri)
ODB_FILES = camp/data/camp-data.h
H_DIR = $$PWD/data/*.h
ODB_OTHER_INCLUDES = -I $$PWD/../shop -I $$PWD/../addressbook/data -I $$PWD/../services/data
include(../odb.pri)
unix {
target.path = /usr/lib
INSTALLS += target
}
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lshop
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lshop
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -lshop
INCLUDEPATH += $$PWD/../shop
DEPENDPATH += $$PWD/../shop
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
INCLUDEPATH += $$PWD/../addressbook
DEPENDPATH += $$PWD/../addressbook
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lservices
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lservices
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -lservices
INCLUDEPATH += $$PWD/../services
INCLUDEPATH += $$PWD/../services/data
DEPENDPATH += $$PWD/../services
DISTFILES += \
camp.json
RESOURCES += \
camprc.qrc
FORMS += \
campform.ui

@ -0,0 +1,12 @@
#ifndef CAMP_GLOBAL_H
#define CAMP_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(CAMP_LIBRARY)
# define CAMPSHARED_EXPORT Q_DECL_EXPORT
#else
# define CAMPSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // CAMP_GLOBAL_H

@ -0,0 +1,14 @@
#include "campform.h"
#include "ui_campform.h"
CampForm::CampForm(QWidget *parent) :
AutoForm<CampData>(parent),
ui(new Ui::CampForm)
{
ui->setupUi(this);
}
CampForm::~CampForm()
{
delete ui;
}

@ -0,0 +1,25 @@
#ifndef CAMPFORM_H
#define CAMPFORM_H
#include <QWidget>
#include <core.h>
#include "data/camp-data.h"
#include "camp-odb.hxx"
namespace Ui {
class CampForm;
}
class CampForm : public AutoForm<CampData>
{
Q_OBJECT
public:
explicit CampForm(QWidget *parent = 0);
~CampForm();
private:
Ui::CampForm *ui;
};
#endif // CAMPFORM_H

@ -0,0 +1,21 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>CampForm</class>
<widget class="QWidget" name="CampForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

@ -0,0 +1,6 @@
#include "campgrid.h"
CampGrid::CampGrid(QWidget *parent) : GridForm<CampData>(parent)
{
setTableModel(new AutoTableModel<CampData>);
}

@ -0,0 +1,14 @@
#ifndef CAMPGRID_H
#define CAMPGRID_H
#include <core.h>
#include "data/camp-data.h"
#include "camp-odb.hxx"
class CampGrid : public GridForm<CampData>
{
public:
CampGrid(QWidget *parent = NULL);
};
#endif // CAMPGRID_H

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>icons/campPlugin.svg</file>
</qresource>
</RCC>

@ -0,0 +1,67 @@
#include "addressitem.h"
#include <define.h>
AddressItem::AddressItem(QObject *parent) : QObject(parent)
{
}
int AddressItem::id() const
{
return m_id;
}
void AddressItem::setId(int id)
{
m_id = id;
}
QString AddressItem::firstName() const
{
return m_firstName;
}
void AddressItem::setFirstName(const QString &firstName)
{
m_firstName = firstName;
}
QString AddressItem::lastName() const
{
return m_lastName;
}
void AddressItem::setLastName(const QString &lastName)
{
m_lastName = lastName;
}
QString AddressItem::address() const
{
return m_address;
}
void AddressItem::setAddress(const QString &address)
{
m_address = address;
}
QDecDouble AddressItem::price() const
{
return TO_DEC(m_price);
}
void AddressItem::setPrice(QDecDouble price)
{
m_price = FROM_DEC(price);
}
QWeakPointer<CampData> AddressItem::campData() const
{
return m_campData;
}
void AddressItem::setCampData(const QWeakPointer<CampData> &campData)
{
m_campData = campData;
}

@ -0,0 +1,55 @@
#ifndef ADDRESSITEM_H
#define ADDRESSITEM_H
#include "camp-data.h"
#include <QObject>
#include <QSharedPointer>
#include <QWeakPointer>
#include <QDecDouble.hh>
#include <odb/core.hxx>
class CampData;
#pragma db object
class AddressItem : public QObject
{
Q_OBJECT
Q_PROPERTY(QString firstName READ firstName WRITE setFirstName)
Q_PROPERTY(QString lastName READ lastName WRITE setLastName)
Q_PROPERTY(QString address READ address WRITE setAddress)
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
public:
explicit AddressItem(QObject *parent = 0);
int id() const;
void setId(int id);
QString firstName() const;
void setFirstName(const QString &firstName);
QString lastName() const;
void setLastName(const QString &lastName);
QString address() const;
void setAddress(const QString &address);
QDecDouble price() const;
void setPrice(QDecDouble price);
QWeakPointer<CampData> campData() const;
void setCampData(const QWeakPointer<CampData> &campData);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_firstName;
QString m_lastName;
QString m_address;
int m_price;
#pragma db not_null
QWeakPointer<CampData> m_campData;
};
#endif // ADDRESSITEM_H

@ -0,0 +1,18 @@
#ifndef CAMP_DATA_H
#define CAMP_DATA_H
#include <QSharedPointer>
class CampData;
class AddressItem;
class ServiceItem;
typedef QSharedPointer<CampData> CampDataPtr;
typedef QSharedPointer<ServiceItem> ServiceItemPtr;
typedef QSharedPointer<AddressItem> AddressItemPtr;
#include "campdata.h"
#include "addressitem.h"
#include "serviceitem.h"
#endif // CAMP_DATA_H

@ -0,0 +1,117 @@
#include "campdata.h"
#include <define.h>
CampData::CampData(QObject *parent) : QObject(parent)
{
}
int CampData::id() const
{
return m_id;
}
void CampData::setId(int id)
{
m_id = id;
}
QDate CampData::start() const
{
return m_start;
}
void CampData::setStart(const QDate &start)
{
m_start = start;
}
QDate CampData::end() const
{
return m_end;
}
void CampData::setEnd(const QDate &end)
{
m_end = end;
}
QString CampData::ownerFirstame() const
{
return m_ownerFirstame;
}
void CampData::setOwnerFirstame(const QString &ownerFirstame)
{
m_ownerFirstame = ownerFirstame;
}
QString CampData::ownerLastname() const
{
return m_ownerLastname;
}
void CampData::setOwnerLastname(const QString &ownerLastname)
{
m_ownerLastname = ownerLastname;
}
QString CampData::ownerAddress() const
{
return m_ownerAddress;
}
void CampData::setOwnerAddress(const QString &ownerAddress)
{
m_ownerAddress = ownerAddress;
}
QOdbList<ServiceItemPtr> CampData::services() const
{
return m_services;
}
void CampData::setServices(const QOdbList<QSharedPointer<ServiceItem> > &services)
{
m_services = services;
}
void CampData::addServiceItem(ServiceItemPtr serviceItem)
{
m_services.append(serviceItem);
}
QOdbList<AddressItemPtr> CampData::people() const
{
return m_people;
}
void CampData::setPeople(const QOdbList<AddressItemPtr> &people)
{
m_people = people;
}
void CampData::addPerson(AddressItemPtr person)
{
m_people.append(person);
}
QDecDouble CampData::totalPrice() const
{
return TO_DEC(m_totalPrice);
}
void CampData::setTotalPrice(QDecDouble totalPrice)
{
m_totalPrice = FROM_DEC(totalPrice);
}
SeasonPtr CampData::season() const
{
return m_season;
}
void CampData::setSeason(const SeasonPtr &season)
{
m_season = season;
}

@ -0,0 +1,76 @@
#ifndef CAMPDATA_H
#define CAMPDATA_H
#include "camp-data.h"
#include <QObject>
#include <QDate>
#include <QDecDouble.hh>
#include <odb/core.hxx>
#include <odb/qt/list.hxx>
#include <data/season.h>
#pragma db object
class CampData : public QObject
{
Q_OBJECT
Q_PROPERTY(QDate start READ start WRITE setStart)
Q_PROPERTY(QDate end READ end WRITE setEnd)
Q_PROPERTY(QString ownerFirstame READ ownerFirstame WRITE setOwnerFirstame)
Q_PROPERTY(QString ownerLastname READ ownerLastname WRITE setOwnerLastname)
Q_PROPERTY(QString ownerAddress READ ownerAddress WRITE setOwnerAddress)
Q_PROPERTY(QDecDouble totalPrice READ totalPrice WRITE setTotalPrice)
public:
explicit CampData(QObject *parent = 0);
int id() const;
void setId(int id);
QDate start() const;
void setStart(const QDate &start);
QDate end() const;
void setEnd(const QDate &end);
QString ownerFirstame() const;
void setOwnerFirstame(const QString &ownerFirstame);
QString ownerLastname() const;
void setOwnerLastname(const QString &ownerLastname);
QString ownerAddress() const;
void setOwnerAddress(const QString &ownerAddress);
QOdbList<QSharedPointer<ServiceItem> > services() const;
void setServices(const QOdbList<QSharedPointer<ServiceItem> > &services);
void addServiceItem(ServiceItemPtr serviceItem);
QOdbList<AddressItemPtr> people() const;
void setPeople(const QOdbList<AddressItemPtr> &people);
void addPerson(AddressItemPtr person);
QDecDouble totalPrice() const;
void setTotalPrice(QDecDouble totalPrice);
SeasonPtr season() const;
void setSeason(const SeasonPtr &season);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QDate m_start;
QDate m_end;
QString m_ownerFirstame;
QString m_ownerLastname;
QString m_ownerAddress;
#pragma db value_not_null inverse(m_campData)
QOdbList<ServiceItemPtr> m_services;
#pragma db value_not_null inverse(m_campData)
QOdbList<AddressItemPtr> m_people;
int m_totalPrice;
SeasonPtr m_season;
};
#endif // CAMPDATA_H

@ -0,0 +1,77 @@
#include "serviceitem.h"
#include <define.h>
ServiceItem::ServiceItem(QObject *parent) : QObject(parent)
{
}
int ServiceItem::id() const
{
return m_id;
}
void ServiceItem::setId(int id)
{
m_id = id;
}
QString ServiceItem::name() const
{
return m_name;
}
void ServiceItem::setName(const QString &name)
{
m_name = name;
}
QString ServiceItem::code() const
{
return m_code;
}
void ServiceItem::setCode(const QString &code)
{
m_code = code;
}
QDecDouble ServiceItem::price() const
{
return TO_DEC(m_price);
}
void ServiceItem::setPrice(QDecDouble price)
{
m_price = FROM_DEC(price);
}
bool ServiceItem::salePossible() const
{
return m_salePossible;
}
void ServiceItem::setSalePossible(bool salePossible)
{
m_salePossible = salePossible;
}
AccService::ServiceType ServiceItem::type() const
{
return m_type;
}
void ServiceItem::setType(const AccService::ServiceType &type)
{
m_type = type;
}
QWeakPointer<CampData> ServiceItem::campData() const
{
return m_campData;
}
void ServiceItem::setCampData(const QWeakPointer<CampData> &campData)
{
m_campData = campData;
}

@ -0,0 +1,63 @@
#ifndef SREVICEITEM_H
#define SREVICEITEM_H
#include "camp-data.h"
#include <QObject>
#include <QSharedPointer>
#include <QWeakPointer>
#include <QDecDouble.hh>
#include <odb/core.hxx>
#include <accservice.h>
class CampData;
#pragma db object
class ServiceItem : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString code READ code WRITE setCode)
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
Q_PROPERTY(bool salePossible READ salePossible WRITE setSalePossible)
Q_PROPERTY(AccService::ServiceType type READ type WRITE setType)
Q_ENUMS(AccService::ServiceType)
public:
explicit ServiceItem(QObject *parent = 0);
int id() const;
void setId(int id);
QString name() const;
void setName(const QString &name);
QString code() const;
void setCode(const QString &code);
QDecDouble price() const;
void setPrice(QDecDouble price);
bool salePossible() const;
void setSalePossible(bool salePossible);
AccService::ServiceType type() const;
void setType(const AccService::ServiceType &type);
QWeakPointer<CampData> campData() const;
void setCampData(const QWeakPointer<CampData> &campData);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_name;
QString m_code;
int m_price;
bool m_salePossible;
AccService::ServiceType m_type;
#pragma db not_null
QWeakPointer<CampData> m_campData;
};
#endif // SREVICEITEM_H

@ -0,0 +1,7 @@
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 5000 5000" xmlns="http://www.w3.org/2000/svg"><defs><style type="text/css"><![CDATA[
.str1 {stroke:#434242;stroke-width:100}
.str0 {stroke:#434242;stroke-width:300;stroke-linecap:round}
.fil0 {fill:none}
.fil1 {fill:#434242}
.fil2 {fill:url(#id0)}
]]></style><linearGradient gradientUnits="userSpaceOnUse" id="id0" x1="2500.01" x2="2500.01" y1="4260.19" y2="1474.81"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient></defs><g id="Layer_x0020_1"><path class="fil0 str0" d="M300 2000l2050-1600c100-50 200-50 300 0l2050 1500"/><path class="fil1" d="M3500 1022l600 439v-861c0-55-45-100-100-100h-400c-55 0-100 45-100 100v422z"/><path class="fil2 str1" d="M899 4700h901v-1500c0-110 90-200 200-200h900c110 0 200 90 200 200v1500h1001c165 0 300-135 300-300l-1-2000-1776-1328c-33-26-79-37-124-36s-92 14-127 40l-1773 1324-1 2000c0 165 135 300 300 300z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -62,7 +62,8 @@ SOURCES += \
settings/seasonnamedialog.cpp \ settings/seasonnamedialog.cpp \
reporting/report.cpp \ reporting/report.cpp \
reporting/reportviewer.cpp \ reporting/reportviewer.cpp \
reporting/reportdialog.cpp reporting/reportdialog.cpp \
csvimporter.cpp
HEADERS += core.h\ HEADERS += core.h\
core_global.h \ core_global.h \
@ -122,7 +123,9 @@ HEADERS += core.h\
settings/seasonnamedialog.h \ settings/seasonnamedialog.h \
reporting/report.h \ reporting/report.h \
reporting/reportviewer.h \ reporting/reportviewer.h \
reporting/reportdialog.h reporting/reportdialog.h \
iimporter.h \
csvimporter.h
unix { unix {
target.path = /usr/lib target.path = /usr/lib

@ -0,0 +1,93 @@
#include "csvimporter.h"
#include <QFile>
#include <QVariant>
CsvImporter::CsvImporter(const QMetaObject *metaObject, QObject *parent)
:QObject(parent),
IImporter(metaObject)
{
m_parsed = false;
m_currentRec = 1;
m_error = false;
}
void CsvImporter::setImportFile(const QString &fileName)
{
m_fileName = fileName;
}
int CsvImporter::recordCount()
{
if (!m_parsed)
{
parseFile();
}
return m_lines.count() - 1;
}
QSharedPointer<QObject> CsvImporter::nextRecord()
{
if (!m_parsed)
{
parseFile();
}
QObject *entity = m_metaObject->newInstance();
if (entity == NULL || m_currentRec > recordCount())
{
++m_currentRec;
return QSharedPointer<QObject>();
}
QStringList props = m_header.split(m_separator);
QString line = m_lines[m_currentRec];
QStringList values = line.split(m_separator);
for (int i = 0; i < props.size(); i++) {
QString property = props[i];
QString value = values[i];
if (!entity->setProperty(property.toStdString().c_str(), QVariant(value)))
{
m_error = true;
emit noSuchProperty(property);
++m_currentRec;
return QSharedPointer<QObject>();
}
}
++m_currentRec;
return QSharedPointer<QObject>(entity);
}
bool CsvImporter::isError()
{
return m_error;
}
void CsvImporter::parseFile()
{
QFile file(m_fileName);
if (!file.open(QFile::ReadOnly | QFile::Text))
{
m_error = true;
emit parseError();
return;
}
QByteArray data = file.readAll();
QString strData(data);
m_lines = strData.split("\n");
m_header = m_lines[0];
m_parsed = true;
}
void CsvImporter::setSeparator(const QString &separator)
{
m_separator = separator;
}

@ -0,0 +1,40 @@
#ifndef CSVIMPORTER_H
#define CSVIMPORTER_H
#include "iimporter.h"
#include <QStringList>
#include <QObject>
class CsvImporter : public QObject, public IImporter
{
Q_OBJECT
public:
explicit CsvImporter(const QMetaObject *metaObject, QObject *parent = NULL);
// IImporter interface
public:
void setImportFile(const QString &fileName);
int recordCount();
QSharedPointer<QObject> nextRecord();
bool isError();
void setSeparator(const QString &separator);
signals:
void parseError();
void noSuchProperty(QString propName);
private:
void parseFile();
QString m_header;
QString m_separator;
QString m_fileName;
QStringList m_lines;
bool m_parsed;
bool m_error;
int m_currentRec;
};
#endif // CSVIMPORTER_H

@ -54,6 +54,11 @@ QTableView *IGridForm::tableView()
return ui->tableView; return ui->tableView;
} }
QWidget *IGridForm::toolbar()
{
return ui->widget;
}
void IGridForm::hideColumns(const QList<int> &cols) void IGridForm::hideColumns(const QList<int> &cols)
{ {
foreach (int col, cols) { foreach (int col, cols) {

@ -6,6 +6,7 @@
#include <QTableView> #include <QTableView>
#include <QMenu> #include <QMenu>
#include <QList> #include <QList>
#include <QWidget>
#include "columndialog.h" #include "columndialog.h"
#include "filterui.h" #include "filterui.h"
@ -27,6 +28,7 @@ public:
void setPluginId(const QString &pluginId); void setPluginId(const QString &pluginId);
QString pluginId(); QString pluginId();
QTableView *tableView(); QTableView *tableView();
QWidget *toolbar();
virtual void setTranslations(const QMap<QString, QString> &translations) = 0; virtual void setTranslations(const QMap<QString, QString> &translations) = 0;
signals: signals:

@ -0,0 +1,22 @@
#ifndef IIMPORTER_H
#define IIMPORTER_H
#include <QMetaObject>
#include <QObject>
#include <QSharedPointer>
class IImporter
{
public:
explicit IImporter(const QMetaObject *metaObject) { m_metaObject = metaObject; }
virtual void setImportFile(const QString &fileName) = 0;
virtual int recordCount() = 0;
virtual QSharedPointer<QObject> nextRecord() = 0;
virtual bool isError() = 0;
protected:
const QMetaObject *m_metaObject;
};
#endif // IIMPORTER_H

@ -75,6 +75,7 @@ public:
return (Service<T>*)m_service; return (Service<T>*)m_service;
} }
virtual bool showIcon() { return true; }
virtual QTranslator* translator() { return NULL; } virtual QTranslator* translator() { return NULL; }
virtual QIcon pluginIcon() { return QIcon(); } virtual QIcon pluginIcon() { return QIcon(); }
QMap<QString, QString> translations() { return m_translations; } QMap<QString, QString> translations() { return m_translations; }

@ -14,6 +14,7 @@
#include "context.h" #include "context.h"
#include "iservice.h" #include "iservice.h"
#include "permissionevaluator.h" #include "permissionevaluator.h"
#include "iimporter.h"
#include "transaction.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: protected:
bool checkPermission(const QString &permission) { bool checkPermission(const QString &permission) {
if (!m_pluginId.isEmpty()) { if (!m_pluginId.isEmpty()) {

@ -5,9 +5,9 @@ SUBDIRS += \
qdecimal \ qdecimal \
core \ core \
application \ application \
accommodation \
services \ services \
addressbook \ addressbook \
shop \ shop \
commodity commodity \
camp

Loading…
Cancel
Save