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

View File

@@ -71,7 +71,8 @@ public:
virtual ~PathChooser();
enum Kind {
Directory,
ExistingDirectory,
Directory, // A directory, doesn't need to exist
File,
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)

View File

@@ -329,7 +329,7 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
m_workingDirectoryEdit = new Utils::PathChooser();
m_workingDirectoryEdit->setBaseDirectory(m_cmakeRunConfiguration->target()->project()->projectDirectory());
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"));
QToolButton *resetButton = new QToolButton();

View File

@@ -554,7 +554,7 @@ StartExternalDialog::StartExternalDialog(QWidget *parent)
m_ui->execFile->lineEdit()->setCompleter(
new HistoryCompleter(m_ui->execFile->lineEdit()));
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->lineEdit()->setCompleter(
new HistoryCompleter(m_ui->workingDirectory->lineEdit()));

View File

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

View File

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

View File

@@ -84,7 +84,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
layout->addRow(tr("Arguments:"), m_commandLineArgumentsLineEdit);
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->setEnvironment(rc->environment());
layout->addRow(tr("Working directory:"), m_workingDirectory);

View File

@@ -385,7 +385,7 @@ void GettingStartedWelcomePageWidget::slotOpenExample()
QLabel *txt = new QLabel(tr("&Location:"));
Utils::PathChooser *chooser = new Utils::PathChooser;
txt->setBuddy(chooser);
chooser->setExpectedKind(Utils::PathChooser::Directory);
chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
QSettings *settings = Core::ICore::instance()->settings();
chooser->setPath(settings->value(
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->setPath(m_qt4RunConfiguration->baseWorkingDirectory());
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->setPromptDialogTitle(tr("Select Working Directory"));

View File

@@ -82,7 +82,7 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4BaseTarget *target)
// TODO refix the layout
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());
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->qmakePath->setExpectedKind(Utils::PathChooser::File);
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"));
QWidget *debuggingHelperDetailsWidget = new QWidget();

View File

@@ -97,10 +97,10 @@ QWidget *HighlighterSettingsPage::createPage(QWidget *parent)
QWidget *w = new QWidget(parent);
m_d->m_page = new Ui::HighlighterSettingsPage;
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,
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,
SLOT(resetDefinitionsLocation()));

View File

@@ -60,7 +60,7 @@ BaseCheckoutWizardPage::BaseCheckoutWizardPage(QWidget *parent) :
connect(d->ui.branchComboBox, SIGNAL(currentIndexChanged(int)),
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()));
d->ui.branchComboBox->setEnabled(false);