Build system changed to Cmake, ORM changed to QxORM, Qt6 compatibility.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(addressbook)
|
||||
|
||||
include(../3rdparty/QxOrm/QxOrm.cmake)
|
||||
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ../plugins)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
find_package(Qt6 COMPONENTS
|
||||
Core
|
||||
Gui
|
||||
Widgets
|
||||
REQUIRED)
|
||||
|
||||
add_library(addressbook SHARED
|
||||
addressbook.cpp
|
||||
addressbook.h
|
||||
addressbookrc.qrc
|
||||
addressbook_global.h
|
||||
addressbookform.cpp
|
||||
addressbookform.h
|
||||
addressbookform.ui
|
||||
addressbookgrid.cpp
|
||||
addressbookgrid.h
|
||||
addressbookservice.cpp
|
||||
addressbookservice.h
|
||||
addressbooktablemodel.cpp
|
||||
addressbooktablemodel.h
|
||||
data/addressbookdata.cpp
|
||||
data/addressbookdata.h)
|
||||
|
||||
target_compile_definitions(addressbook PRIVATE -DADDRESSBOOK_LIBRARY)
|
||||
|
||||
include_directories(../core)
|
||||
include_directories(../countryregister)
|
||||
|
||||
target_link_libraries(addressbook
|
||||
Qt::Core
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
qdecimal
|
||||
decnumber
|
||||
QxOrm
|
||||
core
|
||||
countryregister
|
||||
)
|
||||
|
||||
install(TARGETS addressbook
|
||||
LIBRARY DESTINATION ../plugins)
|
||||
@@ -26,8 +26,8 @@ protected:
|
||||
|
||||
// IPlugin interface
|
||||
public:
|
||||
virtual QIcon pluginIcon();
|
||||
QTranslator *translator();
|
||||
QIcon pluginIcon() override;
|
||||
QTranslator *translator() override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# 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 \
|
||||
addressbookservice.cpp
|
||||
|
||||
HEADERS += addressbook.h\
|
||||
addressbook_global.h \
|
||||
data/addressbookdata.h \
|
||||
addressbookform.h \
|
||||
addressbookgrid.h \
|
||||
addressbooktablemodel.h \
|
||||
addressbookservice.h
|
||||
|
||||
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 += \
|
||||
addressbook.json
|
||||
|
||||
FORMS += \
|
||||
addressbookform.ui
|
||||
|
||||
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
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define ADDRESSBOOK_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QxOrm.h>
|
||||
|
||||
#if defined(ADDRESSBOOK_LIBRARY)
|
||||
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT
|
||||
@@ -9,4 +10,12 @@
|
||||
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#ifdef ADDRESSBOOK_LIBRARY
|
||||
#define QX_REGISTER_HPP_ADDR QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_ADDR QX_REGISTER_CPP_EXPORT_DLL
|
||||
#else // ADDRESSBOOK_LIBRARY
|
||||
#define QX_REGISTER_HPP_ADDR QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_ADDR QX_REGISTER_CPP_IMPORT_DLL
|
||||
#endif
|
||||
|
||||
#endif // ADDRESSBOOK_GLOBAL_H
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <data/countrydata.h>
|
||||
#include "addressbookform.h"
|
||||
#include "ui_addressbookform.h"
|
||||
#include <countrydata.h>
|
||||
#include <data/countrydata.h>
|
||||
|
||||
AddressbookForm::AddressbookForm(QWidget *parent) :
|
||||
AutoForm<AddressbookData>(parent),
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <QWidget>
|
||||
#include <autoform.h>
|
||||
#include "data/addressbookdata.h"
|
||||
#include "addressbook-odb.hxx"
|
||||
|
||||
namespace Ui {
|
||||
class AddressbookForm;
|
||||
@@ -16,14 +15,14 @@ class AddressbookForm : public AutoForm<AddressbookData>
|
||||
|
||||
public:
|
||||
explicit AddressbookForm(QWidget *parent = 0);
|
||||
~AddressbookForm();
|
||||
~AddressbookForm() override;
|
||||
|
||||
private:
|
||||
Ui::AddressbookForm *ui;
|
||||
|
||||
// FormBinder interface
|
||||
protected:
|
||||
void registerCombos();
|
||||
void registerCombos() override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6,14 +6,17 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>407</height>
|
||||
<width>624</width>
|
||||
<height>363</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <core.h>
|
||||
#include "data/addressbookdata.h"
|
||||
#include "addressbook-odb.hxx"
|
||||
|
||||
class AddressbookGrid : public GridForm<AddressbookData>
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <service.h>
|
||||
#include "addressbookservice.h"
|
||||
#include "addressbook-odb.hxx"
|
||||
|
||||
AddressBookService::AddressBookService()
|
||||
{
|
||||
@@ -24,7 +23,7 @@ AddressbookDataPtr AddressBookService::copyAddress(AddressbookDataPtr address)
|
||||
newAddress->setAddressHouseNumber(address->addressHouseNumber());
|
||||
newAddress->setAddressZipCode(address->addressZipCode());
|
||||
newAddress->setAddressCity(address->addressCity());
|
||||
newAddress->setCountry(address->country());
|
||||
//newAddress->setCountry(address->country());
|
||||
|
||||
return newAddress;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
#include <data/countrydata.h>
|
||||
#include "addressbookdata.h"
|
||||
|
||||
QX_REGISTER_CPP_ADDR(AddressbookData)
|
||||
|
||||
namespace qx {
|
||||
template<> void register_class(QxClass<AddressbookData>& t) {
|
||||
t.setName("AddressbookData");
|
||||
t.id(&AddressbookData::m_id, "id");
|
||||
t.data(&AddressbookData::m_title, "title");
|
||||
t.data(&AddressbookData::m_firstName, "firstName");
|
||||
t.data(&AddressbookData::m_lastName, "lastName");
|
||||
t.data(&AddressbookData::m_birthDate, "birthDate");
|
||||
t.data(&AddressbookData::m_idCardNumber, "idCardNumber");
|
||||
t.data(&AddressbookData::m_ztp, "ztp");
|
||||
t.data(&AddressbookData::m_addressCity, "addressCity");
|
||||
t.data(&AddressbookData::m_addressHouseNumber, "addressHouseNumber");
|
||||
t.data(&AddressbookData::m_addressZipCode, "addressZipCode");
|
||||
|
||||
t.relationManyToOne(&AddressbookData::m_country, "country");
|
||||
}
|
||||
}
|
||||
|
||||
AddressbookData::AddressbookData(QObject * parent)
|
||||
:ComboItem(parent)
|
||||
{
|
||||
@@ -96,12 +117,12 @@ void AddressbookData::setAddressZipCode(const QString &addressZipCode)
|
||||
{
|
||||
m_addressZipCode = addressZipCode;
|
||||
}
|
||||
int AddressbookData::id() const
|
||||
long AddressbookData::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void AddressbookData::setId(int id)
|
||||
void AddressbookData::setId(long id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
@@ -122,7 +143,7 @@ void AddressbookData::setCountry(const QSharedPointer<QObject> &country)
|
||||
bool AddressbookData::eq(ComboItem *other)
|
||||
{
|
||||
AddressbookData *adb = qobject_cast<AddressbookData*>(other);
|
||||
return adb != NULL && adb->id() == this->id();
|
||||
return adb != nullptr && adb->id() == this->id();
|
||||
}
|
||||
|
||||
QString AddressbookData::toString()
|
||||
@@ -130,4 +151,8 @@ QString AddressbookData::toString()
|
||||
return m_lastName + " " + m_firstName + ", " + m_addressStreet + " " + m_addressHouseNumber + ", " + m_addressCity;
|
||||
}
|
||||
|
||||
QStringList AddressbookData::eagerLoad() {
|
||||
return { "country" };
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
#ifndef ADDRESSBOOKDATA_H
|
||||
#define ADDRESSBOOKDATA_H
|
||||
|
||||
#include "../addressbook_global.h"
|
||||
#include <data/comboitem.h>
|
||||
#include <data/countrydata.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDate>
|
||||
#include <odb/core.hxx>
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <data/comboitem.h>
|
||||
#include <countrydata.h>
|
||||
#include <QxOrm.h>
|
||||
|
||||
#if defined(ADDRESSBOOK_LIBRARY)
|
||||
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#pragma db object
|
||||
class ADDRESSBOOKSHARED_EXPORT AddressbookData : public ComboItem
|
||||
{
|
||||
Q_OBJECT
|
||||
QX_REGISTER_FRIEND_CLASS(AddressbookData)
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle)
|
||||
Q_PROPERTY(QString firstName READ firstName WRITE setFirstName)
|
||||
Q_PROPERTY(QString lastName READ lastName WRITE setLastName)
|
||||
@@ -35,6 +31,7 @@ class ADDRESSBOOKSHARED_EXPORT AddressbookData : public ComboItem
|
||||
|
||||
public:
|
||||
AddressbookData(QObject *parent = 0);
|
||||
|
||||
QString title() const;
|
||||
void setTitle(const QString &title);
|
||||
|
||||
@@ -65,16 +62,16 @@ public:
|
||||
QString addressZipCode() const;
|
||||
void setAddressZipCode(const QString &addressZipCode);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
long id() const;
|
||||
void setId(long id);
|
||||
|
||||
QSharedPointer<QObject> country() const;
|
||||
void setCountry(const QSharedPointer<QObject> &country);
|
||||
|
||||
Q_INVOKABLE QStringList eagerLoad();
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
long m_id{0};
|
||||
QString m_title;
|
||||
QString m_firstName;
|
||||
QString m_lastName;
|
||||
@@ -89,10 +86,12 @@ private:
|
||||
|
||||
// ComboItem interface
|
||||
public:
|
||||
virtual bool eq(ComboItem *other);
|
||||
virtual QString toString();
|
||||
bool eq(ComboItem *other) override;
|
||||
QString toString() override;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<AddressbookData> AddressbookDataPtr;
|
||||
|
||||
QX_REGISTER_HPP_ADDR(AddressbookData, ComboItem, 0)
|
||||
|
||||
#endif // ADDRESSBOOKDATA_H
|
||||
|
||||
Reference in New Issue
Block a user