added value to CheckableItem, implemented exclusive checking in PassivModel
This commit is contained in:
parent
0a1eea0fe2
commit
02eaa7be16
6 changed files with 55 additions and 9 deletions
|
@ -20,6 +20,21 @@ void CheckableItem::setState(bool checked)
|
|||
m_checked = checked;
|
||||
}
|
||||
|
||||
unsigned int CheckableItem::value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void CheckableItem::setValue(unsigned int value)
|
||||
{
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
unsigned int CheckableItem::points() const
|
||||
{
|
||||
return m_checked ? m_value : 0;
|
||||
}
|
||||
|
||||
void CheckableItem::write(QJsonObject &json) const
|
||||
{
|
||||
json["text"] = m_text.c_str();
|
||||
|
|
|
@ -9,15 +9,22 @@ class CheckableItem
|
|||
private:
|
||||
bool m_checked = false;
|
||||
std::string m_text;
|
||||
unsigned int m_value = 1;
|
||||
|
||||
public:
|
||||
CheckableItem() = default;
|
||||
CheckableItem(const std::string &text);
|
||||
|
||||
std::string getText() const;
|
||||
|
||||
bool isChecked() const;
|
||||
void setState(bool checked);
|
||||
|
||||
unsigned int value() const;
|
||||
void setValue(unsigned int value);
|
||||
|
||||
unsigned int points() const;
|
||||
|
||||
void write(QJsonObject &json) const;
|
||||
void read(const QJsonObject &json);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue