LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / utils / pathchooser.h
blob8540d7fe9cd8f1c93118d2a7d7562675c7cf1a69
1 /**
2 ******************************************************************************
4 * @file pathchooser.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @brief
8 * @see The GNU Public License (GPL) Version 3
9 * @defgroup
10 * @{
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef PATHCHOOSER_H
30 #define PATHCHOOSER_H
32 #include "utils_global.h"
34 #include <QWidget>
35 #include <QAbstractButton>
37 namespace Utils {
38 struct PathChooserPrivate;
40 /**
41 * A control that let's the user choose a path, consisting of a QLineEdit and
42 * a "Browse" button. Has some validation logic for embedding into QWizardPage.
44 class QTCREATOR_UTILS_EXPORT PathChooser : public QWidget {
45 Q_DISABLE_COPY(PathChooser)
46 Q_OBJECT
47 Q_ENUMS(Kind)
48 Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
49 Q_PROPERTY(QString promptDialogTitle READ promptDialogTitle WRITE setPromptDialogTitle DESIGNABLE true)
50 Q_PROPERTY(Kind expectedKind READ expectedKind WRITE setExpectedKind DESIGNABLE true)
52 public:
53 static const char *const browseButtonLabel;
55 explicit PathChooser(QWidget *parent = 0);
56 virtual ~PathChooser();
58 enum Kind {
59 Directory,
60 File,
61 Command
62 // ,Any
65 // Default is <Directory>
66 void setExpectedKind(Kind expected);
67 Kind expectedKind() const;
69 void setPromptDialogTitle(const QString &title);
70 QString promptDialogTitle() const;
72 void setPromptDialogFilter(const QString &filter);
73 QString promptDialogFilter() const;
75 void setInitialBrowsePathBackup(const QString &path);
77 bool isValid() const;
78 QString errorMessage() const;
80 QString path() const;
82 /** Returns the suggested label title when used in a form layout. */
83 static QString label();
85 virtual bool validatePath(const QString &path, QString *errorMessage = 0);
87 /** Return the home directory, which needs some fixing under Windows. */
88 static QString homePath();
90 void addButton(const QString &text, QObject *receiver, const char *slotFunc);
91 QAbstractButton *buttonAtIndex(int index) const;
93 private:
94 // Returns overridden title or the one from <title>
95 QString makeDialogTitle(const QString &title);
97 signals:
98 void validChanged();
99 void validChanged(bool validState);
100 void changed(const QString &text);
101 void editingFinished();
102 void beforeBrowsing();
103 void browsingFinished();
104 void returnPressed();
106 public slots:
107 void setPath(const QString &);
109 private slots:
110 void slotBrowse();
112 private:
113 PathChooserPrivate *m_d;
115 } // namespace Utils
118 #endif // PATHCHOOSER_H