diff --git a/addressbook/addressbook.cpp b/addressbook/addressbook.cpp new file mode 100644 index 0000000..6d7ebe2 --- /dev/null +++ b/addressbook/addressbook.cpp @@ -0,0 +1,31 @@ +#include "addressbook.h" +#include "data/addressbookdata.h" +#include "addressbookform.h" +#include "addressbookgrid.h" + + +Addressbook::Addressbook() +{ +} + +void Addressbook::initServiceUi() +{ + AddressbookGrid *grid = new AddressbookGrid(); + AddressbookForm *form = new AddressbookForm(); + + m_service = new Service; + m_ui = grid; + ((AddressbookGrid *) m_ui)->setForm(form); +} + + + + + + + + + + + + diff --git a/addressbook/addressbook.h b/addressbook/addressbook.h new file mode 100644 index 0000000..c5e8916 --- /dev/null +++ b/addressbook/addressbook.h @@ -0,0 +1,28 @@ +#ifndef ADDRESSBOOK_H +#define ADDRESSBOOK_H + +#include "addressbook_global.h" +#include +#include +#include + + + +class ADDRESSBOOKSHARED_EXPORT Addressbook : public QObject, IMetaDataPlugin +{ + Q_OBJECT + + Q_PLUGIN_METADATA(IID PluginInterface_iid FILE "addressbook.json") + Q_INTERFACES(IPlugin) + +public: + Addressbook(); + +protected: + void initServiceUi() Q_DECL_OVERRIDE; + + + +}; + +#endif // ADDRESSBOOK_H diff --git a/addressbook/addressbook.json b/addressbook/addressbook.json new file mode 100644 index 0000000..6c6a779 --- /dev/null +++ b/addressbook/addressbook.json @@ -0,0 +1,28 @@ +{ + "id" : "ADDRESSBOOK", + "name" : { + "default" : "Addressbook", + "CZ" : "Adresář" + }, + "descriptoin" : { + "default" : "", + "CZ" : "" + }, + "schemaVersion" : 1, + "sql" : [ + "CREATE TABLE \"AddressbookData\" ( + \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + \"title\" TEXT NULL, + \"firstName\" TEXT NULL, + \"lastName\" TEXT NULL, + \"birthDate\" TEXT NULL, + \"idCardNumber\" TEXT NULL, + \"ztp\" INTEGER NOT NULL, + \"addressCity\" TEXT NULL, + \"addressStreet\" TEXT NULL, + \"addressHouseNumber\" TEXT NULL, + \"addressZipCode\" TEXT NULL);" + + ], + "dependencies" : [] +} diff --git a/addressbook/addressbook.pro b/addressbook/addressbook.pro new file mode 100644 index 0000000..7e00357 --- /dev/null +++ b/addressbook/addressbook.pro @@ -0,0 +1,66 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2016-02-09T21:27:28 +# +#------------------------------------------------- + +QT += widgets sql + +QT -= gui + +TARGET = addressbook +TEMPLATE = lib + +DEFINES += ADDRESSBOOK_LIBRARY + +SOURCES += addressbook.cpp \ + data/addressbookdata.cpp \ + addressbookform.cpp \ + addressbookgrid.cpp \ + addressbooktablemodel.cpp + +HEADERS += addressbook.h\ + addressbook_global.h \ + data/addressbookdata.h \ + addressbookform.h \ + addressbookgrid.h \ + addressbooktablemodel.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 + + +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 + +ODB_FILES = addressbook/data/addressbookdata.h +H_DIR = $$PWD/data/*.h +include(../odb.pri) + +OTHER_FILES += \ + addressbook.json + +FORMS += \ + addressbookform.ui diff --git a/addressbook/addressbook_global.h b/addressbook/addressbook_global.h new file mode 100644 index 0000000..795f959 --- /dev/null +++ b/addressbook/addressbook_global.h @@ -0,0 +1,12 @@ +#ifndef ADDRESSBOOK_GLOBAL_H +#define ADDRESSBOOK_GLOBAL_H + +#include + +#if defined(ADDRESSBOOK_LIBRARY) +# define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT +#else +# define ADDRESSBOOKSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // ADDRESSBOOK_GLOBAL_H diff --git a/addressbook/addressbookform.cpp b/addressbook/addressbookform.cpp new file mode 100644 index 0000000..0ea80db --- /dev/null +++ b/addressbook/addressbookform.cpp @@ -0,0 +1,24 @@ +#include "addressbookform.h" +#include "ui_addressbookform.h" + +AddressbookForm::AddressbookForm(QWidget *parent) : + AutoForm(parent), + ui(new Ui::AddressbookForm) +{ + ui->setupUi(this); + registerBinding(ui->title); + registerBinding(ui->firstName); + registerBinding(ui->lastName); + registerBinding(ui->birthDate); + registerBinding(ui->ztp); + registerBinding(ui->idCardNumber); + registerBinding(ui->addressCity); + registerBinding(ui->addressStreet); + registerBinding(ui->addressHouseNumber); + registerBinding(ui->addressZipCode); +} + +AddressbookForm::~AddressbookForm() +{ + delete ui; +} diff --git a/addressbook/addressbookform.h b/addressbook/addressbookform.h new file mode 100644 index 0000000..4c1a377 --- /dev/null +++ b/addressbook/addressbookform.h @@ -0,0 +1,28 @@ +#ifndef ADDRESSBOOKFORM_H +#define ADDRESSBOOKFORM_H + +#include +#include +#include "autoform.h" +#include "data/addressbookdata.h" +#include "addressbook-odb.hxx" + +namespace Ui { +class AddressbookForm; +} + +class AddressbookForm : public AutoForm +{ + Q_OBJECT + +public: + explicit AddressbookForm(QWidget *parent = 0); + ~AddressbookForm(); + +private: + Ui::AddressbookForm *ui; +}; + + + +#endif // ADDRESSBOOKFORM_H diff --git a/addressbook/addressbookform.ui b/addressbook/addressbookform.ui new file mode 100644 index 0000000..8500b86 --- /dev/null +++ b/addressbook/addressbookform.ui @@ -0,0 +1,122 @@ + + + AddressbookForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Title + + + + + + + + + + First Name + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + Last Name + + + + + + + Day of Birth + + + + + + + ID Card Number + + + + + + + City + + + + + + + ZTP + + + + + + + Street + + + + + + + + + + House Number + + + + + + + ZIP + + + + + + + + diff --git a/addressbook/addressbookgrid.cpp b/addressbook/addressbookgrid.cpp new file mode 100644 index 0000000..549aec0 --- /dev/null +++ b/addressbook/addressbookgrid.cpp @@ -0,0 +1,10 @@ +#include "addressbookgrid.h" +#include "addressbooktablemodel.h" + +AddressbookGrid::AddressbookGrid(QWidget *parent): + GridForm(parent) +{ + setTableModel(new AddressbookTableModel()); +} + + diff --git a/addressbook/addressbookgrid.h b/addressbook/addressbookgrid.h new file mode 100644 index 0000000..04cd4f1 --- /dev/null +++ b/addressbook/addressbookgrid.h @@ -0,0 +1,15 @@ +#ifndef ADDRESSBOOKGRID_H +#define ADDRESSBOOKGRID_H + +#include +#include "data/addressbookdata.h" +#include "addressbook-odb.hxx" + +class AddressbookGrid : public GridForm +{ + Q_OBJECT +public: + AddressbookGrid(QWidget *parent = NULL); +}; + +#endif // ADDRESSBOOKGRID_H diff --git a/addressbook/addressbooktablemodel.cpp b/addressbook/addressbooktablemodel.cpp new file mode 100644 index 0000000..e2fa6de --- /dev/null +++ b/addressbook/addressbooktablemodel.cpp @@ -0,0 +1,7 @@ +#include "addressbooktablemodel.h" + +AddressbookTableModel::AddressbookTableModel(QObject *parent) + :AutoTableModel(parent) +{ +} + diff --git a/addressbook/addressbooktablemodel.h b/addressbook/addressbooktablemodel.h new file mode 100644 index 0000000..c429018 --- /dev/null +++ b/addressbook/addressbooktablemodel.h @@ -0,0 +1,15 @@ +#ifndef ADDRESSBOOKTABLEMODEL_H +#define ADDRESSBOOKTABLEMODEL_H +#include + +#include "data/addressbookdata.h" + +class AddressbookTableModel : public AutoTableModel +{ + Q_OBJECT +public: + AddressbookTableModel(QObject *parent= NULL); +}; + +#endif // ADDRESSBOOKTABLEMODEL_H + diff --git a/addressbook/data/addressbookdata.cpp b/addressbook/data/addressbookdata.cpp new file mode 100644 index 0000000..c339309 --- /dev/null +++ b/addressbook/data/addressbookdata.cpp @@ -0,0 +1,108 @@ +#include "addressbookdata.h" + +AddressbookData::AddressbookData(QObject * parent) + :QObject(parent) +{ +} + + QString AddressbookData::title() const + { + return m_title; + } + + void AddressbookData::setTitle(const QString &title) + { + m_title = title; + } + QString AddressbookData::firstName() const + { + return m_firstName; + } + + void AddressbookData::setFirstName(const QString &firstName) + { + m_firstName = firstName; + } + QString AddressbookData::lastName() const + { + return m_lastName; + } + + void AddressbookData::setLastName(const QString &lastName) + { + m_lastName = lastName; + } + QDate AddressbookData::birthDate() const + { + return m_birthDate; + } + + void AddressbookData::setBirthDate(const QDate &birthDate) + { + m_birthDate = birthDate; + } + QString AddressbookData::idCardNumber() const + { + return m_idCardNumber; + } + + void AddressbookData::setIdCardNumber(const QString &idCardNumber) + { + m_idCardNumber = idCardNumber; + } + bool AddressbookData::ztp() const + { + return m_ztp; + } + + void AddressbookData::setZtp(bool ztp) + { + m_ztp = ztp; + } + QString AddressbookData::addressCity() const + { + return m_addressCity; + } + + void AddressbookData::setAddressCity(const QString &addressCity) + { + m_addressCity = addressCity; + } + QString AddressbookData::addressStreet() const + { + return m_addressStreet; + } + + void AddressbookData::setAddressStreet(const QString &addressStreet) + { + m_addressStreet = addressStreet; + } + QString AddressbookData::addressHouseNumber() const + { + return m_addressHouseNumber; + } + + void AddressbookData::setAddressHouseNumber(const QString &addressHouseNumber) + { + m_addressHouseNumber = addressHouseNumber; + } + QString AddressbookData::addressZipCode() const + { + return m_addressZipCode; + } + + void AddressbookData::setAddressZipCode(const QString &addressZipCode) + { + m_addressZipCode = addressZipCode; + } + int AddressbookData::id() const + { + return m_id; + } + + void AddressbookData::setId(int id) + { + m_id = id; + } + + diff --git a/addressbook/data/addressbookdata.h b/addressbook/data/addressbookdata.h new file mode 100644 index 0000000..07fba57 --- /dev/null +++ b/addressbook/data/addressbookdata.h @@ -0,0 +1,75 @@ +#ifndef ADDRESSBOOKDATA_H +#define ADDRESSBOOKDATA_H + +#include +#include +#include +#include "odb/core.hxx" + +#pragma db object +class AddressbookData : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString title READ title WRITE setTitle) + Q_PROPERTY(QString firstName READ firstName WRITE setFirstName) + Q_PROPERTY(QString lastName READ lastName WRITE setLastName) + Q_PROPERTY(QDate birthDate READ birthDate WRITE setBirthDate) + Q_PROPERTY(QString idCardNumber READ idCardNumber WRITE setIdCardNumber) + Q_PROPERTY(bool ztp READ ztp WRITE setZtp) + Q_PROPERTY(QString addressCity READ addressCity WRITE setAddressCity) + Q_PROPERTY(QString addressStreet READ addressStreet WRITE setAddressStreet) + Q_PROPERTY(QString addressHouseNumber READ addressHouseNumber WRITE setAddressHouseNumber) + Q_PROPERTY(QString addressZipCode READ addressZipCode WRITE setAddressZipCode) + +public: + AddressbookData(QObject *parent = 0); + QString title() const; + void setTitle(const QString &title); + + QString firstName() const; + void setFirstName(const QString &firstName); + + QString lastName() const; + void setLastName(const QString &lastName); + + QDate birthDate() const; + void setBirthDate(const QDate &birthDate); + + QString idCardNumber() const; + void setIdCardNumber(const QString &idCardNumber); + + bool ztp() const; + void setZtp(bool ztp); + + QString addressCity() const; + void setAddressCity(const QString &addressCity); + + QString addressStreet() const; + void setAddressStreet(const QString &addressStreet); + + QString addressHouseNumber() const; + void setAddressHouseNumber(const QString &addressHouseNumber); + + QString addressZipCode() const; + void setAddressZipCode(const QString &addressZipCode); + + int id() const; + void setId(int id); + +private: + friend class odb::access; +#pragma db id auto + int m_id; + QString m_title; + QString m_firstName; + QString m_lastName; + QDate m_birthDate; + QString m_idCardNumber; + bool m_ztp; + QString m_addressCity; + QString m_addressStreet; + QString m_addressHouseNumber; + QString m_addressZipCode; +}; + +#endif // ADDRESSBOOKDATA_H