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