Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom.git into Dev_0.6.1
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFileSelector.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModuleBase_WidgetFileSelector.h
5  *
6  *  Created on: Aug 28, 2014
7  *      Author: sbh
8  */
9
10 #ifndef MODULEBASE_WIDGETFILESELECTOR_H_
11 #define MODULEBASE_WIDGETFILESELECTOR_H_
12
13 #include <ModuleBase.h>
14 #include <ModuleBase_ModelWidget.h>
15
16 #include <QList>
17 #include <QString>
18 #include <QStringList>
19
20 class QWidget;
21 class QLineEdit;
22
23 class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelWidget
24 {
25   Q_OBJECT
26  public:
27   ModuleBase_WidgetFileSelector(QWidget* theParent,
28                                 const Config_WidgetAPI* theData,
29                                 const std::string& theParentId);
30   virtual ~ModuleBase_WidgetFileSelector();
31
32   /// Saves the internal parameters to the given feature
33   /// \param theObject a model feature to be changed
34   virtual bool storeValue() const;
35
36   virtual bool restoreValue();
37
38   /// Returns the internal parent wiget control, that can be shown anywhere
39   /// \returns the widget
40   QWidget* getControl() const;
41
42   /// Returns list of widget controls
43   /// \return a control list
44   virtual QList<QWidget*> getControls() const;
45
46   /// Returns true if a file on the current path in the line edit
47   /// exists and has supported format
48   bool isCurrentPathValid();
49
50  public slots:
51   void onPathSelectionBtn();
52   void onPathChanged();
53
54  protected:
55   QString formatsString() const;
56   QStringList getValidatorFormats() const;
57
58  private:
59   QLineEdit* myPathField;
60   QWidget* myMainWidget;
61
62   QString myTitle;
63   QString myDefaultPath;
64 };
65
66 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */