This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
ESGRAF48/source/CheckableItem/CheckableItem.cpp

43 lines
677 B
C++
Raw Normal View History

#include "CheckableItem.h"
CheckableItem::CheckableItem(const std::string &text)
2018-05-23 15:47:04 +00:00
: m_text(text)
{
}
std::string CheckableItem::getText() const
{
2018-05-23 15:47:04 +00:00
return m_text;
}
bool CheckableItem::isChecked() const
{
2018-05-23 15:47:04 +00:00
return m_checked;
}
void CheckableItem::setState(bool checked)
{
2018-05-23 15:47:04 +00:00
m_checked = checked;
}
2018-05-23 09:08:50 +00:00
void CheckableItem::write(QJsonObject &json) const
{
2018-05-23 15:47:04 +00:00
json["text"] = m_text.c_str();
json["checked"] = m_checked;
2018-05-23 09:08:50 +00:00
}
void CheckableItem::read(const QJsonObject &json)
{
2018-05-23 15:47:04 +00:00
const auto &text = json["text"];
if (text.isString())
{
m_text = text.toString().toStdString();
}
2018-05-23 09:08:50 +00:00
2018-05-23 15:47:04 +00:00
const auto &checked = json["checked"];
if (checked.isBool())
{
m_checked = checked.toBool();
}
2018-05-23 09:08:50 +00:00
}