diff --git a/src/items/item.cpp b/src/items/item.cpp index 7f350a2..98e2a1b 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -13,8 +13,8 @@ #include -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(itemId_); json["Value"] = static_cast(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(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; } diff --git a/src/items/item.h b/src/items/item.h index d461006..1156933 100644 --- a/src/items/item.h +++ b/src/items/item.h @@ -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);