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