diff --git a/addressbook/addressbook.json b/addressbook/addressbook.json index ce7ac2f..5a41280 100644 --- a/addressbook/addressbook.json +++ b/addressbook/addressbook.json @@ -8,7 +8,7 @@ "default" : "", "CZ" : "" }, - "schemaVersion" : 1, + "schemaVersion" : 2, "sql" : [ "CREATE TABLE \"AddressbookData\" ( \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, @@ -21,10 +21,14 @@ \"addressCity\" TEXT NULL, \"addressStreet\" TEXT NULL, \"addressHouseNumber\" TEXT NULL, - \"addressZipCode\" TEXT NULL);" + \"addressZipCode\" TEXT NULL); +", + +"ALTER TABLE AddressbookData ADD \"country\" INTEGER NULL; +" ], - "dependencies" : [], + "dependencies" : [ "COUNTRYREGISTER" ], "translations" : { "CZ" : { "title" : "Titul", diff --git a/addressbook/addressbook.pro b/addressbook/addressbook.pro index 91a39b1..f88dd05 100644 --- a/addressbook/addressbook.pro +++ b/addressbook/addressbook.pro @@ -32,6 +32,7 @@ include(../config_plugin.pri) ODB_FILES = addressbook/data/addressbookdata.h H_DIR = $$PWD/data/*.h +ODB_OTHER_INCLUDES = -I $$PWD/../countryregister/data include(../odb.pri) OTHER_FILES += \ @@ -43,3 +44,11 @@ FORMS += \ RESOURCES += \ addressbookrc.qrc TRANSLATIONS = translations/addressbook_cs_CZ.ts + +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lcountryregister +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lcountryregister +else:unix: LIBS += -L$$OUT_PWD/../plugins/ -lcountryregister + +INCLUDEPATH += $$PWD/../countryregister/data +INCLUDEPATH += $$PWD/../countryregister + diff --git a/addressbook/addressbookform.cpp b/addressbook/addressbookform.cpp index 0ea80db..e6d30f9 100644 --- a/addressbook/addressbookform.cpp +++ b/addressbook/addressbookform.cpp @@ -1,5 +1,6 @@ #include "addressbookform.h" #include "ui_addressbookform.h" +#include AddressbookForm::AddressbookForm(QWidget *parent) : AutoForm(parent), @@ -22,3 +23,9 @@ AddressbookForm::~AddressbookForm() { delete ui; } + +void AddressbookForm::registerCombos() +{ + Service srv; + registerBinding(ui->country, ComboData::createComboData(srv.all())); +} diff --git a/addressbook/addressbookform.h b/addressbook/addressbookform.h index 7888b7d..85eb79c 100644 --- a/addressbook/addressbookform.h +++ b/addressbook/addressbookform.h @@ -20,6 +20,10 @@ public: private: Ui::AddressbookForm *ui; + + // FormBinder interface +protected: + void registerCombos(); }; diff --git a/addressbook/addressbookform.ui b/addressbook/addressbookform.ui index 8500b86..853d121 100644 --- a/addressbook/addressbookform.ui +++ b/addressbook/addressbookform.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 300 + 610 + 407 @@ -115,8 +115,35 @@ + + + + Country + + + + + + + true + + + + + title + firstName + lastName + birthDate + idCardNumber + ztp + addressCity + addressStreet + addressHouseNumber + addressZipCode + country + diff --git a/addressbook/data/addressbookdata.cpp b/addressbook/data/addressbookdata.cpp index 899b7b5..bee6c41 100644 --- a/addressbook/data/addressbookdata.cpp +++ b/addressbook/data/addressbookdata.cpp @@ -106,6 +106,19 @@ void AddressbookData::setId(int id) m_id = id; } +QSharedPointer AddressbookData::country() const +{ + return m_country; +} + +void AddressbookData::setCountry(const QSharedPointer &country) +{ + if (qobject_cast(country.data()) != NULL) + { + m_country = qSharedPointerDynamicCast(country); + } +} + bool AddressbookData::eq(ComboItem *other) { AddressbookData *adb = qobject_cast(other); diff --git a/addressbook/data/addressbookdata.h b/addressbook/data/addressbookdata.h index ab21936..4a250aa 100644 --- a/addressbook/data/addressbookdata.h +++ b/addressbook/data/addressbookdata.h @@ -9,6 +9,7 @@ #include #include +#include #if defined(ADDRESSBOOK_LIBRARY) # define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT @@ -30,6 +31,7 @@ class ADDRESSBOOKSHARED_EXPORT AddressbookData : public ComboItem Q_PROPERTY(QString addressStreet READ addressStreet WRITE setAddressStreet) Q_PROPERTY(QString addressHouseNumber READ addressHouseNumber WRITE setAddressHouseNumber) Q_PROPERTY(QString addressZipCode READ addressZipCode WRITE setAddressZipCode) + Q_PROPERTY(QSharedPointer country READ country WRITE setCountry) public: AddressbookData(QObject *parent = 0); @@ -66,6 +68,9 @@ public: int id() const; void setId(int id); + QSharedPointer country() const; + void setCountry(const QSharedPointer &country); + private: friend class odb::access; #pragma db id auto @@ -80,6 +85,7 @@ private: QString m_addressStreet; QString m_addressHouseNumber; QString m_addressZipCode; + CountryDataPtr m_country; // ComboItem interface public: diff --git a/camp/camp.pro b/camp/camp.pro index 08cfebd..8436342 100644 --- a/camp/camp.pro +++ b/camp/camp.pro @@ -50,7 +50,7 @@ include(../config_plugin.pri) ODB_FILES = camp/data/camp-data.h H_DIR = $$PWD/data/*.h -ODB_OTHER_INCLUDES = -I $$PWD/../shop -I $$PWD/../addressbook/data -I $$PWD/../services/data +ODB_OTHER_INCLUDES = -I $$PWD/../shop -I $$PWD/../addressbook/data -I $$PWD/../countryregister/data -I $$PWD/../services/data include(../odb.pri) win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lshop @@ -68,6 +68,9 @@ INCLUDEPATH += $$PWD/../addressbook INCLUDEPATH += $$PWD/../addressbook/data DEPENDPATH += $$PWD/../addressbook +INCLUDEPATH += $$PWD/../countryregister/data +INCLUDEPATH += $$PWD/../countryregister + win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lservices else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lservices else:unix: LIBS += -L$$OUT_PWD/../plugins/ -lservices diff --git a/countryregister/data/countrydata.cpp b/countryregister/data/countrydata.cpp index 3d37d13..b47cd92 100644 --- a/countryregister/data/countrydata.cpp +++ b/countryregister/data/countrydata.cpp @@ -1,6 +1,6 @@ #include "countrydata.h" -CountryData::CountryData(QObject *parent) : QObject(parent) +CountryData::CountryData(QObject *parent) : ComboItem(parent) { } @@ -74,3 +74,20 @@ void CountryData::setEnglishName(const QString &englishName) { m_englishName = englishName; } + +bool CountryData::eq(ComboItem *other) +{ + CountryData *obj = qobject_cast(other); + + if (obj == NULL) + { + return false; + } + + return this == obj || (m_id == obj->m_id && m_code2 == obj->m_code2 && m_code3 == obj->m_code3); +} + +QString CountryData::toString() +{ + return m_code3 + " - " + m_czechFullName; +} diff --git a/countryregister/data/countrydata.h b/countryregister/data/countrydata.h index 8b3e66d..4caffb2 100644 --- a/countryregister/data/countrydata.h +++ b/countryregister/data/countrydata.h @@ -4,9 +4,11 @@ #include #include #include +#include +#include #pragma db object -class CountryData : public QObject +class CountryData : public ComboItem { Q_OBJECT Q_PROPERTY(QString code2 READ code2 WRITE setCode2) @@ -50,6 +52,13 @@ private: QString m_englishFullName; QString m_englishName; + + // ComboItem interface +public: + bool eq(ComboItem *other); + QString toString(); }; +typedef QSharedPointer CountryDataPtr; + #endif // COUNTRYDATA_H diff --git a/shop/shop.pro b/shop/shop.pro index 3a4210f..84869c4 100644 --- a/shop/shop.pro +++ b/shop/shop.pro @@ -9,7 +9,7 @@ QT += widgets sql TARGET = shop TEMPLATE = lib -#CONFIG += eet +CONFIG += eet DEFINES += SHOP_LIBRARY @@ -63,7 +63,7 @@ OTHER_FILES += shop.json ODB_FILES = shop/data/shop-data.h H_DIR = $$PWD/data/*.h -ODB_OTHER_INCLUDES = -I $$PWD/../addressbook/data -I $$PWD/ +ODB_OTHER_INCLUDES = -I $$PWD/../addressbook/data -I $$PWD/../countryregister/data -I $$PWD/ include(../odb.pri) RESOURCES += \ @@ -89,6 +89,9 @@ INCLUDEPATH += $$PWD/../addressbook INCLUDEPATH += $$PWD/ DEPENDPATH += $$PWD/../addressbook +INCLUDEPATH += $$PWD/../countryregister/data +INCLUDEPATH += $$PWD/../countryregister + TRANSLATIONS = translations/shop_cs_CZ.ts win32 {