From 5846f8757e785ecc0af4292bffd2193aba0f23b4 Mon Sep 17 00:00:00 2001 From: Zdenek Jonak Date: Thu, 18 Feb 2016 21:51:18 +0100 Subject: [PATCH] new enums class in core binding for combos --- core/context.cpp | 2 +- core/core.pro | 3 ++- core/enums.h | 20 ++++++++++++++++++ services/accserviceform.cpp | 21 +++++++++--------- services/accserviceform.h | 3 --- services/accserviceform.ui | 41 ++++++++++++++++++++++++++++++------ services/data/accservice.cpp | 20 ++++++++++++++++++ services/data/accservice.h | 13 ++++++++++++ services/service.json | 4 +++- 9 files changed, 104 insertions(+), 23 deletions(-) create mode 100644 core/enums.h diff --git a/core/context.cpp b/core/context.cpp index e052ee8..2052f57 100644 --- a/core/context.cpp +++ b/core/context.cpp @@ -49,7 +49,7 @@ void Context::loadPlugins() m_plugins.append(new Users); m_plugins.append(new Roles); - QDir pluginsDir(qApp->applicationDirPath() + "/../../plugins"); + QDir pluginsDir(qApp->applicationDirPath() + "/../plugins"); foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) { QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); diff --git a/core/core.pro b/core/core.pro index ea2edf0..8fce268 100644 --- a/core/core.pro +++ b/core/core.pro @@ -88,7 +88,8 @@ HEADERS += core.h\ data/core_global.h \ iservice.h \ combodata.h \ - data/comboitem.h + data/comboitem.h \ + enums.h unix { target.path = /usr/lib diff --git a/core/enums.h b/core/enums.h new file mode 100644 index 0000000..1c7858a --- /dev/null +++ b/core/enums.h @@ -0,0 +1,20 @@ +#ifndef ENUMS_H +#define ENUMS_H +#include + + +class Enums : public QObject +{ + Q_OBJECT + Q_ENUMS(VatType) + public: + + enum VatType { HIGH,FIRST_LOWER,SECOND_LOWER }; + + Enums() + { + + } + +}; +#endif // ENUMS_H diff --git a/services/accserviceform.cpp b/services/accserviceform.cpp index 5db7953..65f8bc3 100644 --- a/services/accserviceform.cpp +++ b/services/accserviceform.cpp @@ -1,5 +1,8 @@ #include "accserviceform.h" #include "ui_accserviceform.h" +#include +#include + AccServiceForm::AccServiceForm(QWidget *parent) : AutoForm(parent), @@ -7,9 +10,16 @@ AccServiceForm::AccServiceForm(QWidget *parent) : { ui->setupUi(this); registerBinding(ui->accServiceName); + registerBinding(ui->accServiceCode); registerBinding(ui->price); registerBinding(ui->salePossible); registerBinding(ui->active); + QList cd ; + cd << ComboData(AccService::CAR,tr("Car")) << ComboData(AccService::TENT,tr("Tent")) << ComboData(AccService::OTHER,tr("OTHER")); + registerBinding(ui->serviceType,cd); + QList vt ; + vt << ComboData(Enums::HIGH,tr("High")) << ComboData(Enums::FIRST_LOWER,tr("First Lower")) << ComboData(Enums::SECOND_LOWER,tr("Second Lower")); + registerBinding(ui->vatType,vt); } @@ -18,15 +28,4 @@ AccServiceForm::~AccServiceForm() delete ui; } -void AccServiceForm::bindOtherToUi() -{ - ui->serviceType->clear(); - ui->serviceType->addItems(QStringList()<serviceType->setCurrentIndex(this->entity()->serviceType()); -} -bool AccServiceForm::bindOtherToData() -{ - this->entity()->setServiceType((AccService::ServiceType)ui->serviceType->currentIndex()); - return true; -} diff --git a/services/accserviceform.h b/services/accserviceform.h index 32f0ed7..432cb22 100644 --- a/services/accserviceform.h +++ b/services/accserviceform.h @@ -21,9 +21,6 @@ public: private: Ui::AccServiceForm *ui; // AutoForm interface -protected: - void bindOtherToUi(); - bool bindOtherToData(); }; #endif // ACCSERVICEFORM_H diff --git a/services/accserviceform.ui b/services/accserviceform.ui index 1823f08..75db442 100644 --- a/services/accserviceform.ui +++ b/services/accserviceform.ui @@ -24,42 +24,71 @@ - + Price - + - + Service Type - + - + Sale Possible - + Active + + + + + + + ServiceCode + + + + + + + + + + Vat Type + + + + + accServiceName + accServiceCode + price + serviceType + vatType + salePossible + active + diff --git a/services/data/accservice.cpp b/services/data/accservice.cpp index e283609..3b8fd50 100644 --- a/services/data/accservice.cpp +++ b/services/data/accservice.cpp @@ -60,6 +60,26 @@ void AccService::setAccServiceName(const QString &accServiceName) { m_accServiceName = accServiceName; } +QString AccService::accServiceCode() const +{ + return m_accServiceCode; +} + +void AccService::setAccServiceCode(const QString &accServiceCode) +{ + m_accServiceCode = accServiceCode; +} +Enums::VatType AccService::vatType() const +{ + return m_vatType; +} + +void AccService::setVatType(const Enums::VatType &VatType) +{ + m_vatType = VatType; +} + + diff --git a/services/data/accservice.h b/services/data/accservice.h index f3d1f85..9043016 100644 --- a/services/data/accservice.h +++ b/services/data/accservice.h @@ -6,17 +6,21 @@ #include +#include + #pragma db object class AccService : public QObject { Q_OBJECT Q_PROPERTY(QString accServiceName READ accServiceName WRITE setAccServiceName) + Q_PROPERTY(QString accServiceCode READ accServiceCode WRITE setAccServiceCode) Q_PROPERTY(int price READ price WRITE setPrice) Q_PROPERTY(bool active READ active WRITE setActive) Q_PROPERTY(bool salePossible READ salePossible WRITE setSalePossible) Q_PROPERTY(ServiceType serviceType READ serviceType WRITE setServiceType) Q_ENUMS(ServiceType) + Q_PROPERTY(Enums::VatType vatType READ vatType WRITE setVatType) public: AccService(); @@ -43,6 +47,13 @@ public: QString accServiceName() const; void setAccServiceName(const QString &accServiceName); + + QString accServiceCode() const; + void setAccServiceCode(const QString &accServiceCode); + + Enums::VatType vatType() const; + void setVatType(const Enums::VatType &vatType); + private: friend class odb::access; #pragma db id auto @@ -52,6 +63,8 @@ private: bool m_active; bool m_salePossible; ServiceType m_serviceType; + QString m_accServiceCode; + Enums::VatType m_vatType; }; #endif // ACCSERVICE_H diff --git a/services/service.json b/services/service.json index dc54ddc..c35c844 100644 --- a/services/service.json +++ b/services/service.json @@ -13,10 +13,12 @@ "CREATE TABLE \"AccService\" ( \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \"accServiceName\" TEXT NULL, + \"accServiceCode\" TEXT NULL, \"price\" INTEGER NOT NULL, \"active\" INTEGER NOT NULL, \"salePossible\" INTEGER NOT NULL, - \"serviceType\" INTEGER NOT NULL);" + \"serviceType\" INTEGER NOT NULL + \"vatType\" INTEGER NOT NULL);" ], "dependencies" : []