closes #1: Favorite buttons has been extended with category buttons.
This commit is contained in:
@@ -13,6 +13,7 @@ namespace qx {
|
||||
t.data(&CommodityData::m_price, "price");
|
||||
t.data(&CommodityData::m_vat, "vat");
|
||||
t.data(&CommodityData::m_count, "count");
|
||||
t.data(&CommodityData::m_favorite, "favorite");
|
||||
|
||||
t.relationManyToOne(&CommodityData::m_type, "type");
|
||||
}
|
||||
@@ -25,7 +26,7 @@ CommodityData::CommodityData(QObject *parent)
|
||||
m_price = 0;
|
||||
m_vat = Enums::NONE;
|
||||
}
|
||||
long CommodityData::id()
|
||||
long CommodityData::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
@@ -114,7 +115,7 @@ Enums::VatType CommodityData::vatType()
|
||||
return vat();
|
||||
}
|
||||
|
||||
QString CommodityData::pluginId()
|
||||
QString CommodityData::pluginId() const
|
||||
{
|
||||
return "COMMODITY";
|
||||
}
|
||||
@@ -123,6 +124,22 @@ QStringList CommodityData::eagerLoad() {
|
||||
return { "type" };
|
||||
}
|
||||
|
||||
bool CommodityData::favorite() {
|
||||
return m_favorite;
|
||||
}
|
||||
|
||||
void CommodityData::setFavorite(bool favorite) {
|
||||
m_favorite = favorite;
|
||||
}
|
||||
|
||||
QString CommodityData::color() {
|
||||
return m_type->color();
|
||||
}
|
||||
|
||||
QString CommodityData::category() {
|
||||
return m_type->name();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,11 +24,12 @@ class CommodityData : public IShopItem
|
||||
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
|
||||
Q_PROPERTY(Enums::VatType vat READ vat WRITE setVat)
|
||||
Q_PROPERTY(int count READ count WRITE setCount)
|
||||
Q_PROPERTY(bool favorite READ favorite WRITE setFavorite)
|
||||
|
||||
public:
|
||||
explicit CommodityData(QObject *parent = nullptr);
|
||||
|
||||
long id() override;
|
||||
long id() const override;
|
||||
void setId(long id);
|
||||
|
||||
QString name() override;
|
||||
@@ -52,6 +53,9 @@ public:
|
||||
int count() const;
|
||||
void setCount(int count);
|
||||
|
||||
bool favorite() override;
|
||||
void setFavorite(bool favorite);
|
||||
|
||||
Q_INVOKABLE QStringList eagerLoad();
|
||||
|
||||
private:
|
||||
@@ -63,13 +67,15 @@ private:
|
||||
int m_price;
|
||||
Enums::VatType m_vat;
|
||||
int m_count;
|
||||
bool m_favorite;
|
||||
|
||||
// IShopItem interface
|
||||
public:
|
||||
QDecDouble unitPrice() override;
|
||||
Enums::VatType vatType() override;
|
||||
QString pluginId() override;
|
||||
|
||||
QString pluginId() const override;
|
||||
QString color() override;
|
||||
QString category() override;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<CommodityData> CommodityDataPtr;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace qx {
|
||||
t.setName("CommodityTypeData");
|
||||
t.id(&CommodityTypeData::m_id, "id");
|
||||
t.data(&CommodityTypeData::m_name, "name");
|
||||
t.data(&CommodityTypeData::m_color, "color");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +48,12 @@ QString CommodityTypeData::toString()
|
||||
return this->name();
|
||||
}
|
||||
|
||||
QString CommodityTypeData::color() const {
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void CommodityTypeData::setColor(const QString& color) {
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ class CommodityTypeData :public ComboItem
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(CommodityTypeData)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString color READ color WRITE setColor)
|
||||
|
||||
public:
|
||||
explicit CommodityTypeData(QObject *parent = nullptr);
|
||||
@@ -22,9 +23,13 @@ public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
QString color() const;
|
||||
void setColor(const QString& color);
|
||||
|
||||
private:
|
||||
long m_id{0};
|
||||
QString m_name;
|
||||
QString m_color;
|
||||
|
||||
// ComboItem interface
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user