diff --git a/source/Genus/CheckableItem.cpp b/source/Genus/CheckableItem.cpp index 9d67826..9056a4b 100644 --- a/source/Genus/CheckableItem.cpp +++ b/source/Genus/CheckableItem.cpp @@ -1,42 +1,42 @@ #include "CheckableItem.h" CheckableItem::CheckableItem(const std::string &text) - : m_text(text) + : m_text(text) { } std::string CheckableItem::getText() const { - return m_text; + return m_text; } bool CheckableItem::isChecked() const { - return m_checked; + return m_checked; } void CheckableItem::setState(bool checked) { - m_checked = checked; + m_checked = checked; } void CheckableItem::write(QJsonObject &json) const { - json["text"] = m_text.c_str(); - json["checked"] = m_checked; + json["text"] = m_text.c_str(); + json["checked"] = m_checked; } void CheckableItem::read(const QJsonObject &json) { - const auto &text = json["text"]; - if (text.isString()) - { - m_text = text.toString().toStdString(); - } + const auto &text = json["text"]; + if (text.isString()) + { + m_text = text.toString().toStdString(); + } - const auto &checked = json["checked"]; - if (checked.isBool()) - { - m_checked = checked.toBool(); - } + const auto &checked = json["checked"]; + if (checked.isBool()) + { + m_checked = checked.toBool(); + } } diff --git a/source/Genus/CheckableItem.h b/source/Genus/CheckableItem.h index f097bdf..912ca14 100644 --- a/source/Genus/CheckableItem.h +++ b/source/Genus/CheckableItem.h @@ -7,17 +7,17 @@ class CheckableItem { private: - bool m_checked = false; - std::string m_text; + bool m_checked = false; + std::string m_text; public: - CheckableItem() = default; - CheckableItem(const std::string &text); + CheckableItem() = default; + CheckableItem(const std::string &text); - std::string getText() const; - bool isChecked() const; - void setState(bool checked); + std::string getText() const; + bool isChecked() const; + void setState(bool checked); - void write(QJsonObject &json) const; - void read(const QJsonObject &json); + void write(QJsonObject &json) const; + void read(const QJsonObject &json); }; diff --git a/source/Genus/CheckableItems.cpp b/source/Genus/CheckableItems.cpp index c3348a2..30532f3 100644 --- a/source/Genus/CheckableItems.cpp +++ b/source/Genus/CheckableItems.cpp @@ -4,33 +4,33 @@ CheckableItems::CheckableItems(std::initializer_list itemNames) { - for (const auto &itemName : itemNames) - { - emplace_back(itemName); - } + for (const auto &itemName : itemNames) + { + emplace_back(itemName); + } } void CheckableItems::write(QJsonArray &json) const { - for (const auto &item : *this) - { - QJsonObject itemObject; - item.write(itemObject); - json.append(itemObject); - } + for (const auto &item : *this) + { + QJsonObject itemObject; + item.write(itemObject); + json.append(itemObject); + } } void CheckableItems::read(const QJsonArray &json) { - clear(); + clear(); - for (const auto &itemObject : json) - { - if (itemObject.isObject()) - { - CheckableItem item; - item.read(itemObject.toObject()); - emplace_back(item); - } - } + for (const auto &itemObject : json) + { + if (itemObject.isObject()) + { + CheckableItem item; + item.read(itemObject.toObject()); + emplace_back(item); + } + } } diff --git a/source/Genus/CheckableItems.h b/source/Genus/CheckableItems.h index 2a1a77d..164f829 100644 --- a/source/Genus/CheckableItems.h +++ b/source/Genus/CheckableItems.h @@ -3,13 +3,13 @@ #include "CheckableItem.h" #include -#include +#include class CheckableItems : public std::vector { public: - CheckableItems(std::initializer_list itemNames); + CheckableItems(std::initializer_list itemNames); - void write(QJsonArray &json) const; - void read(const QJsonArray &json); + void write(QJsonArray &json) const; + void read(const QJsonArray &json); }; diff --git a/source/Genus/GenusModel.cpp b/source/Genus/GenusModel.cpp index 229ea31..7d2321e 100644 --- a/source/Genus/GenusModel.cpp +++ b/source/Genus/GenusModel.cpp @@ -105,35 +105,35 @@ QVariant GenusModel::headerData( void GenusModel::write(QJsonObject &json) const { - QJsonArray tiere; + QJsonArray tiere; m_tiere.write(tiere); json["Tiere"] = tiere; - QJsonArray futter; + QJsonArray futter; m_futter.write(futter); json["Futter"] = futter; - QJsonArray zirkus; + QJsonArray zirkus; m_zirkus.write(zirkus); json["Zirkus"] = zirkus; } void GenusModel::read(const QJsonObject &json) { - if (json["Tiere"].isArray()) - { - m_tiere.read(json["Tiere"].toArray()); - } + if (json["Tiere"].isArray()) + { + m_tiere.read(json["Tiere"].toArray()); + } - if (json["Futter"].isArray()) - { - m_futter.read(json["Futter"].toArray()); - } + if (json["Futter"].isArray()) + { + m_futter.read(json["Futter"].toArray()); + } - if (json["Zirkus"].isArray()) - { - m_zirkus.read(json["Zirkus"].toArray()); - } + if (json["Zirkus"].isArray()) + { + m_zirkus.read(json["Zirkus"].toArray()); + } } bool GenusModel::isValidIndex(const QModelIndex &index) const @@ -141,11 +141,11 @@ bool GenusModel::isValidIndex(const QModelIndex &index) const switch (index.row()) { case 0: - return index.column() < m_tiere.size(); + return index.column() < m_tiere.size(); case 1: - return index.column() < m_futter.size(); + return index.column() < m_futter.size(); case 2: - return index.column() < m_zirkus.size(); + return index.column() < m_zirkus.size(); default: return false; } @@ -188,21 +188,21 @@ const CheckableItems &GenusModel::getItems(const QModelIndex &index) const CheckableItem &GenusModel::getItem(const QModelIndex &index) { auto &items = getItems(index); - if (index.column() < items.size()) - { - return items.at(index.column()); - } + if (index.column() < items.size()) + { + return items.at(index.column()); + } throw std::runtime_error("invalid index"); } const CheckableItem &GenusModel::getItem(const QModelIndex &index) const { - auto &items = getItems(index); - if (index.column() < items.size()) - { - return items.at(index.column()); - } + auto &items = getItems(index); + if (index.column() < items.size()) + { + return items.at(index.column()); + } throw std::runtime_error("invalid index"); } diff --git a/source/Genus/GenusModel.h b/source/Genus/GenusModel.h index 436f2a3..54b1d4c 100644 --- a/source/Genus/GenusModel.h +++ b/source/Genus/GenusModel.h @@ -10,9 +10,11 @@ class GenusModel : public QAbstractTableModel Q_OBJECT private: - CheckableItems m_tiere = { "Tiger", "Bär", "Katze", "Pferd", "Gans", "Elefant", "Katze", "Hund" }; - CheckableItems m_futter = { "Salat", "Fleisch", "Knocken", "Banane", "Apfel", "Möhre", "Honig", "Zucker" }; - CheckableItems m_zirkus = { "Kiste", "Holz", "Vorhang", "Baum" }; + CheckableItems m_tiere = { + "Tiger", "Bär", "Katze", "Pferd", "Gans", "Elefant", "Katze", "Hund"}; + CheckableItems m_futter = {"Salat", "Fleisch", "Knocken", "Banane", "Apfel", + "Möhre", "Honig", "Zucker"}; + CheckableItems m_zirkus = {"Kiste", "Holz", "Vorhang", "Baum"}; public: GenusModel(QObject *parent); diff --git a/source/Genus/GenusWidget.cpp b/source/Genus/GenusWidget.cpp index 41faea5..4141cb0 100644 --- a/source/Genus/GenusWidget.cpp +++ b/source/Genus/GenusWidget.cpp @@ -9,15 +9,15 @@ GenusWidget::GenusWidget(QWidget *parent) { ui->setupUi(this); - ui->genusTableView->horizontalHeader()->hide(); + ui->genusTableView->horizontalHeader()->hide(); } GenusWidget::~GenusWidget() { - delete ui; + delete ui; } void GenusWidget::setModel(GenusModel *model) { - ui->genusTableView->setModel(model); + ui->genusTableView->setModel(model); } diff --git a/source/Genus/GenusWidget.h b/source/Genus/GenusWidget.h index b8ae706..ab6ea95 100644 --- a/source/Genus/GenusWidget.h +++ b/source/Genus/GenusWidget.h @@ -19,5 +19,5 @@ public: GenusWidget(QWidget *parent = nullptr); ~GenusWidget(); - void setModel(GenusModel *model); + void setModel(GenusModel *model); };