Added support for binding QDecimal values.
This commit is contained in:
@@ -60,3 +60,10 @@ ODB_FILES = accommodation/data/accommodation-data.h
|
||||
H_DIR = $$PWD/data/*.h
|
||||
include(../odb.pri)
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
|
||||
INCLUDEPATH += $$PWD/../qdecimal/src
|
||||
INCLUDEPATH += $$PWD/../qdecimal/decnumber
|
||||
|
||||
|
||||
@@ -47,5 +47,12 @@ else:unix: LIBS += -L$$OUT_PWD/../core/ -lcore
|
||||
INCLUDEPATH += $$PWD/../core
|
||||
DEPENDPATH += $$PWD/../core
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
|
||||
INCLUDEPATH += $$PWD/../qdecimal/src
|
||||
INCLUDEPATH += $$PWD/../qdecimal/decnumber
|
||||
|
||||
RESOURCES += \
|
||||
appRc.qrc
|
||||
|
||||
+20
-2
@@ -10,6 +10,9 @@
|
||||
#include <QVariant>
|
||||
#include <QMessageBox>
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
|
||||
#include "../qdecimal/src/QDecDouble.hh"
|
||||
|
||||
#include "iform.h"
|
||||
#include "service.h"
|
||||
@@ -77,7 +80,15 @@ private:
|
||||
registerCombos();
|
||||
foreach (QWidget *widget, m_bindWidgets) {
|
||||
const char* prop = widget->metaObject()->userProperty().name();
|
||||
widget->setProperty(prop, ((QObject*)m_entity.data())->property(widget->objectName().toStdString().c_str()));
|
||||
QVariant value = ((QObject*)m_entity.data())->property(widget->objectName().toStdString().c_str());
|
||||
if (value.canConvert<QDecDouble>())
|
||||
{
|
||||
widget->setProperty(prop, value.value<QDecDouble>().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
widget->setProperty(prop, value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (QComboBox *combo, m_bindCombos.keys()) {
|
||||
@@ -117,7 +128,14 @@ private:
|
||||
|
||||
foreach (QWidget *widget, m_bindWidgets) {
|
||||
const char* prop = widget->metaObject()->userProperty().name();
|
||||
((QObject*)m_entity.data())->setProperty(widget->objectName().toStdString().c_str(), widget->property(prop));
|
||||
|
||||
QVariant val = widget->property(prop);
|
||||
if (((QObject*)m_entity.data())->property(widget->objectName().toStdString().c_str()).canConvert<QDecDouble>())
|
||||
{
|
||||
QDecDouble dec(val.toDouble());
|
||||
val = QVariant::fromValue(dec);
|
||||
}
|
||||
((QObject*)m_entity.data())->setProperty(widget->objectName().toStdString().c_str(), val);
|
||||
}
|
||||
|
||||
foreach (QComboBox *combo, m_bindCombos.keys()) {
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QMetaProperty>
|
||||
#include <QModelIndex>
|
||||
#include <QDebug>
|
||||
|
||||
#include "../qdecimal/src/QDecDouble.hh"
|
||||
|
||||
#include "define.h"
|
||||
#include "core_global.h"
|
||||
@@ -58,6 +61,11 @@ public:
|
||||
return qobject_cast<ComboItem*>(dispData.value<QObject*>())->toString();
|
||||
}
|
||||
|
||||
if (dispData.canConvert<QDecDouble>())
|
||||
{
|
||||
return dispData.value<QDecDouble>().toDouble();
|
||||
}
|
||||
|
||||
return dispData;
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -127,4 +127,9 @@ OTHER_FILES += \
|
||||
users/metaData.json \
|
||||
roles/metaData.json
|
||||
|
||||
TRANSLATIONS = core_cz.ts
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
|
||||
INCLUDEPATH += $$PWD/../qdecimal/src
|
||||
INCLUDEPATH += $$PWD/../qdecimal/decnumber
|
||||
|
||||
@@ -9,5 +9,7 @@
|
||||
#define PERM_EDIT "EDIT"
|
||||
#define PERM_DELETE "DELETE"
|
||||
|
||||
#define DEC_MULTIPLE 100
|
||||
|
||||
#endif // DEFINE_H
|
||||
|
||||
|
||||
+4
-3
@@ -2,18 +2,19 @@
|
||||
#define ENUMS_H
|
||||
#include <QObject>
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
class Enums : public QObject
|
||||
class CORESHARED_EXPORT Enums : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS(VatType)
|
||||
public:
|
||||
public:
|
||||
|
||||
enum VatType { HIGH,FIRST_LOWER,SECOND_LOWER };
|
||||
|
||||
Enums()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -43,6 +43,8 @@ DEFINES += DATABASE_SQLITE
|
||||
ODB_FLAGS += -I $$[QT_INSTALL_HEADERS]
|
||||
ODB_FLAGS += -I $$[QT_INSTALL_HEADERS]/QtCore
|
||||
ODB_FLAGS += -I $$PWD/core
|
||||
ODB_FLAGS += -I $$PWD/qdecimal/src
|
||||
ODB_FLAGS += -I $$PWD/qdecimal/decnumber
|
||||
ODB_FLAGS += -D __PIC__
|
||||
|
||||
win32 {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "accservice.h"
|
||||
#include <define.h>
|
||||
|
||||
AccService::AccService()
|
||||
{
|
||||
@@ -14,14 +15,14 @@ void AccService::setId(int id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
int AccService::price() const
|
||||
QDecDouble AccService::price() const
|
||||
{
|
||||
return m_price;
|
||||
return QDecDouble((double)m_price / DEC_MULTIPLE);
|
||||
}
|
||||
|
||||
void AccService::setPrice(int price)
|
||||
void AccService::setPrice(QDecDouble price)
|
||||
{
|
||||
m_price = price;
|
||||
m_price = price.toDouble() * DEC_MULTIPLE;
|
||||
}
|
||||
bool AccService::active() const
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDecDouble.hh>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
|
||||
@@ -15,7 +16,7 @@ class AccService : public QObject
|
||||
|
||||
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(QDecDouble 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)
|
||||
@@ -32,8 +33,8 @@ public:
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
|
||||
int price() const;
|
||||
void setPrice(int price);
|
||||
QDecDouble price() const;
|
||||
void setPrice(QDecDouble price);
|
||||
|
||||
bool active() const;
|
||||
void setActive(bool active);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
\"price\" INTEGER NOT NULL,
|
||||
\"active\" INTEGER NOT NULL,
|
||||
\"salePossible\" INTEGER NOT NULL,
|
||||
\"serviceType\" INTEGER NOT NULL
|
||||
\"serviceType\" INTEGER NOT NULL,
|
||||
\"vatType\" INTEGER NOT NULL);"
|
||||
|
||||
],
|
||||
|
||||
@@ -57,11 +57,12 @@ include(../odb.pri)
|
||||
FORMS += \
|
||||
accserviceform.ui
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/release/ -lqdecimal
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/debug/ -lqdecimal
|
||||
else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
|
||||
INCLUDEPATH += $$PWD/../qdecimal/src
|
||||
INCLUDEPATH += $$PWD/../qdecimal/decnumber
|
||||
DEPENDPATH += $$PWD/../qdecimal/src
|
||||
|
||||
#win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../qdecimal/src/release/libqdecimal.a
|
||||
|
||||
Reference in New Issue
Block a user