PathChooser: rename Directory to ExistingDirectory, introduce Directory

Existing Directory checks for whether the directory exists, which
Directory does not. Also changes all existing PathChoosers from
Directory to ExistingDirectory as that does not change behaviour.
This commit is contained in:
dt
2011-02-21 12:42:20 +01:00
parent a9963b6313
commit 7edd89ba85
13 changed files with 31 additions and 21 deletions

View File

@@ -188,6 +188,12 @@ public:
QHBoxLayout *m_hLayout; QHBoxLayout *m_hLayout;
PathValidatingLineEdit *m_lineEdit; PathValidatingLineEdit *m_lineEdit;
#ifdef Q_WS_MAC
QPushButton *m_button;
#else
QToolButton *m_button;
#endif
PathChooser::Kind m_acceptingKind; PathChooser::Kind m_acceptingKind;
QString m_dialogTitleOverride; QString m_dialogTitleOverride;
QString m_dialogFilter; QString m_dialogFilter;
@@ -200,7 +206,7 @@ public:
PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) : PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) :
m_hLayout(new QHBoxLayout), m_hLayout(new QHBoxLayout),
m_lineEdit(new PathValidatingLineEdit(chooser)), m_lineEdit(new PathValidatingLineEdit(chooser)),
m_acceptingKind(PathChooser::Directory), m_acceptingKind(PathChooser::ExistingDirectory),
m_binaryVersionToolTipEventFilter(0) m_binaryVersionToolTipEventFilter(0)
{ {
} }
@@ -222,6 +228,7 @@ QString PathChooserPrivate::expandedPath(const QString &input) const
case PathChooser::Any: case PathChooser::Any:
break; break;
case PathChooser::Directory: case PathChooser::Directory:
case PathChooser::ExistingDirectory:
case PathChooser::File: case PathChooser::File:
if (!m_baseDirectory.isEmpty() && QFileInfo(path).isRelative()) if (!m_baseDirectory.isEmpty() && QFileInfo(path).isRelative())
return QFileInfo(m_baseDirectory + QLatin1Char('/') + path).absoluteFilePath(); return QFileInfo(m_baseDirectory + QLatin1Char('/') + path).absoluteFilePath();
@@ -261,13 +268,13 @@ PathChooser::~PathChooser()
void PathChooser::addButton(const QString &text, QObject *receiver, const char *slotFunc) void PathChooser::addButton(const QString &text, QObject *receiver, const char *slotFunc)
{ {
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
QPushButton *button = new QPushButton; m_d->m_button = new QPushButton;
#else #else
QToolButton *button = new QToolButton; m_d->m_button = new QToolButton;
#endif #endif
button->setText(text); m_d->m_button->setText(text);
connect(button, SIGNAL(clicked()), receiver, slotFunc); connect(m_d->m_button, SIGNAL(clicked()), receiver, slotFunc);
m_d->m_hLayout->addWidget(button); m_d->m_hLayout->addWidget(m_d->m_button);
} }
QAbstractButton *PathChooser::buttonAtIndex(int index) const QAbstractButton *PathChooser::buttonAtIndex(int index) const
@@ -324,6 +331,7 @@ void PathChooser::slotBrowse()
QString newPath; QString newPath;
switch (m_d->m_acceptingKind) { switch (m_d->m_acceptingKind) {
case PathChooser::Directory: case PathChooser::Directory:
case PathChooser::ExistingDirectory:
newPath = QFileDialog::getExistingDirectory(this, newPath = QFileDialog::getExistingDirectory(this,
makeDialogTitle(tr("Choose Directory")), predefined); makeDialogTitle(tr("Choose Directory")), predefined);
break; break;
@@ -401,7 +409,7 @@ bool PathChooser::validatePath(const QString &path, QString *errorMessage)
// Check if existing // Check if existing
switch (m_d->m_acceptingKind) { switch (m_d->m_acceptingKind) {
case PathChooser::Directory: // fall through case PathChooser::ExistingDirectory: // fall through
case PathChooser::File: // fall through case PathChooser::File: // fall through
case PathChooser::ExistingCommand: case PathChooser::ExistingCommand:
if (!fi.exists()) { if (!fi.exists()) {
@@ -411,6 +419,7 @@ bool PathChooser::validatePath(const QString &path, QString *errorMessage)
} }
break; break;
case PathChooser::Directory:
case PathChooser::Command: // fall through case PathChooser::Command: // fall through
default: default:
; ;
@@ -418,7 +427,7 @@ bool PathChooser::validatePath(const QString &path, QString *errorMessage)
// Check expected kind // Check expected kind
switch (m_d->m_acceptingKind) { switch (m_d->m_acceptingKind) {
case PathChooser::Directory: case PathChooser::ExistingDirectory:
if (!fi.isDir()) { if (!fi.isDir()) {
if (errorMessage) if (errorMessage)
*errorMessage = tr("The path <b>%1</b> is not a directory.").arg(QDir::toNativeSeparators(expandedPath)); *errorMessage = tr("The path <b>%1</b> is not a directory.").arg(QDir::toNativeSeparators(expandedPath));

View File

@@ -71,7 +71,8 @@ public:
virtual ~PathChooser(); virtual ~PathChooser();
enum Kind { enum Kind {
Directory, ExistingDirectory,
Directory, // A directory, doesn't need to exist
File, File,
ExistingCommand, // A command that must exist at the time of selection ExistingCommand, // A command that must exist at the time of selection
Command, // A command that may or may not exist at the time of selection (e.g. result of a build) Command, // A command that may or may not exist at the time of selection (e.g. result of a build)

View File

@@ -329,7 +329,7 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
m_workingDirectoryEdit = new Utils::PathChooser(); m_workingDirectoryEdit = new Utils::PathChooser();
m_workingDirectoryEdit->setBaseDirectory(m_cmakeRunConfiguration->target()->project()->projectDirectory()); m_workingDirectoryEdit->setBaseDirectory(m_cmakeRunConfiguration->target()->project()->projectDirectory());
m_workingDirectoryEdit->setPath(m_cmakeRunConfiguration->baseWorkingDirectory()); m_workingDirectoryEdit->setPath(m_cmakeRunConfiguration->baseWorkingDirectory());
m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory); m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory")); m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory"));
QToolButton *resetButton = new QToolButton(); QToolButton *resetButton = new QToolButton();

View File

@@ -554,7 +554,7 @@ StartExternalDialog::StartExternalDialog(QWidget *parent)
m_ui->execFile->lineEdit()->setCompleter( m_ui->execFile->lineEdit()->setCompleter(
new HistoryCompleter(m_ui->execFile->lineEdit())); new HistoryCompleter(m_ui->execFile->lineEdit()));
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
m_ui->workingDirectory->setExpectedKind(PathChooser::Directory); m_ui->workingDirectory->setExpectedKind(PathChooser::ExistingDirectory);
m_ui->workingDirectory->setPromptDialogTitle(tr("Select Working Directory")); m_ui->workingDirectory->setPromptDialogTitle(tr("Select Working Directory"));
m_ui->workingDirectory->lineEdit()->setCompleter( m_ui->workingDirectory->lineEdit()->setCompleter(
new HistoryCompleter(m_ui->workingDirectory->lineEdit())); new HistoryCompleter(m_ui->workingDirectory->lineEdit()));

View File

@@ -60,7 +60,7 @@ CacheDirectoryDialog::CacheDirectoryDialog(QWidget *parent) :
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QFormLayout *formLayout = new QFormLayout; QFormLayout *formLayout = new QFormLayout;
m_chooser->setExpectedKind(Utils::PathChooser::Directory); m_chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_chooser->setMinimumWidth(400); m_chooser->setMinimumWidth(400);
formLayout->addRow(tr("Path:"), m_chooser); formLayout->addRow(tr("Path:"), m_chooser);

View File

@@ -42,7 +42,7 @@ SrcDestDialog::SrcDestDialog(QWidget *parent) :
m_ui(new Ui::SrcDestDialog) m_ui(new Ui::SrcDestDialog)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::Directory); m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
} }
SrcDestDialog::~SrcDestDialog() SrcDestDialog::~SrcDestDialog()

View File

@@ -84,7 +84,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
layout->addRow(tr("Arguments:"), m_commandLineArgumentsLineEdit); layout->addRow(tr("Arguments:"), m_commandLineArgumentsLineEdit);
m_workingDirectory = new CustomDirectoryPathChooser(this); m_workingDirectory = new CustomDirectoryPathChooser(this);
m_workingDirectory->setExpectedKind(Utils::PathChooser::Directory); m_workingDirectory->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_workingDirectory->setBaseDirectory(rc->target()->project()->projectDirectory()); m_workingDirectory->setBaseDirectory(rc->target()->project()->projectDirectory());
m_workingDirectory->setEnvironment(rc->environment()); m_workingDirectory->setEnvironment(rc->environment());
layout->addRow(tr("Working directory:"), m_workingDirectory); layout->addRow(tr("Working directory:"), m_workingDirectory);

View File

@@ -385,7 +385,7 @@ void GettingStartedWelcomePageWidget::slotOpenExample()
QLabel *txt = new QLabel(tr("&Location:")); QLabel *txt = new QLabel(tr("&Location:"));
Utils::PathChooser *chooser = new Utils::PathChooser; Utils::PathChooser *chooser = new Utils::PathChooser;
txt->setBuddy(chooser); txt->setBuddy(chooser);
chooser->setExpectedKind(Utils::PathChooser::Directory); chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
chooser->setPath(settings->value( chooser->setPath(settings->value(
QString::fromLatin1("General/ProjectsFallbackRoot"), QDir::homePath()).toString()); QString::fromLatin1("General/ProjectsFallbackRoot"), QDir::homePath()).toString());

View File

@@ -215,7 +215,7 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
m_workingDirectoryEdit = new Utils::PathChooser(this); m_workingDirectoryEdit = new Utils::PathChooser(this);
m_workingDirectoryEdit->setPath(m_qt4RunConfiguration->baseWorkingDirectory()); m_workingDirectoryEdit->setPath(m_qt4RunConfiguration->baseWorkingDirectory());
m_workingDirectoryEdit->setBaseDirectory(m_qt4RunConfiguration->target()->project()->projectDirectory()); m_workingDirectoryEdit->setBaseDirectory(m_qt4RunConfiguration->target()->project()->projectDirectory());
m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory); m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_workingDirectoryEdit->setEnvironment(m_qt4RunConfiguration->environment()); m_workingDirectoryEdit->setEnvironment(m_qt4RunConfiguration->environment());
m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory")); m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory"));

View File

@@ -82,7 +82,7 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4BaseTarget *target)
// TODO refix the layout // TODO refix the layout
m_ui->shadowBuildDirEdit->setPromptDialogTitle(tr("Shadow Build Directory")); m_ui->shadowBuildDirEdit->setPromptDialogTitle(tr("Shadow Build Directory"));
m_ui->shadowBuildDirEdit->setExpectedKind(Utils::PathChooser::Directory); m_ui->shadowBuildDirEdit->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_ui->shadowBuildDirEdit->setBaseDirectory(target->qt4Project()->projectDirectory()); m_ui->shadowBuildDirEdit->setBaseDirectory(target->qt4Project()->projectDirectory());
connect(m_ui->shadowBuildCheckBox, SIGNAL(clicked(bool)), connect(m_ui->shadowBuildCheckBox, SIGNAL(clicked(bool)),

View File

@@ -151,7 +151,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
m_versionUi->setupUi(versionInfoWidget); m_versionUi->setupUi(versionInfoWidget);
m_versionUi->qmakePath->setExpectedKind(Utils::PathChooser::File); m_versionUi->qmakePath->setExpectedKind(Utils::PathChooser::File);
m_versionUi->qmakePath->setPromptDialogTitle(tr("Select qmake Executable")); m_versionUi->qmakePath->setPromptDialogTitle(tr("Select qmake Executable"));
m_versionUi->s60SDKPath->setExpectedKind(Utils::PathChooser::Directory); m_versionUi->s60SDKPath->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_versionUi->s60SDKPath->setPromptDialogTitle(tr("Select S60 SDK Root")); m_versionUi->s60SDKPath->setPromptDialogTitle(tr("Select S60 SDK Root"));
QWidget *debuggingHelperDetailsWidget = new QWidget(); QWidget *debuggingHelperDetailsWidget = new QWidget();

View File

@@ -97,10 +97,10 @@ QWidget *HighlighterSettingsPage::createPage(QWidget *parent)
QWidget *w = new QWidget(parent); QWidget *w = new QWidget(parent);
m_d->m_page = new Ui::HighlighterSettingsPage; m_d->m_page = new Ui::HighlighterSettingsPage;
m_d->m_page->setupUi(w); m_d->m_page->setupUi(w);
m_d->m_page->definitionFilesPath->setExpectedKind(Utils::PathChooser::Directory); m_d->m_page->definitionFilesPath->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_d->m_page->definitionFilesPath->addButton(tr("Download Definitions"), this, m_d->m_page->definitionFilesPath->addButton(tr("Download Definitions"), this,
SLOT(requestAvailableDefinitionsMetaData())); SLOT(requestAvailableDefinitionsMetaData()));
m_d->m_page->fallbackDefinitionFilesPath->setExpectedKind(Utils::PathChooser::Directory); m_d->m_page->fallbackDefinitionFilesPath->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_d->m_page->fallbackDefinitionFilesPath->addButton(tr("Autodetect"), this, m_d->m_page->fallbackDefinitionFilesPath->addButton(tr("Autodetect"), this,
SLOT(resetDefinitionsLocation())); SLOT(resetDefinitionsLocation()));

View File

@@ -60,7 +60,7 @@ BaseCheckoutWizardPage::BaseCheckoutWizardPage(QWidget *parent) :
connect(d->ui.branchComboBox, SIGNAL(currentIndexChanged(int)), connect(d->ui.branchComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotChanged())); this, SLOT(slotChanged()));
d->ui.pathChooser->setExpectedKind(Utils::PathChooser::Directory); d->ui.pathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
connect(d->ui.pathChooser, SIGNAL(validChanged()), this, SLOT(slotChanged())); connect(d->ui.pathChooser, SIGNAL(validChanged()), this, SLOT(slotChanged()));
d->ui.branchComboBox->setEnabled(false); d->ui.branchComboBox->setEnabled(false);