ENH: Improve performance with file completion. Fix for #8292.

This commit is contained in:
Clinton Stimpson 2008-12-16 15:15:33 -05:00
parent 64b377d707
commit b0c8b15fb9
1 changed files with 23 additions and 6 deletions

View File

@ -104,15 +104,32 @@ void QCMakePathEditor::chooseFile()
}
}
// use same QDirModel for all completers
static QDirModel* fileDirModel()
{
static QDirModel* m = NULL;
if(!m)
{
m = new QDirModel();
}
return m;
}
static QDirModel* pathDirModel()
{
static QDirModel* m = NULL;
if(!m)
{
m = new QDirModel();
m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot);
}
return m;
}
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);
QDirModel* m = dirs ? pathDirModel() : fileDirModel();
this->setModel(m);
}
QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const