service plugin and qdecimal library has been added

This commit is contained in:
Zdenek Jonak
2016-02-09 21:55:05 +01:00
parent 3d68281c87
commit 4d74bed177
251 changed files with 127772 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
#include "accserviceform.h"
#include "ui_accserviceform.h"
AccServiceForm::AccServiceForm(QWidget *parent) :
AutoForm<AccService>(parent),
ui(new Ui::AccServiceForm)
{
ui->setupUi(this);
registerBinding(ui->accServiceName);
registerBinding(ui->price);
registerBinding(ui->salePossible);
registerBinding(ui->active);
}
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;
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef ACCSERVICEFORM_H
#define ACCSERVICEFORM_H
#include <QWidget>
#include "autoform.h"
#include "data/accservice.h"
#include "services-odb.hxx"
namespace Ui {
class AccServiceForm;
}
class AccServiceForm : public AutoForm<AccService>
{
Q_OBJECT
public:
explicit AccServiceForm(QWidget *parent = 0);
~AccServiceForm();
private:
Ui::AccServiceForm *ui;
// AutoForm interface
protected:
void bindOtherToUi();
bool bindOtherToData();
};
#endif // ACCSERVICEFORM_H
+65
View File
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AccServiceForm</class>
<widget class="QWidget" name="AccServiceForm">
<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>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Service Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="accServiceName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Price</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="price"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Service Type</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="serviceType"/>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="salePossible">
<property name="text">
<string>Sale Possible</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="active">
<property name="text">
<string>Active</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+10
View File
@@ -0,0 +1,10 @@
#include "accservicegrid.h"
#include "accservicestablemodel.h"
AccServiceGrid::AccServiceGrid(QWidget *parent) :
GridForm<AccService>(parent)
{
setTableModel(new AccServiceTableModel());
}
+16
View File
@@ -0,0 +1,16 @@
#ifndef ACCSERVICEGRID_H
#define ACCSERVICEGRID_H
#include <core.h>
#include "data/accservice.h"
#include "services-odb.hxx"
class AccServiceGrid : public GridForm<AccService>
{
Q_OBJECT
public:
AccServiceGrid(QWidget *parent = NULL);
};
#endif // ACCSERVICEGRID_H
+6
View File
@@ -0,0 +1,6 @@
#include "accservicestablemodel.h"
AccServiceTableModel::AccServiceTableModel(QObject *parent)
:AutoTableModel<AccService>(parent)
{
}
+16
View File
@@ -0,0 +1,16 @@
#ifndef ACCSERVICESTABLEMODEL_H
#define ACCSERVICESTABLEMODEL_H
#include <autotablemodel.h>
#include "data/accservice.h"
class AccServiceTableModel : public AutoTableModel<AccService>
{
Q_OBJECT
public:
explicit AccServiceTableModel(QObject *parent = NULL);
};
#endif // ACCSERVICESTABLEMODEL_H
+65
View File
@@ -0,0 +1,65 @@
#include "accservice.h"
AccService::AccService()
{
m_price = 0;
m_active = 1;
}
int AccService::id() const
{
return m_id;
}
void AccService::setId(int id)
{
m_id = id;
}
int AccService::price() const
{
return m_price;
}
void AccService::setPrice(int price)
{
m_price = price;
}
bool AccService::active() const
{
return m_active;
}
void AccService::setActive(bool active)
{
m_active = active;
}
bool AccService::salePossible() const
{
return m_salePossible;
}
void AccService::setSalePossible(bool salePossible)
{
m_salePossible = salePossible;
}
AccService::ServiceType AccService::serviceType() const
{
return m_serviceType;
}
void AccService::setServiceType(const AccService::ServiceType &serviceType)
{
m_serviceType = serviceType;
}
QString AccService::accServiceName() const
{
return m_accServiceName;
}
void AccService::setAccServiceName(const QString &accServiceName)
{
m_accServiceName = accServiceName;
}
+57
View File
@@ -0,0 +1,57 @@
#ifndef ACCSERVICE_H
#define ACCSERVICE_H
#include <QObject>
#include <QString>
#include <odb/core.hxx>
#pragma db object
class AccService : public QObject
{
Q_OBJECT
Q_PROPERTY(QString accServiceName READ accServiceName WRITE setAccServiceName)
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)
public:
AccService();
enum ServiceType { CAR,TENT,OTHER };
int id() const;
void setId(int id);
int price() const;
void setPrice(int price);
bool active() const;
void setActive(bool active);
bool salePossible() const;
void setSalePossible(bool salePossible);
ServiceType serviceType() const;
void setServiceType(const ServiceType &serviceType);
QString accServiceName() const;
void setAccServiceName(const QString &accServiceName);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_accServiceName;
int m_price;
bool m_active;
bool m_salePossible;
ServiceType m_serviceType;
};
#endif // ACCSERVICE_H
+23
View File
@@ -0,0 +1,23 @@
{
"id" : "SERVICE",
"name" : {
"default" : "Service",
"CZ" : "Služby"
},
"descriptoin" : {
"default" : "",
"CZ" : ""
},
"schemaVersion" : 1,
"sql" : [
"CREATE TABLE \"AccService\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
\"accServiceName\" TEXT NULL,
\"price\" INTEGER NOT NULL,
\"active\" INTEGER NOT NULL,
\"salePossible\" INTEGER NOT NULL,
\"serviceType\" INTEGER NOT NULL);"
],
"dependencies" : []
}
+21
View File
@@ -0,0 +1,21 @@
#include <context.h>
#include "services.h"
#include "data/accservice.h"
#include "accserviceform.h"
#include "accservicegrid.h"
Services::Services()
{
}
void Services::initServiceUi()
{
AccServiceGrid *grid = new AccServiceGrid();
AccServiceForm *form = new AccServiceForm();
m_service = new Service<AccService>;
m_ui = grid;
((AccServiceGrid *) m_ui)->setForm(form);
}
+24
View File
@@ -0,0 +1,24 @@
#ifndef SERVICES_H
#define SERVICES_H
#include "services_global.h"
#include <core.h>
#include <QObject>
#include <QtPlugin>
class SERVICESSHARED_EXPORT Services : public QObject, IMetaDataPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID PluginInterface_iid FILE "service.json")
Q_INTERFACES(IPlugin)
public:
Services();
protected:
void initServiceUi() Q_DECL_OVERRIDE;
};
#endif // SERVICES_H
+71
View File
@@ -0,0 +1,71 @@
#-------------------------------------------------
#
# Project created by QtCreator 2016-02-04T20:14:07
#
#-------------------------------------------------
QT += widgets sql
TARGET = services
TEMPLATE = lib
DEFINES += SERVICES_LIBRARY\
_GLIBCXX_USE_CXX11_ABI=0
SOURCES += services.cpp \
data/accservice.cpp \
accserviceform.cpp \
accservicestablemodel.cpp \
accservicegrid.cpp
HEADERS += services.h\
services_global.h \
data/accservice.h \
accserviceform.h \
accservicestablemodel.h \
accservicegrid.h
unix {
target.path = /usr/lib
INSTALLS += target
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -Wno-unknown-pragmas
}
win32 {
QMAKE_CXXFLAGS += -wd4995 -wd4068
}
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../core/release/ -lcore
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../core/debug/ -lcore
else:unix: LIBS += -L$$OUT_PWD/../core/ -lcore
INCLUDEPATH += $$PWD/../core
DEPENDPATH += $$PWD/../core
DESTDIR = ../plugins
OTHER_FILES += service.json
ODB_FILES = services/data/accservice.h
H_DIR = $$PWD/data/*.h
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
INCLUDEPATH += $$PWD/../qdecimal/src
DEPENDPATH += $$PWD/../qdecimal/src
#win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../qdecimal/src/release/libqdecimal.a
#else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../qdecimal/src/debug/libqdecimal.a
#else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../qdecimal/src/release/qdecimal.lib
#else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../qdecimal/src/debug/qdecimal.lib
#else:unix: PRE_TARGETDEPS += $$OUT_PWD/../qdecimal/src/libqdecimal.a
+12
View File
@@ -0,0 +1,12 @@
#ifndef SERVICES_GLOBAL_H
#define SERVICES_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(SERVICES_LIBRARY)
# define SERVICESSHARED_EXPORT Q_DECL_EXPORT
#else
# define SERVICESSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // SERVICES_GLOBAL_H