added page to display raw config
This commit is contained in:
parent
c13b9754eb
commit
3aaa7b62ef
16 changed files with 266 additions and 30 deletions
|
@ -17,6 +17,7 @@ QHash<int, QByteArray> ProtocolsModel::roleNames() const
|
|||
|
||||
roles[ProtocolNameRole] = "protocolName";
|
||||
roles[ProtocolPageRole] = "protocolPage";
|
||||
roles[RawConfigRole] = "rawConfig";
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
@ -34,6 +35,19 @@ QVariant ProtocolsModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
case ProtocolPageRole:
|
||||
return static_cast<int>(protocolPage(ProtocolProps::protoFromString(m_content.keys().at(index.row()))));
|
||||
case RawConfigRole: {
|
||||
auto protocolConfig = m_content.value(ContainerProps::containerTypeToString(m_container)).toObject();
|
||||
auto lastConfigJsonDoc =
|
||||
QJsonDocument::fromJson(protocolConfig.value(config_key::last_config).toString().toUtf8());
|
||||
auto lastConfigJson = lastConfigJsonDoc.object();
|
||||
|
||||
QString rawConfig;
|
||||
QStringList lines = lastConfigJson.value(config_key::config).toString().replace("\r", "").split("\n");
|
||||
for (const QString &l : lines) {
|
||||
rawConfig.append(l + "\n");
|
||||
}
|
||||
return rawConfig;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
|
|
@ -13,7 +13,8 @@ class ProtocolsModel : public QAbstractListModel
|
|||
public:
|
||||
enum Roles {
|
||||
ProtocolNameRole = Qt::UserRole + 1,
|
||||
ProtocolPageRole
|
||||
ProtocolPageRole,
|
||||
RawConfigRole
|
||||
};
|
||||
|
||||
ProtocolsModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue