added value to CheckableItem, implemented exclusive checking in PassivModel

This commit is contained in:
Michael Mandl 2018-06-29 19:31:28 +02:00
parent 0a1eea0fe2
commit 02eaa7be16
6 changed files with 55 additions and 9 deletions

View file

@ -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();

View file

@ -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);
};