1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * ModuleBase_WidgetFileSelector.h
6 * Created on: Aug 28, 2014
10 #ifndef MODULEBASE_WIDGETFILESELECTOR_H_
11 #define MODULEBASE_WIDGETFILESELECTOR_H_
13 #include <ModuleBase.h>
14 #include <ModuleBase_ModelWidget.h>
18 #include <QStringList>
25 * Implementation of model widget for open file widget.
26 * It can be defined as following:
29 * id="import_file_selector"
33 * <validator id="ExchangePlugin_ImportFormat" parameters="BREP:BREPImport,STEP:STEPImport" />
37 class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelWidget
42 /// \param theParent the parent object
43 /// \param theData the widget configuation. The attribute of the model widget is obtained from
44 /// \param theParentId is Id of a parent of the current attribute
45 ModuleBase_WidgetFileSelector(QWidget* theParent,
46 const Config_WidgetAPI* theData,
47 const std::string& theParentId);
48 virtual ~ModuleBase_WidgetFileSelector();
50 virtual bool restoreValue();
52 virtual QList<QWidget*> getControls() const;
54 /// Returns true if a file on the current path in the line edit
55 /// exists and has supported format
56 bool isCurrentPathValid();
59 /// Processing of path selection button press
60 void onPathSelectionBtn();
62 /// Processing of path changing
66 /// Saves the internal parameters to the given feature
67 /// \return True in success
68 virtual bool storeValueCustom() const;
71 /// Returns string containing formats
72 QString filterString() const;
74 /// Returns list of validator formats
75 QStringList getValidatorFormats() const;
77 /// Returns a format received from theArgument
78 QString getFormat( const std::string& theArgument ) const;
81 /// A control for path input
82 QLineEdit* myPathField;
84 /// A title of open file dialog box
87 /// A title of open file dialog box
88 enum { WFS_OPEN, WFS_SAVE } myType;
91 QString myDefaultPath;
94 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */