Commit 0378e40e authored by CABEL Tristan's avatar CABEL Tristan

add method to generator to fill a dtkWidgetsMenu

parent 481b40e7
...@@ -127,6 +127,24 @@ dtkWidgetsParameterMenuBarGenerator::~dtkWidgetsParameterMenuBarGenerator(void) ...@@ -127,6 +127,24 @@ dtkWidgetsParameterMenuBarGenerator::~dtkWidgetsParameterMenuBarGenerator(void)
delete d; delete d;
} }
void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenu *menu_to_fill)
{
for(auto it = d->menu.begin(); it != d->menu.end(); ++it) {
if(it->isObject()) {
QJsonObject content_object = it->toObject();
if(content_object.contains("group")) {
QJsonObject group_object = content_object["group"].toObject();
d->parseGroup(menu_to_fill, group_object);
} else {
qWarning() << Q_FUNC_INFO << "'contents' sections are expected to contain objects only. Non object entry is ignored.";
}
} else {
qWarning() << Q_FUNC_INFO << "'contents' sections are expected to contain objects only. Non object entry is ignored.";
}
}
}
void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenuBar *menubar) void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenuBar *menubar)
{ {
for(auto it = d->menu.begin(); it != d->menu.end(); ++it) { for(auto it = d->menu.begin(); it != d->menu.end(); ++it) {
...@@ -147,7 +165,7 @@ void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenuBar *menubar) ...@@ -147,7 +165,7 @@ void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenuBar *menubar)
void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenuBarContainer *container) void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenuBarContainer *container)
{ {
dtkWidgetsMenuBar *dummy = new dtkWidgetsMenuBar; dtkWidgetsMenuBar *dummy = new dtkWidgetsMenuBar;
for(auto it = d->menu.begin(); it != d->menu.end(); ++it) { for(auto it = d->menu.begin(); it != d->menu.end(); ++it) {
if(it->isObject()) { if(it->isObject()) {
QJsonObject content_object = it->toObject(); QJsonObject content_object = it->toObject();
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <QtCore> #include <QtCore>
class dtkWidgetsMenu;
class dtkWidgetsMenuBar; class dtkWidgetsMenuBar;
class dtkWidgetsMenuBarContainer; class dtkWidgetsMenuBarContainer;
class dtkCoreParameter; class dtkCoreParameter;
...@@ -35,6 +36,7 @@ public: ...@@ -35,6 +36,7 @@ public:
~dtkWidgetsParameterMenuBarGenerator(void); ~dtkWidgetsParameterMenuBarGenerator(void);
public: public:
void populate(dtkWidgetsMenu *);
void populate(dtkWidgetsMenuBar *); void populate(dtkWidgetsMenuBar *);
void populate(dtkWidgetsMenuBarContainer *); void populate(dtkWidgetsMenuBarContainer *);
......
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