From 854f5ea1cbc7f3b015150e91f6b6371004128faa Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Dec 2020 08:29:50 -0500 Subject: cmake-gui: Restore completion during path editing Revert commit 0fc1818831 (QCMakeWidgets: replace QDirModel, 2020-06-15, v3.19.0-rc1~696^2). `QFileSystemModel` is not a drop-in replacement for `QDirModel`. Additional changes are needed to make it work fully. Revert the change and suppress the `QDirModel` deprecation warning pending further investigation. Fixes: #21589 --- Source/QtDialog/QCMakeWidgets.cxx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx index 1fc839f..e68faba 100644 --- a/Source/QtDialog/QCMakeWidgets.cxx +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -1,12 +1,17 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ + +// FIXME: Port to QFileSystemModel from the deprecated QDirModel. +// Be sure completion works when incrementally editing existing paths. +#define QT_DEPRECATED_WARNINGS_SINCE QT_VERSION_CHECK(5, 14, 0) + #include "QCMakeWidgets.h" #include +#include #include #include -#include #include #include @@ -88,20 +93,20 @@ void QCMakePathEditor::chooseFile() } } -// use same QFileSystemModel for all completers -static QFileSystemModel* fileDirModel() +// use same QDirModel for all completers +static QDirModel* fileDirModel() { - static QFileSystemModel* m = nullptr; + static QDirModel* m = nullptr; if (!m) { - m = new QFileSystemModel(); + m = new QDirModel(); } return m; } -static QFileSystemModel* pathDirModel() +static QDirModel* pathDirModel() { - static QFileSystemModel* m = nullptr; + static QDirModel* m = nullptr; if (!m) { - m = new QFileSystemModel(); + m = new QDirModel(); m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); } return m; @@ -110,7 +115,7 @@ static QFileSystemModel* pathDirModel() QCMakeFileCompleter::QCMakeFileCompleter(QObject* o, bool dirs) : QCompleter(o) { - QFileSystemModel* m = dirs ? pathDirModel() : fileDirModel(); + QDirModel* m = dirs ? pathDirModel() : fileDirModel(); this->setModel(m); } -- cgit v0.12