SHAPER  9.12.0
ModuleBase_WidgetFactory.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef MODULEBASE_WIDGETFACTORY_H_
21 #define MODULEBASE_WIDGETFACTORY_H_
22 
23 #include <ModuleBase.h>
24 #include <ModuleBase_ModelWidget.h>
25 
26 #include <QString>
27 #include <QList>
28 
29 class QObject;
30 class QWidget;
31 class Config_WidgetAPI;
34 
40 class MODULEBASE_EXPORT ModuleBase_WidgetFactory
41 {
42  public:
47  ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,
48  ModuleBase_IWorkshop* theWorkshop,
49  const std::string theAttributePrefix = "");
50  virtual ~ModuleBase_WidgetFactory();
51 
55  void createWidget(ModuleBase_PageBase* thePage, bool alignToTop = true);
56 
60  void createPanel(ModuleBase_PageBase* thePage, const FeaturePtr& theFeature);
61 
65  void createWidget(ModuleBase_PageBase* thePage,
66  const std::string& theWidgetId);
67 
69  QList<ModuleBase_ModelWidget*> getModelWidgets() const
70  {
71  return myModelWidgets;
72  }
73 
77  void getAttributeTitle(const std::string& theAttributeId,
78  std::string& theTitle);
79 
82  void getGreedAttribute(std::string& theAttributeId);
83 
85  const Config_WidgetAPI* widgetAPI() const { return myWidgetApi; }
86 
87 protected:
89  bool hasExpandingControls(QWidget* theParent);
90 
94  ModuleBase_PageBase* createPageByType(const std::string& theType,
95  QWidget* theParent);
96 
100  ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
101  QWidget* theParent = NULL);
102 
105  static QString qs(const std::string& theStdString);
106 
111  void moveToWidgetId(const std::string& theWidgetId, bool& theFound);
112 
113  private:
115  Config_WidgetAPI* myWidgetApi;
116 
118  ModuleBase_IWorkshop* myWorkshop;
119 
121  QList<ModuleBase_ModelWidget*> myModelWidgets;
122 };
123 
124 #endif /* ModuleBase_WidgetFactory_H_ */
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
An abstract custom widget class.
Definition: ModuleBase_ModelWidget.h:60
Definition: ModuleBase_PageBase.h:35
A class for creation of widgets instances in for property panel using XML deskription of a feature.
Definition: ModuleBase_WidgetFactory.h:41
const Config_WidgetAPI * widgetAPI() const
Returns widget API from XML.
Definition: ModuleBase_WidgetFactory.h:85
QList< ModuleBase_ModelWidget * > getModelWidgets() const
Returns list of model widgets.
Definition: ModuleBase_WidgetFactory.h:69
bool hasExpandingControls(QWidget *theParent)
check if ModuleBase_Widget has expandable widgets in getControls