summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog
diff options
context:
space:
mode:
Diffstat (limited to 'Source/QtDialog')
-rw-r--r--Source/QtDialog/CMakeSetup.cxx37
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx3
-rw-r--r--Source/QtDialog/EnvironmentDialog.cxx14
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx8
-rw-r--r--Source/QtDialog/QCMakeCacheView.h7
-rw-r--r--Source/QtDialog/QCMakeWidgets.cxx34
-rw-r--r--Source/QtDialog/QCMakeWidgets.h8
7 files changed, 76 insertions, 35 deletions
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index fb12b7d..50e8e3a 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -22,26 +22,27 @@
#include "cmSystemTools.h" // IWYU pragma: keep
#include "cmake.h"
-static const char* cmDocumentationName[][2] = { { nullptr,
- " cmake-gui - CMake GUI." },
- { nullptr, nullptr } };
-
-static const char* cmDocumentationUsage[][2] = {
- { nullptr,
- " cmake-gui [options]\n"
- " cmake-gui [options] <path-to-source>\n"
- " cmake-gui [options] <path-to-existing-build>\n"
- " cmake-gui [options] -S <path-to-source> -B <path-to-build>\n"
- " cmake-gui [options] --browse-manual\n" },
- { nullptr, nullptr }
+namespace {
+const cmDocumentationEntry cmDocumentationName = {
+ {},
+ " cmake-gui - CMake GUI."
};
-static const char* cmDocumentationOptions[][2] = {
+const cmDocumentationEntry cmDocumentationUsage = {
+ {},
+ " cmake-gui [options]\n"
+ " cmake-gui [options] <path-to-source>\n"
+ " cmake-gui [options] <path-to-existing-build>\n"
+ " cmake-gui [options] -S <path-to-source> -B <path-to-build>\n"
+ " cmake-gui [options] --browse-manual"
+};
+
+const cmDocumentationEntry cmDocumentationOptions[3] = {
{ "-S <path-to-source>", "Explicitly specify a source directory." },
{ "-B <path-to-build>", "Explicitly specify a build directory." },
- { "--preset=<preset>", "Specify a configure preset." },
- { nullptr, nullptr }
+ { "--preset=<preset>", "Specify a configure preset." }
};
+} // anonymous namespace
#if defined(Q_OS_MAC)
static int cmOSXInstall(std::string dir);
@@ -79,7 +80,7 @@ int main(int argc, char** argv)
doc.addCMakeStandardDocSections();
if (argc2 > 1 && doc.CheckOptions(argc2, argv2)) {
// Construct and print requested documentation.
- cmake hcm(cmake::RoleInternal, cmState::Unknown);
+ cmake hcm(cmake::RoleInternal, cmState::Help);
hcm.SetHomeDirectory("");
hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
@@ -91,7 +92,7 @@ int main(int argc, char** argv)
doc.AppendSection("Generators", generators);
doc.PrependSection("Options", cmDocumentationOptions);
- return (doc.PrintRequestedDocumentation(std::cout) ? 0 : 1);
+ return !doc.PrintRequestedDocumentation(std::cout);
}
#if defined(Q_OS_MAC)
@@ -252,6 +253,7 @@ int main(int argc, char** argv)
# include <unistd.h>
# include "cm_sys_stat.h"
+
static bool cmOSXInstall(std::string const& dir, std::string const& tool)
{
if (tool.empty()) {
@@ -277,6 +279,7 @@ static bool cmOSXInstall(std::string const& dir, std::string const& tool)
<< "': " << strerror(err) << "\n";
return false;
}
+
static int cmOSXInstall(std::string dir)
{
if (!cmHasLiteralSuffix(dir, "/")) {
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 01fa7bb..3d4d726 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -1344,7 +1344,8 @@ void CMakeSetupDialog::showUserChanges()
void CMakeSetupDialog::setSearchFilter(const QString& str)
{
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)
diff --git a/Source/QtDialog/EnvironmentDialog.cxx b/Source/QtDialog/EnvironmentDialog.cxx
index bf89816..2752c0f 100644
--- a/Source/QtDialog/EnvironmentDialog.cxx
+++ b/Source/QtDialog/EnvironmentDialog.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "EnvironmentDialog.h"
+#include "QCMakeWidgets.h"
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QItemSelectionModel>
@@ -110,14 +111,11 @@ EnvironmentDialog::EnvironmentDialog(const QProcessEnvironment& environment,
&EnvironmentDialog::addEntry);
QObject::connect(this->RemoveEntry, &QAbstractButton::clicked, this,
&EnvironmentDialog::removeSelectedEntries);
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
- QObject::connect(this->Search, &QLineEdit::textChanged, this->m_filter,
- QOverload<const QString&>::of(
- &EnvironmentSearchFilter::setFilterRegularExpression));
-#else
- QObject::connect(this->Search, &QLineEdit::textChanged, this->m_filter,
- &EnvironmentSearchFilter::setFilterFixedString);
-#endif
+ QObject::connect(
+ this->Search, &QLineEdit::textChanged, [this](const QString& text) {
+ const bool valid = QtCMake::setSearchFilter(this->m_filter, text);
+ QtCMake::setSearchFilterColor(this->Search, valid);
+ });
QObject::connect(this->Environment->selectionModel(),
&QItemSelectionModel::selectionChanged, this,
&EnvironmentDialog::selectionChanged);
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index f79d6fc..6f19b67 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -167,13 +167,9 @@ bool QCMakeCacheView::showAdvanced() const
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))
- this->SearchFilter->setFilterRegularExpression(s);
-#else
- this->SearchFilter->setFilterFixedString(s);
-#endif
+ return QtCMake::setSearchFilter(this->SearchFilter, s);
}
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h
index c5e6dd4..89068ab 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -28,12 +28,13 @@ public:
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:
// set whether to show advanced entries
void setShowAdvanced(bool);
- // set the search filter string. any property key or value not matching will
- // be filtered out
- void setSearchFilter(const QString&);
protected:
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx
index 03d6ed1..f1bb2f1 100644
--- a/Source/QtDialog/QCMakeWidgets.cxx
+++ b/Source/QtDialog/QCMakeWidgets.cxx
@@ -10,8 +10,13 @@
#include <QFileDialog>
#include <QFileInfo>
#include <QResizeEvent>
+#include <QSortFilterProxyModel>
#include <QToolButton>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
+# include <QRegularExpression>
+#endif
+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
# include <QFileSystemModel>
#else
@@ -155,3 +160,32 @@ QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const
{
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);
+}
+}
diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h
index 9a2a27e..858a913 100644
--- a/Source/QtDialog/QCMakeWidgets.h
+++ b/Source/QtDialog/QCMakeWidgets.h
@@ -9,6 +9,7 @@
#include <QLineEdit>
class QToolButton;
+class QSortFilterProxyModel;
// 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);
+}