summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMakeWidgets.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/QtDialog/QCMakeWidgets.cxx')
-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