Added country combo to addressbook. Addressbook plugin depends on Countryregister which must be loaded first.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "addressbookform.h"
|
||||
#include "ui_addressbookform.h"
|
||||
#include <countrydata.h>
|
||||
|
||||
AddressbookForm::AddressbookForm(QWidget *parent) :
|
||||
AutoForm<AddressbookData>(parent),
|
||||
@@ -22,3 +23,9 @@ AddressbookForm::~AddressbookForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AddressbookForm::registerCombos()
|
||||
{
|
||||
Service<CountryData> srv;
|
||||
registerBinding(ui->country, ComboData::createComboData(srv.all()));
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ public:
|
||||
|
||||
private:
|
||||
Ui::AddressbookForm *ui;
|
||||
|
||||
// FormBinder interface
|
||||
protected:
|
||||
void registerCombos();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>610</width>
|
||||
<height>407</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -115,8 +115,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Country</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QComboBox" name="country">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>title</tabstop>
|
||||
<tabstop>firstName</tabstop>
|
||||
<tabstop>lastName</tabstop>
|
||||
<tabstop>birthDate</tabstop>
|
||||
<tabstop>idCardNumber</tabstop>
|
||||
<tabstop>ztp</tabstop>
|
||||
<tabstop>addressCity</tabstop>
|
||||
<tabstop>addressStreet</tabstop>
|
||||
<tabstop>addressHouseNumber</tabstop>
|
||||
<tabstop>addressZipCode</tabstop>
|
||||
<tabstop>country</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -106,6 +106,19 @@ void AddressbookData::setId(int id)
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
QSharedPointer<QObject> AddressbookData::country() const
|
||||
{
|
||||
return m_country;
|
||||
}
|
||||
|
||||
void AddressbookData::setCountry(const QSharedPointer<QObject> &country)
|
||||
{
|
||||
if (qobject_cast<CountryData*>(country.data()) != NULL)
|
||||
{
|
||||
m_country = qSharedPointerDynamicCast<CountryData, QObject>(country);
|
||||
}
|
||||
}
|
||||
|
||||
bool AddressbookData::eq(ComboItem *other)
|
||||
{
|
||||
AddressbookData *adb = qobject_cast<AddressbookData*>(other);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <data/comboitem.h>
|
||||
#include <countrydata.h>
|
||||
|
||||
#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<QObject> country READ country WRITE setCountry)
|
||||
|
||||
public:
|
||||
AddressbookData(QObject *parent = 0);
|
||||
@@ -66,6 +68,9 @@ public:
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
|
||||
QSharedPointer<QObject> country() const;
|
||||
void setCountry(const QSharedPointer<QObject> &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:
|
||||
|
||||
+4
-1
@@ -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
|
||||
|
||||
@@ -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<CountryData*>(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;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
#include <odb/core.hxx>
|
||||
#include <QSharedPointer>
|
||||
#include <data/comboitem.h>
|
||||
|
||||
#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<CountryData> CountryDataPtr;
|
||||
|
||||
#endif // COUNTRYDATA_H
|
||||
|
||||
+5
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user