new enums class in core

binding for combos
print
Zdenek Jonak 9 years ago
parent 580b623aca
commit 5846f8757e

@ -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));

@ -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

@ -0,0 +1,20 @@
#ifndef ENUMS_H
#define ENUMS_H
#include <QObject>
class Enums : public QObject
{
Q_OBJECT
Q_ENUMS(VatType)
public:
enum VatType { HIGH,FIRST_LOWER,SECOND_LOWER };
Enums()
{
}
};
#endif // ENUMS_H

@ -1,5 +1,8 @@
#include "accserviceform.h"
#include "ui_accserviceform.h"
#include <combodata.h>
#include <qlist.h>
AccServiceForm::AccServiceForm(QWidget *parent) :
AutoForm<AccService>(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<ComboData> cd ;
cd << ComboData(AccService::CAR,tr("Car")) << ComboData(AccService::TENT,tr("Tent")) << ComboData(AccService::OTHER,tr("OTHER"));
registerBinding(ui->serviceType,cd);
QList<ComboData> 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()<<tr("Car")<<tr("Tent")<<tr("Other"));
ui->serviceType->setCurrentIndex(this->entity()->serviceType());
}
bool AccServiceForm::bindOtherToData()
{
this->entity()->setServiceType((AccService::ServiceType)ui->serviceType->currentIndex());
return true;
}

@ -21,9 +21,6 @@ public:
private:
Ui::AccServiceForm *ui;
// AutoForm interface
protected:
void bindOtherToUi();
bool bindOtherToData();
};
#endif // ACCSERVICEFORM_H

@ -24,42 +24,71 @@
<item row="0" column="1">
<widget class="QLineEdit" name="accServiceName"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Price</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QLineEdit" name="price"/>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Service Type</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QComboBox" name="serviceType"/>
</item>
<item row="3" column="1">
<item row="5" column="1">
<widget class="QCheckBox" name="salePossible">
<property name="text">
<string>Sale Possible</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1">
<widget class="QCheckBox" name="active">
<property name="text">
<string>Active</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="accServiceCode"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>ServiceCode</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="vatType"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Vat Type</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>accServiceName</tabstop>
<tabstop>accServiceCode</tabstop>
<tabstop>price</tabstop>
<tabstop>serviceType</tabstop>
<tabstop>vatType</tabstop>
<tabstop>salePossible</tabstop>
<tabstop>active</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

@ -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;
}

@ -6,17 +6,21 @@
#include <odb/core.hxx>
#include <enums.h>
#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

@ -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" : []

Loading…
Cancel
Save