Add group field to items
This commit is contained in:
parent
9648c7c040
commit
0e09b6f46c
2 changed files with 21 additions and 4 deletions
|
|
@ -13,8 +13,8 @@
|
|||
|
||||
#include <QJsonArray>
|
||||
|
||||
ItemData::ItemData(uint32_t itemIdIn, QString name, uint8_t value, bool loaded, bool hidden, item_value_type_t type):
|
||||
name_(name), value_(value), itemId_(itemIdIn), loaded_(loaded), hidden_(hidden), type_(type)
|
||||
ItemData::ItemData(uint32_t itemIdIn, QString name, uint8_t value, bool loaded, bool hidden, item_value_type_t type, QString groupName):
|
||||
name_(name), value_(value), itemId_(itemIdIn), loaded_(loaded), hidden_(hidden), type_(type), groupName_(groupName)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -49,6 +49,7 @@ void ItemData::store(QJsonObject &json)
|
|||
json["Name"] = name_;
|
||||
json["ItemId"] = static_cast<double>(itemId_);
|
||||
json["Value"] = static_cast<double>(value_);
|
||||
json["GroupName"] = groupName_;
|
||||
}
|
||||
|
||||
void ItemData::load(const QJsonObject &json, const bool preserve)
|
||||
|
|
@ -58,6 +59,7 @@ void ItemData::load(const QJsonObject &json, const bool preserve)
|
|||
name_ = json["Name"].toString(name_);
|
||||
itemId_ = static_cast<uint32_t>(json["ItemId"].toDouble(0));
|
||||
value_ = json["Value"].toInt();
|
||||
groupName_ = json["GroupName"].toString("All");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,10 +101,20 @@ item_value_type_t ItemData::getValueType()
|
|||
return type_;
|
||||
}
|
||||
|
||||
QString ItemData::getGroupName() const
|
||||
{
|
||||
return groupName_;
|
||||
}
|
||||
|
||||
void ItemData::setGroupName(QString groupName)
|
||||
{
|
||||
groupName_ = groupName;
|
||||
}
|
||||
|
||||
//item
|
||||
|
||||
Item::Item(uint32_t itemIdIn, QString name, uint8_t value, QObject *parent): QObject(parent), ItemData (itemIdIn, name,
|
||||
value)
|
||||
value, false, false, ITEM_VALUE_BOOL, "All")
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -156,6 +168,7 @@ Item& Item::operator=(const ItemData& other)
|
|||
value_ = other.getValue();
|
||||
itemId_ = other.id();
|
||||
hidden_ = other.isHidden();
|
||||
groupName_ = other.getGroupName();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ protected:
|
|||
bool loaded_;
|
||||
bool hidden_;
|
||||
item_value_type_t type_;
|
||||
QString groupName_;
|
||||
|
||||
public:
|
||||
ItemData(uint32_t itemIdIn = QRandomGenerator::global()->generate(),
|
||||
|
|
@ -39,7 +40,8 @@ public:
|
|||
uint8_t value = 0,
|
||||
bool loaded = false,
|
||||
bool hidden = false,
|
||||
item_value_type_t type = ITEM_VALUE_BOOL);
|
||||
item_value_type_t type = ITEM_VALUE_BOOL,
|
||||
QString groupName = "All");
|
||||
|
||||
inline bool operator==(const ItemData& in) const
|
||||
{
|
||||
|
|
@ -61,6 +63,8 @@ public:
|
|||
bool isHidden() const;
|
||||
void setHidden(bool hidden);
|
||||
item_value_type_t getValueType();
|
||||
QString getGroupName() const;
|
||||
void setGroupName(QString groupName);
|
||||
virtual QString getName() const;
|
||||
virtual void store(QJsonObject& json);
|
||||
virtual void load(const QJsonObject& json, const bool preserve = false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue