+void ModuleBase_WidgetFactory::getAttributeTitle(const std::string& theAttributeId,
+ std::string& theTitle)
+{
+ bool aFound = false;
+ moveToWidgetId(theAttributeId, aFound);
+ if (aFound) {
+ theTitle = QString::fromStdString(myWidgetApi->widgetLabel()).toStdString().c_str();
+ if (theTitle.empty())
+ theTitle =
+ QString::fromStdString(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)).toStdString().c_str();
+ }
+}
+
+void ModuleBase_WidgetFactory::getGreedAttribute(std::string& theAttributeId)
+{
+ if (!theAttributeId.empty())
+ return;
+
+ if (!myWidgetApi->toChildWidget())
+ return;
+
+ do { //Iterate over each node
+ std::string aWdgType = myWidgetApi->widgetType();
+ // Find title under PageGroup
+ if (myWidgetApi->isGroupBoxWidget() ||
+ ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {
+ getGreedAttribute(theAttributeId);
+ }
+ else {
+ // Find title here
+ std::string anAttributeId = myWidgetApi->widgetId();
+ if (myWidgetApi->getBooleanAttribute(ATTR_GREED, false))
+ theAttributeId = anAttributeId;
+ if (theAttributeId.empty() && myWidgetApi->isPagedWidget()) {
+ //If current widget is toolbox or switch-casebox then fetch all
+ //it's pages recursively and setup into the widget.
+ if (myWidgetApi->toChildWidget()) {
+ do {
+ getGreedAttribute(theAttributeId);
+ } while (theAttributeId.empty() && myWidgetApi->toNextWidget());
+ }
+ }
+ }
+ } while (theAttributeId.empty() && myWidgetApi->toNextWidget());
+}
+
+void ModuleBase_WidgetFactory::moveToWidgetId(const std::string& theWidgetId, bool& theFound)
+{
+ if (theFound)
+ return;
+
+ if (!myWidgetApi->toChildWidget())
+ return;
+
+ do { //Iterate over each node
+ std::string aWdgType = myWidgetApi->widgetType();
+ // Find title under PageGroup
+ if (myWidgetApi->isGroupBoxWidget() ||
+ ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {
+ moveToWidgetId(theWidgetId, theFound);
+ }
+ else {
+ // Find title here
+ std::string anAttributeId = myWidgetApi->widgetId();
+ theFound = anAttributeId == theWidgetId;
+ if (!theFound && myWidgetApi->isPagedWidget()) {
+ //If current widget is toolbox or switch-casebox then fetch all
+ //it's pages recursively and setup into the widget.
+ if (myWidgetApi->toChildWidget()) {
+ do {
+ moveToWidgetId(theWidgetId, theFound);
+ } while (!theFound && myWidgetApi->toNextWidget());
+ }
+ }
+ }
+ } while (!theFound && myWidgetApi->toNextWidget());
+}
+