From 44f1744bed50e6ef47b179810a7533538b31722b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 1 Jun 2020 08:00:25 -0400 Subject: QtDialog: avoid using deprecated APIs --- Source/QtDialog/CMakeSetupDialog.cxx | 4 ++++ Source/QtDialog/QCMakeCacheView.cxx | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 930f300..5916a96 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -595,7 +595,11 @@ void CMakeSetupDialog::doHelp() QDialog dialog; QFontMetrics met(this->font()); +#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + int msgWidth = met.horizontalAdvance(msg); +#else int msgWidth = met.width(msg); +#endif dialog.setMinimumSize(msgWidth / 15, 20); dialog.setWindowTitle(tr("Help")); QVBoxLayout* l = new QVBoxLayout(&dialog); diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 3e6a49e..40cc89c 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -209,6 +209,10 @@ void QCMakeCacheModel::clear() void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + this->beginResetModel(); +#endif + QSet newProps; QSet newProps2; @@ -231,8 +235,13 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) if (View == FlatView) { QCMakePropertyList newP = newProps.toList(); QCMakePropertyList newP2 = newProps2.toList(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) + std::sort(newP.begin(), newP.end()); + std::sort(newP2.begin(), newP2.end()); +#else qSort(newP); qSort(newP2); +#endif int row_count = 0; foreach (QCMakeProperty const& p, newP) { this->insertRow(row_count); @@ -262,10 +271,17 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) parentItems.append( new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key)); parentItems.append(new QStandardItem()); +#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) + parentItems[0]->setData(QBrush(QColor(255, 100, 100)), + Qt::BackgroundRole); + parentItems[1]->setData(QBrush(QColor(255, 100, 100)), + Qt::BackgroundRole); +#else parentItems[0]->setData(QBrush(QColor(255, 100, 100)), Qt::BackgroundColorRole); parentItems[1]->setData(QBrush(QColor(255, 100, 100)), Qt::BackgroundColorRole); +#endif parentItems[0]->setData(1, GroupRole); parentItems[1]->setData(1, GroupRole); root->appendRow(parentItems); @@ -305,7 +321,11 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) } this->blockSignals(b); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + this->endResetModel(); +#else this->reset(); +#endif } QCMakeCacheModel::ViewType QCMakeCacheModel::viewType() const @@ -315,6 +335,10 @@ QCMakeCacheModel::ViewType QCMakeCacheModel::viewType() const void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + this->beginResetModel(); +#endif + this->View = t; QCMakePropertyList props = this->properties(); @@ -330,7 +354,11 @@ void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t) this->setProperties(oldProps); this->setProperties(props); this->blockSignals(b); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + this->endResetModel(); +#else this->reset(); +#endif } void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1, @@ -356,10 +384,15 @@ void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1, } if (isNew) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) + this->setData(idx1, QBrush(QColor(255, 100, 100)), Qt::BackgroundRole); + this->setData(idx2, QBrush(QColor(255, 100, 100)), Qt::BackgroundRole); +#else this->setData(idx1, QBrush(QColor(255, 100, 100)), Qt::BackgroundColorRole); this->setData(idx2, QBrush(QColor(255, 100, 100)), Qt::BackgroundColorRole); +#endif } } @@ -409,7 +442,11 @@ void QCMakeCacheModel::breakProperties( reorgProps.append((*iter)[0]); iter = tmp.erase(iter); } else { +#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) + std::sort(iter->begin(), iter->end()); +#else qSort(*iter); +#endif ++iter; } } @@ -639,9 +676,15 @@ QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option, // increase to checkbox size QStyleOptionButton opt; opt.QStyleOption::operator=(option); +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) + sz = sz.expandedTo( + style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &opt, nullptr) + .size()); +#else sz = sz.expandedTo( style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, nullptr) .size()); +#endif return sz; } -- cgit v0.12 From ed2fe558b03e006d708c0fb210f218d9a80ffc01 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 1 Jun 2020 08:14:45 -0400 Subject: CursesDialog: resolve clang-tidy warnings Fixes: - unnecessary bool expression (cmCursesMainForm) - removes a duplicate if/else branch (RegexExplorer) - collapses redundant if/else branch logic (CMakeSetupDialog and cmCursesStringWidget) --- Source/CursesDialog/cmCursesMainForm.cxx | 6 +----- Source/CursesDialog/cmCursesStringWidget.cxx | 10 ++++------ Source/QtDialog/CMakeSetupDialog.cxx | 9 +-------- Source/QtDialog/RegexExplorer.cxx | 3 --- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index df34283..ce1a715 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -853,11 +853,7 @@ void cmCursesMainForm::HandleInput() } // switch advanced on/off else if (key == 't') { - if (this->AdvancedMode) { - this->AdvancedMode = false; - } else { - this->AdvancedMode = true; - } + this->AdvancedMode = !this->AdvancedMode; getmaxyx(stdscr, y, x); this->RePost(); this->Render(1, 1, x, y); diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index c629478..4830d63 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -105,12 +105,10 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, if (!this->InEdit && (key != 10 && key != KEY_ENTER && key != 'i')) { return false; } - // enter edit with return and i (vim binding) - if (!this->InEdit && (key == 10 || key == KEY_ENTER || key == 'i')) { - this->OnReturn(fm, w); - } - // leave edit with return (but not i -- not a toggle) - else if (this->InEdit && (key == 10 || key == KEY_ENTER)) { + // toggle edit with return + if ((key == 10 || key == KEY_ENTER) + // enter edit with i (and not-edit mode) + || (!this->InEdit && key == 'i')) { this->OnReturn(fm, w); } else if (key == KEY_DOWN || key == ctrl('n') || key == KEY_UP || key == ctrl('p') || key == KEY_NPAGE || key == ctrl('d') || diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 5916a96..6dbfe11 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -1060,14 +1060,7 @@ void CMakeSetupDialog::enterState(CMakeSetupDialog::State s) this->GenerateAction->setEnabled(false); this->OpenProjectButton->setEnabled(false); this->GenerateButton->setText(tr("&Stop")); - } else if (s == ReadyConfigure) { - this->setEnabledState(true); - this->GenerateButton->setEnabled(true); - this->GenerateAction->setEnabled(true); - this->ConfigureButton->setEnabled(true); - this->ConfigureButton->setText(tr("&Configure")); - this->GenerateButton->setText(tr("&Generate")); - } else if (s == ReadyGenerate) { + } else if (s == ReadyConfigure || s == ReadyGenerate) { this->setEnabledState(true); this->GenerateButton->setEnabled(true); this->GenerateAction->setEnabled(true); diff --git a/Source/QtDialog/RegexExplorer.cxx b/Source/QtDialog/RegexExplorer.cxx index 746fd8a..6194940 100644 --- a/Source/QtDialog/RegexExplorer.cxx +++ b/Source/QtDialog/RegexExplorer.cxx @@ -147,9 +147,6 @@ bool RegexExplorer::stripEscapes(std::string& source) } else if (nextc == 'n') { result.append(1, '\n'); in++; - } else if (nextc == 't') { - result.append(1, '\t'); - in++; } else if (isalnum(nextc) || nextc == '\0') { return false; } else { -- cgit v0.12 From 95721f0a822e85e962ccb49a57de5bd4ca7baddd Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 1 Jun 2020 06:53:39 -0400 Subject: ci: install ncurses and Qt development into the Fedora 31 image --- .gitlab/ci/docker/fedora31/install_deps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/docker/fedora31/install_deps.sh b/.gitlab/ci/docker/fedora31/install_deps.sh index bcb1564..0d857c1 100755 --- a/.gitlab/ci/docker/fedora31/install_deps.sh +++ b/.gitlab/ci/docker/fedora31/install_deps.sh @@ -1,8 +1,10 @@ #!/bin/sh # Install build requirements. -dnf install -y \ - openssl-devel +dnf install --setopt=install_weak_deps=False -y \ + ncurses-devel \ + openssl-devel \ + qt5-qtbase-devel # Install development tools. dnf install --setopt=install_weak_deps=False -y \ -- cgit v0.12 From 1e8ecfccdd6faf5c46e933cf21209bb5885694a2 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 1 Jun 2020 06:51:58 -0400 Subject: gitlab-ci: also build ncurses and Qt code on Linux --- .gitlab-ci.yml | 8 ++++---- .gitlab/ci/configure_fedora31_common.cmake | 4 ++++ .gitlab/ci/configure_fedora31_makefiles.cmake | 2 +- .gitlab/ci/configure_fedora31_ninja.cmake | 2 +- .gitlab/ci/configure_fedora31_tidy.cmake | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 .gitlab/ci/configure_fedora31_common.cmake diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e7440f2..0a7c98a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,7 @@ - when: never .fedora31: &fedora31 - image: "kitware/cmake:ci-fedora31-x86_64-2020-05-08" + image: "kitware/cmake:ci-fedora31-x86_64-2020-06-01" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" @@ -321,7 +321,7 @@ build:fedora31-tidy: <<: - *fedora31_tidy - *cmake_build_unix - - *linux_builder_tags + - *linux_builder_tags_qt rules: *rules_settings build:fedora31-sphinx: @@ -336,7 +336,7 @@ build:fedora31-ninja: - *fedora31_ninja - *cmake_build_unix - *cmake_build_artifacts - - *linux_builder_tags + - *linux_builder_tags_qt rules: *manual_rules_settings test:fedora31-ninja: @@ -355,7 +355,7 @@ build:fedora31-makefiles: - *fedora31_makefiles - *cmake_build_unix - *cmake_build_artifacts - - *linux_builder_tags + - *linux_builder_tags_qt rules: *manual_rules_settings test:fedora31-makefiles: diff --git a/.gitlab/ci/configure_fedora31_common.cmake b/.gitlab/ci/configure_fedora31_common.cmake new file mode 100644 index 0000000..dc068d5 --- /dev/null +++ b/.gitlab/ci/configure_fedora31_common.cmake @@ -0,0 +1,4 @@ +set(BUILD_CursesDialog ON CACHE BOOL "") +set(BUILD_QtDialog ON CACHE BOOL "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/ci/configure_fedora31_makefiles.cmake b/.gitlab/ci/configure_fedora31_makefiles.cmake index 33f0db0..74768b7 100644 --- a/.gitlab/ci/configure_fedora31_makefiles.cmake +++ b/.gitlab/ci/configure_fedora31_makefiles.cmake @@ -1 +1 @@ -include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora31_common.cmake") diff --git a/.gitlab/ci/configure_fedora31_ninja.cmake b/.gitlab/ci/configure_fedora31_ninja.cmake index 33f0db0..74768b7 100644 --- a/.gitlab/ci/configure_fedora31_ninja.cmake +++ b/.gitlab/ci/configure_fedora31_ninja.cmake @@ -1 +1 @@ -include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora31_common.cmake") diff --git a/.gitlab/ci/configure_fedora31_tidy.cmake b/.gitlab/ci/configure_fedora31_tidy.cmake index f41ad82..55d022c 100644 --- a/.gitlab/ci/configure_fedora31_tidy.cmake +++ b/.gitlab/ci/configure_fedora31_tidy.cmake @@ -1,3 +1,3 @@ set(CMake_RUN_CLANG_TIDY ON CACHE BOOL "") -include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora31_common.cmake") -- cgit v0.12 From e1b2c0108f84ff6deaae8c4469a871caf4854a9c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 1 Jun 2020 06:52:43 -0400 Subject: gitlab-ci: add a Ninja Multi-Config test job This reuses the Ninja generator's tested build. --- .gitlab-ci.yml | 34 +++++++++++++++++++++++++ .gitlab/ci/configure_fedora31_ninja_multi.cmake | 1 + 2 files changed, 35 insertions(+) create mode 100644 .gitlab/ci/configure_fedora31_ninja_multi.cmake diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0a7c98a..cf7cb26 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -57,6 +57,14 @@ CMAKE_CONFIGURATION: fedora31_ninja CTEST_NO_WARNINGS_ALLOWED: 1 +.fedora31_ninja_multi: &fedora31_ninja_multi + extends: .fedora31 + + variables: + CMAKE_CONFIGURATION: fedora31_ninja_multi + CTEST_NO_WARNINGS_ALLOWED: 1 + CMAKE_GENERATOR: "Ninja Multi-Config" + .fedora31_makefiles: &fedora31_makefiles extends: .fedora31 @@ -297,6 +305,20 @@ interruptible: true +.cmake_test_unix_external: &cmake_test_unix_external + stage: test-ext + + script: + - *before_script_unix + - .gitlab/ci/sccache.sh + # Allow the server to already be running. + - "sccache --start-server || :" + - sccache --show-stats + - "$LAUNCHER build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake" + - sccache --show-stats + + interruptible: true + .cmake_test_windows_external: &cmake_test_windows_external stage: test-ext @@ -344,12 +366,24 @@ test:fedora31-ninja: - *fedora31_ninja - *cmake_test_unix - *linux_builder_tags_qt + - *cmake_test_artifacts rules: *rules_settings dependencies: - build:fedora31-ninja needs: - build:fedora31-ninja +test:fedora31-ninja-multi: + <<: + - *fedora31_ninja_multi + - *cmake_test_unix_external + - *linux_builder_tags_qt + rules: *rules_settings + dependencies: + - test:fedora31-ninja + needs: + - test:fedora31-ninja + build:fedora31-makefiles: <<: - *fedora31_makefiles diff --git a/.gitlab/ci/configure_fedora31_ninja_multi.cmake b/.gitlab/ci/configure_fedora31_ninja_multi.cmake new file mode 100644 index 0000000..20863a2 --- /dev/null +++ b/.gitlab/ci/configure_fedora31_ninja_multi.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") -- cgit v0.12