ENH: Convert native paths from QFileDialog and QDirModel/QCompleter.
BUG: Block possible completion loop.
This commit is contained in:
parent
df3169273a
commit
d0d67d0015
|
@ -24,8 +24,6 @@
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QCompleter>
|
|
||||||
#include <QDirModel>
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
@ -117,16 +115,8 @@ CMakeSetupDialog::CMakeSetupDialog()
|
||||||
QStringList buildPaths = this->loadBuildPaths();
|
QStringList buildPaths = this->loadBuildPaths();
|
||||||
this->BinaryDirectory->addItems(buildPaths);
|
this->BinaryDirectory->addItems(buildPaths);
|
||||||
|
|
||||||
QCompleter* compBinaryDir = new QCompleter(this);
|
this->BinaryDirectory->setCompleter(new QCMakeFileCompleter(this, true));
|
||||||
QDirModel* modelBinaryDir = new QDirModel(compBinaryDir);
|
this->SourceDirectory->setCompleter(new QCMakeFileCompleter(this, true));
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
// start the cmake worker thread
|
// start the cmake worker thread
|
||||||
|
@ -416,7 +406,7 @@ void CMakeSetupDialog::doSourceBrowse()
|
||||||
tr("Enter Path to Source"), this->SourceDirectory->text());
|
tr("Enter Path to Source"), this->SourceDirectory->text());
|
||||||
if(!dir.isEmpty())
|
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)
|
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());
|
tr("Enter Path to Build"), this->BinaryDirectory->currentText());
|
||||||
if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText())
|
if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText())
|
||||||
{
|
{
|
||||||
this->setBinaryDirectory(dir);
|
this->setBinaryDirectory(QDir::fromNativeSeparators(dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDirModel>
|
#include <QDirModel>
|
||||||
#include <QCompleter>
|
|
||||||
|
|
||||||
static QRegExp AdvancedRegExp[2] = { QRegExp("(false)"), QRegExp("(true|false)") };
|
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)
|
QCMakeCacheFilePathEditor::QCMakeCacheFilePathEditor(QWidget* p, const QString& var)
|
||||||
: QCMakeCacheFileEditor(p, var)
|
: QCMakeCacheFileEditor(p, var)
|
||||||
{
|
{
|
||||||
QCompleter* comp = new QCompleter(this);
|
this->setCompleter(new QCMakeFileCompleter(this, false));
|
||||||
QDirModel* model = new QDirModel(comp);
|
|
||||||
comp->setModel(model);
|
|
||||||
this->setCompleter(comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QCMakeCachePathEditor::QCMakeCachePathEditor(QWidget* p, const QString& var)
|
QCMakeCachePathEditor::QCMakeCachePathEditor(QWidget* p, const QString& var)
|
||||||
: QCMakeCacheFileEditor(p, var)
|
: QCMakeCacheFileEditor(p, var)
|
||||||
{
|
{
|
||||||
QCompleter* comp = new QCompleter(this);
|
this->setCompleter(new QCMakeFileCompleter(this, true));
|
||||||
QDirModel* model = new QDirModel(comp);
|
|
||||||
model->setFilter(QDir::AllDirs | QDir::Drives);
|
|
||||||
comp->setModel(model);
|
|
||||||
this->setCompleter(comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCMakeCacheFileEditor::resizeEvent(QResizeEvent* e)
|
void QCMakeCacheFileEditor::resizeEvent(QResizeEvent* e)
|
||||||
|
@ -504,7 +496,7 @@ void QCMakeCacheFilePathEditor::chooseFile()
|
||||||
|
|
||||||
if(!path.isEmpty())
|
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());
|
path = QFileDialog::getExistingDirectory(this, title, this->text());
|
||||||
if(!path.isEmpty())
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QCompleter>
|
||||||
|
|
||||||
class QCMakeCacheModel;
|
class QCMakeCacheModel;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
@ -139,5 +140,13 @@ public:
|
||||||
void chooseFile();
|
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
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue