forked from qt-creator/qt-creator
Path Chooser: Add a basedirectory
Reviewed-By: Friedemann Kleint
This commit is contained in:
@@ -89,6 +89,7 @@ struct PathChooserPrivate
|
|||||||
QString m_dialogTitleOverride;
|
QString m_dialogTitleOverride;
|
||||||
QString m_dialogFilter;
|
QString m_dialogFilter;
|
||||||
QString m_initialBrowsePathOverride;
|
QString m_initialBrowsePathOverride;
|
||||||
|
QString m_baseDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) :
|
PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) :
|
||||||
@@ -142,9 +143,23 @@ QAbstractButton *PathChooser::buttonAtIndex(int index) const
|
|||||||
return findChildren<QAbstractButton*>().at(index);
|
return findChildren<QAbstractButton*>().at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PathChooser::baseDirectory() const
|
||||||
|
{
|
||||||
|
return m_d->m_baseDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathChooser::setBaseDirectory(const QString &directory)
|
||||||
|
{
|
||||||
|
m_d->m_baseDirectory = directory;
|
||||||
|
}
|
||||||
|
|
||||||
QString PathChooser::path() const
|
QString PathChooser::path() const
|
||||||
{
|
{
|
||||||
return m_d->m_lineEdit->text();
|
const QString path = m_d->m_lineEdit->text();
|
||||||
|
if (!m_d->m_baseDirectory.isEmpty() && QFileInfo(path).isRelative())
|
||||||
|
return QFileInfo(m_d->m_baseDirectory + QLatin1Char('/') + path).absoluteFilePath();
|
||||||
|
else
|
||||||
|
return QFileInfo(path).absoluteFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathChooser::setPath(const QString &path)
|
void PathChooser::setPath(const QString &path)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class QTCREATOR_UTILS_EXPORT PathChooser : public QWidget
|
|||||||
Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
|
Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
|
||||||
Q_PROPERTY(QString promptDialogTitle READ promptDialogTitle WRITE setPromptDialogTitle DESIGNABLE true)
|
Q_PROPERTY(QString promptDialogTitle READ promptDialogTitle WRITE setPromptDialogTitle DESIGNABLE true)
|
||||||
Q_PROPERTY(Kind expectedKind READ expectedKind WRITE setExpectedKind DESIGNABLE true)
|
Q_PROPERTY(Kind expectedKind READ expectedKind WRITE setExpectedKind DESIGNABLE true)
|
||||||
|
Q_PROPERTY(QString baseDirectory READ baseDirectory WRITE setBaseDirectory DESIGNABLE true)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const char * const browseButtonLabel;
|
static const char * const browseButtonLabel;
|
||||||
@@ -87,6 +88,9 @@ public:
|
|||||||
|
|
||||||
QString path() const;
|
QString path() const;
|
||||||
|
|
||||||
|
QString baseDirectory() const;
|
||||||
|
void setBaseDirectory(const QString &directory);
|
||||||
|
|
||||||
/** Returns the suggested label title when used in a form layout. */
|
/** Returns the suggested label title when used in a form layout. */
|
||||||
static QString label();
|
static QString label();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user