X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetFactory.cpp;h=c9561a13ba458fddc63d95e139bcaa1c7bc18fb1;hb=cdc2caa21375bc96aaad9bb7c3ee1140dac1d738;hp=25f3c1979f87c9ecbfb1ddf35c780104317705a8;hpb=2734393c7c19899fca7e7c36577b31317887a9c9;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 25f3c1979..c9561a13b 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -11,14 +11,11 @@ #include #include -//#include -//#include #include #include #include #include #include -//#include #include #include #include @@ -31,6 +28,7 @@ #include #include #include +#include #include #include @@ -73,26 +71,19 @@ void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage) if (!myWidgetApi->toChildWidget()) return; - //bool isStretchLayout = false; - QWidget* aPageWidget = dynamic_cast(thePage); - if(!aPageWidget) { - #ifdef _DEBUG - std::cout << "ModuleBase_WidgetFactory::createWidget: can not reinterpret_cast thePage" << std::endl; - #endif - } do { //Iterate over each node std::string aWdgType = myWidgetApi->widgetType(); // Create PageGroup TODO: extract if (myWidgetApi->isGroupBoxWidget()) { //if current widget is groupbox (container) process it's children recursively QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)); - ModuleBase_PageGroupBox* aPage = new ModuleBase_PageGroupBox(aPageWidget); + ModuleBase_PageGroupBox* aPage = new ModuleBase_PageGroupBox(thePage->pageWidget()); aPage->setTitle(aGroupName); createWidget(aPage); thePage->addPageWidget(aPage); } else { // Create a ModelWidget - ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, aPageWidget); + ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, thePage->pageWidget()); if (aWidget) { if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) { thePage->addModelWidget(aWidget); @@ -110,92 +101,57 @@ void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage) QString aCaseId = qs(myWidgetApi->getProperty(_ID)); ModuleBase_PageBase* aPage = new ModuleBase_PageWidget(aWidget); createWidget(aPage); - QWidget* aCasePageWidget = dynamic_cast(aPage); - if (aWdgType == WDG_SWITCH) { - ModuleBase_WidgetSwitch* aSwitch = qobject_cast(aWidget); - aSwitch->addPage(aCasePageWidget, aPageName); - } else if (aWdgType == WDG_TOOLBOX) { - ModuleBase_WidgetToolbox* aToolbox = qobject_cast(aWidget); - aToolbox->addPage(aCasePageWidget, aPageName, aCaseId); + if (aWdgType == WDG_SWITCH || aWdgType == WDG_TOOLBOX) { + ModuleBase_PagedContainer* aContainer = qobject_cast(aWidget); + aContainer->addPage(aPage, aPageName, aCaseId); } } while (myWidgetApi->toNextWidget()); } } -// if (aWidget && !isStretchLayout) { -// isStretchLayout = !hasExpandingControls(aWidget); -// } } while (myWidgetApi->toNextWidget()); -// if (isStretchLayout) { -// aWidgetLay->addStretch(1); -// } -} -bool ModuleBase_WidgetFactory::hasExpandingControls(QWidget* theParent) -{ - bool result = false; - QList aListToCheck; - aListToCheck << theParent; - ModuleBase_ModelWidget* aModelWidget = qobject_cast(theParent); - if(aModelWidget) { - aListToCheck << aModelWidget->getControls(); - } - foreach(QWidget* eachWidget, aListToCheck) { - QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy(); - if(aVPolicy & QSizePolicy::ExpandFlag) { - result = true; - } - } - return result; + thePage->alignToTop(); } -ModuleBase_ModelWidget* ModuleBase_WidgetFactory -::createWidgetByType(const std::string& theType, QWidget* theParent) +ModuleBase_ModelWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType, + QWidget* theParent) { ModuleBase_ModelWidget* result = NULL; if (theType == WDG_INFO) { result = new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId); - } else if (theType == WDG_DOUBLEVALUE) { result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId); - } else if (theType == WDG_SHAPE_SELECTOR) { - result = new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId); - + result = new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId); } else if (theType == WDG_BOOLVALUE) { result = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId); - - } else if (theType == WDG_DOUBLEVALUE_EDITOR) { - result = new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId); - + //} else if (theType == WDG_DOUBLEVALUE_EDITOR) { + // result = new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId); } else if (theType == WDG_FILE_SELECTOR) { result = new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId); - } else if (theType == WDG_CHOICE) { - result = new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId); - + result = new ModuleBase_WidgetChoice(theParent, myWidgetApi, myParentId); } else if (theType == WDG_STRINGVALUE) { - result = new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId); - + result = new ModuleBase_WidgetLineEdit(theParent, myWidgetApi, myParentId); + } else if (theType == WDG_EXPR_EDITOR) { + result = new ModuleBase_WidgetExprEditor(theParent, myWidgetApi, myParentId); } else if (theType == WDG_MULTISELECTOR) { - result = new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi,myParentId); - + result = new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi, myParentId); } else if (theType == WDG_TOOLBOX) { result = new ModuleBase_WidgetToolbox(theParent, myWidgetApi, myParentId); - } else if (theType == WDG_SWITCH) { result = new ModuleBase_WidgetSwitch(theParent, myWidgetApi, myParentId); - return result; - } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) { // Do nothing for "box" and "case" result = NULL; } else { - result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi, - myParentId); -#ifdef _DEBUG - if (!result) {qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type");} -#endif + result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi, myParentId); + #ifdef _DEBUG + if (!result) { + qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type"); + } + #endif } if (result) { myModelWidgets.append(result);