summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2008-02-15 00:58:31 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2008-02-15 00:58:31 (GMT)
commitd0d67d00153cad4f460eab7b930f7c2d3572b498 (patch)
tree5d69e530830aaaa88e98eee9cbd7b4e27338b34c /Source/QtDialog
parentdf3169273a3333efe8ecb45da51e4c53b5d27fe9 (diff)
downloadCMake-d0d67d00153cad4f460eab7b930f7c2d3572b498.zip
CMake-d0d67d00153cad4f460eab7b930f7c2d3572b498.tar.gz
CMake-d0d67d00153cad4f460eab7b930f7c2d3572b498.tar.bz2
ENH: Convert native paths from QFileDialog and QDirModel/QCompleter.
BUG: Block possible completion loop.
Diffstat (limited to 'Source/QtDialog')
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx22
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx31
-rw-r--r--Source/QtDialog/QCMakeCacheView.h9
3 files changed, 35 insertions, 27 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 5a280c9..724896c 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -24,8 +24,6 @@
#include <QDialogButtonBox>
#include <QCloseEvent>
#include <QCoreApplication>
-#include <QCompleter>
-#include <QDirModel>
#include <QSettings>
#include <QMenu>
#include <QMenuBar>
@@ -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 776e10b..74492bf 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -27,7 +27,6 @@
#include <QKeyEvent>
#include <QMenu>
#include <QDirModel>
-#include <QCompleter>
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 8a6e1de..fd8c2fe 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -25,6 +25,7 @@
#include <QLineEdit>
#include <QItemDelegate>
#include <QSortFilterProxyModel>
+#include <QCompleter>
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