Skip to content
Snippets Groups Projects
Commit cd107321 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'cmake-gui-completion' into release-3.19


854f5ea1 cmake-gui: Restore completion during path editing

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !5619
parents 7932e0a4 854f5ea1
No related branches found
No related tags found
No related merge requests found
/* 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 <utility>
#include <QDirModel>
#include <QFileDialog>
#include <QFileInfo>
#include <QFileSystemModel>
#include <QResizeEvent>
#include <QToolButton>
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment