summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2008-12-16 20:15:33 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2008-12-16 20:15:33 (GMT)
commitb0c8b15fb94f5b60d7738438d99a633a31bff537 (patch)
tree6208d26889651a1a249f9573a8355e55e128a765
parent64b377d7074a4c070384630938c2d317348df165 (diff)
downloadCMake-b0c8b15fb94f5b60d7738438d99a633a31bff537.zip
CMake-b0c8b15fb94f5b60d7738438d99a633a31bff537.tar.gz
CMake-b0c8b15fb94f5b60d7738438d99a633a31bff537.tar.bz2
ENH: Improve performance with file completion. Fix for #8292.
-rw-r--r--Source/QtDialog/QCMakeWidgets.cxx29
1 files changed, 23 insertions, 6 deletions
diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx
index 3dbec11..b4061d2 100644
--- a/Source/QtDialog/QCMakeWidgets.cxx
+++ b/Source/QtDialog/QCMakeWidgets.cxx
@@ -104,15 +104,32 @@ void QCMakePathEditor::chooseFile()
}
}
-QCMakeFileCompleter::QCMakeFileCompleter(QObject* o, bool dirs)
- : QCompleter(o)
+// use same QDirModel for all completers
+static QDirModel* fileDirModel()
+{
+ static QDirModel* m = NULL;
+ if(!m)
+ {
+ m = new QDirModel();
+ }
+ return m;
+}
+static QDirModel* pathDirModel()
{
- QDirModel* model = new QDirModel(this);
- if(dirs)
+ static QDirModel* m = NULL;
+ if(!m)
{
- model->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot);
+ m = new QDirModel();
+ m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot);
}
- this->setModel(model);
+ return m;
+}
+
+QCMakeFileCompleter::QCMakeFileCompleter(QObject* o, bool dirs)
+ : QCompleter(o)
+{
+ QDirModel* m = dirs ? pathDirModel() : fileDirModel();
+ this->setModel(m);
}
QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const