Build system changed to Cmake, ORM changed to QxORM, Qt6 compatibility.
This commit is contained in:
@@ -1,22 +1,40 @@
|
||||
#include "commoditydata.h"
|
||||
#include <define.h>
|
||||
|
||||
QX_REGISTER_CPP_COMM(CommodityData)
|
||||
|
||||
namespace qx {
|
||||
template<> void register_class(QxClass<CommodityData>& t) {
|
||||
t.setName("CommodityData");
|
||||
t.id(&CommodityData::m_id, "id");
|
||||
t.data(&CommodityData::m_name, "name");
|
||||
t.data(&CommodityData::m_shortName, "shortName");
|
||||
t.data(&CommodityData::m_code, "code");
|
||||
t.data(&CommodityData::m_price, "price");
|
||||
t.data(&CommodityData::m_vat, "vat");
|
||||
t.data(&CommodityData::m_count, "count");
|
||||
|
||||
t.relationManyToOne(&CommodityData::m_type, "type");
|
||||
}
|
||||
}
|
||||
|
||||
CommodityData::CommodityData(QObject *parent)
|
||||
:ShopItem(parent)
|
||||
:IShopItem(parent)
|
||||
{
|
||||
m_count = 0;
|
||||
m_price = 0;
|
||||
m_vat = Enums::NONE;
|
||||
}
|
||||
int CommodityData::id()
|
||||
long CommodityData::id()
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void CommodityData::setId(int id)
|
||||
void CommodityData::setId(long id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
QString CommodityData::name()
|
||||
{
|
||||
return m_name;
|
||||
@@ -26,6 +44,7 @@ void CommodityData::setName(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
QString CommodityData::shortName()
|
||||
{
|
||||
return m_shortName;
|
||||
@@ -35,6 +54,7 @@ void CommodityData::setShortName(const QString &shortName)
|
||||
{
|
||||
m_shortName = shortName;
|
||||
}
|
||||
|
||||
QString CommodityData::code() const
|
||||
{
|
||||
return m_code;
|
||||
@@ -44,6 +64,7 @@ void CommodityData::setCode(const QString &code)
|
||||
{
|
||||
m_code = code;
|
||||
}
|
||||
|
||||
QSharedPointer<QObject> CommodityData::type() const
|
||||
{
|
||||
return m_type;
|
||||
@@ -51,7 +72,7 @@ QSharedPointer<QObject> CommodityData::type() const
|
||||
|
||||
void CommodityData::setType(const QSharedPointer<QObject> &type)
|
||||
{
|
||||
if (qobject_cast<CommodityTypeData*>(type.data()) != NULL) {
|
||||
if (qobject_cast<CommodityTypeData*>(type.data()) != nullptr) {
|
||||
m_type = qSharedPointerDynamicCast<CommodityTypeData, QObject>(type);
|
||||
}
|
||||
}
|
||||
@@ -98,6 +119,10 @@ QString CommodityData::pluginId()
|
||||
return "COMMODITY";
|
||||
}
|
||||
|
||||
QStringList CommodityData::eagerLoad() {
|
||||
return { "type" };
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,17 +3,20 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <odb/core.hxx>
|
||||
#include "commoditytypedata.h"
|
||||
#include <shopitem.h>
|
||||
#include <QDecDouble.hh>
|
||||
#include <QSharedDataPointer>
|
||||
#include <enums.h>
|
||||
|
||||
#include "../commodity_global.h"
|
||||
|
||||
#pragma db object
|
||||
class CommodityData : public ShopItem
|
||||
class CommodityData : public IShopItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(CommodityData)
|
||||
Q_PROPERTY(QString code READ code WRITE setCode)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString shortName READ shortName WRITE setShortName)
|
||||
@@ -23,10 +26,10 @@ class CommodityData : public ShopItem
|
||||
Q_PROPERTY(int count READ count WRITE setCount)
|
||||
|
||||
public:
|
||||
CommodityData(QObject *parent = 0);
|
||||
explicit CommodityData(QObject *parent = nullptr);
|
||||
|
||||
int id() override;
|
||||
void setId(int id);
|
||||
long id() override;
|
||||
void setId(long id);
|
||||
|
||||
QString name() override;
|
||||
void setName(const QString &name);
|
||||
@@ -49,10 +52,10 @@ public:
|
||||
int count() const;
|
||||
void setCount(int count);
|
||||
|
||||
Q_INVOKABLE QStringList eagerLoad();
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
long m_id{0};
|
||||
QString m_name;
|
||||
QString m_shortName;
|
||||
QString m_code;
|
||||
@@ -66,8 +69,11 @@ public:
|
||||
QDecDouble unitPrice() override;
|
||||
Enums::VatType vatType() override;
|
||||
QString pluginId() override;
|
||||
|
||||
};
|
||||
|
||||
typedef QSharedPointer<CommodityData> CommodityDataPtr;
|
||||
|
||||
QX_REGISTER_HPP_COMM(CommodityData, IShopItem, 0)
|
||||
|
||||
#endif // COMMODITYDATA_H
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
#include "commoditytypedata.h"
|
||||
|
||||
QX_REGISTER_CPP_COMM(CommodityTypeData)
|
||||
|
||||
namespace qx {
|
||||
template<> void register_class(QxClass<CommodityTypeData>& t) {
|
||||
t.setName("CommodityTypeData");
|
||||
t.id(&CommodityTypeData::m_id, "id");
|
||||
t.data(&CommodityTypeData::m_name, "name");
|
||||
}
|
||||
}
|
||||
|
||||
CommodityTypeData::CommodityTypeData(QObject *parent)
|
||||
:ComboItem(parent)
|
||||
{
|
||||
m_id = 0;
|
||||
}
|
||||
int CommodityTypeData::id() const
|
||||
long CommodityTypeData::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void CommodityTypeData::setId(int id)
|
||||
void CommodityTypeData::setId(long id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
QString CommodityTypeData::name() const
|
||||
{
|
||||
return m_name;
|
||||
@@ -28,7 +39,7 @@ bool CommodityTypeData::eq(ComboItem *other)
|
||||
{
|
||||
CommodityTypeData* ct = qobject_cast<CommodityTypeData *> (other);
|
||||
|
||||
return ct != NULL && this->id() == ct->id() ;
|
||||
return ct != nullptr && this->id() == ct->id() ;
|
||||
}
|
||||
|
||||
QString CommodityTypeData::toString()
|
||||
|
||||
@@ -3,34 +3,35 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <odb/core.hxx>
|
||||
#include <data/comboitem.h>
|
||||
#include "../commodity_global.h"
|
||||
|
||||
#pragma db object
|
||||
class CommodityTypeData :public ComboItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(CommodityTypeData)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
|
||||
public:
|
||||
CommodityTypeData(QObject *parent = 0);
|
||||
explicit CommodityTypeData(QObject *parent = nullptr);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
long id() const;
|
||||
void setId(long id);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
long m_id{0};
|
||||
QString m_name;
|
||||
|
||||
// ComboItem interface
|
||||
public:
|
||||
bool eq(ComboItem *other);
|
||||
QString toString();
|
||||
bool eq(ComboItem *other) override;
|
||||
QString toString() override;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_COMM(CommodityTypeData, ComboItem, 0)
|
||||
|
||||
#endif // COMMODITYTYPEDATA_H
|
||||
|
||||
Reference in New Issue
Block a user