diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 5a280c955..724896c1e 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include #include #include @@ -117,16 +115,8 @@ CMakeSetupDialog::CMakeSetupDialog() QStringList buildPaths = this->loadBuildPaths(); this->BinaryDirectory->addItems(buildPaths); - QCompleter* compBinaryDir = new QCompleter(this); - QDirModel* modelBinaryDir = new QDirModel(compBinaryDir); - modelBinaryDir->setFilter(QDir::NoDotAndDotDot | QDir::Dirs); - compBinaryDir->setModel(modelBinaryDir); - this->BinaryDirectory->setCompleter(compBinaryDir); - QCompleter* compSourceDir = new QCompleter(this); - QDirModel* modelSourceDir = new QDirModel(compSourceDir); - modelSourceDir->setFilter(QDir::NoDotAndDotDot | QDir::Dirs); - compSourceDir->setModel(modelSourceDir); - this->SourceDirectory->setCompleter(compSourceDir); + this->BinaryDirectory->setCompleter(new QCMakeFileCompleter(this, true)); + this->SourceDirectory->setCompleter(new QCMakeFileCompleter(this, true)); // start the cmake worker thread @@ -416,7 +406,7 @@ void CMakeSetupDialog::doSourceBrowse() tr("Enter Path to Source"), this->SourceDirectory->text()); if(!dir.isEmpty()) { - this->setSourceDirectory(dir); + this->setSourceDirectory(QDir::fromNativeSeparators(dir)); } } @@ -424,7 +414,9 @@ void CMakeSetupDialog::updateSourceDirectory(const QString& dir) { if(this->SourceDirectory->text() != dir) { - this->setSourceDirectory(dir); + this->SourceDirectory->blockSignals(true); + this->SourceDirectory->setText(dir); + this->SourceDirectory->blockSignals(false); } } @@ -434,7 +426,7 @@ void CMakeSetupDialog::doBinaryBrowse() tr("Enter Path to Build"), this->BinaryDirectory->currentText()); if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText()) { - this->setBinaryDirectory(dir); + this->setBinaryDirectory(QDir::fromNativeSeparators(dir)); } } diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 776e10b35..74492bfea 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -27,7 +27,6 @@ #include #include #include -#include static QRegExp AdvancedRegExp[2] = { QRegExp("(false)"), QRegExp("(true|false)") }; @@ -460,20 +459,13 @@ QCMakeCacheFileEditor::QCMakeCacheFileEditor(QWidget* p, const QString& var) QCMakeCacheFilePathEditor::QCMakeCacheFilePathEditor(QWidget* p, const QString& var) : QCMakeCacheFileEditor(p, var) { - QCompleter* comp = new QCompleter(this); - QDirModel* model = new QDirModel(comp); - comp->setModel(model); - this->setCompleter(comp); + this->setCompleter(new QCMakeFileCompleter(this, false)); } QCMakeCachePathEditor::QCMakeCachePathEditor(QWidget* p, const QString& var) : QCMakeCacheFileEditor(p, var) { - QCompleter* comp = new QCompleter(this); - QDirModel* model = new QDirModel(comp); - model->setFilter(QDir::AllDirs | QDir::Drives); - comp->setModel(model); - this->setCompleter(comp); +this->setCompleter(new QCMakeFileCompleter(this, true)); } void QCMakeCacheFileEditor::resizeEvent(QResizeEvent* e) @@ -504,7 +496,7 @@ void QCMakeCacheFilePathEditor::chooseFile() if(!path.isEmpty()) { - this->setText(path); + this->setText(QDir::fromNativeSeparators(path)); } } @@ -525,8 +517,23 @@ void QCMakeCachePathEditor::chooseFile() path = QFileDialog::getExistingDirectory(this, title, this->text()); if(!path.isEmpty()) { - this->setText(path); + this->setText(QDir::fromNativeSeparators(path)); } } +QCMakeFileCompleter::QCMakeFileCompleter(QObject* o, bool dirs) + : QCompleter(o) +{ + QDirModel* model = new QDirModel(this); + if(dirs) + { + model->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); + } + this->setModel(model); +} + +QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const +{ + return QDir::fromNativeSeparators(QCompleter::pathFromIndex(idx)); +} diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 8a6e1de1f..fd8c2fe48 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -25,6 +25,7 @@ #include #include #include +#include class QCMakeCacheModel; class QToolButton; @@ -139,5 +140,13 @@ public: void chooseFile(); }; +/// completer class that returns native cmake paths +class QCMakeFileCompleter : public QCompleter +{ +public: + QCMakeFileCompleter(QObject* o, bool dirs); + virtual QString pathFromIndex(const QModelIndex& idx) const; +}; + #endif