Debian Codegraph @

widgets/pathselection.h

raw symbols SCIP
1 #ifndef WIDGETS_PATHSELECTION_H
2 #define WIDGETS_PATHSELECTION_H
3
4 #include "../global.h"
5
6 #include <QFileDialog>
7
8 QT_FORWARD_DECLARE_CLASS(QPushButton)
9 QT_FORWARD_DECLARE_CLASS(QCompleter)
10
11 namespace QtUtilities {
12
13 class ClearLineEdit;
14
15 class QT_UTILITIES_EXPORT PathSelection : public QWidget {
16 Q_OBJECT
17
18 public:
19 explicit PathSelection(QWidget *parent = nullptr);
20
21 ClearLineEdit *lineEdit();
22 const ClearLineEdit *lineEdit() const;
23 void provideCustomFileMode(QFileDialog::FileMode customFileMode);
24 void provideCustomFileDialog(QFileDialog *customFileDialog);
25
26 protected:
27 bool event(QEvent *event) override;
28 bool eventFilter(QObject *obj, QEvent *event) override;
29
30 private Q_SLOTS:
31 void showFileDialog();
32 void setTexts();
33
34 private:
35 ClearLineEdit *m_lineEdit;
36 QPushButton *m_button;
37 QFileDialog *m_customDialog;
38 QFileDialog::FileMode m_customMode;
39 static QCompleter *s_completer;
40 };
41
42 /*!
43 * \brief Returns the line edit with the selected path.
44 */
45 inline ClearLineEdit *PathSelection::lineEdit()
46 {
47 return m_lineEdit;
48 }
49
50 /*!
51 * \brief Returns the line edit with the selected path.
52 */
53 inline const ClearLineEdit *PathSelection::lineEdit() const
54 {
55 return m_lineEdit;
56 }
57
58 /*!
59 * \brief Can be used to provide a custom file mode.
60 *
61 * The default file mode is QFileDialog::Directory.
62 */
63 inline void PathSelection::provideCustomFileMode(QFileDialog::FileMode customFileMode)
64 {
65 m_customMode = customFileMode;
66 }
67
68 /*!
69 * \brief Can be used to provide a custom file dialog.
70 *
71 * The default file mode is ignored when a custom file dialog has been
72 * specified.
73 */
74 inline void PathSelection::provideCustomFileDialog(QFileDialog *customFileDialog)
75 {
76 m_customDialog = customFileDialog;
77 }
78 } // namespace QtUtilities
79
80 #endif // WIDGETS_PATHSELECTION_H