2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-05 12:21:18 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef PATHCHOOSER_H
|
|
|
|
|
#define PATHCHOOSER_H
|
|
|
|
|
|
|
|
|
|
#include "utils_global.h"
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QWidget>
|
2010-07-02 16:42:34 +02:00
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QAbstractButton)
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
|
|
|
|
struct PathChooserPrivate;
|
|
|
|
|
|
2009-03-19 16:33:44 +01:00
|
|
|
/**
|
|
|
|
|
* A control that let's the user choose a path, consisting of a QLineEdit and
|
|
|
|
|
* a "Browse" button. Has some validation logic for embedding into QWizardPage.
|
|
|
|
|
*/
|
2009-05-08 12:09:21 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT PathChooser : public QWidget
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_DISABLE_COPY(PathChooser)
|
|
|
|
|
Q_OBJECT
|
2009-06-29 14:47:04 +02:00
|
|
|
Q_ENUMS(Kind)
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
|
2009-06-29 14:47:04 +02:00
|
|
|
Q_PROPERTY(QString promptDialogTitle READ promptDialogTitle WRITE setPromptDialogTitle DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(Kind expectedKind READ expectedKind WRITE setExpectedKind DESIGNABLE true)
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
public:
|
2008-12-05 18:51:07 +01:00
|
|
|
static const char * const browseButtonLabel;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
explicit PathChooser(QWidget *parent = 0);
|
|
|
|
|
virtual ~PathChooser();
|
|
|
|
|
|
2008-12-05 18:51:07 +01:00
|
|
|
enum Kind {
|
|
|
|
|
Directory,
|
|
|
|
|
File,
|
2009-07-28 11:37:16 +02:00
|
|
|
Command
|
2008-12-05 18:51:07 +01:00
|
|
|
// ,Any
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Default is <Directory>
|
|
|
|
|
void setExpectedKind(Kind expected);
|
2009-06-29 14:47:04 +02:00
|
|
|
Kind expectedKind() const;
|
2008-12-05 18:51:07 +01:00
|
|
|
|
|
|
|
|
void setPromptDialogTitle(const QString &title);
|
2009-06-29 14:47:04 +02:00
|
|
|
QString promptDialogTitle() const;
|
|
|
|
|
|
|
|
|
|
void setPromptDialogFilter(const QString &filter);
|
|
|
|
|
QString promptDialogFilter() const;
|
2008-12-05 18:51:07 +01:00
|
|
|
|
2008-12-19 18:25:20 +01:00
|
|
|
void setInitialBrowsePathBackup(const QString &path);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
bool isValid() const;
|
|
|
|
|
QString errorMessage() const;
|
|
|
|
|
|
|
|
|
|
QString path() const;
|
|
|
|
|
|
2009-03-19 16:33:44 +01:00
|
|
|
/** Returns the suggested label title when used in a form layout. */
|
2008-12-02 12:01:29 +01:00
|
|
|
static QString label();
|
|
|
|
|
|
2009-03-17 16:06:19 +01:00
|
|
|
virtual bool validatePath(const QString &path, QString *errorMessage = 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-19 16:33:44 +01:00
|
|
|
/** Return the home directory, which needs some fixing under Windows. */
|
2008-12-02 12:01:29 +01:00
|
|
|
static QString homePath();
|
|
|
|
|
|
2009-04-17 09:03:32 +02:00
|
|
|
void addButton(const QString &text, QObject *receiver, const char *slotFunc);
|
2009-07-22 15:18:42 +02:00
|
|
|
QAbstractButton *buttonAtIndex(int index) const;
|
2009-04-17 09:03:32 +02:00
|
|
|
|
2008-12-05 18:51:07 +01:00
|
|
|
private:
|
|
|
|
|
// Returns overridden title or the one from <title>
|
|
|
|
|
QString makeDialogTitle(const QString &title);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
|
|
|
|
void validChanged();
|
2009-10-22 17:57:16 +02:00
|
|
|
void validChanged(bool validState);
|
2009-06-19 17:55:47 +02:00
|
|
|
void changed(const QString &text);
|
2009-03-19 09:32:09 +01:00
|
|
|
void editingFinished();
|
2008-12-19 18:25:20 +01:00
|
|
|
void beforeBrowsing();
|
2008-12-19 15:32:21 +01:00
|
|
|
void browsingFinished();
|
2008-12-02 12:01:29 +01:00
|
|
|
void returnPressed();
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void setPath(const QString &);
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void slotBrowse();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
PathChooserPrivate *m_d;
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
} // namespace Utils
|
2009-10-05 11:06:05 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#endif // PATHCHOOSER_H
|