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);
44 /// Creates one widget for property panel for the widget with given index
45 /// \param theParent a parent widget
46 /// \param theWidgetId a widget index
47 void createWidget(ModuleBase_PageBase* thePage,
48 const std::string& theWidgetId);
50 /// Returns list of model widgets
51 QList<ModuleBase_ModelWidget*> getModelWidgets() const
53 return myModelWidgets;
56 /// Returns the value of the title key from XML definition of the attribute in the feature
57 /// \param theFeatureKind a value of a kind of a feature
58 /// \param theAttributeId a value of a kind of the attribute under the feature
59 /// \param theTitle the result title
60 void getAttributeTitle(const std::string& theFeatureKind,
61 const std::string& theAttributeId,
62 std::string& theTitle);
65 /// check if ModuleBase_Widget has expandable widgets in getControls
66 bool hasExpandingControls(QWidget* theParent);
68 /// Create page by its type
69 /// \param theType a type
70 /// \param theParent a parent widget
71 ModuleBase_PageBase* createPageByType(const std::string& theType,
74 /// Create widget by its type
75 /// \param theType a type
76 /// \param theParent a parent widget
77 ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
78 QWidget* theParent = NULL);
80 /// Convert STD string to QT string
81 /// \param theStdString is STD string
82 static QString qs(const std::string& theStdString);
84 /// It updates internal config api to point in the structure to given id of widget
85 /// The method is recusive and it stops when the found flag is true
86 /// \param theWidgetId a widget id key value
87 /// \param theFound a flag about found windget and recursive search should be stopped
88 void moveToWidgetId(const std::string& theWidgetId, bool& theFound);
91 /// API object for XML reading
92 Config_WidgetAPI* myWidgetApi;
94 /// Reference to workshop
95 ModuleBase_IWorkshop* myWorkshop;
97 /// List of created model widgets
98 QList<ModuleBase_ModelWidget*> myModelWidgets;
100 /// Id of current parent
101 std::string myParentId;
104 #endif /* ModuleBase_WidgetFactory_H_ */