FileDialog.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef GUI_FILEDIALOG_H
00025 #define GUI_FILEDIALOG_H
00026
00027 #include <QFileDialog>
00028 #include <QFileIconProvider>
00029
00030 class QButtonGroup;
00031 class QGridLayout;
00032 class QGroupBox;
00033 class QHBoxLayout;
00034 class QLineEdit;
00035 class QSpacerItem;
00036
00037 namespace Gui {
00038
00043 class GuiExport FileDialog : public QFileDialog
00044 {
00045 Q_OBJECT
00046
00047 public:
00048 static QString getOpenFileName( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(),
00049 const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 );
00050 static QString getSaveFileName( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(),
00051 const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 );
00052 static QString getExistingDirectory( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(),
00053 Options options = ShowDirsOnly );
00054 static QStringList getOpenFileNames( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(),
00055 const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 );
00056
00057 static QString getWorkingDirectory();
00058 static void setWorkingDirectory( const QString& );
00059 };
00060
00061
00062
00068 class GuiExport FileOptionsDialog : public QFileDialog
00069 {
00070 Q_OBJECT
00071
00072 public:
00073 enum ExtensionPosition {
00074 ExtensionRight = 0,
00075 ExtensionBottom = 1
00076 };
00077
00078 FileOptionsDialog ( QWidget* parent, Qt::WFlags );
00079 virtual ~FileOptionsDialog();
00080
00081 void accept();
00082
00083 void setOptionsWidget( ExtensionPosition pos , QWidget*, bool show = false );
00084 QWidget* getOptionsWidget() const;
00085
00086 protected Q_SLOTS:
00087 void toggleExtension();
00088
00089 Q_SIGNALS:
00090 void filterSelected(const QString&);
00091
00092 private:
00093 QPushButton* extensionButton;
00094 };
00095
00096
00097
00102 class FileIconProvider : public QFileIconProvider
00103 {
00104 public:
00105 FileIconProvider();
00106 ~FileIconProvider();
00107
00108 QIcon icon ( IconType type ) const;
00109 QIcon icon ( const QFileInfo & info ) const;
00110 QString type ( const QFileInfo & info ) const;
00111 };
00112
00113
00114
00120 class GuiExport FileChooser : public QWidget
00121 {
00122 Q_OBJECT
00123
00124 Q_ENUMS( Mode )
00125 Q_PROPERTY( Mode mode READ mode WRITE setMode )
00126 Q_PROPERTY( QString fileName READ fileName WRITE setFileName )
00127 Q_PROPERTY( QString filter READ filter WRITE setFilter )
00128 Q_PROPERTY( QString buttonText READ buttonText WRITE setButtonText )
00129
00130 public:
00131 enum Mode { File, Directory };
00132
00133 FileChooser ( QWidget * parent = 0 );
00134 virtual ~FileChooser();
00135
00139 QString filter() const;
00140
00144 QString fileName() const;
00145
00150 Mode mode() const;
00151
00155 QString buttonText() const;
00156
00157 public Q_SLOTS:
00158 virtual void setFileName( const QString &fn );
00159 virtual void setMode( Mode m );
00160 virtual void setFilter ( const QString & );
00161 virtual void setButtonText ( const QString & );
00162
00163 Q_SIGNALS:
00164 void fileNameChanged( const QString & );
00165 void fileNameSelected( const QString & );
00166
00167 private Q_SLOTS:
00168 void chooseFile();
00169
00170 private:
00171 QLineEdit *lineEdit;
00172 QPushButton *button;
00173 Mode md;
00174 QString _filter;
00175 };
00176
00177
00178
00184 class GuiExport SelectModule : public QDialog
00185 {
00186 Q_OBJECT
00187
00188 public:
00189 typedef QMap<QString, QString> Dict;
00190
00191 SelectModule (const QString& type, const Dict&, QWidget* parent);
00192 virtual ~SelectModule();
00193 QString getModule() const;
00194
00201 static Dict exportHandler(const QString& fn, const QString& filter=QString());
00202 static Dict exportHandler(const QStringList& fn, const QString& filter=QString());
00203 static Dict importHandler(const QString& fn, const QString& filter=QString());
00204 static Dict importHandler(const QStringList& fn, const QString& filter=QString());
00206
00207 void accept();
00208 void reject();
00209
00210 private Q_SLOTS:
00211 void onButtonClicked();
00212
00213 private:
00214 QPushButton *okButton;
00215 QButtonGroup* group;
00216 QGridLayout *gridLayout;
00217 QHBoxLayout *hboxLayout;
00218 QGroupBox *groupBox;
00219 QGridLayout *gridLayout1;
00220 QSpacerItem *spacerItem;
00221 QSpacerItem *spacerItem1;
00222 };
00223
00224 }
00225
00226 #endif // GUI_FILEDIALOG_H