1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * ModuleBase_WidgetFactory.h
6 * Created on: Apr 3, 2014
10 #ifndef MODULEBASE_WIDGETFACTORY_H_
11 #define MODULEBASE_WIDGETFACTORY_H_
13 #include <ModuleBase.h>
14 #include <ModuleBase_ModelWidget.h>
21 class Config_WidgetAPI;
22 class ModuleBase_IWorkshop;
23 class ModuleBase_PageBase;
27 * A class for creation of widgets instances in for property panel using XML deskription of
30 class MODULEBASE_EXPORT ModuleBase_WidgetFactory
34 /// \param theXmlRepresentation content of XML file
35 /// \param theWorkshop reference to workshop instance
36 ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,
37 ModuleBase_IWorkshop* theWorkshop);
38 virtual ~ModuleBase_WidgetFactory();
40 /// Creates content widget for property panel
41 /// \param thePage a parent page
42 void createWidget(ModuleBase_PageBase* thePage, bool alignToTop = true);
44 /// Creates property panel content for the feature
45 /// \param thePage a parent page
46 /// \param theFeature a feature to fill the panel
47 void createPanel(ModuleBase_PageBase* thePage, const FeaturePtr& theFeature);
49 /// Creates one widget for property panel for the widget with given index
50 /// \param theParent a parent widget
51 /// \param theWidgetId a widget index
52 void createWidget(ModuleBase_PageBase* thePage,
53 const std::string& theWidgetId);
55 /// Returns list of model widgets
56 QList<ModuleBase_ModelWidget*> getModelWidgets() const
58 return myModelWidgets;
61 /// Returns the value of the title key from XML definition of the attribute in the feature
62 /// \param theAttributeId a value of a kind of the attribute under the feature
63 /// \param theTitle the result title
64 void getAttributeTitle(const std::string& theAttributeId,
65 std::string& theTitle);
67 /// Returns the identifier of the first found attribute where greed field value is set and true
68 /// \param theAttributeId an outpup parameter with attribute
69 void getGreedAttribute(std::string& theAttributeId);
71 /// Returns widget API from XML
72 const Config_WidgetAPI* widgetAPI() const { return myWidgetApi; }
75 /// check if ModuleBase_Widget has expandable widgets in getControls
76 bool hasExpandingControls(QWidget* theParent);
78 /// Create page by its type
79 /// \param theType a type
80 /// \param theParent a parent widget
81 ModuleBase_PageBase* createPageByType(const std::string& theType,
84 /// Create widget by its type
85 /// \param theType a type
86 /// \param theParent a parent widget
87 ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
88 QWidget* theParent = NULL);
90 /// Convert STD string to QT string
91 /// \param theStdString is STD string
92 static QString qs(const std::string& theStdString);
94 /// It updates internal config api to point in the structure to given id of widget
95 /// The method is recusive and it stops when the found flag is true
96 /// \param theWidgetId a widget id key value
97 /// \param theFound a flag about found windget and recursive search should be stopped
98 void moveToWidgetId(const std::string& theWidgetId, bool& theFound);
101 /// API object for XML reading
102 Config_WidgetAPI* myWidgetApi;
104 /// Reference to workshop
105 ModuleBase_IWorkshop* myWorkshop;
107 /// List of created model widgets
108 QList<ModuleBase_ModelWidget*> myModelWidgets;
111 #endif /* ModuleBase_WidgetFactory_H_ */