Build system changed to Cmake, ORM changed to QxORM, Qt6 compatibility.
This commit is contained in:
@@ -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