Commit 4128b5ca authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

change terminology: use menu and not nature

parent 740803d2
......@@ -34,7 +34,7 @@ public:
void parseParameter(dtkWidgetsMenu *, const QJsonObject&);
public:
QJsonArray nature;
QJsonArray menu;
QJsonObject definition;
public:
......@@ -97,21 +97,21 @@ void dtkWidgetsParameterMenuBarGeneratorPrivate::parseGroup(T* menu, const QJson
// dtkWidgetsParameterMenuBarGenerator implementation
// ///////////////////////////////////////////////////////////////////
dtkWidgetsParameterMenuBarGenerator::dtkWidgetsParameterMenuBarGenerator(const QString& nature_file_path, const QString& definition_file_path) : d(new dtkWidgetsParameterMenuBarGeneratorPrivate)
dtkWidgetsParameterMenuBarGenerator::dtkWidgetsParameterMenuBarGenerator(const QString& menu_file_path, const QString& definition_file_path) : d(new dtkWidgetsParameterMenuBarGeneratorPrivate)
{
QFile nature_file(nature_file_path);
QFile menu_file(menu_file_path);
QFile definition_file(definition_file_path);
if (nature_file.open(QFile::ReadOnly) && definition_file.open(QFile::ReadOnly)) {
QJsonParseError nature_error;
QJsonDocument nature_document = QJsonDocument::fromJson(nature_file.readAll(), &nature_error);
if(nature_error.error != QJsonParseError::NoError) {
qWarning() << Q_FUNC_INFO << "Error :" << nature_error.errorString() << "parsing" << nature_file_path << "offset :" << nature_error.offset << ".";
if (menu_file.open(QFile::ReadOnly) && definition_file.open(QFile::ReadOnly)) {
QJsonParseError menu_error;
QJsonDocument menu_document = QJsonDocument::fromJson(menu_file.readAll(), &menu_error);
if(menu_error.error != QJsonParseError::NoError) {
qWarning() << Q_FUNC_INFO << "Error :" << menu_error.errorString() << "parsing" << menu_file_path << "offset :" << menu_error.offset << ".";
return;
}
QJsonObject nature_object = nature_document.object();
if(!nature_object.contains("contents")) {
qWarning() << Q_FUNC_INFO << "The nature parameters file should contain a first json object with key 'contents'. The file cannot be processed any further.";
QJsonObject menu_object = menu_document.object();
if(!menu_object.contains("contents")) {
qWarning() << Q_FUNC_INFO << "The menu parameters file should contain a first json object with key 'contents'. The file cannot be processed any further.";
return;
}
......@@ -124,20 +124,20 @@ dtkWidgetsParameterMenuBarGenerator::dtkWidgetsParameterMenuBarGenerator(const Q
QJsonObject definition_object = definition_document.object();
if(!definition_object.contains("contents")) {
qWarning() << Q_FUNC_INFO << "The nature parameters file should contain a first json object with key 'contents'. The file cannot be processed any further.";
qWarning() << Q_FUNC_INFO << "The menu parameters file should contain a first json object with key 'contents'. The file cannot be processed any further.";
return;
}
QJsonValue nature_contents = nature_object["contents"];
QJsonValue menu_contents = menu_object["contents"];
QJsonValue definition_contents = definition_object["contents"];
if (nature_contents.isArray() && definition_contents.isObject()) {
d->nature = nature_contents.toArray();
if (menu_contents.isArray() && definition_contents.isObject()) {
d->menu = menu_contents.toArray();
d->definition = definition_contents.toObject();
} else {
qWarning() << Q_FUNC_INFO << "The first object with key 'contents' must be an array.";
}
} else {
qWarning() << Q_FUNC_INFO << "The file" << nature_file_path << "could not be opened.";
qWarning() << Q_FUNC_INFO << "The file" << menu_file_path << "could not be opened.";
}
}
......@@ -148,7 +148,7 @@ dtkWidgetsParameterMenuBarGenerator::~dtkWidgetsParameterMenuBarGenerator(void)
void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenuBar *menubar)
{
for(auto it = d->nature.begin(); it != d->nature.end(); ++it) {
for(auto it = d->menu.begin(); it != d->menu.end(); ++it) {
if(it->isObject()) {
QJsonObject content_object = it->toObject();
if(content_object.contains("group")) {
......
......@@ -29,7 +29,7 @@ class dtkWidgetsParameter;
class DTKWIDGETS_EXPORT dtkWidgetsParameterMenuBarGenerator
{
public:
dtkWidgetsParameterMenuBarGenerator(const QString&, const QString&);
dtkWidgetsParameterMenuBarGenerator(const QString& menu_file, const QString& definition_file);
~dtkWidgetsParameterMenuBarGenerator(void);
public:
......
{
"contents": [
{"uid" : "hyp", "label": "hyp", "doc": "documentation", "default_value": 2, "bound_min": 0, "bound_max": 5},
{"uid" : "dif", "label": "dif", "doc": "documentation", "default_value": false},
{"uid" : "res", "label": "res", "doc": "documentation", "default_value": false},
{"uid" : "prec", "label": "prec", "doc": "documentation", "default_value": false},
{"uid" : "inf", "label": "inf", "doc": "documentation", "default_value": false},
{"uid" : "wind", "label": "wind", "doc": "documentation", "default_value": false},
]
}
{
"contents": [
{ "group": {"uid" : "Model parameters", "icon": "fa::cogs", "advanced": false,
"contents": [
{"parameter": {"uid": "hyp", "type": "dtk::d_int", "widget": "dtkWidgetsParameterIntSpinBox", "advanced": false}},
{"parameter": {"uid": "dif", "type": "dtk::d_bool", "widget": "dtkWidgetsParameterBoolCheckBox", "advanced": false}},
{"parameter": {"uid": "res", "type": "dtk::d_bool", "widget": "dtkWidgetsParameterBoolCheckBox", "advanced": false}},
{"parameter": {"uid": "prec", "type": "dtk::d_bool", "widget": "dtkWidgetsParameterBoolCheckBox", "advanced": false}},
{"parameter": {"uid": "inf", "type": "dtk::d_bool", "widget": "dtkWidgetsParameterBoolCheckBox", "advanced": false}},
{"parameter": {"uid": "wind", "type": "dtk::d_bool", "widget": "dtkWidgetsParameterBoolCheckBox", "advanced": false}}
]
} }
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment