added verb-end test
This commit is contained in:
parent
498abc873e
commit
8452054746
17 changed files with 393 additions and 6 deletions
|
@ -13,9 +13,9 @@ qt5_wrap_ui(UI_HEADERS
|
|||
add_library(${PROJECT_NAME}
|
||||
GenusWidget.cpp
|
||||
GenusModel.cpp
|
||||
CheckableItem.cpp
|
||||
CheckableItems.cpp
|
||||
${UI_HEADERS}
|
||||
../CheckableItem.cpp
|
||||
../CheckableItems.cpp
|
||||
${UI_HEADERS}
|
||||
)
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
#include "CheckableItem.h"
|
||||
|
||||
CheckableItem::CheckableItem(const std::string &text)
|
||||
: m_text(text)
|
||||
{
|
||||
}
|
||||
|
||||
std::string CheckableItem::getText() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
bool CheckableItem::isChecked() const
|
||||
{
|
||||
return m_checked;
|
||||
}
|
||||
|
||||
void CheckableItem::setState(bool checked)
|
||||
{
|
||||
m_checked = checked;
|
||||
}
|
||||
|
||||
void CheckableItem::write(QJsonObject &json) const
|
||||
{
|
||||
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 &checked = json["checked"];
|
||||
if (checked.isBool())
|
||||
{
|
||||
m_checked = checked.toBool();
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
#include <string>
|
||||
|
||||
class CheckableItem
|
||||
{
|
||||
private:
|
||||
bool m_checked = false;
|
||||
std::string m_text;
|
||||
|
||||
public:
|
||||
CheckableItem() = default;
|
||||
CheckableItem(const std::string &text);
|
||||
|
||||
std::string getText() const;
|
||||
bool isChecked() const;
|
||||
void setState(bool checked);
|
||||
|
||||
void write(QJsonObject &json) const;
|
||||
void read(const QJsonObject &json);
|
||||
};
|
|
@ -1,36 +0,0 @@
|
|||
#include "CheckableItems.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
CheckableItems::CheckableItems(std::initializer_list<std::string> itemNames)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckableItems::read(const QJsonArray &json)
|
||||
{
|
||||
clear();
|
||||
|
||||
for (const auto &itemObject : json)
|
||||
{
|
||||
if (itemObject.isObject())
|
||||
{
|
||||
CheckableItem item;
|
||||
item.read(itemObject.toObject());
|
||||
emplace_back(item);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "CheckableItem.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <vector>
|
||||
|
||||
class CheckableItems : public std::vector<CheckableItem>
|
||||
{
|
||||
public:
|
||||
CheckableItems(std::initializer_list<std::string> itemNames);
|
||||
|
||||
void write(QJsonArray &json) const;
|
||||
void read(const QJsonArray &json);
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "CheckableItem.h"
|
||||
#include "CheckableItems.h"
|
||||
#include "../CheckableItem.h"
|
||||
#include "../CheckableItems.h"
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue