+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());
+}
+
+ModuleBase_PageBase* ModuleBase_WidgetFactory::createPageByType(const std::string& theType,
+ QWidget* theParent)
+{
+ ModuleBase_PageBase* aResult = NULL;
+
+ if (theType == WDG_GROUP) {
+ QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
+ ModuleBase_PageGroupBox* aPage = new ModuleBase_PageGroupBox(theParent);
+ aPage->setTitle(ModuleBase_Tools::translate(
+ myWidgetApi->myFeatureId, aGroupName.toStdString()));
+ aResult = aPage;
+ }
+ else if (theType == WDG_OPTIONALBOX) {
+ ModuleBase_WidgetOptionalBox* aPage = new ModuleBase_WidgetOptionalBox(theParent,
+ myWidgetApi);
+ aResult = aPage;
+ }
+ if (!aResult)
+ aResult = ModuleBase_WidgetCreatorFactory::get()->createPageByType(theType, theParent,
+ myWidgetApi);
+
+ ModuleBase_ModelWidget* aWidget = dynamic_cast<ModuleBase_ModelWidget*>(aResult);
+ if (aWidget)
+ myModelWidgets.append(aWidget);
+
+ return aResult;
+}
+