mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-28 01:51:02 -06:00
@@ -1344,7 +1344,8 @@ void CMakeSetupDialog::showUserChanges()
|
|||||||
void CMakeSetupDialog::setSearchFilter(const QString& str)
|
void CMakeSetupDialog::setSearchFilter(const QString& str)
|
||||||
{
|
{
|
||||||
this->CacheValues->selectionModel()->clear();
|
this->CacheValues->selectionModel()->clear();
|
||||||
this->CacheValues->setSearchFilter(str);
|
const bool valid = this->CacheValues->setSearchFilter(str);
|
||||||
|
QtCMake::setSearchFilterColor(this->Search, valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeSetupDialog::doOutputContextMenu(QPoint pt)
|
void CMakeSetupDialog::doOutputContextMenu(QPoint pt)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#include "EnvironmentDialog.h"
|
#include "EnvironmentDialog.h"
|
||||||
|
|
||||||
|
#include "QCMakeWidgets.h"
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
@@ -110,14 +111,11 @@ EnvironmentDialog::EnvironmentDialog(const QProcessEnvironment& environment,
|
|||||||
&EnvironmentDialog::addEntry);
|
&EnvironmentDialog::addEntry);
|
||||||
QObject::connect(this->RemoveEntry, &QAbstractButton::clicked, this,
|
QObject::connect(this->RemoveEntry, &QAbstractButton::clicked, this,
|
||||||
&EnvironmentDialog::removeSelectedEntries);
|
&EnvironmentDialog::removeSelectedEntries);
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
QObject::connect(
|
||||||
QObject::connect(this->Search, &QLineEdit::textChanged, this->m_filter,
|
this->Search, &QLineEdit::textChanged, [this](const QString& text) {
|
||||||
QOverload<const QString&>::of(
|
const bool valid = QtCMake::setSearchFilter(this->m_filter, text);
|
||||||
&EnvironmentSearchFilter::setFilterRegularExpression));
|
QtCMake::setSearchFilterColor(this->Search, valid);
|
||||||
#else
|
});
|
||||||
QObject::connect(this->Search, &QLineEdit::textChanged, this->m_filter,
|
|
||||||
&EnvironmentSearchFilter::setFilterFixedString);
|
|
||||||
#endif
|
|
||||||
QObject::connect(this->Environment->selectionModel(),
|
QObject::connect(this->Environment->selectionModel(),
|
||||||
&QItemSelectionModel::selectionChanged, this,
|
&QItemSelectionModel::selectionChanged, this,
|
||||||
&EnvironmentDialog::selectionChanged);
|
&EnvironmentDialog::selectionChanged);
|
||||||
|
|||||||
@@ -167,13 +167,9 @@ bool QCMakeCacheView::showAdvanced() const
|
|||||||
return this->AdvancedFilter->showAdvanced();
|
return this->AdvancedFilter->showAdvanced();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCMakeCacheView::setSearchFilter(const QString& s)
|
bool QCMakeCacheView::setSearchFilter(const QString& s)
|
||||||
{
|
{
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
return QtCMake::setSearchFilter(this->SearchFilter, s);
|
||||||
this->SearchFilter->setFilterRegularExpression(s);
|
|
||||||
#else
|
|
||||||
this->SearchFilter->setFilterFixedString(s);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
|
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
|
||||||
|
|||||||
@@ -28,12 +28,13 @@ public:
|
|||||||
|
|
||||||
QSize sizeHint() const { return QSize(200, 200); }
|
QSize sizeHint() const { return QSize(200, 200); }
|
||||||
|
|
||||||
|
// set the search filter string. any property key or value not matching will
|
||||||
|
// be filtered out
|
||||||
|
bool setSearchFilter(const QString&);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// set whether to show advanced entries
|
// set whether to show advanced entries
|
||||||
void setShowAdvanced(bool);
|
void setShowAdvanced(bool);
|
||||||
// set the search filter string. any property key or value not matching will
|
|
||||||
// be filtered out
|
|
||||||
void setSearchFilter(const QString&);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
|
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
|
||||||
|
|||||||
@@ -10,8 +10,13 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
|
# include <QRegularExpression>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
# include <QFileSystemModel>
|
# include <QFileSystemModel>
|
||||||
#else
|
#else
|
||||||
@@ -155,3 +160,32 @@ QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const
|
|||||||
{
|
{
|
||||||
return QDir::fromNativeSeparators(QCompleter::pathFromIndex(idx));
|
return QDir::fromNativeSeparators(QCompleter::pathFromIndex(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace QtCMake {
|
||||||
|
bool setSearchFilter(QSortFilterProxyModel* model, const QString& searchString)
|
||||||
|
{
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
|
QRegularExpression const regex(searchString,
|
||||||
|
QRegularExpression::CaseInsensitiveOption |
|
||||||
|
QRegularExpression::DontCaptureOption);
|
||||||
|
if (regex.isValid()) {
|
||||||
|
model->setFilterRegularExpression(regex);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
model->setFilterFixedString(QString{});
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
model->setFilterFixedString(searchString);
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSearchFilterColor(QLineEdit* edit, bool valid)
|
||||||
|
{
|
||||||
|
QPalette palette;
|
||||||
|
if (!valid) {
|
||||||
|
palette.setColor(QPalette::Base, Qt::red);
|
||||||
|
}
|
||||||
|
edit->setPalette(palette);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
class QSortFilterProxyModel;
|
||||||
|
|
||||||
// common widgets for Qt based CMake
|
// common widgets for Qt based CMake
|
||||||
|
|
||||||
@@ -76,3 +77,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace QtCMake {
|
||||||
|
bool setSearchFilter(QSortFilterProxyModel* model,
|
||||||
|
const QString& searchString);
|
||||||
|
|
||||||
|
void setSearchFilterColor(QLineEdit* edit, bool valid);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user