1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #ifndef DIALOGLINEEDIT_H
22 #define DIALOGLINEEDIT_H
26 #include <QtDesigner/QDesignerExportWidget>
28 #include <QPushButton>
30 /// A QWidget with a QLineEdit and a small QPushButton.
31 /** It allows easy file or directory selection. The clicked() signal can also be used to call up a custom dialog instead. */
34 QDESIGNER_WIDGET_EXPORT
36 DialogLineEdit
: public QWidget
39 Q_PROPERTY(bool m_openfile READ getMode WRITE setMode
)
40 Q_PROPERTY(bool m_UseFileDialog READ getUseFileDialog WRITE useFileDialog
)
43 QPushButton
*m_button
;///< The QPushButton
44 QLineEdit
*m_lineedit
;///< The QLineEdit
45 QString m_caption
;///< The caption to use in the dialog
46 QString m_dir
;///< The default directory to use in the dialog
47 QString m_filter
;///< The filter to use in the dialog
48 bool m_openfile
;///< if true a getOpenFileName dialog is used, otherwise a getExistingDirectory dialog is used.
49 bool m_UseFileDialog
;///< if true a standard dialog is used, otherwise nothing happens (but the clicked() signal can be used to open a custom dialog)
52 void build();///< builds the widget
53 //QString getDir(QString str);///< returns the path of the selected file or the selected path
56 DialogLineEdit(QWidget
*parent
= 0);///< Default constructor
58 * @param openfile true = use open file dialog, false = use open directory dialog
59 * @param parent parent widget
61 DialogLineEdit(bool openfile
, QWidget
*parent
= 0);
62 QString
text();///< Get the text of the QLineEdit
63 void setText(QString str
);///< set the text of the QLineEdit
66 void setCaption(QString str
);///< set the caption to use in the file dialog
67 void setDir(QString str
);///< set the default directory to use in the file dialog
68 void setFilter(QString str
);///< set the filter to use in the file dialog
69 QString
getCaption();///< get the caption used in the file dialog
70 QString
getDir();///< get the default directory used in the file dialog
71 QString
getFilter();///< get the filter used in the file dialog
72 bool getMode();///< get the mode: true = use open file dialog, false = use open directory dialog
73 void setMode(bool mode
);///< set the mode: true = use open file dialog, false = use open directory dialog
74 void useFileDialog(bool arg
);///< set whether or not to use standard dialogs when the button is clicked
75 bool getUseFileDialog() {return m_UseFileDialog
;}///< get whether or not to use standard dialogs when the button is clicked
78 void openDialog();///< emit the clicked signal + open standard dialog if m_UseFileDialog is true
81 void clicked();///< This signal is emitted when the QPushButton is clicked