From 1cc61a93a255c7771988e467c27d8f7e82b9226a Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Wed, 29 May 2019 16:26:49 +0200 Subject: [PATCH] src: refactored project wizard file structure * renamed wizzard to wizard * split QtProjectWizardContentPath into multiple files * split QtProjectWizardContentPaths into multiple files * restructured subdirectories --- CMakeLists.txt | 2 +- src/lib_gui/CMakeLists.txt | 117 +- .../QtProjectWizard.cpp} | 496 +++---- .../QtProjectWizard.h} | 36 +- .../QtProjectWizardWindow.cpp} | 30 +- .../QtProjectWizardWindow.h} | 18 +- .../QtSourceGroupWizard.h} | 68 +- .../project_wizard/QtSourceGroupWizardPage.h | 163 +++ .../content/QtProjectWizardContent.cpp} | 56 +- .../content/QtProjectWizardContent.h} | 14 +- .../QtProjectWizardContentCStandard.cpp} | 18 +- .../QtProjectWizardContentCStandard.h} | 18 +- .../QtProjectWizardContentCppStandard.cpp} | 18 +- .../QtProjectWizardContentCppStandard.h} | 18 +- ...tWizardContentCrossCompilationOptions.cpp} | 30 +- ...ectWizardContentCrossCompilationOptions.h} | 18 +- .../QtProjectWizardContentCustomCommand.cpp} | 22 +- .../QtProjectWizardContentCustomCommand.h} | 18 +- .../QtProjectWizardContentExtensions.cpp} | 20 +- .../QtProjectWizardContentExtensions.h} | 20 +- .../content/QtProjectWizardContentFlags.cpp} | 22 +- .../content/QtProjectWizardContentFlags.h | 31 + .../content/QtProjectWizardContentGroup.cpp | 128 ++ .../content/QtProjectWizardContentGroup.h | 38 + .../QtProjectWizardContentJavaStandard.cpp} | 18 +- .../QtProjectWizardContentJavaStandard.h} | 18 +- .../QtProjectWizardContentPreferences.cpp} | 96 +- .../QtProjectWizardContentPreferences.h} | 18 +- .../QtProjectWizardContentProjectData.cpp} | 28 +- .../QtProjectWizardContentProjectData.h} | 18 +- .../content/QtProjectWizardContentSelect.cpp} | 28 +- .../content/QtProjectWizardContentSelect.h} | 16 +- ...QtProjectWizardContentSourceGroupData.cpp} | 32 +- .../QtProjectWizardContentSourceGroupData.h} | 18 +- ...ojectWizardContentSourceGroupInfoText.cpp} | 14 +- ...tProjectWizardContentSourceGroupInfoText.h | 18 + .../content/QtProjectWizardContentVS.cpp} | 20 +- .../content/QtProjectWizardContentVS.h | 20 + .../path/QtProjectWizardContentPath.cpp | 112 ++ .../content/path/QtProjectWizardContentPath.h | 46 + .../path/QtProjectWizardContentPathCDB.cpp | 118 ++ .../path/QtProjectWizardContentPathCDB.h | 39 + ...jectWizardContentPathCodeblocksProject.cpp | 115 ++ ...rojectWizardContentPathCodeblocksProject.h | 40 + ...ectWizardContentPathDependenciesGradle.cpp | 33 + ...ojectWizardContentPathDependenciesGradle.h | 27 + ...jectWizardContentPathDependenciesMaven.cpp | 32 + ...rojectWizardContentPathDependenciesMaven.h | 26 + ...jectWizardContentPathPythonEnvironment.cpp | 90 ++ ...rojectWizardContentPathPythonEnvironment.h | 30 + ...jectWizardContentPathSonargraphProject.cpp | 166 +++ ...rojectWizardContentPathSonargraphProject.h | 46 + ...QtProjectWizardContentPathSourceGradle.cpp | 73 + .../QtProjectWizardContentPathSourceGradle.h | 33 + .../QtProjectWizardContentPathSourceMaven.cpp | 102 ++ .../QtProjectWizardContentPathSourceMaven.h | 33 + .../paths/QtProjectWizardContentPaths.cpp | 179 +++ .../paths/QtProjectWizardContentPaths.h | 62 + .../QtProjectWizardContentPathsClassJava.cpp | 56 + .../QtProjectWizardContentPathsClassJava.h | 24 + .../QtProjectWizardContentPathsExclude.cpp | 39 + .../QtProjectWizardContentPathsExclude.h | 17 + ...ojectWizardContentPathsFrameworkSearch.cpp | 40 + ...ProjectWizardContentPathsFrameworkSearch.h | 21 + ...izardContentPathsFrameworkSearchGlobal.cpp | 34 + ...tWizardContentPathsFrameworkSearchGlobal.h | 18 + ...tProjectWizardContentPathsHeaderSearch.cpp | 394 ++++++ .../QtProjectWizardContentPathsHeaderSearch.h | 42 + ...ctWizardContentPathsHeaderSearchGlobal.cpp | 116 ++ ...jectWizardContentPathsHeaderSearchGlobal.h | 26 + ...rojectWizardContentPathsIndexedHeaders.cpp | 324 +++++ ...tProjectWizardContentPathsIndexedHeaders.h | 39 + .../QtProjectWizardContentPathsSource.cpp | 84 ++ .../paths/QtProjectWizardContentPathsSource.h | 22 + src/lib_gui/qt/window/QtMainWindow.cpp | 18 +- src/lib_gui/qt/window/QtPreferencesWindow.cpp | 19 +- src/lib_gui/qt/window/QtPreferencesWindow.h | 4 +- .../QtProjectWizzardContentFlags.h | 31 - .../QtProjectWizzardContentGroup.cpp | 128 -- .../QtProjectWizzardContentGroup.h | 38 - .../QtProjectWizzardContentPath.cpp | 815 ----------- .../QtProjectWizzardContentPath.h | 262 ---- .../QtProjectWizzardContentPaths.cpp | 1231 ----------------- .../QtProjectWizzardContentPaths.h | 225 --- ...ProjectWizzardContentSourceGroupInfoText.h | 18 - .../QtProjectWizzardContentVS.h | 20 - .../QtSourceGroupWizzardPage.h | 163 --- 87 files changed, 3834 insertions(+), 3617 deletions(-) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzard.cpp => project_wizard/QtProjectWizard.cpp} (51%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzard.h => project_wizard/QtProjectWizard.h} (68%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardWindow.cpp => project_wizard/QtProjectWizardWindow.cpp} (61%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardWindow.h => project_wizard/QtProjectWizardWindow.h} (61%) rename src/lib_gui/qt/{window/project_wizzard/QtSourceGroupWizzard.h => project_wizard/QtSourceGroupWizard.h} (53%) create mode 100644 src/lib_gui/qt/project_wizard/QtSourceGroupWizardPage.h rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContent.cpp => project_wizard/content/QtProjectWizardContent.cpp} (54%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContent.h => project_wizard/content/QtProjectWizardContent.h} (83%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentCStandard.cpp => project_wizard/content/QtProjectWizardContentCStandard.cpp} (63%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentCStandard.h => project_wizard/content/QtProjectWizardContentCStandard.h} (52%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentCppStandard.cpp => project_wizard/content/QtProjectWizardContentCppStandard.cpp} (63%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentCppStandard.h => project_wizard/content/QtProjectWizardContentCppStandard.h} (51%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp => project_wizard/content/QtProjectWizardContentCrossCompilationOptions.cpp} (82%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h => project_wizard/content/QtProjectWizardContentCrossCompilationOptions.h} (60%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentCustomCommand.cpp => project_wizard/content/QtProjectWizardContentCustomCommand.cpp} (78%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentCustomCommand.h => project_wizard/content/QtProjectWizardContentCustomCommand.h} (53%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentExtensions.cpp => project_wizard/content/QtProjectWizardContentExtensions.cpp} (53%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentExtensions.h => project_wizard/content/QtProjectWizardContentExtensions.h} (53%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentFlags.cpp => project_wizard/content/QtProjectWizardContentFlags.cpp} (67%) create mode 100644 src/lib_gui/qt/project_wizard/content/QtProjectWizardContentFlags.h create mode 100644 src/lib_gui/qt/project_wizard/content/QtProjectWizardContentGroup.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/QtProjectWizardContentGroup.h rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentJavaStandard.cpp => project_wizard/content/QtProjectWizardContentJavaStandard.cpp} (62%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentJavaStandard.h => project_wizard/content/QtProjectWizardContentJavaStandard.h} (51%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentPreferences.cpp => project_wizard/content/QtProjectWizardContentPreferences.cpp} (86%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentPreferences.h => project_wizard/content/QtProjectWizardContentPreferences.h} (89%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentProjectData.cpp => project_wizard/content/QtProjectWizardContentProjectData.cpp} (79%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentProjectData.h => project_wizard/content/QtProjectWizardContentProjectData.h} (59%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentSelect.cpp => project_wizard/content/QtProjectWizardContentSelect.cpp} (93%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentSelect.h => project_wizard/content/QtProjectWizardContentSelect.h} (64%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentSourceGroupData.cpp => project_wizard/content/QtProjectWizardContentSourceGroupData.cpp} (57%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentSourceGroupData.h => project_wizard/content/QtProjectWizardContentSourceGroupData.h} (59%) rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.cpp => project_wizard/content/QtProjectWizardContentSourceGroupInfoText.cpp} (67%) create mode 100644 src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupInfoText.h rename src/lib_gui/qt/{window/project_wizzard/QtProjectWizzardContentVS.cpp => project_wizard/content/QtProjectWizardContentVS.cpp} (66%) create mode 100644 src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.h create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.h create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.h create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.h create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.h create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.h create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.h create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.h create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.h create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.h create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPaths.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPaths.h create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.h create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.h create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.h create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.h create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.h create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.h create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.h create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.cpp create mode 100644 src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.h delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentGroup.cpp delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentGroup.h delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.h delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentVS.h delete mode 100644 src/lib_gui/qt/window/project_wizzard/QtSourceGroupWizzardPage.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ba43af79..8bc5ba30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -475,7 +475,7 @@ set_property( "${LIB_INCLUDE_PATHS}" "${LIB_CXX_INCLUDE_PATHS}" "${LIB_JAVA_INCLUDE_PATHS}" - "${LIB_PYTHON_INCLUDE_PATHS}" # required for QtProjectWizzardContentPathsSource::getFilePaths() + "${LIB_PYTHON_INCLUDE_PATHS}" # required for QtProjectWizardContentPathsSource::getFilePaths() "${LIB_LICENSE_INCLUDE_PATHS}" "${CMAKE_BINARY_DIR}/src/lib_gui" "${CMAKE_BINARY_DIR}/src/lib_license" diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index 3ba8f6e8..2c14395a 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -106,6 +106,82 @@ add_files( qt/network/QtUpdateChecker.cpp qt/network/QtUpdateChecker.h + qt/project_wizard/content/path/QtProjectWizardContentPath.cpp + qt/project_wizard/content/path/QtProjectWizardContentPath.h + qt/project_wizard/content/path/QtProjectWizardContentPathCDB.cpp + qt/project_wizard/content/path/QtProjectWizardContentPathCDB.h + qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp + qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.h + qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.cpp + qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.h + qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.cpp + qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.h + qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp + qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.h + qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.cpp + qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.h + qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp + qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.h + qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp + qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.h + + qt/project_wizard/content/paths/QtProjectWizardContentPaths.cpp + qt/project_wizard/content/paths/QtProjectWizardContentPaths.h + qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.cpp + qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.h + qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.cpp + qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.h + qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.cpp + qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.h + qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.cpp + qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.h + qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.cpp + qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.h + qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.cpp + qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.h + qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.cpp + qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.h + qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.cpp + qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.h + + qt/project_wizard/content/QtProjectWizardContent.cpp + qt/project_wizard/content/QtProjectWizardContent.h + qt/project_wizard/content/QtProjectWizardContentCppStandard.cpp + qt/project_wizard/content/QtProjectWizardContentCppStandard.h + qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.cpp + qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.h + qt/project_wizard/content/QtProjectWizardContentCStandard.cpp + qt/project_wizard/content/QtProjectWizardContentCStandard.h + qt/project_wizard/content/QtProjectWizardContentCustomCommand.cpp + qt/project_wizard/content/QtProjectWizardContentCustomCommand.h + qt/project_wizard/content/QtProjectWizardContentExtensions.cpp + qt/project_wizard/content/QtProjectWizardContentExtensions.h + qt/project_wizard/content/QtProjectWizardContentFlags.cpp + qt/project_wizard/content/QtProjectWizardContentFlags.h + qt/project_wizard/content/QtProjectWizardContentGroup.cpp + qt/project_wizard/content/QtProjectWizardContentGroup.h + qt/project_wizard/content/QtProjectWizardContentJavaStandard.cpp + qt/project_wizard/content/QtProjectWizardContentJavaStandard.h + qt/project_wizard/content/QtProjectWizardContentPreferences.cpp + qt/project_wizard/content/QtProjectWizardContentPreferences.h + qt/project_wizard/content/QtProjectWizardContentProjectData.cpp + qt/project_wizard/content/QtProjectWizardContentProjectData.h + qt/project_wizard/content/QtProjectWizardContentSelect.cpp + qt/project_wizard/content/QtProjectWizardContentSelect.h + qt/project_wizard/content/QtProjectWizardContentSourceGroupData.cpp + qt/project_wizard/content/QtProjectWizardContentSourceGroupData.h + qt/project_wizard/content/QtProjectWizardContentSourceGroupInfoText.cpp + qt/project_wizard/content/QtProjectWizardContentSourceGroupInfoText.h + qt/project_wizard/content/QtProjectWizardContentVS.cpp + qt/project_wizard/content/QtProjectWizardContentVS.h + + qt/project_wizard/QtProjectWizard.cpp + qt/project_wizard/QtProjectWizard.h + qt/project_wizard/QtProjectWizardWindow.cpp + qt/project_wizard/QtProjectWizardWindow.h + qt/project_wizard/QtSourceGroupWizard.h + qt/project_wizard/QtSourceGroupWizardPage.h + qt/utility/QtContextMenu.cpp qt/utility/QtContextMenu.h qt/utility/QtDeviceScaledPixmap.cpp @@ -193,47 +269,6 @@ add_files( qt/view/QtViewWidgetWrapper.cpp qt/view/QtViewWidgetWrapper.h - qt/window/project_wizzard/QtProjectWizzard.cpp - qt/window/project_wizzard/QtProjectWizzard.h - qt/window/project_wizzard/QtProjectWizzardContent.cpp - qt/window/project_wizzard/QtProjectWizzardContent.h - qt/window/project_wizzard/QtProjectWizzardContentCppStandard.cpp - qt/window/project_wizzard/QtProjectWizzardContentCppStandard.h - qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp - qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h - qt/window/project_wizzard/QtProjectWizzardContentCStandard.cpp - qt/window/project_wizzard/QtProjectWizzardContentCStandard.h - qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.cpp - qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.h - qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp - qt/window/project_wizzard/QtProjectWizzardContentExtensions.h - qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp - qt/window/project_wizzard/QtProjectWizzardContentFlags.h - qt/window/project_wizzard/QtProjectWizzardContentGroup.cpp - qt/window/project_wizzard/QtProjectWizzardContentGroup.h - qt/window/project_wizzard/QtProjectWizzardContentJavaStandard.cpp - qt/window/project_wizzard/QtProjectWizzardContentJavaStandard.h - qt/window/project_wizzard/QtProjectWizzardContentPath.cpp - qt/window/project_wizzard/QtProjectWizzardContentPath.h - qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp - qt/window/project_wizzard/QtProjectWizzardContentPaths.h - qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp - qt/window/project_wizzard/QtProjectWizzardContentPreferences.h - qt/window/project_wizzard/QtProjectWizzardContentProjectData.cpp - qt/window/project_wizzard/QtProjectWizzardContentProjectData.h - qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp - qt/window/project_wizzard/QtProjectWizzardContentSelect.h - qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.cpp - qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h - qt/window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.cpp - qt/window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.h - qt/window/project_wizzard/QtProjectWizzardContentVS.cpp - qt/window/project_wizzard/QtProjectWizzardContentVS.h - qt/window/project_wizzard/QtProjectWizzardWindow.cpp - qt/window/project_wizzard/QtProjectWizzardWindow.h - qt/window/project_wizzard/QtSourceGroupWizzard.h - qt/window/project_wizzard/QtSourceGroupWizzardPage.h - qt/window/QtAbout.cpp qt/window/QtAbout.h qt/window/QtAboutLicense.cpp diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp similarity index 51% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp rename to src/lib_gui/qt/project_wizard/QtProjectWizard.cpp index 88397af4..e9fb2d93 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzard.h" +#include "QtProjectWizard.h" #include #include @@ -7,23 +7,39 @@ #include #include -#include "QtProjectWizzardContent.h" -#include "QtProjectWizzardContentCppStandard.h" -#include "QtProjectWizzardContentCrossCompilationOptions.h" -#include "QtProjectWizzardContentCStandard.h" -#include "QtProjectWizzardContentCustomCommand.h" -#include "QtProjectWizzardContentExtensions.h" -#include "QtProjectWizzardContentFlags.h" -#include "QtProjectWizzardContentJavaStandard.h" -#include "QtProjectWizzardContentPath.h" -#include "QtProjectWizzardContentPaths.h" -#include "QtProjectWizzardContentProjectData.h" -#include "QtProjectWizzardContentSelect.h" -#include "QtProjectWizzardContentSourceGroupData.h" -#include "QtProjectWizzardContentSourceGroupInfoText.h" -#include "QtProjectWizzardContentGroup.h" -#include "QtProjectWizzardContentVS.h" -#include "QtSourceGroupWizzardPage.h" +#include "QtProjectWizardContent.h" +#include "QtProjectWizardContentCppStandard.h" +#include "QtProjectWizardContentCrossCompilationOptions.h" +#include "QtProjectWizardContentCStandard.h" +#include "QtProjectWizardContentCustomCommand.h" +#include "QtProjectWizardContentExtensions.h" +#include "QtProjectWizardContentFlags.h" +#include "QtProjectWizardContentGroup.h" +#include "QtProjectWizardContentJavaStandard.h" +#include "QtProjectWizardContentPath.h" +#include "QtProjectWizardContentPathCDB.h" +#include "QtProjectWizardContentPathCodeblocksProject.h" +#include "QtProjectWizardContentPathDependenciesGradle.h" +#include "QtProjectWizardContentPathDependenciesMaven.h" +#include "QtProjectWizardContentPathPythonEnvironment.h" +#include "QtProjectWizardContentPathSonargraphProject.h" +#include "QtProjectWizardContentPathSourceGradle.h" +#include "QtProjectWizardContentPathSourceMaven.h" +#include "QtProjectWizardContentPaths.h" +#include "QtProjectWizardContentPathsClassJava.h" +#include "QtProjectWizardContentPathsExclude.h" +#include "QtProjectWizardContentPathsFrameworkSearch.h" +#include "QtProjectWizardContentPathsFrameworkSearchGlobal.h" +#include "QtProjectWizardContentPathsHeaderSearch.h" +#include "QtProjectWizardContentPathsHeaderSearchGlobal.h" +#include "QtProjectWizardContentPathsIndexedHeaders.h" +#include "QtProjectWizardContentPathsSource.h" +#include "QtProjectWizardContentProjectData.h" +#include "QtProjectWizardContentSelect.h" +#include "QtProjectWizardContentSourceGroupData.h" +#include "QtProjectWizardContentSourceGroupInfoText.h" +#include "QtProjectWizardContentVS.h" +#include "QtSourceGroupWizardPage.h" #include "SourceGroupSettingsCEmpty.h" #include "SourceGroupSettingsCppEmpty.h" #include "SourceGroupSettingsCustomCommand.h" @@ -90,41 +106,41 @@ namespace } template - std::vector> getSourceGroupWizzardPages(); + std::vector> getSourceGroupWizardPages(); template <> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Language Standard", 470, 460); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Language Standard", 470, 460); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Indexed Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Indexed Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Include Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Include Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } if (utility::getOsType() == OS_MAC) { - QtSourceGroupWizzardPage page("Framework Search Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Framework Search Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Advanced (optional)"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Advanced (optional)"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } @@ -132,38 +148,38 @@ namespace } template <> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Language Standard", 470, 460); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Language Standard", 470, 460); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Indexed Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Indexed Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Include Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Include Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } if (utility::getOsType() == OS_MAC) { - QtSourceGroupWizzardPage page("Framework Search Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Framework Search Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Advanced (optional)"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Advanced (optional)"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } @@ -171,32 +187,32 @@ namespace } template <> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Compilation Database Path"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL, "Compilation Database"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Compilation Database Path"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL, "Compilation Database"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Include Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_SUMMARY); + QtSourceGroupWizardPage page("Include Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_SUMMARY); pages.push_back(page); } if (utility::getOsType() == OS_MAC) { - QtSourceGroupWizzardPage page("Framework Search Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_SUMMARY); + QtSourceGroupWizardPage page("Framework Search Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_SUMMARY); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Advanced (optional)"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); + QtSourceGroupWizardPage page("Advanced (optional)"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); pages.push_back(page); } @@ -204,35 +220,35 @@ namespace } template <> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Code::Blocks Project Path"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL, std::string("Code::Blocks Project")); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Code::Blocks Project Path"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL, std::string("Code::Blocks Project")); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Include Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_SUMMARY); + QtSourceGroupWizardPage page("Include Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_SUMMARY); pages.push_back(page); } if (utility::getOsType() == OS_MAC) { - QtSourceGroupWizzardPage page("Framework Search Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_SUMMARY); + QtSourceGroupWizardPage page("Framework Search Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_SUMMARY); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Advanced (optional)"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); + QtSourceGroupWizardPage page("Advanced (optional)"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); pages.push_back(page); } @@ -240,38 +256,38 @@ namespace } template <> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Sonargraph Project Path"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Sonargraph Project Path"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); page.addContentCreator( - WIZZARD_CONTENT_CONTEXT_ALL, - [](std::shared_ptr settings, QtProjectWizzardWindow* window) + WIZARD_CONTENT_CONTEXT_ALL, + [](std::shared_ptr settings, QtProjectWizardWindow* window) { - return new QtProjectWizzardContentSonargraphProjectPath(settings, settings, settings, window); + return new QtProjectWizardContentPathSonargraphProject(settings, settings, settings, window); } ); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL, std::string("Sonargraph project")); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL, std::string("Sonargraph project")); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Include Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_SUMMARY); + QtSourceGroupWizardPage page("Include Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_SUMMARY); pages.push_back(page); } if (utility::getOsType() == OS_MAC) { - QtSourceGroupWizzardPage page("Framework Search Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_SUMMARY); + QtSourceGroupWizardPage page("Framework Search Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_SUMMARY); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Advanced (optional)"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); + QtSourceGroupWizardPage page("Advanced (optional)"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); pages.push_back(page); } @@ -279,33 +295,33 @@ namespace } template <> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("VS Solution"); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_SETUP); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL, std::string("Compilation Database")); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("VS Solution"); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_SETUP); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL, std::string("Compilation Database")); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Include Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_SUMMARY); + QtSourceGroupWizardPage page("Include Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_SUMMARY); pages.push_back(page); } if (utility::getOsType() == OS_MAC) { - QtSourceGroupWizzardPage page("Framework Search Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); - page.addContentCreatorSimple(WIZZARD_CONTENT_CONTEXT_SUMMARY); + QtSourceGroupWizardPage page("Framework Search Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); + page.addContentCreatorSimple(WIZARD_CONTENT_CONTEXT_SUMMARY); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Advanced (optional)"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_SUMMARY, true); + QtSourceGroupWizardPage page("Advanced (optional)"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_SUMMARY, true); pages.push_back(page); } @@ -314,24 +330,24 @@ namespace template<> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Language Standard", 470, 230); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Language Standard", 470, 230); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Indexed Paths", 750, 600); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Indexed Paths", 750, 600); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Dependencies", 750, 600); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Dependencies", 750, 600); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } @@ -339,20 +355,20 @@ namespace } template<> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Indexed Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Indexed Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Advanced (optional)"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Advanced (optional)"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } @@ -360,20 +376,20 @@ namespace } template<> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Indexed Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Indexed Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Advanced (optional)"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Advanced (optional)"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } @@ -381,24 +397,24 @@ namespace } template<> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Sonargraph Project Path"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Sonargraph Project Path"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); page.addContentCreator( - WIZZARD_CONTENT_CONTEXT_ALL, - [](std::shared_ptr settings, QtProjectWizzardWindow* window) + WIZARD_CONTENT_CONTEXT_ALL, + [](std::shared_ptr settings, QtProjectWizardWindow* window) { - return new QtProjectWizzardContentSonargraphProjectPath(settings, std::shared_ptr(), settings, window); + return new QtProjectWizardContentPathSonargraphProject(settings, std::shared_ptr(), settings, window); } ); pages.push_back(page); } { - QtSourceGroupWizzardPage page("Dependencies"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Dependencies"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } @@ -407,15 +423,15 @@ namespace template<> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Indexed Paths", 750, 600); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Indexed Paths", 750, 600); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } @@ -423,28 +439,28 @@ namespace } template<> - std::vector> getSourceGroupWizzardPages() + std::vector> getSourceGroupWizardPages() { - std::vector> pages; + std::vector> pages; { - QtSourceGroupWizzardPage page("Indexed Paths"); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); - page.addContentCreatorWithSettings(WIZZARD_CONTENT_CONTEXT_ALL); + QtSourceGroupWizardPage page("Indexed Paths"); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); + page.addContentCreatorWithSettings(WIZARD_CONTENT_CONTEXT_ALL); pages.push_back(page); } return pages; } template - void fillSummary(QtProjectWizzardContentGroup* summary, std::shared_ptr settings, QtProjectWizzardWindow* window) + void fillSummary(QtProjectWizardContentGroup* summary, std::shared_ptr settings, QtProjectWizardWindow* window) { - const std::vector> pages = getSourceGroupWizzardPages(); + const std::vector> pages = getSourceGroupWizardPages(); - for (const QtSourceGroupWizzardPage& page : pages) + for (const QtSourceGroupWizardPage& page : pages) { - QtProjectWizzardContentGroup* contentGroup = page.createContentGroup(WIZZARD_CONTENT_CONTEXT_SUMMARY, settings, window); + QtProjectWizardContentGroup* contentGroup = page.createContentGroup(WIZARD_CONTENT_CONTEXT_SUMMARY, settings, window); if (contentGroup && contentGroup->hasContents()) { summary->addContent(contentGroup); @@ -454,8 +470,8 @@ namespace } } -QtProjectWizzard::QtProjectWizzard(QWidget* parent) - : QtProjectWizzardWindow(parent, false) +QtProjectWizard::QtProjectWizard(QWidget* parent) + : QtProjectWizardWindow(parent, false) , m_windowStack(this) , m_editing(false) , m_previouslySelectedIndex(-1) @@ -463,9 +479,9 @@ QtProjectWizzard::QtProjectWizzard(QWidget* parent) { setScrollAble(true); - connect(&m_windowStack, &QtWindowStack::push, this, &QtProjectWizzard::windowStackChanged); - connect(&m_windowStack, &QtWindowStack::pop, this, &QtProjectWizzard::windowStackChanged); - connect(&m_windowStack, &QtWindowStack::empty, this, &QtProjectWizzard::windowStackChanged); + connect(&m_windowStack, &QtWindowStack::push, this, &QtProjectWizard::windowStackChanged); + connect(&m_windowStack, &QtWindowStack::pop, this, &QtProjectWizard::windowStackChanged); + connect(&m_windowStack, &QtWindowStack::empty, this, &QtProjectWizard::windowStackChanged); // save old application settings so they can be compared later ApplicationSettings* appSettings = ApplicationSettings::getInstance().get(); @@ -473,18 +489,18 @@ QtProjectWizzard::QtProjectWizzard(QWidget* parent) m_appSettings.setFrameworkSearchPaths(appSettings->getFrameworkSearchPaths()); } -QSize QtProjectWizzard::sizeHint() const +QSize QtProjectWizard::sizeHint() const { return QSize(900, 600); } -void QtProjectWizzard::newProject() +void QtProjectWizard::newProject() { m_projectSettings = std::make_shared(); setup(); } -void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath) +void QtProjectWizard::newProjectFromCDB(const FilePath& filePath) { if (!m_projectSettings) { @@ -514,14 +530,14 @@ void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath) executeSourceGroupSetup(sourceGroupSettings); } -void QtProjectWizzard::editProject(const FilePath& settingsPath) +void QtProjectWizard::editProject(const FilePath& settingsPath) { std::shared_ptr settings = std::make_shared(settingsPath); settings->reload(); editProject(settings); } -void QtProjectWizzard::editProject(std::shared_ptr settings) +void QtProjectWizard::editProject(std::shared_ptr settings) { m_projectSettings = settings; m_allSourceGroupSettings = settings->getAllSourceGroupSettings(); @@ -530,7 +546,7 @@ void QtProjectWizzard::editProject(std::shared_ptr settings) setup(); } -void QtProjectWizzard::populateWindow(QWidget* widget) +void QtProjectWizard::populateWindow(QWidget* widget) { QHBoxLayout* layout = new QHBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); @@ -549,7 +565,7 @@ void QtProjectWizzard::populateWindow(QWidget* widget) m_generalButton = new QPushButton("General"); m_generalButton->setObjectName("general_button"); m_generalButton->setCheckable(true); - connect(m_generalButton, &QPushButton::clicked, this, &QtProjectWizzard::generalButtonClicked); + connect(m_generalButton, &QPushButton::clicked, this, &QtProjectWizard::generalButtonClicked); menuLayout->addWidget(m_generalButton); QLabel* sourceGroupLabel = new QLabel("Source Groups:"); @@ -557,7 +573,7 @@ void QtProjectWizzard::populateWindow(QWidget* widget) m_sourceGroupList = new QListWidget(); m_sourceGroupList->setAttribute(Qt::WA_MacShowFocusRect, 0); - connect(m_sourceGroupList, &QListWidget::currentRowChanged, this, &QtProjectWizzard::selectedSourceGroupChanged); + connect(m_sourceGroupList, &QListWidget::currentRowChanged, this, &QtProjectWizard::selectedSourceGroupChanged); menuLayout->addWidget(m_sourceGroupList); QHBoxLayout* buttonsLayout = new QHBoxLayout(); @@ -594,9 +610,9 @@ void QtProjectWizzard::populateWindow(QWidget* widget) m_removeButton->setEnabled(false); m_duplicateButton->setEnabled(false); - connect(addButton, &QPushButton::clicked, this, &QtProjectWizzard::newSourceGroup); - connect(m_removeButton, &QPushButton::clicked, this, &QtProjectWizzard::removeSelectedSourceGroup); - connect(m_duplicateButton, &QPushButton::clicked, this, &QtProjectWizzard::duplicateSelectedSourceGroup); + connect(addButton, &QPushButton::clicked, this, &QtProjectWizard::newSourceGroup); + connect(m_removeButton, &QPushButton::clicked, this, &QtProjectWizard::removeSelectedSourceGroup); + connect(m_duplicateButton, &QPushButton::clicked, this, &QtProjectWizard::duplicateSelectedSourceGroup); buttonsLayout->addWidget(addButton); buttonsLayout->addWidget(m_removeButton); @@ -630,7 +646,7 @@ void QtProjectWizzard::populateWindow(QWidget* widget) widget->setLayout(layout); } -void QtProjectWizzard::windowReady() +void QtProjectWizard::windowReady() { if (m_editing) { @@ -647,8 +663,8 @@ void QtProjectWizzard::windowReady() updateSubTitle("Overview"); updatePreviousButton("Add Source Group"); - connect(this, &QtProjectWizzard::previous, this, &QtProjectWizzard::newSourceGroup); - connect(this, &QtProjectWizzard::next, this, &QtProjectWizzard::createProject); + connect(this, &QtProjectWizard::previous, this, &QtProjectWizard::newSourceGroup); + connect(this, &QtProjectWizard::next, this, &QtProjectWizard::createProject); updateSourceGroupList(); @@ -662,36 +678,36 @@ void QtProjectWizzard::windowReady() } } -void QtProjectWizzard::handlePrevious() +void QtProjectWizard::handlePrevious() { QtWindow::handlePrevious(); } template -void QtProjectWizzard::executeSourceGroupSetup(std::shared_ptr settings) +void QtProjectWizard::executeSourceGroupSetup(std::shared_ptr settings) { - std::shared_ptr> wizzard = std::make_shared>( + std::shared_ptr> wizard = std::make_shared>( settings, - std::bind(&QtProjectWizzard::cancelSourceGroup, this), - std::bind(&QtProjectWizzard::createSourceGroup, this, std::placeholders::_1) + std::bind(&QtProjectWizard::cancelSourceGroup, this), + std::bind(&QtProjectWizard::createSourceGroup, this, std::placeholders::_1) ); - for (const QtSourceGroupWizzardPage& page : getSourceGroupWizzardPages()) + for (const QtSourceGroupWizardPage& page : getSourceGroupWizardPages()) { - wizzard->addPage(page); + wizard->addPage(page); } - m_sourceGroupWizzard = wizzard; - m_sourceGroupWizzard->execute(m_windowStack); + m_sourceGroupWizard = wizard; + m_sourceGroupWizard->execute(m_windowStack); } -QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent( - std::function func +QtProjectWizardWindow* QtProjectWizard::createWindowWithContent( + std::function func ){ - QtProjectWizzardWindow* window = new QtProjectWizzardWindow(parentWidget()); + QtProjectWizardWindow* window = new QtProjectWizardWindow(parentWidget()); - connect(window, &QtProjectWizzardWindow::previous, &m_windowStack, &QtWindowStack::popWindow); - connect(window, &QtProjectWizzardWindow::canceled, this, &QtProjectWizzard::cancelSourceGroup); + connect(window, &QtProjectWizardWindow::previous, &m_windowStack, &QtWindowStack::popWindow); + connect(window, &QtProjectWizardWindow::canceled, this, &QtProjectWizard::cancelSourceGroup); window->setPreferredSize(QSize(580, 340)); window->setContent(func(window)); @@ -703,15 +719,15 @@ QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent( return window; } -QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContentGroup( - std::function func +QtProjectWizardWindow* QtProjectWizard::createWindowWithContentGroup( + std::function func ){ - QtProjectWizzardWindow* window = new QtProjectWizzardWindow(parentWidget()); + QtProjectWizardWindow* window = new QtProjectWizardWindow(parentWidget()); - connect(window, &QtProjectWizzardWindow::previous, &m_windowStack, &QtWindowStack::popWindow); - connect(window, &QtProjectWizzardWindow::canceled, this, &QtProjectWizzard::cancelSourceGroup); + connect(window, &QtProjectWizardWindow::previous, &m_windowStack, &QtWindowStack::popWindow); + connect(window, &QtProjectWizardWindow::canceled, this, &QtProjectWizard::cancelSourceGroup); - QtProjectWizzardContentGroup* contentGroup = new QtProjectWizzardContentGroup(window); + QtProjectWizardContentGroup* contentGroup = new QtProjectWizardContentGroup(window); window->setPreferredSize(QSize(750, 600)); window->setContent(contentGroup); @@ -724,7 +740,7 @@ QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContentGroup( return window; } -void QtProjectWizzard::updateSourceGroupList() +void QtProjectWizard::updateSourceGroupList() { m_sourceGroupList->clear(); @@ -741,7 +757,7 @@ void QtProjectWizzard::updateSourceGroupList() } } -bool QtProjectWizzard::canExitContent() +bool QtProjectWizard::canExitContent() { if (content()) { @@ -756,7 +772,7 @@ bool QtProjectWizzard::canExitContent() return true; } -void QtProjectWizzard::generalButtonClicked() +void QtProjectWizard::generalButtonClicked() { if (!canExitContent()) { @@ -764,19 +780,19 @@ void QtProjectWizzard::generalButtonClicked() return; } - QtProjectWizzardContentGroup* contentGroup = new QtProjectWizzardContentGroup(this); - contentGroup->addContent(new QtProjectWizzardContentProjectData(m_projectSettings, this, m_editing)); + QtProjectWizardContentGroup* contentGroup = new QtProjectWizardContentGroup(this); + contentGroup->addContent(new QtProjectWizardContentProjectData(m_projectSettings, this, m_editing)); if (m_allSourceGroupSettings.empty()) { contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentSourceGroupInfoText(this)); + contentGroup->addContent(new QtProjectWizardContentSourceGroupInfoText(this)); } setContent(contentGroup); qDeleteAll(m_contentWidget->children()); - QtProjectWizzardWindow::populateWindow(m_contentWidget); + QtProjectWizardWindow::populateWindow(m_contentWidget); loadContent(); @@ -786,7 +802,7 @@ void QtProjectWizzard::generalButtonClicked() m_sourceGroupList->setCurrentRow(-1); } -void QtProjectWizzard::selectedSourceGroupChanged(int index) +void QtProjectWizard::selectedSourceGroupChanged(int index) { if (index < 0 || index >= int(m_allSourceGroupSettings.size())) { @@ -812,11 +828,11 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index) std::shared_ptr group = m_allSourceGroupSettings[index]; - QtProjectWizzardContentGroup* summary = new QtProjectWizzardContentGroup(this); + QtProjectWizardContentGroup* summary = new QtProjectWizardContentGroup(this); summary->setIsForm(true); - QtProjectWizzardContentSourceGroupData* content = new QtProjectWizzardContentSourceGroupData(group, this); - connect(content, &QtProjectWizzardContentSourceGroupData::nameUpdated, this, &QtProjectWizzard::selectedSourceGroupNameChanged); + QtProjectWizardContentSourceGroupData* content = new QtProjectWizardContentSourceGroupData(group, this); + connect(content, &QtProjectWizardContentSourceGroupData::nameUpdated, this, &QtProjectWizard::selectedSourceGroupNameChanged); summary->addContent(content); summary->addSpace(); @@ -872,19 +888,19 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index) setContent(summary); qDeleteAll(m_contentWidget->children()); - QtProjectWizzardWindow::populateWindow(m_contentWidget); + QtProjectWizardWindow::populateWindow(m_contentWidget); loadContent(); m_previouslySelectedIndex = index; } -void QtProjectWizzard::selectedSourceGroupNameChanged(QString name) +void QtProjectWizard::selectedSourceGroupNameChanged(QString name) { m_sourceGroupList->item(m_sourceGroupList->currentRow())->setText(name); } -void QtProjectWizzard::removeSelectedSourceGroup() +void QtProjectWizard::removeSelectedSourceGroup() { if (!m_allSourceGroupSettings.size() || m_sourceGroupList->currentRow() < 0) { @@ -923,7 +939,7 @@ void QtProjectWizzard::removeSelectedSourceGroup() } } -void QtProjectWizzard::duplicateSelectedSourceGroup() +void QtProjectWizard::duplicateSelectedSourceGroup() { if (!m_allSourceGroupSettings.size() || m_sourceGroupList->currentRow() < 0 || !canExitContent()) { @@ -977,30 +993,30 @@ void QtProjectWizzard::duplicateSelectedSourceGroup() m_sourceGroupList->setCurrentRow(newRow); } -void QtProjectWizzard::cancelSourceGroup() +void QtProjectWizard::cancelSourceGroup() { m_windowStack.clearWindows(); } -void QtProjectWizzard::cancelWizzard() +void QtProjectWizard::cancelWizard() { m_windowStack.clearWindows(); emit canceled(); } -void QtProjectWizzard::finishWizzard() +void QtProjectWizard::finishWizard() { m_windowStack.clearWindows(); emit finished(); } -void QtProjectWizzard::windowStackChanged() +void QtProjectWizard::windowStackChanged() { QWidget* window = m_windowStack.getTopWindow(); if (window) { - dynamic_cast(window)->content()->load(); + dynamic_cast(window)->content()->load(); setEnabled(false); } else @@ -1010,25 +1026,25 @@ void QtProjectWizzard::windowStackChanged() } } -void QtProjectWizzard::newSourceGroup() +void QtProjectWizard::newSourceGroup() { if (!canExitContent()) { return; } - QtProjectWizzardWindow* window = createWindowWithContent( - [](QtProjectWizzardWindow* window) + QtProjectWizardWindow* window = createWindowWithContent( + [](QtProjectWizardWindow* window) { window->setPreferredSize(QSize(560, 520)); - return new QtProjectWizzardContentSelect(window); + return new QtProjectWizardContentSelect(window); } ); window->resize(QSize(560, 520)); - connect(dynamic_cast(window->content()), - &QtProjectWizzardContentSelect::selected, - this, &QtProjectWizzard::selectedProjectType); + connect(dynamic_cast(window->content()), + &QtProjectWizardContentSelect::selected, + this, &QtProjectWizard::selectedProjectType); window->show(); window->setNextEnabled(false); @@ -1036,7 +1052,7 @@ void QtProjectWizzard::newSourceGroup() window->updateSubTitle("Type Selection"); } -void QtProjectWizzard::selectedProjectType(SourceGroupType sourceGroupType) +void QtProjectWizard::selectedProjectType(SourceGroupType sourceGroupType) { const std::string sourceGroupId = utility::getUuidString(); @@ -1139,7 +1155,7 @@ void QtProjectWizzard::selectedProjectType(SourceGroupType sourceGroupType) } } -void QtProjectWizzard::createSourceGroup(std::shared_ptr settings) +void QtProjectWizard::createSourceGroup(std::shared_ptr settings) { m_allSourceGroupSettings.push_back(settings); @@ -1153,7 +1169,7 @@ void QtProjectWizzard::createSourceGroup(std::shared_ptr se m_sourceGroupList->setCurrentRow(m_allSourceGroupSettings.size() - 1); } -void QtProjectWizzard::createProject() +void QtProjectWizard::createProject() { FilePath path = m_projectSettings->getFilePath(); @@ -1179,5 +1195,5 @@ void QtProjectWizzard::createProject() MessageLoadProject(path, settingsChanged).dispatch(); - finishWizzard(); + finishWizard(); } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h b/src/lib_gui/qt/project_wizard/QtProjectWizard.h similarity index 68% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h rename to src/lib_gui/qt/project_wizard/QtProjectWizard.h index d6d1062e..8f690e71 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h +++ b/src/lib_gui/qt/project_wizard/QtProjectWizard.h @@ -1,29 +1,29 @@ -#ifndef QT_PROJECT_WIZZARD_H -#define QT_PROJECT_WIZZARD_H +#ifndef QT_PROJECT_WIZARD_H +#define QT_PROJECT_WIZARD_H #include #include -#include "QtProjectWizzardWindow.h" -#include "QtSourceGroupWizzard.h" +#include "QtProjectWizardWindow.h" +#include "QtSourceGroupWizard.h" #include "QtWindow.h" #include "ApplicationSettings.h" #include "ProjectSettings.h" class QListWidget; class QPushButton; -class QtProjectWizzardContent; -class QtProjectWizzardContentGroup; -class QtProjectWizzardWindow; +class QtProjectWizardContent; +class QtProjectWizardContentGroup; +class QtProjectWizardWindow; -class QtProjectWizzard - : public QtProjectWizzardWindow +class QtProjectWizard + : public QtProjectWizardWindow { Q_OBJECT public: - QtProjectWizzard(QWidget* parent = nullptr); + QtProjectWizard(QWidget* parent = nullptr); virtual QSize sizeHint() const override; public slots: @@ -44,11 +44,11 @@ private: template void executeSourceGroupSetup(std::shared_ptr settings); - QtProjectWizzardWindow* createWindowWithContent( - std::function func); + QtProjectWizardWindow* createWindowWithContent( + std::function func); - QtProjectWizzardWindow* createWindowWithContentGroup( - std::function func); + QtProjectWizardWindow* createWindowWithContentGroup( + std::function func); void updateSourceGroupList(); bool canExitContent(); @@ -57,7 +57,7 @@ private: std::shared_ptr m_projectSettings; std::vector> m_allSourceGroupSettings; - std::shared_ptr m_sourceGroupWizzard; + std::shared_ptr m_sourceGroupWizard; ApplicationSettings m_appSettings; bool m_editing; @@ -78,8 +78,8 @@ private slots: void cancelSourceGroup(); - void cancelWizzard(); - void finishWizzard(); + void cancelWizard(); + void finishWizard(); void windowStackChanged(); @@ -90,4 +90,4 @@ private slots: void createProject(); }; -#endif // QT_PROJECT_WIZZARD_H +#endif // QT_PROJECT_WIZARD_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp b/src/lib_gui/qt/project_wizard/QtProjectWizardWindow.cpp similarity index 61% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp rename to src/lib_gui/qt/project_wizard/QtProjectWizardWindow.cpp index 4c49974e..598eb191 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp +++ b/src/lib_gui/qt/project_wizard/QtProjectWizardWindow.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzardWindow.h" +#include "QtProjectWizardWindow.h" #include #include @@ -6,16 +6,16 @@ #include #include "utilityQt.h" -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" -QtProjectWizzardWindow::QtProjectWizzardWindow(QWidget *parent, bool showSeparator) +QtProjectWizardWindow::QtProjectWizardWindow(QWidget *parent, bool showSeparator) : QtWindow(false, parent) , m_content(nullptr) , m_showSeparator(showSeparator) { } -QSize QtProjectWizzardWindow::sizeHint() const +QSize QtProjectWizardWindow::sizeHint() const { if (m_preferredSize.width()) { @@ -24,38 +24,38 @@ QSize QtProjectWizzardWindow::sizeHint() const return QSize(750, 620); } -QtProjectWizzardContent* QtProjectWizzardWindow::content() const +QtProjectWizardContent* QtProjectWizardWindow::content() const { return m_content; } -void QtProjectWizzardWindow::setContent(QtProjectWizzardContent* content) +void QtProjectWizardWindow::setContent(QtProjectWizardContent* content) { m_content = content; } -void QtProjectWizzardWindow::setPreferredSize(QSize size) +void QtProjectWizardWindow::setPreferredSize(QSize size) { m_preferredSize = size; } -void QtProjectWizzardWindow::saveContent() +void QtProjectWizardWindow::saveContent() { m_content->save(); } -void QtProjectWizzardWindow::loadContent() +void QtProjectWizardWindow::loadContent() { m_content->load(); } -void QtProjectWizzardWindow::populateWindow(QWidget* widget) +void QtProjectWizardWindow::populateWindow(QWidget* widget) { QGridLayout* layout = new QGridLayout(); layout->setContentsMargins(0, 0, 0, 0); - layout->setColumnStretch(QtProjectWizzardWindow::FRONT_COL, 1); - layout->setColumnStretch(QtProjectWizzardWindow::BACK_COL, 3); + layout->setColumnStretch(QtProjectWizardWindow::FRONT_COL, 1); + layout->setColumnStretch(QtProjectWizardWindow::BACK_COL, 3); layout->setColumnStretch(HELP_COL, 0); layout->setColumnStretch(LINE_COL, 0); @@ -80,14 +80,14 @@ void QtProjectWizzardWindow::populateWindow(QWidget* widget) widget->setLayout(layout); } -void QtProjectWizzardWindow::windowReady() +void QtProjectWizardWindow::windowReady() { updateTitle("NEW SOURCE GROUP"); m_content->windowReady(); } -void QtProjectWizzardWindow::handleNext() +void QtProjectWizardWindow::handleNext() { if (m_content) { @@ -102,7 +102,7 @@ void QtProjectWizzardWindow::handleNext() emit next(); } -void QtProjectWizzardWindow::handlePrevious() +void QtProjectWizardWindow::handlePrevious() { if (m_content) { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.h b/src/lib_gui/qt/project_wizard/QtProjectWizardWindow.h similarity index 61% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.h rename to src/lib_gui/qt/project_wizard/QtProjectWizardWindow.h index 563cc748..f235dfd4 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.h +++ b/src/lib_gui/qt/project_wizard/QtProjectWizardWindow.h @@ -1,21 +1,21 @@ -#ifndef QT_PROJECT_WIZZARD_WINDOW_H -#define QT_PROJECT_WIZZARD_WINDOW_H +#ifndef QT_PROJECT_WIZARD_WINDOW_H +#define QT_PROJECT_WIZARD_WINDOW_H #include "QtWindow.h" -class QtProjectWizzardContent; +class QtProjectWizardContent; -class QtProjectWizzardWindow +class QtProjectWizardWindow : public QtWindow { Q_OBJECT public: - QtProjectWizzardWindow(QWidget* parent, bool showSeparator = true); + QtProjectWizardWindow(QWidget* parent, bool showSeparator = true); virtual QSize sizeHint() const override; - QtProjectWizzardContent* content() const; - void setContent(QtProjectWizzardContent* content); + QtProjectWizardContent* content() const; + void setContent(QtProjectWizardContent* content); void setPreferredSize(QSize size); @@ -36,9 +36,9 @@ protected: virtual void handlePrevious() override; private: - QtProjectWizzardContent* m_content; + QtProjectWizardContent* m_content; QSize m_preferredSize; bool m_showSeparator; }; -#endif // QT_PROJECT_WIZZARD_WINDOW_H +#endif // QT_PROJECT_WIZARD_WINDOW_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtSourceGroupWizzard.h b/src/lib_gui/qt/project_wizard/QtSourceGroupWizard.h similarity index 53% rename from src/lib_gui/qt/window/project_wizzard/QtSourceGroupWizzard.h rename to src/lib_gui/qt/project_wizard/QtSourceGroupWizard.h index 09d84687..2feb3812 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtSourceGroupWizzard.h +++ b/src/lib_gui/qt/project_wizard/QtSourceGroupWizard.h @@ -1,78 +1,78 @@ -#ifndef QT_SOURCE_GROUP_WIZZARD_H -#define QT_SOURCE_GROUP_WIZZARD_H +#ifndef QT_SOURCE_GROUP_WIZARD_H +#define QT_SOURCE_GROUP_WIZARD_H #include #include #include -#include "QtProjectWizzardContentGroup.h" -#include "QtProjectWizzardWindow.h" -#include "QtSourceGroupWizzardPage.h" +#include "QtProjectWizardContentGroup.h" +#include "QtProjectWizardWindow.h" +#include "QtSourceGroupWizardPage.h" #include "logging.h" class SourceGroupSettings; -class QtSourceGroupWizzardBase +class QtSourceGroupWizardBase { public: - virtual ~QtSourceGroupWizzardBase() = default; + virtual ~QtSourceGroupWizardBase() = default; virtual void execute(QtWindowStack& windowStack) = 0; virtual bool canProcessSettings(std::shared_ptr settings) = 0; }; template -class QtSourceGroupWizzard: public QtSourceGroupWizzardBase +class QtSourceGroupWizard: public QtSourceGroupWizardBase { public: - QtSourceGroupWizzard( + QtSourceGroupWizard( std::shared_ptr settings, std::function onCancelClicked, - std::function)> onFinishedWizzard + std::function)> onFinishedWizard ); - void addPage(const QtSourceGroupWizzardPage& page); + void addPage(const QtSourceGroupWizardPage& page); void execute(QtWindowStack& windowStack) override; bool canProcessSettings(std::shared_ptr settings) override; private: void createWindowForPage(const size_t pageId, QtWindowStack& windowStack); - int mapToPageIdWithContentForContext(size_t pageId, WizzardContentContextType contextType) const; + int mapToPageIdWithContentForContext(size_t pageId, WizardContentContextType contextType) const; std::shared_ptr m_settings; std::function m_onCancelClicked; - std::function)> m_onFinishedWizzard; - std::vector> m_pages; + std::function)> m_onFinishedWizard; + std::vector> m_pages; }; template -QtSourceGroupWizzard::QtSourceGroupWizzard( +QtSourceGroupWizard::QtSourceGroupWizard( std::shared_ptr settings, std::function onCancelClicked, - std::function)> onFinishedWizzard + std::function)> onFinishedWizard ) : m_settings(settings) , m_onCancelClicked(onCancelClicked) - , m_onFinishedWizzard(onFinishedWizzard) + , m_onFinishedWizard(onFinishedWizard) { } template -void QtSourceGroupWizzard::addPage(const QtSourceGroupWizzardPage& page) +void QtSourceGroupWizard::addPage(const QtSourceGroupWizardPage& page) { m_pages.push_back(page); } template -void QtSourceGroupWizzard::execute(QtWindowStack& windowStack) +void QtSourceGroupWizard::execute(QtWindowStack& windowStack) { if (!m_pages.empty()) { - createWindowForPage(mapToPageIdWithContentForContext(0, WIZZARD_CONTENT_CONTEXT_SETUP), windowStack); + createWindowForPage(mapToPageIdWithContentForContext(0, WIZARD_CONTENT_CONTEXT_SETUP), windowStack); } } template -bool QtSourceGroupWizzard::canProcessSettings(std::shared_ptr settings) +bool QtSourceGroupWizard::canProcessSettings(std::shared_ptr settings) { if (std::dynamic_pointer_cast(settings)) { @@ -82,7 +82,7 @@ bool QtSourceGroupWizzard::canProcessSettings(std::shared_ptr -void QtSourceGroupWizzard::createWindowForPage(const size_t pageId, QtWindowStack& windowStack) +void QtSourceGroupWizard::createWindowForPage(const size_t pageId, QtWindowStack& windowStack) { if (pageId >= m_pages.size()) { @@ -90,27 +90,27 @@ void QtSourceGroupWizzard::createWindowForPage(const size_t pageId return; } - const QtSourceGroupWizzardPage& page = m_pages.at(pageId); - const int nextPageId = mapToPageIdWithContentForContext(pageId + 1, WIZZARD_CONTENT_CONTEXT_SETUP); + const QtSourceGroupWizardPage& page = m_pages.at(pageId); + const int nextPageId = mapToPageIdWithContentForContext(pageId + 1, WIZARD_CONTENT_CONTEXT_SETUP); - QtProjectWizzardWindow* window = new QtProjectWizzardWindow(nullptr); + QtProjectWizardWindow* window = new QtProjectWizardWindow(nullptr); - window->connect(window, &QtProjectWizzardWindow::previous, &windowStack, &QtWindowStack::popWindow); - window->connect(window, &QtProjectWizzardWindow::canceled, m_onCancelClicked); + window->connect(window, &QtProjectWizardWindow::previous, &windowStack, &QtWindowStack::popWindow); + window->connect(window, &QtProjectWizardWindow::canceled, m_onCancelClicked); if (nextPageId > 0) { window->connect( - window, &QtProjectWizzardWindow::next, + window, &QtProjectWizardWindow::next, [this, nextPageId, &windowStack]() { this->createWindowForPage(nextPageId, windowStack); } ); } else { - window->connect(window, &QtProjectWizzardWindow::next, [&]() { m_onFinishedWizzard(m_settings); }); + window->connect(window, &QtProjectWizardWindow::next, [&]() { m_onFinishedWizard(m_settings); }); } - QtProjectWizzardContentGroup* contentGroup = page.createContentGroup(WIZZARD_CONTENT_CONTEXT_SETUP, m_settings, window); + QtProjectWizardContentGroup* contentGroup = page.createContentGroup(WIZARD_CONTENT_CONTEXT_SETUP, m_settings, window); window->setPreferredSize(QSize(page.getPreferredWidth(), page.getPreferredHeight())); window->setContent(contentGroup); @@ -121,7 +121,7 @@ void QtSourceGroupWizzard::createWindowForPage(const size_t pageId size_t totalPages = 0; for (size_t i = 0; i < m_pages.size(); i++) { - if (m_pages[i].hasContentForContext(WIZZARD_CONTENT_CONTEXT_SETUP)) + if (m_pages[i].hasContentForContext(WIZARD_CONTENT_CONTEXT_SETUP)) { if (i <= pageId) { @@ -137,11 +137,11 @@ void QtSourceGroupWizzard::createWindowForPage(const size_t pageId } template -int QtSourceGroupWizzard::mapToPageIdWithContentForContext(size_t pageId, WizzardContentContextType contextType) const +int QtSourceGroupWizard::mapToPageIdWithContentForContext(size_t pageId, WizardContentContextType contextType) const { while (pageId < m_pages.size()) { - const QtSourceGroupWizzardPage& page = m_pages.at(pageId); + const QtSourceGroupWizardPage& page = m_pages.at(pageId); if (page.hasContentForContext(contextType)) { return pageId; @@ -151,4 +151,4 @@ int QtSourceGroupWizzard::mapToPageIdWithContentForContext(size_t return -1; } -#endif // QT_SOURCE_GROUP_WIZZARD_H +#endif // QT_SOURCE_GROUP_WIZARD_H diff --git a/src/lib_gui/qt/project_wizard/QtSourceGroupWizardPage.h b/src/lib_gui/qt/project_wizard/QtSourceGroupWizardPage.h new file mode 100644 index 00000000..fc5808ed --- /dev/null +++ b/src/lib_gui/qt/project_wizard/QtSourceGroupWizardPage.h @@ -0,0 +1,163 @@ +#ifndef QT_SOURCE_GROUP_WIZARD_PAGE_H +#define QT_SOURCE_GROUP_WIZARD_PAGE_H + +#include +#include +#include + +class QtProjectWizardWindow; + +enum WizardContentContextType +{ + WIZARD_CONTENT_CONTEXT_SETUP = 1, + WIZARD_CONTENT_CONTEXT_SUMMARY = 2, + WIZARD_CONTENT_CONTEXT_ALL = 3 +}; + +template +class QtSourceGroupWizardPage +{ +public: + typedef std::function settings, QtProjectWizardWindow* window)> ContentCreator; + + QtSourceGroupWizardPage(const std::string& title, int preferredWidth = 750, int preferredHeight = 600); + + void addContentCreator( + WizardContentContextType contextType, + ContentCreator contentCreator + ); + + template + void addContentCreatorSimple(WizardContentContextType contextType); + + template + void addContentCreatorWithSettings(WizardContentContextType contextType); + + template + void addContentCreatorWithSettings(WizardContentContextType contextType, ParamTypes ... params); + + bool hasContentForContext(WizardContentContextType contextType) const; + + std::string getTitle() const; + int getPreferredWidth() const; + int getPreferredHeight() const; + QtProjectWizardContentGroup* createContentGroup(WizardContentContextType contextType, std::shared_ptr settings, QtProjectWizardWindow* window) const; + +private: + const std::string m_title; + const int m_preferredWidth; + const int m_preferredHeight; + std::vector> m_contentCreators; +}; + +template +QtSourceGroupWizardPage::QtSourceGroupWizardPage(const std::string& title, int preferredWidth, int preferredHeight) + : m_title(title) + , m_preferredWidth(preferredWidth) + , m_preferredHeight(preferredHeight) +{ +} + +template +void QtSourceGroupWizardPage::addContentCreator( + WizardContentContextType contextType, + ContentCreator contentCreator +) +{ + m_contentCreators.push_back(std::make_pair(contextType, contentCreator)); +} + +template +template +void QtSourceGroupWizardPage::addContentCreatorSimple(WizardContentContextType contextType) +{ + addContentCreator( + contextType, + [](std::shared_ptr settings, QtProjectWizardWindow* window) + { + return new ContentType(window); + } + ); +} + +template +template +void QtSourceGroupWizardPage::addContentCreatorWithSettings(WizardContentContextType contextType) +{ + addContentCreator( + contextType, + [](std::shared_ptr settings, QtProjectWizardWindow* window) + { + return new ContentType(settings, window); + } + ); +} + +template +template +void QtSourceGroupWizardPage::addContentCreatorWithSettings(WizardContentContextType contextType, ParamTypes ... params) +{ + addContentCreator( + contextType, + [=](std::shared_ptr settings, QtProjectWizardWindow* window) + { + return new ContentType(settings, window, params...); + } + ); +} + +template +std::string QtSourceGroupWizardPage::getTitle() const +{ + return m_title; +} + +template +int QtSourceGroupWizardPage::getPreferredWidth() const +{ + return m_preferredWidth; +} + +template +int QtSourceGroupWizardPage::getPreferredHeight() const +{ + return m_preferredHeight; +} + +template +bool QtSourceGroupWizardPage::hasContentForContext(WizardContentContextType contextType) const +{ + for (const std::pair& contentCreator : m_contentCreators) + { + if (contentCreator.first & contextType) + { + return true; + } + } + return false; +} + +template +QtProjectWizardContentGroup* QtSourceGroupWizardPage::createContentGroup(WizardContentContextType contextType, std::shared_ptr settings, QtProjectWizardWindow* window) const +{ + QtProjectWizardContentGroup* contentGroup = new QtProjectWizardContentGroup(window); + + bool firstContentAdded = false; + for (const std::pair& contentCreator : m_contentCreators) + { + if (contentCreator.first & contextType) + { + if (firstContentAdded) + { + contentGroup->addSpace(); + } + contentGroup->addContent(contentCreator.second(settings, window)); + firstContentAdded = true; + } + } + + return contentGroup; +} + + +#endif // QT_SOURCE_GROUP_WIZARD_PAGE_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.cpp similarity index 54% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.cpp index 93a10cee..ac792751 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" #include @@ -6,66 +6,66 @@ #include "utility.h" #include "utilityString.h" -QtProjectWizzardContent::QtProjectWizzardContent(QtProjectWizzardWindow* window) +QtProjectWizardContent::QtProjectWizardContent(QtProjectWizardWindow* window) : QWidget(window) , m_window(window) , m_isInForm(false) - , m_showFilesFunctor(std::bind(&QtProjectWizzardContent::showFilesDialog, this, std::placeholders::_1)) + , m_showFilesFunctor(std::bind(&QtProjectWizardContent::showFilesDialog, this, std::placeholders::_1)) { } -void QtProjectWizzardContent::populate(QGridLayout* layout, int& row) +void QtProjectWizardContent::populate(QGridLayout* layout, int& row) { } -void QtProjectWizzardContent::windowReady() +void QtProjectWizardContent::windowReady() { } -void QtProjectWizzardContent::load() +void QtProjectWizardContent::load() { } -void QtProjectWizzardContent::save() +void QtProjectWizardContent::save() { } -bool QtProjectWizzardContent::check() +bool QtProjectWizardContent::check() { return true; } -bool QtProjectWizzardContent::isScrollAble() const +bool QtProjectWizardContent::isScrollAble() const { return false; } -std::vector QtProjectWizzardContent::getFilePaths() const +std::vector QtProjectWizardContent::getFilePaths() const { return {}; } -QString QtProjectWizzardContent::getFileNamesTitle() const +QString QtProjectWizardContent::getFileNamesTitle() const { return "File List"; } -QString QtProjectWizzardContent::getFileNamesDescription() const +QString QtProjectWizardContent::getFileNamesDescription() const { return "files"; } -bool QtProjectWizzardContent::isInForm() const +bool QtProjectWizardContent::isInForm() const { return m_isInForm; } -void QtProjectWizzardContent::setIsInForm(bool isInForm) +void QtProjectWizardContent::setIsInForm(bool isInForm) { m_isInForm = isInForm; } -QLabel* QtProjectWizzardContent::createFormLabel(QString name) const +QLabel* QtProjectWizardContent::createFormLabel(QString name) const { QLabel* label = new QLabel(name); label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); @@ -74,7 +74,7 @@ QLabel* QtProjectWizzardContent::createFormLabel(QString name) const return label; } -QLabel* QtProjectWizzardContent::createFormTitle(QString name) const +QLabel* QtProjectWizardContent::createFormTitle(QString name) const { QLabel* label = new QLabel(name); label->setObjectName("titleLabel"); @@ -82,7 +82,7 @@ QLabel* QtProjectWizzardContent::createFormTitle(QString name) const return label; } -QToolButton* QtProjectWizzardContent::createSourceGroupButton(QString name, QString iconPath) const +QToolButton* QtProjectWizardContent::createSourceGroupButton(QString name, QString iconPath) const { QToolButton* button = new QToolButton(); button->setObjectName("sourceGroupButton"); @@ -94,28 +94,28 @@ QToolButton* QtProjectWizzardContent::createSourceGroupButton(QString name, QStr return button; } -QtHelpButton* QtProjectWizzardContent::addHelpButton(const QString& helpTitle, const QString& helpText, QGridLayout* layout, int row) const +QtHelpButton* QtProjectWizardContent::addHelpButton(const QString& helpTitle, const QString& helpText, QGridLayout* layout, int row) const { QtHelpButton* button = new QtHelpButton(helpTitle, helpText); - layout->addWidget(button, row, QtProjectWizzardWindow::HELP_COL, Qt::AlignTop); + layout->addWidget(button, row, QtProjectWizardWindow::HELP_COL, Qt::AlignTop); return button; } -QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout* layout, int row) const +QPushButton* QtProjectWizardContent::addFilesButton(QString name, QGridLayout* layout, int row) const { QPushButton* button = new QPushButton(name); button->setObjectName("windowButton"); button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac if (layout) { - layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop); + layout->addWidget(button, row, QtProjectWizardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop); } - connect(button, &QPushButton::clicked, this, &QtProjectWizzardContent::filesButtonClicked); + connect(button, &QPushButton::clicked, this, &QtProjectWizardContent::filesButtonClicked); return button; } -QFrame* QtProjectWizzardContent::addSeparator(QGridLayout* layout, int row) const +QFrame* QtProjectWizardContent::addSeparator(QGridLayout* layout, int row) const { QFrame* separator = new QFrame(); separator->setFrameShape(QFrame::HLine); @@ -128,7 +128,7 @@ QFrame* QtProjectWizzardContent::addSeparator(QGridLayout* layout, int row) cons return separator; } -void QtProjectWizzardContent::filesButtonClicked() +void QtProjectWizardContent::filesButtonClicked() { m_window->saveContent(); m_window->loadContent(); @@ -139,7 +139,7 @@ void QtProjectWizzardContent::filesButtonClicked() }).detach(); } -void QtProjectWizzardContent::showFilesDialog(const std::vector& filePaths) +void QtProjectWizardContent::showFilesDialog(const std::vector& filePaths) { if (!m_filesDialog) { @@ -151,15 +151,15 @@ void QtProjectWizzardContent::showFilesDialog(const std::vector& fileP m_filesDialog->setCloseVisible(false); m_filesDialog->setReadOnly(true); - connect(m_filesDialog.get(), &QtTextEditDialog::finished, this, &QtProjectWizzardContent::closedFilesDialog); - connect(m_filesDialog.get(), &QtTextEditDialog::canceled, this, &QtProjectWizzardContent::closedFilesDialog); + connect(m_filesDialog.get(), &QtTextEditDialog::finished, this, &QtProjectWizardContent::closedFilesDialog); + connect(m_filesDialog.get(), &QtTextEditDialog::canceled, this, &QtProjectWizardContent::closedFilesDialog); } m_filesDialog->showWindow(); m_filesDialog->raise(); } -void QtProjectWizzardContent::closedFilesDialog() +void QtProjectWizardContent::closedFilesDialog() { m_filesDialog->hide(); m_filesDialog.reset(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.h similarity index 83% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.h index 89e70072..812a12b2 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContent.h @@ -1,5 +1,5 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_H -#define QT_PROJECT_WIZZARD_CONTENT_H +#ifndef QT_PROJECT_WIZARD_CONTENT_H +#define QT_PROJECT_WIZARD_CONTENT_H #include #include @@ -8,18 +8,18 @@ #include "QtHelpButton.h" #include "QtThreadedFunctor.h" -#include "QtProjectWizzardWindow.h" +#include "QtProjectWizardWindow.h" #include "FilePath.h" class QtTextEditDialog; -class QtProjectWizzardContent +class QtProjectWizardContent : public QWidget { Q_OBJECT public: - QtProjectWizzardContent(QtProjectWizzardWindow* window); + QtProjectWizardContent(QtProjectWizardWindow* window); virtual void populate(QGridLayout* layout, int& row); virtual void windowReady(); @@ -46,7 +46,7 @@ protected: QPushButton* addFilesButton(QString name, QGridLayout* layout, int row) const; QFrame* addSeparator(QGridLayout* layout, int row) const; - QtProjectWizzardWindow* m_window; + QtProjectWizardWindow* m_window; std::shared_ptr m_filesDialog; @@ -61,4 +61,4 @@ private: QtThreadedFunctor&> m_showFilesFunctor; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_H +#endif // QT_PROJECT_WIZARD_CONTENT_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCStandard.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.cpp similarity index 63% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCStandard.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.cpp index bcbb57c4..fc2b0d9a 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCStandard.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.cpp @@ -1,29 +1,29 @@ -#include "QtProjectWizzardContentCStandard.h" +#include "QtProjectWizardContentCStandard.h" #include #include #include "SourceGroupSettingsWithCStandard.h" -QtProjectWizzardContentCStandard::QtProjectWizzardContentCStandard( +QtProjectWizardContentCStandard::QtProjectWizardContentCStandard( std::shared_ptr sourceGroupSettings, - QtProjectWizzardWindow* window + QtProjectWizardWindow* window ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) , m_sourceGroupSettings(sourceGroupSettings) , m_standard(nullptr) { } -void QtProjectWizzardContentCStandard::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentCStandard::populate(QGridLayout* layout, int& row) { m_standard = new QComboBox(); - layout->addWidget(createFormLabel("C Standard"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); - layout->addWidget(m_standard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); + layout->addWidget(createFormLabel("C Standard"), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(m_standard, row, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft); row++; } -void QtProjectWizzardContentCStandard::load() +void QtProjectWizardContentCStandard::load() { m_standard->clear(); @@ -39,7 +39,7 @@ void QtProjectWizzardContentCStandard::load() } } -void QtProjectWizzardContentCStandard::save() +void QtProjectWizardContentCStandard::save() { if (m_sourceGroupSettings) { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCStandard.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.h similarity index 52% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCStandard.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.h index e5155b36..f708a72e 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCStandard.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.h @@ -1,22 +1,22 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_C_STANDARD -#define QT_PROJECT_WIZZARD_CONTENT_C_STANDARD +#ifndef QT_PROJECT_WIZARD_CONTENT_C_STANDARD +#define QT_PROJECT_WIZARD_CONTENT_C_STANDARD -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" class QComboBox; class SourceGroupSettingsWithCStandard; -class QtProjectWizzardContentCStandard - : public QtProjectWizzardContent +class QtProjectWizardContentCStandard + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentCStandard( + QtProjectWizardContentCStandard( std::shared_ptr sourceGroupSettings, - QtProjectWizzardWindow* window); + QtProjectWizardWindow* window); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation virtual void populate(QGridLayout* layout, int& row) override; virtual void load() override; @@ -28,4 +28,4 @@ private: QComboBox* m_standard; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_C_STANDARD +#endif // QT_PROJECT_WIZARD_CONTENT_C_STANDARD diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCppStandard.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.cpp similarity index 63% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCppStandard.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.cpp index e7e9a2be..ebf15bc3 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCppStandard.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.cpp @@ -1,29 +1,29 @@ -#include "QtProjectWizzardContentCppStandard.h" +#include "QtProjectWizardContentCppStandard.h" #include #include #include "SourceGroupSettingsWithCppStandard.h" -QtProjectWizzardContentCppStandard::QtProjectWizzardContentCppStandard( +QtProjectWizardContentCppStandard::QtProjectWizardContentCppStandard( std::shared_ptr sourceGroupSettings, - QtProjectWizzardWindow* window + QtProjectWizardWindow* window ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) , m_sourceGroupSettings(sourceGroupSettings) , m_standard(nullptr) { } -void QtProjectWizzardContentCppStandard::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentCppStandard::populate(QGridLayout* layout, int& row) { m_standard = new QComboBox(); - layout->addWidget(createFormLabel("C++ Standard"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); - layout->addWidget(m_standard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); + layout->addWidget(createFormLabel("C++ Standard"), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(m_standard, row, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft); row++; } -void QtProjectWizzardContentCppStandard::load() +void QtProjectWizardContentCppStandard::load() { m_standard->clear(); @@ -39,7 +39,7 @@ void QtProjectWizzardContentCppStandard::load() } } -void QtProjectWizzardContentCppStandard::save() +void QtProjectWizardContentCppStandard::save() { if (m_sourceGroupSettings) { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCppStandard.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.h similarity index 51% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCppStandard.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.h index d27f0c7f..7779dcb0 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCppStandard.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.h @@ -1,22 +1,22 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_CPP_STANDARD -#define QT_PROJECT_WIZZARD_CONTENT_CPP_STANDARD +#ifndef QT_PROJECT_WIZARD_CONTENT_CPP_STANDARD +#define QT_PROJECT_WIZARD_CONTENT_CPP_STANDARD -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" class QComboBox; class SourceGroupSettingsWithCppStandard; -class QtProjectWizzardContentCppStandard - : public QtProjectWizzardContent +class QtProjectWizardContentCppStandard + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentCppStandard( + QtProjectWizardContentCppStandard( std::shared_ptr sourceGroupSettings, - QtProjectWizzardWindow* window); + QtProjectWizardWindow* window); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation virtual void populate(QGridLayout* layout, int& row) override; virtual void load() override; @@ -28,4 +28,4 @@ private: QComboBox* m_standard; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_CPP_STANDARD +#endif // QT_PROJECT_WIZARD_CONTENT_CPP_STANDARD diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.cpp similarity index 82% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.cpp index 39f9d2ac..19756178 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzardContentCrossCompilationOptions.h" +#include "QtProjectWizardContentCrossCompilationOptions.h" #include #include @@ -7,11 +7,11 @@ #include "SourceGroupSettingsWithCxxCrossCompilationOptions.h" #include "logging.h" -QtProjectWizzardContentCrossCompilationOptions::QtProjectWizzardContentCrossCompilationOptions( +QtProjectWizardContentCrossCompilationOptions::QtProjectWizardContentCrossCompilationOptions( std::shared_ptr sourceGroupSettings, - QtProjectWizzardWindow* window + QtProjectWizardWindow* window ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) , m_sourceGroupSettings(sourceGroupSettings) , m_useTargetOptions(nullptr) , m_arch(nullptr) @@ -21,7 +21,7 @@ QtProjectWizzardContentCrossCompilationOptions::QtProjectWizzardContentCrossComp { } -void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentCrossCompilationOptions::populate(QGridLayout* layout, int& row) { if (!isInForm()) { @@ -29,9 +29,9 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou row++; } - layout->addWidget(createFormLabel("Cross-Compilation"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(createFormLabel("Cross-Compilation"), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); addHelpButton( - "Cross-Compilation", + "Cross-Compilation", "

Use these options to specify the target architecture for the provided source code. Even though Sourcetrail will " "not generate a target binary, providing these options will affect which headers the indexer will be looking for " "while analyzing your source code.

" @@ -42,7 +42,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou { m_useTargetOptions = new QCheckBox("Use specific target"); - connect(m_useTargetOptions, &QCheckBox::stateChanged, this, &QtProjectWizzardContentCrossCompilationOptions::onUseTargetOptionsChanged); + connect(m_useTargetOptions, &QCheckBox::stateChanged, this, &QtProjectWizardContentCrossCompilationOptions::onUseTargetOptionsChanged); QHBoxLayout* rowLayout = new QHBoxLayout(); rowLayout->setContentsMargins(0, 0, 0, 0); @@ -51,7 +51,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou QWidget* rowWidget = new QWidget(); rowWidget->setLayout(rowLayout); - layout->addWidget(rowWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); + layout->addWidget(rowWidget, row, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); row++; } @@ -118,7 +118,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou gridLayout->addWidget(m_abi, 3, 1, Qt::AlignLeft); } - layout->addLayout(gridLayout, row++, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); + layout->addLayout(gridLayout, row++, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); if (!isInForm()) { @@ -127,7 +127,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou } } -void QtProjectWizzardContentCrossCompilationOptions::load() +void QtProjectWizardContentCrossCompilationOptions::load() { m_useTargetOptions->setChecked(m_sourceGroupSettings->getTargetOptionsEnabled()); m_arch->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getTargetArch())); @@ -138,7 +138,7 @@ void QtProjectWizzardContentCrossCompilationOptions::load() updateTargetOptionsEnabled(); } -void QtProjectWizzardContentCrossCompilationOptions::save() +void QtProjectWizardContentCrossCompilationOptions::save() { m_sourceGroupSettings->setTargetOptionsEnabled(m_useTargetOptions->isChecked()); m_sourceGroupSettings->setTargetArch(m_arch->currentText().toStdWString()); @@ -147,17 +147,17 @@ void QtProjectWizzardContentCrossCompilationOptions::save() m_sourceGroupSettings->setTargetAbi(m_abi->currentText().toStdWString()); } -bool QtProjectWizzardContentCrossCompilationOptions::check() +bool QtProjectWizardContentCrossCompilationOptions::check() { return true; } -void QtProjectWizzardContentCrossCompilationOptions::onUseTargetOptionsChanged() +void QtProjectWizardContentCrossCompilationOptions::onUseTargetOptionsChanged() { updateTargetOptionsEnabled(); } -void QtProjectWizzardContentCrossCompilationOptions::updateTargetOptionsEnabled() +void QtProjectWizardContentCrossCompilationOptions::updateTargetOptionsEnabled() { const bool useTargetOptions = m_useTargetOptions->isChecked(); m_arch->setEnabled(useTargetOptions); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.h similarity index 60% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.h index 6db94963..70e4d824 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.h @@ -1,24 +1,24 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_CROSS_COMPILATION_OPTIONS -#define QT_PROJECT_WIZZARD_CONTENT_CROSS_COMPILATION_OPTIONS +#ifndef QT_PROJECT_WIZARD_CONTENT_CROSS_COMPILATION_OPTIONS +#define QT_PROJECT_WIZARD_CONTENT_CROSS_COMPILATION_OPTIONS -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" class QCheckBox; class QComboBox; class QLabel; class SourceGroupSettingsWithCxxCrossCompilationOptions; -class QtProjectWizzardContentCrossCompilationOptions - : public QtProjectWizzardContent +class QtProjectWizardContentCrossCompilationOptions + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentCrossCompilationOptions( + QtProjectWizardContentCrossCompilationOptions( std::shared_ptr sourceGroupSettings, - QtProjectWizzardWindow* window); + QtProjectWizardWindow* window); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation virtual void populate(QGridLayout* layout, int& row) override; virtual void load() override; @@ -38,4 +38,4 @@ private: QComboBox* m_abi; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_CROSS_COMPILATION_OPTIONS +#endif // QT_PROJECT_WIZARD_CONTENT_CROSS_COMPILATION_OPTIONS diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCustomCommand.cpp similarity index 78% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCustomCommand.cpp index 7f9c1de2..9b5a6e6b 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCustomCommand.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzardContentCustomCommand.h" +#include "QtProjectWizardContentCustomCommand.h" #include #include @@ -10,17 +10,17 @@ #include "SourceGroupSettingsCustomCommand.h" #include "SqliteIndexStorage.h" -QtProjectWizzardContentCustomCommand::QtProjectWizzardContentCustomCommand( +QtProjectWizardContentCustomCommand::QtProjectWizardContentCustomCommand( std::shared_ptr settings, - QtProjectWizzardWindow* window + QtProjectWizardWindow* window ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) , m_settings(settings) , m_customCommand(nullptr) { } -void QtProjectWizzardContentCustomCommand::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentCustomCommand::populate(QGridLayout* layout, int& row) { if (!isInForm()) { @@ -52,11 +52,11 @@ void QtProjectWizzardContentCustomCommand::populate(QGridLayout* layout, int& ro layout->setRowMinimumHeight(row, 30); - layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); - layout->addWidget(m_customCommand, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(nameLabel, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(m_customCommand, row, QtProjectWizardWindow::BACK_COL); row++; - layout->addWidget(m_runInParallel, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(m_runInParallel, row, QtProjectWizardWindow::BACK_COL); row++; if (!isInForm()) @@ -66,19 +66,19 @@ void QtProjectWizzardContentCustomCommand::populate(QGridLayout* layout, int& ro } } -void QtProjectWizzardContentCustomCommand::load() +void QtProjectWizardContentCustomCommand::load() { m_customCommand->setText(QString::fromStdWString(m_settings->getCustomCommand())); m_runInParallel->setChecked(m_settings->getRunInParallel()); } -void QtProjectWizzardContentCustomCommand::save() +void QtProjectWizardContentCustomCommand::save() { m_settings->setCustomCommand(m_customCommand->text().toStdWString()); m_settings->setRunInParallel(m_runInParallel->isChecked()); } -bool QtProjectWizzardContentCustomCommand::check() +bool QtProjectWizardContentCustomCommand::check() { if (m_customCommand->text().isEmpty()) { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCustomCommand.h similarity index 53% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCustomCommand.h index 33181b74..b5a8300e 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCustomCommand.h @@ -1,23 +1,23 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_CUSTOM_COMMAND_H -#define QT_PROJECT_WIZZARD_CONTENT_CUSTOM_COMMAND_H +#ifndef QT_PROJECT_WIZARD_CONTENT_CUSTOM_COMMAND_H +#define QT_PROJECT_WIZARD_CONTENT_CUSTOM_COMMAND_H -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" class QCheckBox; class QLineEdit; class SourceGroupSettingsCustomCommand; -class QtProjectWizzardContentCustomCommand - : public QtProjectWizzardContent +class QtProjectWizardContentCustomCommand + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentCustomCommand( + QtProjectWizardContentCustomCommand( std::shared_ptr settings, - QtProjectWizzardWindow* window); + QtProjectWizardWindow* window); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation virtual void populate(QGridLayout* layout, int& row) override; virtual void load() override; @@ -31,4 +31,4 @@ private: QCheckBox* m_runInParallel; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_CUSTOM_COMMAND_H +#endif // QT_PROJECT_WIZARD_CONTENT_CUSTOM_COMMAND_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentExtensions.cpp similarity index 53% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentExtensions.cpp index 3080a367..a2657d3c 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentExtensions.cpp @@ -1,37 +1,37 @@ -#include "QtProjectWizzardContentExtensions.h" +#include "QtProjectWizardContentExtensions.h" #include #include "SourceGroupSettingsWithSourceExtensions.h" #include "QtStringListBox.h" -QtProjectWizzardContentExtensions::QtProjectWizzardContentExtensions( - std::shared_ptr settings, - QtProjectWizzardWindow* window +QtProjectWizardContentExtensions::QtProjectWizardContentExtensions( + std::shared_ptr settings, + QtProjectWizardWindow* window ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) , m_settings(settings) { } -void QtProjectWizzardContentExtensions::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentExtensions::populate(QGridLayout* layout, int& row) { QLabel* sourceLabel = createFormLabel("Source File Extensions"); - layout->addWidget(sourceLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); + layout->addWidget(sourceLabel, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); addHelpButton("Source File Extensions", "Define extensions for source files including the dot (e.g. .cpp or .java)", layout, row); m_listBox = new QtStringListBox(this, sourceLabel->text()); - layout->addWidget(m_listBox, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(m_listBox, row, QtProjectWizardWindow::BACK_COL); row++; } -void QtProjectWizzardContentExtensions::load() +void QtProjectWizardContentExtensions::load() { m_listBox->setStrings(m_settings->getSourceExtensions()); } -void QtProjectWizzardContentExtensions::save() +void QtProjectWizardContentExtensions::save() { m_settings->setSourceExtensions(m_listBox->getStrings()); } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentExtensions.h similarity index 53% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentExtensions.h index 9b44f022..3d03b3d1 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentExtensions.h @@ -1,25 +1,25 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_EXTENSIONS_H -#define QT_PROJECT_WIZZARD_CONTENT_EXTENSIONS_H +#ifndef QT_PROJECT_WIZARD_CONTENT_EXTENSIONS_H +#define QT_PROJECT_WIZARD_CONTENT_EXTENSIONS_H #include -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" class QtStringListBox; class SourceGroupSettingsWithSourceExtensions; -class QtProjectWizzardContentExtensions - : public QtProjectWizzardContent +class QtProjectWizardContentExtensions + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentExtensions( - std::shared_ptr settings, - QtProjectWizzardWindow* window + QtProjectWizardContentExtensions( + std::shared_ptr settings, + QtProjectWizardWindow* window ); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation virtual void populate(QGridLayout* layout, int& row) override; virtual void load() override; @@ -31,4 +31,4 @@ private: QtStringListBox* m_listBox; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_EXTENSIONS_H +#endif // QT_PROJECT_WIZARD_CONTENT_EXTENSIONS_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentFlags.cpp similarity index 67% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentFlags.cpp index 4a2e518d..50901cc8 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentFlags.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzardContentFlags.h" +#include "QtProjectWizardContentFlags.h" #include #include @@ -6,44 +6,44 @@ #include "QtStringListBox.h" #include "SourceGroupSettingsCxx.h" -QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional) - : QtProjectWizzardContent(window) +QtProjectWizardContentFlags::QtProjectWizardContentFlags(std::shared_ptr settings, QtProjectWizardWindow* window, bool indicateAsAdditional) + : QtProjectWizardContent(window) , m_settings(settings) , m_indicateAsAdditional(indicateAsAdditional) { } -void QtProjectWizzardContentFlags::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentFlags::populate(QGridLayout* layout, int& row) { const QString labelText((std::string(m_indicateAsAdditional ? "Additional " : "") + "Compiler Flags").c_str()); QLabel* label = createFormLabel(labelText); - layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); + layout->addWidget(label, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); addHelpButton( - labelText, + labelText, "

Define additional Clang compiler flags used during indexing. Here are some examples:

" "

use \"-DRELEASE\" to add a preprocessor #define for \"RELEASE\"

" "

use \"-U__clang__\" to remove the preprocessor #define for \"__clang__\"

", - layout, + layout, row ); m_list = new QtStringListBox(this, label->text()); - layout->addWidget(m_list, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(m_list, row, QtProjectWizardWindow::BACK_COL); row++; } -void QtProjectWizzardContentFlags::load() +void QtProjectWizardContentFlags::load() { m_list->setStrings(m_settings->getCompilerFlags()); } -void QtProjectWizzardContentFlags::save() +void QtProjectWizardContentFlags::save() { m_settings->setCompilerFlags(m_list->getStrings()); } -bool QtProjectWizzardContentFlags::check() +bool QtProjectWizardContentFlags::check() { std::wstring error; diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentFlags.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentFlags.h new file mode 100644 index 00000000..5705714d --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentFlags.h @@ -0,0 +1,31 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_FLAGS_H +#define QT_PROJECT_WIZARD_CONTENT_FLAGS_H + +#include "QtProjectWizardContent.h" + +class QtStringListBox; +class SourceGroupSettingsCxx; + +class QtProjectWizardContentFlags + : public QtProjectWizardContent +{ + Q_OBJECT + +public: + QtProjectWizardContentFlags(std::shared_ptr settings, QtProjectWizardWindow* window, bool indicateAsAdditional = false); + + // QtProjectWizardContent implementation + virtual void populate(QGridLayout* layout, int& row) override; + + virtual void load() override; + virtual void save() override; + virtual bool check() override; + +private: + std::shared_ptr m_settings; + const bool m_indicateAsAdditional; + + QtStringListBox* m_list; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_FLAGS_H diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentGroup.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentGroup.cpp new file mode 100644 index 00000000..6f4683bf --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentGroup.cpp @@ -0,0 +1,128 @@ +#include "QtProjectWizardContentGroup.h" + +QtProjectWizardContentGroup::QtProjectWizardContentGroup( + QtProjectWizardWindow* window +) + : QtProjectWizardContent(window) + , m_isForm(false) +{ +} + +void QtProjectWizardContentGroup::addContent(QtProjectWizardContent* content) +{ + m_contents.push_back(content); + + if (content) + { + content->setIsInForm(m_isForm); + } +} + +void QtProjectWizardContentGroup::addSpace() +{ + m_contents.push_back(nullptr); +} + +void QtProjectWizardContentGroup::setIsForm(bool isForm) +{ + m_isForm = isForm; +} + +bool QtProjectWizardContentGroup::hasContents() const +{ + for (QtProjectWizardContent* content : m_contents) + { + if (content) + { + return true; + } + } + + return false; +} + +void QtProjectWizardContentGroup::populate(QGridLayout* layout, int& row) +{ + if (m_isForm) + { + populateForm(layout, row); + return; + } + + layout->setRowMinimumHeight(row++, 10); + + for (QtProjectWizardContent* content : m_contents) + { + if (content) + { + content->populate(layout, row); + } + else + { + layout->setRowMinimumHeight(row++, 20); + } + } + + layout->setRowMinimumHeight(row, 10); + layout->setRowStretch(row, 1); +} + +void QtProjectWizardContentGroup::populateForm(QGridLayout* layout, int& row) +{ + layout->setRowMinimumHeight(row++, 10); + + for (QtProjectWizardContent* content : m_contents) + { + if (content) + { + content->populate(layout, row); + } + else + { + layout->setRowMinimumHeight(row++, 15); + } + } + + layout->setRowMinimumHeight(row, 10); + layout->setRowStretch(row, 1); +} + +void QtProjectWizardContentGroup::load() +{ + for (QtProjectWizardContent* content : m_contents) + { + if (content) + { + content->load(); + } + } +} + +void QtProjectWizardContentGroup::save() +{ + for (QtProjectWizardContent* content : m_contents) + { + if (content) + { + content->save(); + } + } +} + +bool QtProjectWizardContentGroup::check() +{ + for (QtProjectWizardContent* content : m_contents) + { + if (content && !content->check()) + { + return false; + } + } + + return true; +} + +bool QtProjectWizardContentGroup::isScrollAble() const +{ + return true; +} diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentGroup.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentGroup.h new file mode 100644 index 00000000..3c72acac --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentGroup.h @@ -0,0 +1,38 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_GROUP_H +#define QT_PROJECT_WIZARD_CONTENT_GROUP_H + +#include "QtProjectWizardContent.h" + +class QCheckBox; + +class QtProjectWizardContentGroup + : public QtProjectWizardContent +{ + Q_OBJECT + +public: + QtProjectWizardContentGroup(QtProjectWizardWindow* window); + + void addContent(QtProjectWizardContent* content); + void addSpace(); + + void setIsForm(bool isForm); + bool hasContents() const; + +protected: + // QtProjectWizardContent implementation + virtual void populate(QGridLayout* layout, int& row) override; + void populateForm(QGridLayout* layout, int& row); + + virtual void load() override; + virtual void save() override; + virtual bool check() override; + + virtual bool isScrollAble() const override; + +private: + std::vector m_contents; + bool m_isForm; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_GROUP_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentJavaStandard.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentJavaStandard.cpp similarity index 62% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentJavaStandard.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentJavaStandard.cpp index f2c6c3ed..3b36dc77 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentJavaStandard.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentJavaStandard.cpp @@ -1,29 +1,29 @@ -#include "QtProjectWizzardContentJavaStandard.h" +#include "QtProjectWizardContentJavaStandard.h" #include #include #include "SourceGroupSettingsWithJavaStandard.h" -QtProjectWizzardContentJavaStandard::QtProjectWizzardContentJavaStandard( +QtProjectWizardContentJavaStandard::QtProjectWizardContentJavaStandard( std::shared_ptr sourceGroupSettings, - QtProjectWizzardWindow* window + QtProjectWizardWindow* window ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) , m_sourceGroupSettings(sourceGroupSettings) , m_standard(nullptr) { } -void QtProjectWizzardContentJavaStandard::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentJavaStandard::populate(QGridLayout* layout, int& row) { m_standard = new QComboBox(); - layout->addWidget(createFormLabel("Java Standard"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); - layout->addWidget(m_standard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); + layout->addWidget(createFormLabel("Java Standard"), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(m_standard, row, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft); row++; } -void QtProjectWizzardContentJavaStandard::load() +void QtProjectWizardContentJavaStandard::load() { m_standard->clear(); @@ -39,7 +39,7 @@ void QtProjectWizzardContentJavaStandard::load() } } -void QtProjectWizzardContentJavaStandard::save() +void QtProjectWizardContentJavaStandard::save() { if (m_sourceGroupSettings) { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentJavaStandard.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentJavaStandard.h similarity index 51% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentJavaStandard.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentJavaStandard.h index d83c3ff9..eab2b63a 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentJavaStandard.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentJavaStandard.h @@ -1,22 +1,22 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_JAVA_STANDARD -#define QT_PROJECT_WIZZARD_CONTENT_JAVA_STANDARD +#ifndef QT_PROJECT_WIZARD_CONTENT_JAVA_STANDARD +#define QT_PROJECT_WIZARD_CONTENT_JAVA_STANDARD -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" class QComboBox; class SourceGroupSettingsWithJavaStandard; -class QtProjectWizzardContentJavaStandard - : public QtProjectWizzardContent +class QtProjectWizardContentJavaStandard + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentJavaStandard( + QtProjectWizardContentJavaStandard( std::shared_ptr sourceGroupSettings, - QtProjectWizzardWindow* window); + QtProjectWizardWindow* window); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation virtual void populate(QGridLayout* layout, int& row) override; virtual void load() override; @@ -28,4 +28,4 @@ private: QComboBox* m_standard; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_JAVA_STANDARD +#endif // QT_PROJECT_WIZARD_CONTENT_JAVA_STANDARD diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp similarity index 86% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp index ee25bc13..baa6499f 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzardContentPreferences.h" +#include "QtProjectWizardContentPreferences.h" #include #include @@ -17,10 +17,10 @@ #include "utilityApp.h" #include "utility.h" -QtProjectWizzardContentPreferences::QtProjectWizzardContentPreferences( - QtProjectWizzardWindow* window +QtProjectWizardContentPreferences::QtProjectWizardContentPreferences( + QtProjectWizardWindow* window ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) , m_oldColorSchemeIndex(-1) , m_newColorSchemeIndex(-1) , m_screenAutoScaling(nullptr) @@ -30,7 +30,7 @@ QtProjectWizzardContentPreferences::QtProjectWizzardContentPreferences( FileSystem::getFilePathsFromDirectory(ResourcePaths::getColorSchemesPath(), { L".xml" }); } -QtProjectWizzardContentPreferences::~QtProjectWizzardContentPreferences() +QtProjectWizardContentPreferences::~QtProjectWizardContentPreferences() { if (m_oldColorSchemeIndex != -1 && m_oldColorSchemeIndex != m_newColorSchemeIndex) { @@ -38,7 +38,7 @@ QtProjectWizzardContentPreferences::~QtProjectWizzardContentPreferences() } } -void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentPreferences::populate(QGridLayout* layout, int& row) { ApplicationSettings* appSettings = ApplicationSettings::getInstance().get(); @@ -92,7 +92,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) m_colorSchemes->insertItem(i, QString::fromStdWString(m_colorSchemePaths[i].withoutExtension().fileName())); } connect(m_colorSchemes, static_cast(&QComboBox::activated), - this, &QtProjectWizzardContentPreferences::colorSchemeChanged); + this, &QtProjectWizardContentPreferences::colorSchemeChanged); // animations m_useAnimations = addCheckBox("Animations", "Enable animations", @@ -113,7 +113,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) QLabel* hint = new QLabel(""); hint->setStyleSheet("color: grey"); - layout->addWidget(hint, row-1, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight); + layout->addWidget(hint, row-1, QtProjectWizardWindow::BACK_COL, Qt::AlignRight); // auto scaling m_screenAutoScalingInfoLabel = new QLabel(""); @@ -132,7 +132,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) m_screenAutoScaling->addItem("off", 0); m_screenAutoScaling->addItem("on", 1); connect(m_screenAutoScaling, static_cast(&QComboBox::activated), - this, &QtProjectWizzardContentPreferences::uiAutoScalingChanges); + this, &QtProjectWizardContentPreferences::uiAutoScalingChanges); // scale factor m_screenScaleFactorInfoLabel = new QLabel(""); @@ -160,7 +160,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) m_screenScaleFactor->addItem("300%", 3.0); m_screenScaleFactor->addItem("400%", 4.0); connect(m_screenScaleFactor, static_cast(&QComboBox::activated), - this, &QtProjectWizzardContentPreferences::uiScaleFactorChanges); + this, &QtProjectWizardContentPreferences::uiScaleFactorChanges); addGap(layout, row); } @@ -193,7 +193,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) // logging m_loggingEnabled = addCheckBox("Logging", "Enable console and file logging", "

Show logs in the console and save this information in files.

", layout, row); - connect(m_loggingEnabled, &QCheckBox::clicked, this, &QtProjectWizzardContentPreferences::loggingEnabledChanged); + connect(m_loggingEnabled, &QCheckBox::clicked, this, &QtProjectWizardContentPreferences::loggingEnabledChanged); m_verboseIndexerLoggingEnabled = addCheckBox( "Indexer Logging", @@ -246,7 +246,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) ); m_threads->setItemText(0, "default"); connect(m_threads, static_cast(&QComboBox::activated), - this, &QtProjectWizzardContentPreferences::indexerThreadsChanges); + this, &QtProjectWizardContentPreferences::indexerThreadsChanges); // multi process indexing m_multiProcessIndexing = addCheckBox("Multi Process
C/C++ Indexing", @@ -326,7 +326,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) // JRE System Library const QString title = "JRE System Library"; QLabel* label = createFormLabel(title); - layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); + layout->addWidget(label, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); addHelpButton( "JRE System Library", @@ -336,7 +336,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) m_jreSystemLibraryPaths = new QtPathListBox(this, title, QtPathListBox::SELECTION_POLICY_FILES_ONLY); - layout->addWidget(m_jreSystemLibraryPaths, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(m_jreSystemLibraryPaths, row, QtProjectWizardWindow::BACK_COL); row++; m_jreSystemLibraryPathsDetector = utility::getJreSystemLibraryPathsDetector(); @@ -390,7 +390,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row) addTitle("C/C++", layout, row); } -void QtProjectWizzardContentPreferences::load() +void QtProjectWizardContentPreferences::load() { ApplicationSettings* appSettings = ApplicationSettings::getInstance().get(); @@ -464,7 +464,7 @@ void QtProjectWizzardContentPreferences::load() m_pythonPostProcessing->setChecked(appSettings->getPythonPostProcessingEnabled()); } -void QtProjectWizzardContentPreferences::save() +void QtProjectWizardContentPreferences::save() { std::shared_ptr appSettings = ApplicationSettings::getInstance(); @@ -530,18 +530,18 @@ void QtProjectWizzardContentPreferences::save() appSettings->save(); } -bool QtProjectWizzardContentPreferences::check() +bool QtProjectWizardContentPreferences::check() { return true; } -void QtProjectWizzardContentPreferences::colorSchemeChanged(int index) +void QtProjectWizardContentPreferences::colorSchemeChanged(int index) { m_newColorSchemeIndex = index; MessageSwitchColorScheme(m_colorSchemePaths[index]).dispatch(); } -void QtProjectWizzardContentPreferences::javaPathDetectionClicked() +void QtProjectWizardContentPreferences::javaPathDetectionClicked() { std::vector paths = m_javaPathDetector->getPaths(m_javaPathDetectorBox->currentText().toStdString()); if (!paths.empty()) @@ -550,7 +550,7 @@ void QtProjectWizzardContentPreferences::javaPathDetectionClicked() } } -void QtProjectWizzardContentPreferences::jreSystemLibraryPathsDetectionClicked() +void QtProjectWizardContentPreferences::jreSystemLibraryPathsDetectionClicked() { std::vector paths = m_jreSystemLibraryPathsDetector->getPaths(m_jreSystemLibraryPathsDetectorBox->currentText().toStdString()); @@ -558,7 +558,7 @@ void QtProjectWizzardContentPreferences::jreSystemLibraryPathsDetectionClicked() m_jreSystemLibraryPaths->setPaths(utility::unique(utility::concat(oldPaths, paths))); } -void QtProjectWizzardContentPreferences::mavenPathDetectionClicked() +void QtProjectWizardContentPreferences::mavenPathDetectionClicked() { std::vector paths = m_mavenPathDetector->getPaths(m_mavenPathDetectorBox->currentText().toStdString()); if (!paths.empty()) @@ -567,12 +567,12 @@ void QtProjectWizzardContentPreferences::mavenPathDetectionClicked() } } -void QtProjectWizzardContentPreferences::loggingEnabledChanged() +void QtProjectWizardContentPreferences::loggingEnabledChanged() { m_verboseIndexerLoggingEnabled->setEnabled(m_loggingEnabled->isChecked()); } -void QtProjectWizzardContentPreferences::indexerThreadsChanges(int index) +void QtProjectWizardContentPreferences::indexerThreadsChanges(int index) { if (index == 0) { @@ -586,7 +586,7 @@ void QtProjectWizzardContentPreferences::indexerThreadsChanges(int index) } } -void QtProjectWizzardContentPreferences::uiAutoScalingChanges(int index) +void QtProjectWizardContentPreferences::uiAutoScalingChanges(int index) { if (index == 0) { @@ -609,7 +609,7 @@ void QtProjectWizzardContentPreferences::uiAutoScalingChanges(int index) } } -void QtProjectWizzardContentPreferences::uiScaleFactorChanges(int index) +void QtProjectWizardContentPreferences::uiScaleFactorChanges(int index) { if (index == 0) { @@ -630,7 +630,7 @@ void QtProjectWizzardContentPreferences::uiScaleFactorChanges(int index) } } -void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layout, int& row) +void QtProjectWizardContentPreferences::addJavaPathDetection(QGridLayout* layout, int& row) { std::vector detectorNames = m_javaPathDetector->getWorkingDetectorNames(); if (detectorNames.empty()) @@ -649,7 +649,7 @@ void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layou QPushButton* button = new QPushButton("detect"); button->setObjectName("windowButton"); - connect(button, &QPushButton::clicked, this, &QtProjectWizzardContentPreferences::javaPathDetectionClicked); + connect(button, &QPushButton::clicked, this, &QtProjectWizardContentPreferences::javaPathDetectionClicked); QHBoxLayout* hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0, 0, 0, 0); @@ -660,11 +660,11 @@ void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layou QWidget* detectionWidget = new QWidget(); detectionWidget->setLayout(hlayout); - layout->addWidget(detectionWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); + layout->addWidget(detectionWidget, row, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); row++; } -void QtProjectWizzardContentPreferences::addJreSystemLibraryPathsDetection(QGridLayout* layout, int& row) +void QtProjectWizardContentPreferences::addJreSystemLibraryPathsDetection(QGridLayout* layout, int& row) { const std::vector detectorNames = m_jreSystemLibraryPathsDetector->getWorkingDetectorNames(); if (detectorNames.empty()) @@ -683,7 +683,7 @@ void QtProjectWizzardContentPreferences::addJreSystemLibraryPathsDetection(QGrid QPushButton* button = new QPushButton("detect"); button->setObjectName("windowButton"); - connect(button, &QPushButton::clicked, this, &QtProjectWizzardContentPreferences::jreSystemLibraryPathsDetectionClicked); + connect(button, &QPushButton::clicked, this, &QtProjectWizardContentPreferences::jreSystemLibraryPathsDetectionClicked); QHBoxLayout* hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0, 0, 0, 0); @@ -694,11 +694,11 @@ void QtProjectWizzardContentPreferences::addJreSystemLibraryPathsDetection(QGrid QWidget* detectionWidget = new QWidget(); detectionWidget->setLayout(hlayout); - layout->addWidget(detectionWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); + layout->addWidget(detectionWidget, row, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); row++; } -void QtProjectWizzardContentPreferences::addMavenPathDetection(QGridLayout* layout, int& row) +void QtProjectWizardContentPreferences::addMavenPathDetection(QGridLayout* layout, int& row) { std::vector detectorNames = m_mavenPathDetector->getWorkingDetectorNames(); if (detectorNames.empty()) @@ -717,7 +717,7 @@ void QtProjectWizzardContentPreferences::addMavenPathDetection(QGridLayout* layo QPushButton* button = new QPushButton("detect"); button->setObjectName("windowButton"); - connect(button, &QPushButton::clicked, this, &QtProjectWizzardContentPreferences::mavenPathDetectionClicked); + connect(button, &QPushButton::clicked, this, &QtProjectWizardContentPreferences::mavenPathDetectionClicked); QHBoxLayout* hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0, 0, 0, 0); @@ -728,39 +728,39 @@ void QtProjectWizzardContentPreferences::addMavenPathDetection(QGridLayout* layo QWidget* detectionWidget = new QWidget(); detectionWidget->setLayout(hlayout); - layout->addWidget(detectionWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); + layout->addWidget(detectionWidget, row, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); row++; } -void QtProjectWizzardContentPreferences::addTitle(QString title, QGridLayout* layout, int& row) +void QtProjectWizardContentPreferences::addTitle(QString title, QGridLayout* layout, int& row) { - layout->addWidget(createFormTitle(title), row++, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft); + layout->addWidget(createFormTitle(title), row++, QtProjectWizardWindow::FRONT_COL, Qt::AlignLeft); } -void QtProjectWizzardContentPreferences::addLabel(QString label, QGridLayout* layout, int row) +void QtProjectWizardContentPreferences::addLabel(QString label, QGridLayout* layout, int row) { - layout->addWidget(createFormLabel(label), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(createFormLabel(label), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); } -void QtProjectWizzardContentPreferences::addWidget( +void QtProjectWizardContentPreferences::addWidget( QWidget* widget, QGridLayout* layout, int row, Qt::Alignment widgetAlignment) { - layout->addWidget(widget, row, QtProjectWizzardWindow::BACK_COL, widgetAlignment); + layout->addWidget(widget, row, QtProjectWizardWindow::BACK_COL, widgetAlignment); } -void QtProjectWizzardContentPreferences::addLabelAndWidget( +void QtProjectWizardContentPreferences::addLabelAndWidget( QString label, QWidget* widget, QGridLayout* layout, int row, Qt::Alignment widgetAlignment) { addLabel(label, layout, row); addWidget(widget, layout, row, widgetAlignment); } -void QtProjectWizzardContentPreferences::addGap(QGridLayout* layout, int& row) +void QtProjectWizardContentPreferences::addGap(QGridLayout* layout, int& row) { layout->setRowMinimumHeight(row++, 20); } -QCheckBox* QtProjectWizzardContentPreferences::addCheckBox( +QCheckBox* QtProjectWizardContentPreferences::addCheckBox( QString label, QString text, QString helpText, QGridLayout* layout, int& row) { QCheckBox* checkBox = new QCheckBox(text, this); @@ -776,7 +776,7 @@ QCheckBox* QtProjectWizzardContentPreferences::addCheckBox( return checkBox; } -QComboBox* QtProjectWizzardContentPreferences::addComboBox( +QComboBox* QtProjectWizardContentPreferences::addComboBox( QString label, QString helpText, QGridLayout* layout, int& row) { QComboBox* comboBox = new QComboBox(this); @@ -792,7 +792,7 @@ QComboBox* QtProjectWizzardContentPreferences::addComboBox( return comboBox; } -QComboBox* QtProjectWizzardContentPreferences::addComboBoxWithWidgets( +QComboBox* QtProjectWizardContentPreferences::addComboBoxWithWidgets( QString label, QString helpText, std::vector widgets, QGridLayout* layout, int& row) { QComboBox* comboBox = new QComboBox(this); @@ -821,7 +821,7 @@ QComboBox* QtProjectWizzardContentPreferences::addComboBoxWithWidgets( return comboBox; } -QComboBox* QtProjectWizzardContentPreferences::addComboBox( +QComboBox* QtProjectWizardContentPreferences::addComboBox( QString label, int min, int max, QString helpText, QGridLayout* layout, int& row) { QComboBox* comboBox = addComboBox(label, helpText, layout, row); @@ -837,7 +837,7 @@ QComboBox* QtProjectWizzardContentPreferences::addComboBox( return comboBox; } -QComboBox* QtProjectWizzardContentPreferences::addComboBoxWithWidgets( +QComboBox* QtProjectWizardContentPreferences::addComboBoxWithWidgets( QString label, int min, int max, QString helpText, std::vector widgets, QGridLayout* layout, int& row) { QComboBox* comboBox = addComboBoxWithWidgets(label, helpText, widgets, layout, row); @@ -853,7 +853,7 @@ QComboBox* QtProjectWizzardContentPreferences::addComboBoxWithWidgets( return comboBox; } -QLineEdit* QtProjectWizzardContentPreferences::addLineEdit(QString label, QString helpText, QGridLayout* layout, int& row) +QLineEdit* QtProjectWizardContentPreferences::addLineEdit(QString label, QString helpText, QGridLayout* layout, int& row) { QLineEdit* lineEdit = new QLineEdit(this); lineEdit->setObjectName("name"); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.h similarity index 89% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.h index 998e6654..ae7af35c 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.h @@ -1,11 +1,11 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H -#define QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H +#ifndef QT_PROJECT_WIZARD_CONTENT_PREFERENCES_H +#define QT_PROJECT_WIZARD_CONTENT_PREFERENCES_H #include #include "QtLocationPicker.h" #include "QtPathListBox.h" -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" #include "CombinedPathDetector.h" class QCheckBox; @@ -30,16 +30,16 @@ public: }; -class QtProjectWizzardContentPreferences - : public QtProjectWizzardContent +class QtProjectWizardContentPreferences + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentPreferences(QtProjectWizzardWindow* window); - ~QtProjectWizzardContentPreferences(); + QtProjectWizardContentPreferences(QtProjectWizardWindow* window); + ~QtProjectWizardContentPreferences(); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation virtual void populate(QGridLayout* layout, int& row) override; virtual void load() override; @@ -129,4 +129,4 @@ private: QCheckBox* m_pythonPostProcessing; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H +#endif // QT_PROJECT_WIZARD_CONTENT_PREFERENCES_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentProjectData.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.cpp similarity index 79% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentProjectData.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.cpp index 0131dfcf..70bd16f1 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentProjectData.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzardContentProjectData.h" +#include "QtProjectWizardContentProjectData.h" #include #include @@ -7,12 +7,12 @@ #include "ProjectSettings.h" #include "FileSystem.h" -QtProjectWizzardContentProjectData::QtProjectWizzardContentProjectData( +QtProjectWizardContentProjectData::QtProjectWizardContentProjectData( std::shared_ptr projectSettings, - QtProjectWizzardWindow* window, + QtProjectWizardWindow* window, bool disableNameEditing ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) , m_projectSettings(projectSettings) , m_disableNameEditing(disableNameEditing) , m_projectName(nullptr) @@ -20,7 +20,7 @@ QtProjectWizzardContentProjectData::QtProjectWizzardContentProjectData( { } -void QtProjectWizzardContentProjectData::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentProjectData::populate(QGridLayout* layout, int& row) { if (!isInForm()) { @@ -33,10 +33,10 @@ void QtProjectWizzardContentProjectData::populate(QGridLayout* layout, int& row) m_projectName->setObjectName("name"); m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0); m_projectName->setEnabled(!m_disableNameEditing); - connect(m_projectName, &QLineEdit::textEdited, this, &QtProjectWizzardContentProjectData::onProjectNameEdited); + connect(m_projectName, &QLineEdit::textEdited, this, &QtProjectWizardContentProjectData::onProjectNameEdited); - layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); - layout->addWidget(m_projectName, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(nameLabel, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(m_projectName, row, QtProjectWizardWindow::BACK_COL); layout->setRowMinimumHeight(row, 30); row++; @@ -45,8 +45,8 @@ void QtProjectWizzardContentProjectData::populate(QGridLayout* layout, int& row) m_projectFileLocation->setPickDirectory(true); m_projectFileLocation->setEnabled(!m_disableNameEditing); - layout->addWidget(locationLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); - layout->addWidget(m_projectFileLocation, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignTop); + layout->addWidget(locationLabel, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(m_projectFileLocation, row, QtProjectWizardWindow::BACK_COL, Qt::AlignTop); addHelpButton("Sourcetrail Project Location", "The directory the Sourcetrail project file (.srctrlprj) will be saved to.", layout, row); layout->setRowMinimumHeight(row, 30); row++; @@ -58,13 +58,13 @@ void QtProjectWizzardContentProjectData::populate(QGridLayout* layout, int& row) } } -void QtProjectWizzardContentProjectData::load() +void QtProjectWizardContentProjectData::load() { m_projectName->setText(QString::fromStdWString(m_projectSettings->getProjectName())); m_projectFileLocation->setText(QString::fromStdWString(m_projectSettings->getProjectDirectoryPath().wstr())); } -void QtProjectWizzardContentProjectData::save() +void QtProjectWizardContentProjectData::save() { m_projectSettings->setProjectFilePath( m_projectName->text().toStdWString(), @@ -72,7 +72,7 @@ void QtProjectWizzardContentProjectData::save() ); } -bool QtProjectWizzardContentProjectData::check() +bool QtProjectWizardContentProjectData::check() { if (m_projectName->text().isEmpty()) { @@ -128,7 +128,7 @@ bool QtProjectWizzardContentProjectData::check() return true; } -void QtProjectWizzardContentProjectData::onProjectNameEdited(QString text) +void QtProjectWizardContentProjectData::onProjectNameEdited(QString text) { const int cursorPosition = m_projectName->cursorPosition(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentProjectData.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.h similarity index 59% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentProjectData.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.h index 5401931d..feabe712 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentProjectData.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentProjectData.h @@ -1,23 +1,23 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_PROJECT_DATA_H -#define QT_PROJECT_WIZZARD_CONTENT_PROJECT_DATA_H +#ifndef QT_PROJECT_WIZARD_CONTENT_PROJECT_DATA_H +#define QT_PROJECT_WIZARD_CONTENT_PROJECT_DATA_H #include "QtLocationPicker.h" -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" class ProjectSettings; -class QtProjectWizzardContentProjectData - : public QtProjectWizzardContent +class QtProjectWizardContentProjectData + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentProjectData( + QtProjectWizardContentProjectData( std::shared_ptr projectSettings, - QtProjectWizzardWindow* window, + QtProjectWizardWindow* window, bool disableNameEditing = false); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation virtual void populate(QGridLayout* layout, int& row) override; virtual void load() override; @@ -35,4 +35,4 @@ private: QtLocationPicker* m_projectFileLocation; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_PROJECT_DATA_H +#endif // QT_PROJECT_WIZARD_CONTENT_PROJECT_DATA_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSelect.cpp similarity index 93% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSelect.cpp index e24d413f..2063dfec 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSelect.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzardContentSelect.h" +#include "QtProjectWizardContentSelect.h" #include @@ -8,21 +8,21 @@ #include #include "LanguageType.h" -#include "QtProjectWizzardWindow.h" +#include "QtProjectWizardWindow.h" #include "QtFlowLayout.h" #include "ResourcePaths.h" #include "SqliteIndexStorage.h" #include "utilityString.h" #include "utilityApp.h" -QtProjectWizzardContentSelect::QtProjectWizzardContentSelect( - QtProjectWizzardWindow* window +QtProjectWizardContentSelect::QtProjectWizardContentSelect( + QtProjectWizardWindow* window ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) { } -void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentSelect::populate(QGridLayout* layout, int& row) { std::string pythonIndexerVersion = " "; { @@ -129,7 +129,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) } vlayout->addStretch(); - layout->addLayout(vlayout, 0, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); + layout->addLayout(vlayout, 0, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); connect(m_languages, static_cast(&QButtonGroup::buttonClicked), [this](QAbstractButton* button) @@ -237,22 +237,22 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) containerLayout->addWidget(m_description, 0); container->setLayout(containerLayout); - layout->addWidget(container, 0, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(container, 0, QtProjectWizardWindow::BACK_COL); m_title = new QLabel("Source Group Types"); m_title->setObjectName("sourceGroupTitle"); - layout->addWidget(m_title, 0, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); + layout->addWidget(m_title, 0, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); layout->setRowStretch(0, 0); - layout->setColumnStretch(QtProjectWizzardWindow::FRONT_COL, 0); - layout->setColumnStretch(QtProjectWizzardWindow::BACK_COL, 1); + layout->setColumnStretch(QtProjectWizardWindow::FRONT_COL, 0); + layout->setColumnStretch(QtProjectWizardWindow::BACK_COL, 1); layout->setHorizontalSpacing(0); m_languages->buttons().constFirst()->click(); } -void QtProjectWizzardContentSelect::save() +void QtProjectWizardContentSelect::save() { SourceGroupType selectedType; @@ -272,7 +272,7 @@ void QtProjectWizzardContentSelect::save() emit selected(selectedType); } -bool QtProjectWizzardContentSelect::check() +bool QtProjectWizardContentSelect::check() { bool sourceGroupChosen = false; @@ -296,7 +296,7 @@ bool QtProjectWizzardContentSelect::check() return true; } -bool QtProjectWizzardContentSelect::isScrollAble() const +bool QtProjectWizardContentSelect::isScrollAble() const { return true; } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSelect.h similarity index 64% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSelect.h index b6925809..c918744e 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSelect.h @@ -1,22 +1,22 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_SELECT_H -#define QT_PROJECT_WIZZARD_CONTENT_SELECT_H +#ifndef QT_PROJECT_WIZARD_CONTENT_SELECT_H +#define QT_PROJECT_WIZARD_CONTENT_SELECT_H -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" #include "LanguageType.h" #include "SourceGroupType.h" class QButtonGroup; class SolutionParserManager; -class QtProjectWizzardContentSelect - : public QtProjectWizzardContent +class QtProjectWizardContentSelect + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentSelect(QtProjectWizzardWindow* window); + QtProjectWizardContentSelect(QtProjectWizardWindow* window); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation void populate(QGridLayout* layout, int& row) override; void save() override; @@ -40,4 +40,4 @@ private: std::vector m_solutionDescription; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_SELECT_H +#endif // QT_PROJECT_WIZARD_CONTENT_SELECT_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.cpp similarity index 57% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.cpp index 77661f95..768e9178 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.cpp @@ -1,4 +1,4 @@ -#include "QtProjectWizzardContentSourceGroupData.h" +#include "QtProjectWizardContentSourceGroupData.h" #include #include @@ -6,32 +6,32 @@ #include "SourceGroupSettings.h" -QtProjectWizzardContentSourceGroupData::QtProjectWizzardContentSourceGroupData( +QtProjectWizardContentSourceGroupData::QtProjectWizardContentSourceGroupData( std::shared_ptr settings, - QtProjectWizzardWindow* window + QtProjectWizardWindow* window ) - : QtProjectWizzardContent(window) + : QtProjectWizardContent(window) , m_settings(settings) , m_name(nullptr) , m_status(nullptr) { } -void QtProjectWizzardContentSourceGroupData::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentSourceGroupData::populate(QGridLayout* layout, int& row) { m_name = new QLineEdit(); m_name->setObjectName("name"); m_name->setAttribute(Qt::WA_MacShowFocusRect, 0); - connect(m_name, &QLineEdit::textEdited, this, &QtProjectWizzardContentSourceGroupData::editedName); + connect(m_name, &QLineEdit::textEdited, this, &QtProjectWizardContentSourceGroupData::editedName); - layout->addWidget(createFormLabel("Source Group Name"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); - layout->addWidget(m_name, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(createFormLabel("Source Group Name"), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(m_name, row, QtProjectWizardWindow::BACK_COL); row++; m_status = new QCheckBox("active"); - connect(m_status, &QCheckBox::toggled, this, &QtProjectWizzardContentSourceGroupData::changedStatus); - layout->addWidget(createFormLabel("Status"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); - layout->addWidget(m_status, row, QtProjectWizzardWindow::BACK_COL); + connect(m_status, &QCheckBox::toggled, this, &QtProjectWizardContentSourceGroupData::changedStatus); + layout->addWidget(createFormLabel("Status"), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight); + layout->addWidget(m_status, row, QtProjectWizardWindow::BACK_COL); addHelpButton("Status", "

Only source files of active Source Groups will be processed during indexing. " "Inactive Source Groups will be ignored or cleared from the index.

Use this setting to temporarily " @@ -40,21 +40,21 @@ void QtProjectWizzardContentSourceGroupData::populate(QGridLayout* layout, int& row++; } -void QtProjectWizzardContentSourceGroupData::load() +void QtProjectWizardContentSourceGroupData::load() { m_name->setText(QString::fromStdString(m_settings->getName())); m_status->setChecked(m_settings->getStatus() == SOURCE_GROUP_STATUS_ENABLED); } -void QtProjectWizzardContentSourceGroupData::save() +void QtProjectWizardContentSourceGroupData::save() { m_settings->setName(m_name->text().toStdString()); m_settings->setStatus(m_status->isChecked() ? SOURCE_GROUP_STATUS_ENABLED : SOURCE_GROUP_STATUS_DISABLED); } -bool QtProjectWizzardContentSourceGroupData::check() +bool QtProjectWizardContentSourceGroupData::check() { if (m_name->text().isEmpty()) { @@ -67,7 +67,7 @@ bool QtProjectWizzardContentSourceGroupData::check() return true; } -void QtProjectWizzardContentSourceGroupData::editedName(QString name) +void QtProjectWizardContentSourceGroupData::editedName(QString name) { if (!m_status->isChecked()) { @@ -77,7 +77,7 @@ void QtProjectWizzardContentSourceGroupData::editedName(QString name) emit nameUpdated(name); } -void QtProjectWizzardContentSourceGroupData::changedStatus(bool checked) +void QtProjectWizardContentSourceGroupData::changedStatus(bool checked) { emit statusUpdated(m_status->isChecked() ? SOURCE_GROUP_STATUS_ENABLED : SOURCE_GROUP_STATUS_DISABLED); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.h similarity index 59% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.h index bbef2528..9bfa9314 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupData.h @@ -1,24 +1,24 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H -#define QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H +#ifndef QT_PROJECT_WIZARD_CONTENT_SOURCE_GROUP_DATA_H +#define QT_PROJECT_WIZARD_CONTENT_SOURCE_GROUP_DATA_H -#include "QtProjectWizzardContent.h" +#include "QtProjectWizardContent.h" #include "SourceGroupStatusType.h" class QCheckBox; class QLineEdit; class SourceGroupSettings; -class QtProjectWizzardContentSourceGroupData - : public QtProjectWizzardContent +class QtProjectWizardContentSourceGroupData + : public QtProjectWizardContent { Q_OBJECT public: - QtProjectWizzardContentSourceGroupData( + QtProjectWizardContentSourceGroupData( std::shared_ptr settings, - QtProjectWizzardWindow* window); + QtProjectWizardWindow* window); - // QtProjectWizzardContent implementation + // QtProjectWizardContent implementation virtual void populate(QGridLayout* layout, int& row) override; virtual void load() override; @@ -40,4 +40,4 @@ private: QCheckBox* m_status; }; -#endif // QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H +#endif // QT_PROJECT_WIZARD_CONTENT_SOURCE_GROUP_DATA_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupInfoText.cpp similarity index 67% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupInfoText.cpp index 53f5d26c..4af156ed 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupInfoText.cpp @@ -1,17 +1,17 @@ -#include "QtProjectWizzardContentSourceGroupInfoText.h" +#include "QtProjectWizardContentSourceGroupInfoText.h" -QtProjectWizzardContentSourceGroupInfoText::QtProjectWizzardContentSourceGroupInfoText(QtProjectWizzardWindow* window) - : QtProjectWizzardContent(window) +QtProjectWizardContentSourceGroupInfoText::QtProjectWizardContentSourceGroupInfoText(QtProjectWizardWindow* window) + : QtProjectWizardContent(window) { } -void QtProjectWizzardContentSourceGroupInfoText::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentSourceGroupInfoText::populate(QGridLayout* layout, int& row) { QHBoxLayout* layoutHorz = new QHBoxLayout(); layout->addLayout( - layoutHorz, - row, QtProjectWizzardWindow::FRONT_COL, - 1, 1 + QtProjectWizzardWindow::BACK_COL - QtProjectWizzardWindow::FRONT_COL, + layoutHorz, + row, QtProjectWizardWindow::FRONT_COL, + 1, 1 + QtProjectWizardWindow::BACK_COL - QtProjectWizardWindow::FRONT_COL, Qt::AlignTop ); diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupInfoText.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupInfoText.h new file mode 100644 index 00000000..e2f0fc2b --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentSourceGroupInfoText.h @@ -0,0 +1,18 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_SOURCE_GROUP_INFO_TEXT_H +#define QT_PROJECT_WIZARD_CONTENT_SOURCE_GROUP_INFO_TEXT_H + +#include "QtProjectWizardContent.h" + +class QtProjectWizardContentSourceGroupInfoText + : public QtProjectWizardContent +{ + Q_OBJECT + +public: + QtProjectWizardContentSourceGroupInfoText(QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + virtual void populate(QGridLayout* layout, int& row) override; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_SOURCE_GROUP_INFO_TEXT_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentVS.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.cpp similarity index 66% rename from src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentVS.cpp rename to src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.cpp index 4f28c4ce..85f16217 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentVS.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.cpp @@ -1,16 +1,16 @@ -#include "QtProjectWizzardContentVS.h" +#include "QtProjectWizardContentVS.h" #include "MessageIDECreateCDB.h" -QtProjectWizzardContentVS::QtProjectWizzardContentVS(QtProjectWizzardWindow* window) - : QtProjectWizzardContent(window) +QtProjectWizardContentVS::QtProjectWizardContentVS(QtProjectWizardWindow* window) + : QtProjectWizardContent(window) { } -void QtProjectWizzardContentVS::populate(QGridLayout* layout, int& row) +void QtProjectWizardContentVS::populate(QGridLayout* layout, int& row) { QLabel* nameLabel = createFormLabel("Create Compilation Database"); - layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL); + layout->addWidget(nameLabel, row, QtProjectWizardWindow::FRONT_COL); addHelpButton( "Create Compilation Database", "To create a new Compilation Database from a Visual Studio Solution, this Solution has to be open in Visual Studio.\n\ @@ -21,26 +21,26 @@ Note: Sourcetrail's Visual Studio plugin has to be installed. Visual Studio has QLabel* descriptionLabel = createFormLabel("Call Visual Studio to create a Compilation Database from the loaded Solution."); descriptionLabel->setObjectName("description"); descriptionLabel->setAlignment(Qt::AlignmentFlag::AlignLeft); - layout->addWidget(descriptionLabel, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(descriptionLabel, row, QtProjectWizardWindow::BACK_COL); row++; QPushButton* button = new QPushButton("Create Compilation Database"); button->setObjectName("windowButton"); - layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(button, row, QtProjectWizardWindow::BACK_COL); row++; QLabel* skipLabel = createFormLabel("*Skip this step if you already have a Compilation Database for your Solution."); skipLabel->setObjectName("description"); skipLabel->setAlignment(Qt::AlignmentFlag::AlignLeft); - layout->addWidget(skipLabel, row, QtProjectWizzardWindow::BACK_COL); + layout->addWidget(skipLabel, row, QtProjectWizardWindow::BACK_COL); row++; addSeparator(layout, row++); - connect(button, &QPushButton::clicked, this, &QtProjectWizzardContentVS::handleVSCDBClicked); + connect(button, &QPushButton::clicked, this, &QtProjectWizardContentVS::handleVSCDBClicked); } -void QtProjectWizzardContentVS::handleVSCDBClicked() +void QtProjectWizardContentVS::handleVSCDBClicked() { MessageIDECreateCDB().dispatch(); } diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.h b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.h new file mode 100644 index 00000000..db98a783 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentVS.h @@ -0,0 +1,20 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_VS_H +#define QT_PROJECT_WIZARD_CONTENT_VS_H + +#include "QtProjectWizardContent.h" + +class QtProjectWizardContentVS + : public QtProjectWizardContent +{ + Q_OBJECT + +public: + QtProjectWizardContentVS(QtProjectWizardWindow* window); + + virtual void populate(QGridLayout* layout, int& row) override; + +private slots: + void handleVSCDBClicked(); +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_VS_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.cpp new file mode 100644 index 00000000..e6ed45ad --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.cpp @@ -0,0 +1,112 @@ +#include "QtProjectWizardContentPath.h" + +#include + +#include "SourceGroupSettings.h" + +QtProjectWizardContentPath::QtProjectWizardContentPath(QtProjectWizardWindow* window) + : QtProjectWizardContent(window) + , m_makePathRelativeToProjectFileLocation(true) + , m_allowEmpty(false) +{ +} + +void QtProjectWizardContentPath::populate(QGridLayout* layout, int& row) +{ + QLabel* label = createFormLabel(m_titleString); + layout->addWidget(label, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); + + if (m_helpString.size() > 0) + { + addHelpButton(m_titleString, m_helpString, layout, row); + } + + m_picker = new QtLocationPicker(this); + m_picker->setPickDirectory(true); + m_picker->setPlaceholderText(m_placeholderString); + + if (m_makePathRelativeToProjectFileLocation) + { + m_picker->setRelativeRootDirectory(getSourceGroupSettings()->getProjectDirectoryPath()); + } + + layout->addWidget(m_picker, row, QtProjectWizardWindow::BACK_COL); + row++; +} + +bool QtProjectWizardContentPath::check() +{ + QString error; + + while (true) + { + if (m_picker->getText().isEmpty()) + { + if (m_allowEmpty) + { + break; + } + else + { + error = "Please define a path at \"" + m_titleString + "\"."; + break; + } + } + + FilePath path = getSourceGroupSettings()->makePathExpandedAndAbsolute(FilePath(m_picker->getText().toStdWString())); + + if (m_picker->pickDirectory()) + { + break; + } + + if (!path.exists()) + { + error = "The entered path does not exist at \"" + m_titleString + "\"."; + break; + } + + if (m_fileEndings.find(path.extension()) == m_fileEndings.end()) + { + error = "The entered path does have a correct file ending at \"" + m_titleString + "\"."; + break; + } + + break; + } + + if (!error.isEmpty()) + { + QMessageBox msgBox; + msgBox.setText(error); + msgBox.exec(); + return false; + } + + return true; +} + +void QtProjectWizardContentPath::setTitleString(const QString& title) +{ + m_titleString = title; +} + +void QtProjectWizardContentPath::setHelpString(const QString& help) +{ + m_helpString = help; +} + +void QtProjectWizardContentPath::setPlaceholderString(const QString& placeholder) +{ + m_placeholderString = placeholder; +} + +void QtProjectWizardContentPath::setFileEndings(const std::set& fileEndings) +{ + m_fileEndings = fileEndings; +} + +void QtProjectWizardContentPath::setAllowEmpty(bool allowEmpty) +{ + m_allowEmpty = allowEmpty; +} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.h new file mode 100644 index 00000000..6fa209ff --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPath.h @@ -0,0 +1,46 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_H +#define QT_PROJECT_WIZARD_CONTENT_PATH_H + +#include + +#include "QtProjectWizardContent.h" +#include "QtLocationPicker.h" + +class SourceGroupSettings; + +class QtProjectWizardContentPath + : public QtProjectWizardContent +{ + Q_OBJECT + +public: + QtProjectWizardContentPath(QtProjectWizardWindow* window); + + // QtSettingsWindow implementation + virtual void populate(QGridLayout* layout, int& row) override; + + virtual bool check() override; + +protected: + void setTitleString(const QString& title); + void setHelpString(const QString& help); + void setPlaceholderString(const QString& placeholder); + + void setFileEndings(const std::set& fileEndings); + void setAllowEmpty(bool allowEmpty); + + QtLocationPicker* m_picker; + + bool m_makePathRelativeToProjectFileLocation; + +private: + virtual std::shared_ptr getSourceGroupSettings() = 0; + + QString m_titleString; + QString m_helpString; + QString m_placeholderString; + std::set m_fileEndings; + bool m_allowEmpty; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATH_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.cpp new file mode 100644 index 00000000..8bddf6dd --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.cpp @@ -0,0 +1,118 @@ +#include "QtProjectWizardContentPathCDB.h" + +#include "QtProjectWizardContentPathsIndexedHeaders.h" +#include "SourceGroupCxxCdb.h" +#include "SourceGroupSettingsCxxCdb.h" +#include "utility.h" +#include "utilityFile.h" + +QtProjectWizardContentPathCDB::QtProjectWizardContentPathCDB( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPath(window) + , m_settings(settings) + , m_filePaths([&]() + { + return utility::getAsRelativeIfShorter( + utility::toVector(SourceGroupCxxCdb(m_settings).getAllSourceFilePaths()), + m_settings->getProjectDirectoryPath() + ); + } + ) +{ + setTitleString("Compilation Database (compile_commands.json)"); + setHelpString( + "Select the compilation database file for the project. Sourcetrail will index your project based on the compile " + "commands. This file contains using all include paths and compiler flags of these compile commands. The project " + "will stay up to date with changes in the compilation database on every refresh.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); + setFileEndings({ L".json" }); +} + +void QtProjectWizardContentPathCDB::populate(QGridLayout* layout, int& row) +{ + QtProjectWizardContentPath::populate(layout, row); + m_picker->setPickDirectory(false); + m_picker->setFileFilter("JSON Compilation Database (*.json)"); + connect(m_picker, &QtLocationPicker::locationPicked, this, &QtProjectWizardContentPathCDB::pickedPath); + + QLabel* description = new QLabel( + "Sourcetrail will use all include paths and compiler flags from the Compilation Database and stay up-to-date " + "with changes on refresh.", this); + description->setObjectName("description"); + description->setWordWrap(true); + layout->addWidget(description, row, QtProjectWizardWindow::BACK_COL); + row++; + + QLabel* title = createFormLabel("Source Files to Index"); + layout->addWidget(title, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); + layout->setRowStretch(row, 0); + + m_fileCountLabel = new QLabel(""); + m_fileCountLabel->setWordWrap(true); + layout->addWidget(m_fileCountLabel, row, QtProjectWizardWindow::BACK_COL, Qt::AlignTop); + row++; + + addFilesButton("show source files", layout, row); + row++; +} + +void QtProjectWizardContentPathCDB::load() +{ + m_picker->setText(QString::fromStdWString(m_settings->getCompilationDatabasePath().wstr())); + + m_filePaths.clear(); + + if (m_fileCountLabel) + { + m_fileCountLabel->setText("" + QString::number(getFilePaths().size()) + + " source files were found in the compilation database."); + } +} + +void QtProjectWizardContentPathCDB::save() +{ + m_settings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdWString())); +} + +std::vector QtProjectWizardContentPathCDB::getFilePaths() const +{ + return m_filePaths.getValue(); +} + +QString QtProjectWizardContentPathCDB::getFileNamesTitle() const +{ + return "Source Files"; +} + +QString QtProjectWizardContentPathCDB::getFileNamesDescription() const +{ + return " source files will be indexed."; +} + +void QtProjectWizardContentPathCDB::pickedPath() +{ + m_window->saveContent(); + + const FilePath projectPath = m_settings->getProjectDirectoryPath(); + + std::set indexedHeaderPaths; + for (const FilePath& path : QtProjectWizardContentPathsIndexedHeaders::getIndexedPathsDerivedFromCDB(m_settings)) + { + if (projectPath.contains(path)) + { + // the relative path is always shorter than the absolute path + indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); + } + } + m_settings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); + + m_window->loadContent(); +} + +std::shared_ptr QtProjectWizardContentPathCDB::getSourceGroupSettings() +{ + return m_settings; +} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.h new file mode 100644 index 00000000..fddd4ac7 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCDB.h @@ -0,0 +1,39 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_CDB_H +#define QT_PROJECT_WIZARD_CONTENT_PATH_CDB_H + +#include "QtProjectWizardContentPath.h" +#include "SingleValueCache.h" + +class SourceGroupSettingsCxxCdb; + +class QtProjectWizardContentPathCDB + : public QtProjectWizardContentPath +{ + Q_OBJECT + +public: + QtProjectWizardContentPathCDB( + std::shared_ptr settings, QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + void populate(QGridLayout* layout, int& row) override; + + void load() override; + void save() override; + + std::vector getFilePaths() const override; + QString getFileNamesTitle() const override; + QString getFileNamesDescription() const override; + +private slots: + void pickedPath(); + +private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; + QLabel* m_fileCountLabel; + mutable SingleValueCache> m_filePaths; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATH_CDB_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp new file mode 100644 index 00000000..46db3757 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp @@ -0,0 +1,115 @@ +#include "QtProjectWizardContentPathCodeblocksProject.h" + +#include "QtProjectWizardContentPathsIndexedHeaders.h" +#include "SourceGroupCxxCodeblocks.h" +#include "SourceGroupSettingsCxxCodeblocks.h" +#include "utility.h" +#include "utilityFile.h" + +QtProjectWizardContentPathCodeblocksProject::QtProjectWizardContentPathCodeblocksProject( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPath(window) + , m_settings(settings) + , m_filePaths([&]() + { + return utility::getAsRelativeIfShorter( + utility::toVector(SourceGroupCxxCodeblocks(m_settings).getAllSourceFilePaths()), + m_settings->getProjectDirectoryPath() + ); + } + ) +{ + setTitleString("Code::Blocks Project (.cbp)"); + setHelpString( + "Select the Code::Blocks file for the project. Sourcetrail will index your project based on the settings " + "this file. It contains using all include paths and compiler flags required. The Sourcetrail project " + "will stay up to date with changes in the Code::Blocks project on every refresh.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); + setFileEndings({ L".cbp" }); +} + +void QtProjectWizardContentPathCodeblocksProject::populate(QGridLayout* layout, int& row) +{ + QtProjectWizardContentPath::populate(layout, row); + m_picker->setPickDirectory(false); + m_picker->setFileFilter("Code::Blocks Project (*.cbp)"); + connect(m_picker, &QtLocationPicker::locationPicked, this, &QtProjectWizardContentPathCodeblocksProject::pickedPath); + + QLabel* description = new QLabel( + "Sourcetrail will use all settings from the Code::Blocks project and stay up-to-date with changes on refresh.", this); + description->setObjectName("description"); + description->setWordWrap(true); + layout->addWidget(description, row, QtProjectWizardWindow::BACK_COL); + row++; + + QLabel* title = createFormLabel("Source Files to Index"); + layout->addWidget(title, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); + layout->setRowStretch(row, 0); + + m_fileCountLabel = new QLabel(""); + m_fileCountLabel->setWordWrap(true); + layout->addWidget(m_fileCountLabel, row, QtProjectWizardWindow::BACK_COL, Qt::AlignTop); + row++; + + addFilesButton("show source files", layout, row); + row++; +} + +void QtProjectWizardContentPathCodeblocksProject::load() +{ + m_picker->setText(QString::fromStdWString(m_settings->getCodeblocksProjectPath().wstr())); + + m_filePaths.clear(); + + if (m_fileCountLabel) + { + m_fileCountLabel->setText("" + QString::number(getFilePaths().size()) + " source files were found in the Code::Blocks project."); + } +} + +void QtProjectWizardContentPathCodeblocksProject::save() +{ + m_settings->setCodeblocksProjectPath(FilePath(m_picker->getText().toStdWString())); +} + +std::vector QtProjectWizardContentPathCodeblocksProject::getFilePaths() const +{ + return m_filePaths.getValue(); +} + +QString QtProjectWizardContentPathCodeblocksProject::getFileNamesTitle() const +{ + return "Source Files"; +} + +QString QtProjectWizardContentPathCodeblocksProject::getFileNamesDescription() const +{ + return " source files will be indexed."; +} + +void QtProjectWizardContentPathCodeblocksProject::pickedPath() +{ + m_window->saveContent(); + + const FilePath projectPath = m_settings->getProjectDirectoryPath(); + + std::set indexedHeaderPaths; + for (const FilePath& path : QtProjectWizardContentPathsIndexedHeaders::getIndexedPathsDerivedFromCodeblocksProject(m_settings)) + { + if (projectPath.contains(path)) + { + indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); // the relative path is always shorter than the absolute path + } + } + m_settings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); + + m_window->loadContent(); +} + +std::shared_ptr QtProjectWizardContentPathCodeblocksProject::getSourceGroupSettings() +{ + return m_settings; +} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.h new file mode 100644 index 00000000..00b340a9 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.h @@ -0,0 +1,40 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_CODE_BLOCKS_PROJECT_H +#define QT_PROJECT_WIZARD_CONTENT_PATH_CODE_BLOCKS_PROJECT_H + +#include "QtProjectWizardContentPath.h" +#include "SingleValueCache.h" + +class SourceGroupSettingsCxxCodeblocks; + +class QtProjectWizardContentPathCodeblocksProject + : public QtProjectWizardContentPath +{ + Q_OBJECT + +public: + QtProjectWizardContentPathCodeblocksProject( + std::shared_ptr settings, + QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + void populate(QGridLayout* layout, int& row) override; + + void load() override; + void save() override; + + std::vector getFilePaths() const override; + QString getFileNamesTitle() const override; + QString getFileNamesDescription() const override; + +private slots: + void pickedPath(); + +private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; + QLabel* m_fileCountLabel; + mutable SingleValueCache> m_filePaths; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATH_CODE_BLOCKS_PROJECT_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.cpp new file mode 100644 index 00000000..1a978433 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.cpp @@ -0,0 +1,33 @@ +#include "QtProjectWizardContentPathDependenciesGradle.h" + +#include "SourceGroupSettingsJavaGradle.h" + +QtProjectWizardContentPathDependenciesGradle::QtProjectWizardContentPathDependenciesGradle( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPath(window) + , m_settings(settings) +{ + setTitleString("Intermediate Dependencies Directory"); + setHelpString( + "This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Gradle " + "project while it is indexed.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); +} + +void QtProjectWizardContentPathDependenciesGradle::load() +{ + m_picker->setText(QString::fromStdWString(m_settings->getGradleDependenciesDirectory().wstr())); +} + +void QtProjectWizardContentPathDependenciesGradle::save() +{ + m_settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdWString())); +} + +std::shared_ptr QtProjectWizardContentPathDependenciesGradle::getSourceGroupSettings() +{ + return m_settings; +} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.h new file mode 100644 index 00000000..f7032b9d --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.h @@ -0,0 +1,27 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_GRADLE_H +#define QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_GRADLE_H + +#include "QtProjectWizardContentPath.h" + +class SourceGroupSettingsJavaGradle; + +class QtProjectWizardContentPathDependenciesGradle + : public QtProjectWizardContentPath +{ + Q_OBJECT + +public: + QtProjectWizardContentPathDependenciesGradle( + std::shared_ptr settings, QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + void load() override; + void save() override; + +private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_GRADLE_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.cpp new file mode 100644 index 00000000..72792905 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.cpp @@ -0,0 +1,32 @@ +#include "QtProjectWizardContentPathDependenciesMaven.h" + +#include "SourceGroupSettingsJavaMaven.h" + +QtProjectWizardContentPathDependenciesMaven::QtProjectWizardContentPathDependenciesMaven( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPath(window) + , m_settings(settings) +{ + setTitleString("Intermediate Dependencies Directory"); + setHelpString( + "This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Maven project while it is indexed.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); +} + +void QtProjectWizardContentPathDependenciesMaven::load() +{ + m_picker->setText(QString::fromStdWString(m_settings->getMavenDependenciesDirectory().wstr())); +} + +void QtProjectWizardContentPathDependenciesMaven::save() +{ + m_settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdWString())); +} + +std::shared_ptr QtProjectWizardContentPathDependenciesMaven::getSourceGroupSettings() +{ + return m_settings; +} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.h new file mode 100644 index 00000000..7569f28a --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.h @@ -0,0 +1,26 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_MAVEN_H +#define QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_MAVEN_H + +#include "QtProjectWizardContentPath.h" + +class SourceGroupSettingsJavaMaven; + +class QtProjectWizardContentPathDependenciesMaven + : public QtProjectWizardContentPath +{ + Q_OBJECT +public: + QtProjectWizardContentPathDependenciesMaven( + std::shared_ptr settings, QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + void load() override; + void save() override; + +private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_MAVEN_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp new file mode 100644 index 00000000..a6ad6685 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp @@ -0,0 +1,90 @@ +#include "QtProjectWizardContentPathPythonEnvironment.h" + +#include "ResourcePaths.h" +#include "SourceGroupSettingsPythonEmpty.h" +#include "utilityApp.h" + +QtProjectWizardContentPathPythonEnvironment::QtProjectWizardContentPathPythonEnvironment( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPath(window) + , m_settings(settings) +{ + setTitleString("Python Environment"); + setHelpString( + "Here you can specify the path to the directory or to the executable of the (virtual) Python environment that should be used to resolve " + "dependencies within the indexed source code.
" + "
" + "If you would run:
" + "
" + "$ cd C:\\dev\\python\\envs
" + "$ virtualenv py37
" + "
" + "you would set it to \"C:\\dev\\python\\envs\\py37\" or \"C:\\dev\\python\\envs\\py37\\Scripts\\python.exe\".
" + "Leave blank to use the default Python environment. You can make use of environment variables with ${ENV_VAR}." + ); + setPlaceholderString("Use Default"); + setAllowEmpty(true); +} + +void QtProjectWizardContentPathPythonEnvironment::populate(QGridLayout* layout, int& row) +{ + QtProjectWizardContentPath::populate(layout, row); + connect( + m_picker, &QtLocationPicker::textChanged, + this, &QtProjectWizardContentPathPythonEnvironment::onTextChanged + ); + + m_resultLabel = new QLabel(); + m_resultLabel->setWordWrap(true); + layout->addWidget(m_resultLabel, row, QtProjectWizardWindow::BACK_COL); + row++; +} + +void QtProjectWizardContentPathPythonEnvironment::load() +{ + m_picker->setText(QString::fromStdWString(m_settings->getEnvironmentPath().wstr())); +} + +void QtProjectWizardContentPathPythonEnvironment::save() +{ + m_settings->setEnvironmentPath(FilePath(m_picker->getText().toStdWString())); +} + +void QtProjectWizardContentPathPythonEnvironment::onTextChanged(const QString& text) +{ + if (text.isEmpty()) + { + m_resultLabel->clear(); + } + else + { + m_resultLabel->setText("Checking validity of Python environment..."); + std::thread([=]() { + std::pair out = utility::executeProcess( + "\"" + ResourcePaths::getPythonPath().str() + "SourcetrailPythonIndexer\" check-environment " + + "--environment-path \"" + m_settings->makePathExpandedAndAbsolute(FilePath(text.toStdWString())).str() + "\"", + FilePath(), + 5000 + ); + m_onQtThread( + [=]() + { + if (out.first == 0) + { + m_resultLabel->setText(QString::fromStdString(out.second)); + } + else + { + m_resultLabel->setText("An error occurred while checking environment path. Unable to check validity."); + } + } + ); + }).detach(); + } +} + +std::shared_ptr QtProjectWizardContentPathPythonEnvironment::getSourceGroupSettings() +{ + return m_settings; +} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.h new file mode 100644 index 00000000..2104229b --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.h @@ -0,0 +1,30 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_PYTHON_ENVIRONMENT_H +#define QT_PROJECT_WIZARD_CONTENT_PATH_PYTHON_ENVIRONMENT_H + +#include "QtProjectWizardContentPath.h" +#include "QtThreadedFunctor.h" + +class SourceGroupSettingsPythonEmpty; + +class QtProjectWizardContentPathPythonEnvironment + : public QtProjectWizardContentPath +{ + Q_OBJECT +public: + QtProjectWizardContentPathPythonEnvironment(std::shared_ptr settings, QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + void populate(QGridLayout* layout, int& row) override; + void load() override; + void save() override; + +private: + void onTextChanged(const QString& text); + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; + QtThreadedLambdaFunctor m_onQtThread; + QLabel* m_resultLabel; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATH_PYTHON_ENVIRONMENT_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.cpp new file mode 100644 index 00000000..1f1926c4 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.cpp @@ -0,0 +1,166 @@ +#include "QtProjectWizardContentPathSonargraphProject.h" + +#include + +#include "QtProjectWizardContentPathsIndexedHeaders.h" +#include "SonargraphProject.h" +#include "SourceGroupCxxSonargraph.h" +#include "SourceGroupJavaSonargraph.h" +#include "SourceGroupSettingsCxxSonargraph.h" +#include "SourceGroupSettingsJavaSonargraph.h" +#include "SourceGroupSettingsWithSonargraphProjectPath.h" +#include "utility.h" +#include "utilityFile.h" + +QtProjectWizardContentPathSonargraphProject::QtProjectWizardContentPathSonargraphProject( + std::shared_ptr settings, + std::shared_ptr settingsCxxSonargraph, + std::shared_ptr settingsWithSonargraphProjectPath, + QtProjectWizardWindow* window +) + : QtProjectWizardContentPath(window) + , m_settings(settings) + , m_settingsCxxSonargraph(settingsCxxSonargraph) + , m_settingsWithSonargraphProjectPath(settingsWithSonargraphProjectPath) + , m_filePaths([&]() + { + std::set allSourceFilePaths; + if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) + { + allSourceFilePaths = SourceGroupCxxSonargraph(settings).getAllSourceFilePaths(); + } + else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) + { + allSourceFilePaths = SourceGroupJavaSonargraph(settings).getAllSourceFilePaths(); + } + + return utility::getAsRelativeIfShorter( + utility::toVector(allSourceFilePaths), + m_settings->getProjectDirectoryPath() + ); + } + ) +{ + setTitleString("Sonargraph Project (system.sonargraph)"); + setHelpString( + "Select the Sonargraph file for the project. Sourcetrail will index your project based on the settings " + "this file. It contains using all include paths and compiler flags required. The Sourcetrail project " + "will stay up to date with changes in the Sonargraph project on every refresh.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); + setFileEndings({ L".sonargraph" }); +} + +void QtProjectWizardContentPathSonargraphProject::populate(QGridLayout* layout, int& row) +{ + QtProjectWizardContentPath::populate(layout, row); + m_picker->setPickDirectory(false); + m_picker->setFileFilter("Sonargraph Project (system.sonargraph)"); + connect(m_picker, &QtLocationPicker::locationPicked, this, &QtProjectWizardContentPathSonargraphProject::pickedPath); + + QLabel* description = new QLabel( + "Sourcetrail will use all settings from the Sonargraph project and stay up-to-date with changes on refresh.", this); + description->setObjectName("description"); + description->setWordWrap(true); + layout->addWidget(description, row, QtProjectWizardWindow::BACK_COL); + row++; + + QLabel* title = createFormLabel("Source Files to Index"); + layout->addWidget(title, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); + layout->setRowStretch(row, 0); + + m_fileCountLabel = new QLabel(""); + m_fileCountLabel->setWordWrap(true); + layout->addWidget(m_fileCountLabel, row, QtProjectWizardWindow::BACK_COL, Qt::AlignTop); + row++; + + addFilesButton("show source files", layout, row); + row++; +} + +void QtProjectWizardContentPathSonargraphProject::load() +{ + m_picker->setText(QString::fromStdWString(m_settingsWithSonargraphProjectPath->getSonargraphProjectPath().wstr())); + + m_filePaths.clear(); + + if (m_fileCountLabel) + { + m_fileCountLabel->setText("" + QString::number(getFilePaths().size()) + " source files were found in the Sonargraph project."); + } +} + +void QtProjectWizardContentPathSonargraphProject::save() +{ + m_settingsWithSonargraphProjectPath->setSonargraphProjectPath(FilePath(m_picker->getText().toStdWString())); +} + +bool QtProjectWizardContentPathSonargraphProject::check() +{ + if (!QtProjectWizardContentPath::check()) + { + return false; + } + + if (std::shared_ptr sonargraphProject = Sonargraph::Project::load( + m_settingsWithSonargraphProjectPath->getSonargraphProjectPathExpandedAndAbsolute(), m_settings->getLanguage() + )) + { + if (sonargraphProject->getLoadedModuleCount() == 0) + { + + QMessageBox msgBox; + msgBox.setText(QString::fromStdString( + "The Sonargraph project file doesn't seem to contain any supported " + + languageTypeToString(m_settings->getLanguage()) + " modules. Please " + + "consider choosing another project file or removing this sourcegroup." + )); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + return msgBox.exec() == QMessageBox::Ok; + } + } + return true; +} + +std::vector QtProjectWizardContentPathSonargraphProject::getFilePaths() const +{ + return m_filePaths.getValue(); +} + +QString QtProjectWizardContentPathSonargraphProject::getFileNamesTitle() const +{ + return "Source Files"; +} + +QString QtProjectWizardContentPathSonargraphProject::getFileNamesDescription() const +{ + return " source files will be indexed."; +} + +void QtProjectWizardContentPathSonargraphProject::pickedPath() +{ + m_window->saveContent(); + + if (m_settingsCxxSonargraph) + { + const FilePath projectPath = m_settings->getProjectDirectoryPath(); + + std::set indexedHeaderPaths; + for (const FilePath& path : QtProjectWizardContentPathsIndexedHeaders::getIndexedPathsDerivedFromSonargraphProject(m_settingsCxxSonargraph)) + { + if (projectPath.contains(path)) + { + indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); // the relative path is always shorter than the absolute path + } + } + m_settingsCxxSonargraph->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); + } + m_window->loadContent(); +} + +std::shared_ptr QtProjectWizardContentPathSonargraphProject::getSourceGroupSettings() +{ + return m_settings; +} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.h new file mode 100644 index 00000000..b3b47e31 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.h @@ -0,0 +1,46 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_SONARGRAPH_PROJECT_H +#define QT_PROJECT_WIZARD_CONTENT_PATH_SONARGRAPH_PROJECT_H + +#include "QtProjectWizardContentPath.h" +#include "SingleValueCache.h" + +class SourceGroupSettingsCxxSonargraph; +class SourceGroupSettingsWithSonargraphProjectPath; + +class QtProjectWizardContentPathSonargraphProject + : public QtProjectWizardContentPath +{ + Q_OBJECT + +public: + QtProjectWizardContentPathSonargraphProject( + std::shared_ptr settings, + std::shared_ptr settingsCxxSonargraph, + std::shared_ptr settingsWithSonargraphProjectPath, + QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + void populate(QGridLayout* layout, int& row) override; + + void load() override; + void save() override; + bool check() override; + + std::vector getFilePaths() const override; + QString getFileNamesTitle() const override; + QString getFileNamesDescription() const override; + +private slots: + void pickedPath(); + +private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; + std::shared_ptr m_settingsCxxSonargraph; + std::shared_ptr m_settingsWithSonargraphProjectPath; + QLabel* m_fileCountLabel; + mutable SingleValueCache> m_filePaths; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATH_SONARGRAPH_PROJECT_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp new file mode 100644 index 00000000..6d6245ff --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp @@ -0,0 +1,73 @@ +#include "QtProjectWizardContentPathSourceGradle.h" + +#include + +#include "Application.h" +#include "QtDialogView.h" +#include "SourceGroupJavaGradle.h" +#include "SourceGroupSettingsJavaGradle.h" +#include "utility.h" +#include "utilityFile.h" + +QtProjectWizardContentPathSourceGradle::QtProjectWizardContentPathSourceGradle( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPath(window) + , m_settings(settings) +{ + setTitleString("Gradle Project File (build.gradle)"); + setHelpString( + "Enter the path to the main build.gradle file of your Gradle project.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); + setFileEndings({ L".gradle" }); +} + +void QtProjectWizardContentPathSourceGradle::populate(QGridLayout* layout, int& row) +{ + QtProjectWizardContentPath::populate(layout, row); + m_picker->setPickDirectory(false); + m_picker->setFileFilter("Gradle Build File (build.gradle)"); + + QPushButton* filesButton = addFilesButton("show source files", nullptr, row); + m_shouldIndexTests = new QCheckBox("Should Index Tests"); + + QHBoxLayout* hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(0, 0, 0, 0); + hlayout->addWidget(m_shouldIndexTests); + hlayout->addStretch(); + hlayout->addWidget(filesButton); + + layout->addLayout(hlayout, row, QtProjectWizardWindow::BACK_COL); + row++; +} + +void QtProjectWizardContentPathSourceGradle::load() +{ + m_picker->setText(QString::fromStdWString(m_settings->getGradleProjectFilePath().wstr())); + m_shouldIndexTests->setChecked(m_settings->getShouldIndexGradleTests()); +} + +void QtProjectWizardContentPathSourceGradle::save() +{ + m_settings->setGradleProjectFilePath(FilePath(m_picker->getText().toStdWString())); + m_settings->setShouldIndexGradleTests(m_shouldIndexTests->isChecked()); +} + +std::vector QtProjectWizardContentPathSourceGradle::getFilePaths() const +{ + QtDialogView* dialogView = dynamic_cast( + Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); + dialogView->setParentWindow(m_window); + + return utility::getAsRelativeIfShorter( + utility::toVector(SourceGroupJavaGradle(m_settings).getAllSourceFilePaths()), + m_settings->getProjectDirectoryPath() + ); +} + +std::shared_ptr QtProjectWizardContentPathSourceGradle::getSourceGroupSettings() +{ + return m_settings; +} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.h new file mode 100644 index 00000000..e85301c5 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.h @@ -0,0 +1,33 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_SOURCE_GRADLE_H +#define QT_PROJECT_WIZARD_CONTENT_PATH_SOURCE_GRADLE_H + +#include "QtProjectWizardContentPath.h" + +class QCheckBox; +class SourceGroupSettingsJavaGradle; + +class QtProjectWizardContentPathSourceGradle + : public QtProjectWizardContentPath +{ + Q_OBJECT + +public: + QtProjectWizardContentPathSourceGradle( + std::shared_ptr settings, QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + void populate(QGridLayout* layout, int& row) override; + + void load() override; + void save() override; + + std::vector getFilePaths() const override; + +private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; + QCheckBox* m_shouldIndexTests; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATH_SOURCE_GRADLE_H diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp new file mode 100644 index 00000000..2bb54332 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp @@ -0,0 +1,102 @@ +#include "QtProjectWizardContentPathSourceMaven.h" + +#include + +#include "Application.h" +#include "ApplicationSettings.h" +#include "MessageStatus.h" +#include "QtDialogView.h" +#include "ScopedFunctor.h" +#include "SourceGroupJavaMaven.h" +#include "SourceGroupSettingsJavaMaven.h" +#include "utility.h" +#include "utilityFile.h" +#include "utilityMaven.h" + +QtProjectWizardContentPathSourceMaven::QtProjectWizardContentPathSourceMaven( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPath(window) + , m_settings(settings) +{ + setTitleString("Maven Project File (pom.xml)"); + setHelpString( + "Enter the path to the main pom.xml file of your Maven project.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); + setFileEndings({ L".xml" }); +} + +void QtProjectWizardContentPathSourceMaven::populate(QGridLayout* layout, int& row) +{ + QtProjectWizardContentPath::populate(layout, row); + m_picker->setPickDirectory(false); + m_picker->setFileFilter("POM File (pom.xml)"); + + QPushButton* filesButton = addFilesButton("show source files", nullptr, row); + m_shouldIndexTests = new QCheckBox("Should Index Tests"); + + QHBoxLayout* hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(0, 0, 0, 0); + hlayout->addWidget(m_shouldIndexTests); + hlayout->addStretch(); + hlayout->addWidget(filesButton); + + layout->addLayout(hlayout, row, QtProjectWizardWindow::BACK_COL); + row++; +} + +void QtProjectWizardContentPathSourceMaven::load() +{ + m_picker->setText(QString::fromStdWString(m_settings->getMavenProjectFilePath().wstr())); + m_shouldIndexTests->setChecked(m_settings->getShouldIndexMavenTests()); +} + +void QtProjectWizardContentPathSourceMaven::save() +{ + m_settings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdWString())); + m_settings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked()); +} + +std::vector QtProjectWizardContentPathSourceMaven::getFilePaths() const +{ + { + const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); + const FilePath mavenProjectRoot = m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory(); + + if (!mavenProjectRoot.exists()) + { + LOG_INFO("Could not find any source file paths because Maven project path does not exist."); + return std::vector(); + } + + QtDialogView* dialogView = dynamic_cast( + Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); + + ScopedFunctor scopedFunctor([&dialogView]() { + dialogView->hideUnknownProgressDialog(); + }); + + dialogView->setParentWindow(m_window); + dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nGenerating Source Files"); + + const std::wstring errorMessage = utility::mavenGenerateSources(mavenPath, mavenProjectRoot); + if (!errorMessage.empty()) + { + MessageStatus(errorMessage, true, false).dispatch(); + Application::getInstance()->handleDialog(errorMessage); + return std::vector(); + } + } + + return utility::getAsRelativeIfShorter( + utility::toVector(SourceGroupJavaMaven(m_settings).getAllSourceFilePaths()), + m_settings->getProjectDirectoryPath() + ); +} + +std::shared_ptr QtProjectWizardContentPathSourceMaven::getSourceGroupSettings() +{ + return m_settings; +} diff --git a/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.h b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.h new file mode 100644 index 00000000..749524bc --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.h @@ -0,0 +1,33 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_SOURCE_MAVEN_H +#define QT_PROJECT_WIZARD_CONTENT_PATH_SOURCE_MAVEN_H + +#include "QtProjectWizardContentPath.h" + +class QCheckBox; +class SourceGroupSettingsJavaMaven; + +class QtProjectWizardContentPathSourceMaven + : public QtProjectWizardContentPath +{ + Q_OBJECT + +public: + QtProjectWizardContentPathSourceMaven( + std::shared_ptr settings, QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + void populate(QGridLayout* layout, int& row) override; + + void load() override; + void save() override; + + std::vector getFilePaths() const override; + +private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; + QCheckBox* m_shouldIndexTests; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATH_SOURCE_MAVEN_H diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPaths.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPaths.cpp new file mode 100644 index 00000000..ba746b80 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPaths.cpp @@ -0,0 +1,179 @@ +#include "QtProjectWizardContentPaths.h" + +#include +#include + +#include "SourceGroupSettings.h" +#include "utility.h" + +QtProjectWizardContentPaths::QtProjectWizardContentPaths( + std::shared_ptr settings, + QtProjectWizardWindow* window, + QtPathListBox::SelectionPolicyType selectionPolicy, + bool checkMissingPaths +) + : QtProjectWizardContent(window) + , m_settings(settings) + , m_makePathsRelativeToProjectFileLocation(true) + , m_selectionPolicy(selectionPolicy) + , m_checkMissingPaths(checkMissingPaths) +{ +} + +void QtProjectWizardContentPaths::populate(QGridLayout* layout, int& row) +{ + QLabel* label = createFormLabel(m_titleString); + layout->addWidget(label, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); + + if (m_helpString.size() > 0) + { + addHelpButton(m_titleString, m_helpString, layout, row); + } + + m_list = new QtPathListBox(this, m_titleString, m_selectionPolicy); + + if (m_makePathsRelativeToProjectFileLocation && m_settings) + { + m_list->setRelativeRootDirectory(m_settings->getProjectDirectoryPath()); + } + + layout->addWidget(m_list, row, QtProjectWizardWindow::BACK_COL); + row++; + + if (m_showFilesString.size() > 0) + { + addFilesButton(m_showFilesString, layout, row); + row++; + } + + if (m_pathDetector) + { + addDetection(layout, row); + row++; + } +} + +bool QtProjectWizardContentPaths::check() +{ + if (m_checkMissingPaths) + { + QString missingPaths; + std::vector existingPaths; + + for (const FilePath& path : m_list->getPathsAsDisplayed()) + { + std::vector expandedPaths(1, path); + if (m_settings) + { + expandedPaths = m_settings->makePathsExpandedAndAbsolute(expandedPaths); + } + + size_t existingCount = 0; + for (const FilePath& expandedPath : expandedPaths) + { + if (!expandedPath.exists()) + { + missingPaths.append(QString::fromStdWString(expandedPath.wstr() + L"\n")); + } + else + { + existingCount++; + } + } + + if (!expandedPaths.empty() && expandedPaths.size() == existingCount) + { + existingPaths.push_back(path); + } + } + + if (!missingPaths.isEmpty()) + { + QMessageBox msgBox; + msgBox.setText( + QString( + "Some provided paths do not exist at \"%1\". Do you want to remove them before continuing?" + ).arg(m_titleString) + ); + msgBox.setDetailedText(missingPaths); + QPushButton* removeButton = msgBox.addButton("Remove", QMessageBox::YesRole); + QPushButton* keepButton = msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole); + QPushButton* cancelButton = msgBox.addButton("Cancel", QMessageBox::ButtonRole::RejectRole); + + msgBox.exec(); + + if (msgBox.clickedButton() == removeButton) + { + m_list->setPaths(existingPaths); + save(); + } + else if (msgBox.clickedButton() == keepButton) + { + return true; + } + else if (msgBox.clickedButton() == cancelButton) + { + return false; + } + } + } + return true; +} + +void QtProjectWizardContentPaths::setTitleString(const QString& title) +{ + m_titleString = title; +} + +void QtProjectWizardContentPaths::setHelpString(const QString& help) +{ + m_helpString = help; +} + +void QtProjectWizardContentPaths::addDetection(QGridLayout* layout, int row) +{ + std::vector detectorNames = m_pathDetector->getWorkingDetectorNames(); + if (!detectorNames.size()) + { + return; + } + + QLabel* label = new QLabel("Auto detection from:"); + + m_detectorBox = new QComboBox(); + + for (const std::string& detectorName: detectorNames) + { + m_detectorBox->addItem(detectorName.c_str()); + } + + QPushButton* button = new QPushButton("detect"); + button->setObjectName("windowButton"); + connect(button, &QPushButton::clicked, this, &QtProjectWizardContentPaths::detectionClicked); + + QHBoxLayout* hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(0, 0, 0, 0); + hlayout->addWidget(label); + hlayout->addWidget(m_detectorBox); + hlayout->addWidget(button); + + QWidget* detectionWidget = new QWidget(); + detectionWidget->setLayout(hlayout); + + layout->addWidget(detectionWidget, row, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); +} + +void QtProjectWizardContentPaths::detectionClicked() +{ + std::vector paths = m_pathDetector->getPaths(m_detectorBox->currentText().toStdString()); + std::vector oldPaths = m_list->getPathsAsDisplayed(); + + paths = utility::unique(utility::concat(oldPaths, paths)); + + detectedPaths(paths); +} + +void QtProjectWizardContentPaths::detectedPaths(const std::vector& paths) +{ + m_list->setPaths(paths); +} diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPaths.h b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPaths.h new file mode 100644 index 00000000..1507d7af --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPaths.h @@ -0,0 +1,62 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATHS_H +#define QT_PROJECT_WIZARD_CONTENT_PATHS_H + +#include + +#include "QtPathListBox.h" +#include "QtProjectWizardContent.h" +#include "CombinedPathDetector.h" + +class QComboBox; +class SourceGroupSettings; + +class QtProjectWizardContentPaths + : public QtProjectWizardContent +{ + Q_OBJECT + +signals: + void showSourceFiles(); + +public: + QtProjectWizardContentPaths( + std::shared_ptr settings, + QtProjectWizardWindow* window, + QtPathListBox::SelectionPolicyType selectionPolicy, + bool checkMissingPaths = true); + + // QtSettingsWindow implementation + virtual void populate(QGridLayout* layout, int& row) override; + + virtual bool check() override; + +protected: + void setTitleString(const QString& title); + void setHelpString(const QString& help); + + void addDetection(QGridLayout* layout, int row); + + virtual void detectedPaths(const std::vector& paths); + + std::shared_ptr m_settings; + + QtPathListBox* m_list; + + QString m_showFilesString; + std::shared_ptr m_pathDetector; + + bool m_makePathsRelativeToProjectFileLocation; + +private slots: + void detectionClicked(); + +private: + const QtPathListBox::SelectionPolicyType m_selectionPolicy; + const bool m_checkMissingPaths; + QString m_titleString; + QString m_helpString; + + QComboBox* m_detectorBox; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATHS_H diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.cpp new file mode 100644 index 00000000..dda9c484 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.cpp @@ -0,0 +1,56 @@ +#include "QtProjectWizardContentPathsClassJava.h" + +#include + +#include "SourceGroupSettings.h" +#include "SourceGroupSettingsWithClasspath.h" + +QtProjectWizardContentPathsClassJava::QtProjectWizardContentPathsClassJava( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_FILES_AND_DIRECTORIES) +{ + setTitleString("Class Path"); + setHelpString( + "Enter all the .jar files your project depends on. If your project depends on uncompiled java code that should " + "not be indexed, please add the root directory of those .java files here (the one where all the package names " + "are relative to).
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); +} + +void QtProjectWizardContentPathsClassJava::populate(QGridLayout* layout, int& row) +{ + QtProjectWizardContentPaths::populate(layout, row); + + QLabel* label = createFormLabel("JRE System Library"); + layout->addWidget(label, row, QtProjectWizardWindow::FRONT_COL, Qt::AlignTop); + + m_useJreSystemLibraryCheckBox = new QCheckBox("Use JRE System Library", this); + + layout->addWidget(m_useJreSystemLibraryCheckBox, row, QtProjectWizardWindow::BACK_COL); + row++; +} + +void QtProjectWizardContentPathsClassJava::load() +{ + std::shared_ptr settings = + std::dynamic_pointer_cast(m_settings); + if (settings) + { + m_list->setPaths(settings->getClasspath()); + m_useJreSystemLibraryCheckBox->setChecked(settings->getUseJreSystemLibrary()); + } +} + +void QtProjectWizardContentPathsClassJava::save() +{ + std::shared_ptr settings = + std::dynamic_pointer_cast(m_settings); + if (settings) + { + settings->setClasspath(m_list->getPathsAsDisplayed()); + settings->setUseJreSystemLibrary(m_useJreSystemLibraryCheckBox->isChecked()); + } +} diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.h b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.h new file mode 100644 index 00000000..b35e441f --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsClassJava.h @@ -0,0 +1,24 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATHS_CLASS_JAVA_H +#define QT_PROJECT_WIZARD_CONTENT_PATHS_CLASS_JAVA_H + +#include "QtProjectWizardContentPaths.h" + +class QCheckBox; + +class QtProjectWizardContentPathsClassJava + : public QtProjectWizardContentPaths +{ + Q_OBJECT +public: + QtProjectWizardContentPathsClassJava(std::shared_ptr settings, QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + virtual void populate(QGridLayout* layout, int& row) override; + virtual void load() override; + virtual void save() override; + +private: + QCheckBox* m_useJreSystemLibraryCheckBox; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATHS_CLASS_JAVA_H diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.cpp new file mode 100644 index 00000000..d7bfec91 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.cpp @@ -0,0 +1,39 @@ +#include "QtProjectWizardContentPathsExclude.h" + +#include "SourceGroupSettings.h" +#include "SourceGroupSettingsWithExcludeFilters.h" +#include "utility.h" +#include "utilityString.h" + +QtProjectWizardContentPathsExclude::QtProjectWizardContentPathsExclude( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_FILES_AND_DIRECTORIES, false) +{ + setTitleString("Excluded Files & Directories"); + setHelpString( + "

These paths define the files and directories that will be left out from indexing.

" + "

Hints:" + "

    " + "
  • You can use the wildcard \"*\" which represents characters except \"\\\" or \"/\" (e.g. \"src/*/test.h\" matches \"src/app/test.h\" but does not match \"src/app/widget/test.h\" or \"src/test.h\")
  • " + "
  • You can use the wildcard \"**\" which represents arbitrary characters (e.g. \"src**test.h\" matches \"src/app/test.h\" as well as \"src/app/widget/test.h\" or \"src/test.h\")
  • " + "
  • You can make use of environment variables with ${ENV_VAR}
  • " + "

" + ); +} + +void QtProjectWizardContentPathsExclude::load() +{ + if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type + { + m_list->setPaths(utility::convert(settings->getExcludeFilterStrings(), [](const std::wstring& s) { return FilePath(s); })); + } +} + +void QtProjectWizardContentPathsExclude::save() +{ + if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type + { + settings->setExcludeFilterStrings(utility::toWStrings(m_list->getPathsAsDisplayed())); + } +} diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.h b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.h new file mode 100644 index 00000000..d4206f9c --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsExclude.h @@ -0,0 +1,17 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATHS_EXCLUDE_H +#define QT_PROJECT_WIZARD_CONTENT_PATHS_EXCLUDE_H + +#include "QtProjectWizardContentPaths.h" + +class QtProjectWizardContentPathsExclude + : public QtProjectWizardContentPaths +{ + Q_OBJECT +public: + QtProjectWizardContentPathsExclude(std::shared_ptr settings, QtProjectWizardWindow* window); + + virtual void load() override; + virtual void save() override; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATHS_EXCLUDE_H diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.cpp new file mode 100644 index 00000000..6ab341a6 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.cpp @@ -0,0 +1,40 @@ +#include "QtProjectWizardContentPathsFrameworkSearch.h" + +#include "SourceGroupSettingsCxx.h" + +QtProjectWizardContentPathsFrameworkSearch::QtProjectWizardContentPathsFrameworkSearch( + std::shared_ptr settings, QtProjectWizardWindow* window, bool indicateAsAdditional +) + : QtProjectWizardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY) +{ + setTitleString(indicateAsAdditional ? "Additional Framework Search Paths" : "Framework Search Paths"); + setHelpString( + "Framework Search Paths define where MacOS framework containers (.framework), that your project depends on, are " + "found. These paths are usually passed to the compiler with the '-iframework' flag.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); +} + +void QtProjectWizardContentPathsFrameworkSearch::load() +{ + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + if (cxxSettings) + { + m_list->setPaths(cxxSettings->getFrameworkSearchPaths()); + } +} + +void QtProjectWizardContentPathsFrameworkSearch::save() +{ + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + if (cxxSettings) + { + cxxSettings->setFrameworkSearchPaths(m_list->getPathsAsDisplayed()); + } +} + +bool QtProjectWizardContentPathsFrameworkSearch::isScrollAble() const +{ + return true; +} diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.h b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.h new file mode 100644 index 00000000..1685832a --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearch.h @@ -0,0 +1,21 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATHS_FRAMEWORK_SEARCH_H +#define QT_PROJECT_WIZARD_CONTENT_PATHS_FRAMEWORK_SEARCH_H + +#include "QtProjectWizardContentPaths.h" + +class QtProjectWizardContentPathsFrameworkSearch + : public QtProjectWizardContentPaths +{ + Q_OBJECT +public: + QtProjectWizardContentPathsFrameworkSearch( + std::shared_ptr settings, QtProjectWizardWindow* window, bool indicateAsAdditional = false); + + // QtProjectWizardContent implementation + virtual void load() override; + virtual void save() override; + + virtual bool isScrollAble() const override; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATHS_FRAMEWORK_SEARCH_H diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.cpp new file mode 100644 index 00000000..b51e4613 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.cpp @@ -0,0 +1,34 @@ +#include "QtProjectWizardContentPathsFrameworkSearchGlobal.h" + +#include "ApplicationSettings.h" +#include "utilityPathDetection.h" + +QtProjectWizardContentPathsFrameworkSearchGlobal::QtProjectWizardContentPathsFrameworkSearchGlobal( + QtProjectWizardWindow* window +) + : QtProjectWizardContentPaths(std::shared_ptr(), window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY) +{ + setTitleString("Global Framework Search Paths"); + setHelpString( + "The Global Framework Search Paths will be used in all your projects - in addition to the project specific " + "Framework Search Paths.
" + "
" + "They define where MacOS framework containers (.framework) are found " + "(See " + "Finding System Header Locations or use the auto detection below)." + ); + + m_pathDetector = utility::getCxxFrameworkPathDetector(); + m_makePathsRelativeToProjectFileLocation = false; +} + +void QtProjectWizardContentPathsFrameworkSearchGlobal::load() +{ + m_list->setPaths(ApplicationSettings::getInstance()->getFrameworkSearchPaths()); +} + +void QtProjectWizardContentPathsFrameworkSearchGlobal::save() +{ + ApplicationSettings::getInstance()->setFrameworkSearchPaths(m_list->getPathsAsDisplayed()); + ApplicationSettings::getInstance()->save(); +} diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.h b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.h new file mode 100644 index 00000000..97d1bf1f --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsFrameworkSearchGlobal.h @@ -0,0 +1,18 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATHS_FRAMEWORK_SEARCH_GLOBAL_H +#define QT_PROJECT_WIZARD_CONTENT_PATHS_FRAMEWORK_SEARCH_GLOBAL_H + +#include "QtProjectWizardContentPaths.h" + +class QtProjectWizardContentPathsFrameworkSearchGlobal + : public QtProjectWizardContentPaths +{ + Q_OBJECT +public: + QtProjectWizardContentPathsFrameworkSearchGlobal(QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + virtual void load() override; + virtual void save() override; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATHS_FRAMEWORK_SEARCH_GLOBAL_H diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.cpp new file mode 100644 index 00000000..0629ad18 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.cpp @@ -0,0 +1,394 @@ +#include "QtProjectWizardContentPathsHeaderSearch.h" + +#include + +#include "Application.h" +#include "ApplicationSettings.h" +#include "FileManager.h" +#include "IncludeDirective.h" +#include "IncludeProcessing.h" +#include "QtDialogView.h" +#include "QtPathListDialog.h" +#include "QtTextEditDialog.h" +#include "ScopedFunctor.h" +#include "SourceGroupSettingsCxx.h" +#include "SourceGroupSettingsWithExcludeFilters.h" +#include "SourceGroupSettingsWithSourceExtensions.h" +#include "SourceGroupSettingsWithSourcePaths.h" +#include "utility.h" +#include "utilityFile.h" + +QtProjectWizardContentPathsHeaderSearch::QtProjectWizardContentPathsHeaderSearch( + std::shared_ptr settings, QtProjectWizardWindow* window, bool indicateAsAdditional +) + : QtProjectWizardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY) + , m_showDetectedIncludesResultFunctor(std::bind( + &QtProjectWizardContentPathsHeaderSearch::showDetectedIncludesResult, this, std::placeholders::_1)) + , m_showValidationResultFunctor(std::bind( + &QtProjectWizardContentPathsHeaderSearch::showValidationResult, this, std::placeholders::_1)) + , m_indicateAsAdditional(indicateAsAdditional) +{ + setTitleString(m_indicateAsAdditional ? "Additional Include Paths" : "Include Paths"); + setHelpString( + ( + (m_indicateAsAdditional ? "Note: Use the Additional Include Paths to add paths that are missing in the " + "referenced project file.

" : "" + ) + std::string( + "Include Paths are used for resolving #include directives in the indexed source and header files. These paths are " + "usually passed to the compiler with the '-I' or '-iquote' flags.
" + "
" + "Add all paths #include directives throughout your project are relative to. If all #include directives are " + "specified relative to the project's root directory, please add that root directory here.
" + "
" + "If your project also includes files from external libraries (e.g. boost), please add these directories as well " + "(e.g. add 'path/to/boost_home/include').
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ) + ).c_str() + ); +} + +void QtProjectWizardContentPathsHeaderSearch::populate(QGridLayout* layout, int& row) +{ + QtProjectWizardContentPaths::populate(layout, row); + + if (!m_indicateAsAdditional) + { + { + QPushButton* detectionButton = new QPushButton("auto-detect"); + detectionButton->setObjectName("windowButton"); + connect(detectionButton, &QPushButton::clicked, this, &QtProjectWizardContentPathsHeaderSearch::detectIncludesButtonClicked); + layout->addWidget(detectionButton, row, QtProjectWizardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); + } + { + QPushButton* validateionButton = new QPushButton("validate include directives"); + validateionButton->setObjectName("windowButton"); + connect(validateionButton, &QPushButton::clicked, this, &QtProjectWizardContentPathsHeaderSearch::validateIncludesButtonClicked); + layout->addWidget(validateionButton, row, QtProjectWizardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop); + } + row++; + } +} + +void QtProjectWizardContentPathsHeaderSearch::load() +{ + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + if (cxxSettings) + { + m_list->setPaths(cxxSettings->getHeaderSearchPaths()); + } +} + +void QtProjectWizardContentPathsHeaderSearch::save() +{ + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + if (cxxSettings) + { + cxxSettings->setHeaderSearchPaths(m_list->getPathsAsDisplayed()); + } +} + +bool QtProjectWizardContentPathsHeaderSearch::isScrollAble() const +{ + return true; +} + +void QtProjectWizardContentPathsHeaderSearch::detectIncludesButtonClicked() +{ + m_window->saveContent(); + + m_pathsDialog = std::make_shared( + "Detect Include Paths", + "

Automatically search for header files in the paths provided below to find missing include paths for " + "unresolved include directives in your source code.

" + "

The \"Files & Directories to Index\" will be searched by default, but you can add further paths, such " + "as directories of third-party libraries, if required.

", + QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY + ); + + m_pathsDialog->setup(); + m_pathsDialog->updateNextButton("Start"); + m_pathsDialog->setCloseVisible(true); + + m_pathsDialog->setRelativeRootDirectory(m_settings->getProjectDirectoryPath()); + if (std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type + { + m_pathsDialog->setPaths(pathSettings->getSourcePaths(), true); + } + m_pathsDialog->showWindow(); + + connect(m_pathsDialog.get(), &QtPathListDialog::finished, this, &QtProjectWizardContentPathsHeaderSearch::finishedSelectDetectIncludesRootPathsDialog); + connect(m_pathsDialog.get(), &QtPathListDialog::canceled, this, &QtProjectWizardContentPathsHeaderSearch::closedPathsDialog); +} + +void QtProjectWizardContentPathsHeaderSearch::validateIncludesButtonClicked() +{ + // TODO: regard Force Includes here, too! + m_window->saveContent(); + + std::thread([&]() + { + std::shared_ptr extensionSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr excludeFilterSettings = std::dynamic_pointer_cast(m_settings); + + if (extensionSettings && pathSettings && excludeFilterSettings) // FIXME: pass msettings as required type + { + std::vector unresolvedIncludes; + { + QtDialogView* dialogView = dynamic_cast( + Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); + + std::set sourceFilePaths; + std::vector indexedFilePaths; + std::vector headerSearchPaths; + + { + dialogView->setParentWindow(m_window); + dialogView->showUnknownProgressDialog(L"Processing", L"Gathering Source Files"); + ScopedFunctor dialogHider([&dialogView](){ + dialogView->hideUnknownProgressDialog(); + }); + + FileManager fileManager; + fileManager.update( + pathSettings->getSourcePathsExpandedAndAbsolute(), + excludeFilterSettings->getExcludeFiltersExpandedAndAbsolute(), + extensionSettings->getSourceExtensions() + ); + sourceFilePaths = fileManager.getAllSourceFilePaths(); + + indexedFilePaths = pathSettings->getSourcePathsExpandedAndAbsolute(); + + headerSearchPaths = ApplicationSettings::getInstance()->getHeaderSearchPathsExpanded(); + if (std::shared_ptr cxxSettings = + std::dynamic_pointer_cast(m_settings)) + { + utility::append(headerSearchPaths, cxxSettings->getHeaderSearchPathsExpandedAndAbsolute()); + } + } + { + dialogView->setParentWindow(m_window); + ScopedFunctor dialogHider([&dialogView](){ + dialogView->hideProgressDialog(); + }); + + unresolvedIncludes = IncludeProcessing::getUnresolvedIncludeDirectives( + sourceFilePaths, + utility::toSet(indexedFilePaths), + utility::toSet(headerSearchPaths), + log2(sourceFilePaths.size()), + [&](const float progress) + { + dialogView->showProgressDialog( + L"Processing", std::to_wstring(int(progress * sourceFilePaths.size())) + L" Files", + int(progress * 100.0f) + ); + } + ); + } + } + m_showValidationResultFunctor(unresolvedIncludes); + } + }).detach(); +} + + +void QtProjectWizardContentPathsHeaderSearch::finishedSelectDetectIncludesRootPathsDialog() +{ + // TODO: regard Force Includes here, too! + const std::vector searchedPaths = m_settings->makePathsExpandedAndAbsolute(m_pathsDialog->getPaths()); + closedPathsDialog(); + + std::thread([=]() + { + std::shared_ptr extensionSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr excludeFilterSettings = std::dynamic_pointer_cast(m_settings); + + if (extensionSettings && pathSettings && excludeFilterSettings) // FIXME: pass msettings as required type + { + std::set detectedHeaderSearchPaths; + { + QtDialogView* dialogView = dynamic_cast( + Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); + + std::set sourceFilePaths; + std::vector headerSearchPaths; + { + dialogView->setParentWindow(m_window); + dialogView->showUnknownProgressDialog(L"Processing", L"Gathering Source Files"); + ScopedFunctor dialogHider([&dialogView]() { + dialogView->hideUnknownProgressDialog(); + }); + + FileManager fileManager; + fileManager.update( + pathSettings->getSourcePathsExpandedAndAbsolute(), + excludeFilterSettings->getExcludeFiltersExpandedAndAbsolute(), + extensionSettings->getSourceExtensions() + ); + sourceFilePaths = fileManager.getAllSourceFilePaths(); + + headerSearchPaths = ApplicationSettings::getInstance()->getHeaderSearchPathsExpanded(); + if (std::shared_ptr cxxSettings = + std::dynamic_pointer_cast(m_settings)) + { + utility::append(headerSearchPaths, cxxSettings->getHeaderSearchPathsExpandedAndAbsolute()); + } + } + { + dialogView->setParentWindow(m_window); + ScopedFunctor dialogHider([&dialogView]() { + dialogView->hideProgressDialog(); + }); + + detectedHeaderSearchPaths = IncludeProcessing::getHeaderSearchDirectories( + sourceFilePaths, + utility::toSet(searchedPaths), + utility::toSet(headerSearchPaths), + log2(sourceFilePaths.size()), + [&](const float progress) + { + dialogView->showProgressDialog( + L"Processing", std::to_wstring(int(progress * sourceFilePaths.size())) + L" Files", + int(progress * 100.0f) + ); + } + ); + } + } + + m_showDetectedIncludesResultFunctor(detectedHeaderSearchPaths); + } + }).detach(); +} + +void QtProjectWizardContentPathsHeaderSearch::finishedAcceptDetectedIncludePathsDialog() +{ + const std::vector detectedPaths = utility::split>(m_filesDialog->getText(), L"\n"); + closedFilesDialog(); + + std::vector headerSearchPaths = m_list->getPathsAsDisplayed(); + + headerSearchPaths.reserve(headerSearchPaths.size() + detectedPaths.size()); + for (const std::wstring& detectedPath : detectedPaths) + { + if (!detectedPath.empty()) + { + headerSearchPaths.push_back(FilePath(detectedPath)); + } + } + + m_list->setPaths(headerSearchPaths); +} + +void QtProjectWizardContentPathsHeaderSearch::closedPathsDialog() +{ + m_pathsDialog->hide(); + m_pathsDialog.reset(); + + window()->raise(); +} + +void QtProjectWizardContentPathsHeaderSearch::showDetectedIncludesResult(const std::set& detectedHeaderSearchPaths) +{ + const std::set headerSearchPaths = utility::toSet(m_settings->makePathsExpandedAndAbsolute(m_list->getPathsAsDisplayed())); + + std::vector additionalHeaderSearchPaths; + { + const FilePath relativeRoot = m_list->getRelativeRootDirectory(); + for (const FilePath& detectedHeaderSearchPath : detectedHeaderSearchPaths) + { + if (headerSearchPaths.find(detectedHeaderSearchPath) == headerSearchPaths.end()) + { + additionalHeaderSearchPaths.push_back(utility::getAsRelativeIfShorter(detectedHeaderSearchPath, relativeRoot)); + } + } + } + + if (additionalHeaderSearchPaths.empty()) + { + QMessageBox msgBox; + msgBox.setText("

No additional include paths have been detected while searching the provided paths.

"); + msgBox.exec(); + } + else + { + std::wstring detailedText = L""; + for (const FilePath& path : additionalHeaderSearchPaths) + { + detailedText += path.wstr() + L"\n"; + } + + m_filesDialog = std::make_shared( + "Detected Include Paths", + ( + "

The following " + std::to_string(additionalHeaderSearchPaths.size()) + " include paths have been " + "detected and will be added to the include paths of this Source Group." + ).c_str() + ); + + m_filesDialog->setup(); + m_filesDialog->setReadOnly(true); + m_filesDialog->setCloseVisible(true); + m_filesDialog->updateNextButton("Add"); + + m_filesDialog->setText(detailedText); + m_filesDialog->showWindow(); + + connect(m_filesDialog.get(), &QtTextEditDialog::finished, this, &QtProjectWizardContentPathsHeaderSearch::finishedAcceptDetectedIncludePathsDialog); + connect(m_filesDialog.get(), &QtTextEditDialog::canceled, this, &QtProjectWizardContentPathsHeaderSearch::closedFilesDialog); + } +} + +void QtProjectWizardContentPathsHeaderSearch::showValidationResult(const std::vector& unresolvedIncludes) +{ + if (unresolvedIncludes.empty()) + { + QMessageBox msgBox; + msgBox.setText("

All include directives throughout the indexed files have been resolved.

"); + msgBox.exec(); + } + else + { + std::map> orderedIncludes; + for (const IncludeDirective& unresolvedInclude: unresolvedIncludes) + { + orderedIncludes[unresolvedInclude.getIncludingFile().wstr()].emplace( + unresolvedInclude.getLineNumber(), unresolvedInclude.getDirective()); + } + + std::wstring detailedText = L""; + for (const auto& p: orderedIncludes) + { + detailedText += p.first + L"\n"; + + for (const auto& p2: p.second) + { + detailedText += std::to_wstring(p2.first) + L":\t" + p2.second + L"\n"; + } + + detailedText += L"\n"; + } + + m_filesDialog = std::make_shared("Unresolved Include Directives", + ("

The indexed files contain " + std::to_string(unresolvedIncludes.size()) + " include directive" + + (unresolvedIncludes.size() == 1 ? "" : "s") + " that could not be resolved correctly. Please check the details " + "and add the respective header search paths.

" + "

Note: This is only a quick pass that does not regard block commenting or conditional preprocessor " + "directives. This means that some of the unresolved includes may actually not be required by the indexer.

" + ).c_str()); + + m_filesDialog->setup(); + m_filesDialog->setCloseVisible(false); + m_filesDialog->setReadOnly(true); + + m_filesDialog->setText(detailedText); + m_filesDialog->showWindow(); + + connect(m_filesDialog.get(), &QtTextEditDialog::finished, this, &QtProjectWizardContentPathsHeaderSearch::closedFilesDialog); + connect(m_filesDialog.get(), &QtTextEditDialog::canceled, this, &QtProjectWizardContentPathsHeaderSearch::closedFilesDialog); + } +} diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.h b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.h new file mode 100644 index 00000000..b14d35dd --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.h @@ -0,0 +1,42 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATHS_HEADER_SEARCH_H +#define QT_PROJECT_WIZARD_CONTENT_PATHS_HEADER_SEARCH_H + +#include "FilePathFilter.h" +#include "QtProjectWizardContentPaths.h" + +class IncludeDirective; +class QtPathListDialog; + +class QtProjectWizardContentPathsHeaderSearch + : public QtProjectWizardContentPaths +{ + Q_OBJECT +public: + QtProjectWizardContentPathsHeaderSearch( + std::shared_ptr settings, QtProjectWizardWindow* window, bool indicateAsAdditional = false); + + // QtProjectWizardContent implementation + virtual void populate(QGridLayout* layout, int& row) override; + virtual void load() override; + virtual void save() override; + virtual bool isScrollAble() const override; + +private slots: + void detectIncludesButtonClicked(); + void validateIncludesButtonClicked(); + void finishedSelectDetectIncludesRootPathsDialog(); + void finishedAcceptDetectedIncludePathsDialog(); + void closedPathsDialog(); + +private: + void showDetectedIncludesResult(const std::set& detectedHeaderSearchPaths); + void showValidationResult(const std::vector& unresolvedIncludes); + + QtThreadedFunctor> m_showDetectedIncludesResultFunctor; + QtThreadedFunctor> m_showValidationResultFunctor; + + std::shared_ptr m_pathsDialog; + const bool m_indicateAsAdditional; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATHS_HEADER_SEARCH_H diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.cpp new file mode 100644 index 00000000..38ccf382 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.cpp @@ -0,0 +1,116 @@ +#include "QtProjectWizardContentPathsHeaderSearchGlobal.h" + +#include + +#include "ApplicationSettings.h" +#include "ResourcePaths.h" +#include "utilityApp.h" +#include "utilityPathDetection.h" + +QtProjectWizardContentPathsHeaderSearchGlobal::QtProjectWizardContentPathsHeaderSearchGlobal( + QtProjectWizardWindow* window +) + : QtProjectWizardContentPaths(std::shared_ptr(), window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY) +{ + setTitleString("Global Include Paths"); + setHelpString( + "The Global Include Paths will be used in all your projects in addition to the project specific Include Paths. " + "These paths are usually passed to the compiler with the '-isystem' flag.
" + "
" + "Use them to add system header paths (See " + "Finding System Header Locations or use the auto detection below)." + ); + + m_pathDetector = utility::getCxxHeaderPathDetector(); + m_makePathsRelativeToProjectFileLocation = false; +} + +void QtProjectWizardContentPathsHeaderSearchGlobal::load() +{ + setPaths(ApplicationSettings::getInstance()->getHeaderSearchPaths()); +} + +void QtProjectWizardContentPathsHeaderSearchGlobal::save() +{ + std::vector paths; + for (const FilePath& headerPath : m_list->getPathsAsDisplayed()) + { + if (headerPath != ResourcePaths::getCxxCompilerHeaderPath()) + { + paths.push_back(headerPath); + } + } + + ApplicationSettings::getInstance()->setHeaderSearchPaths(paths); + ApplicationSettings::getInstance()->save(); +} + +bool QtProjectWizardContentPathsHeaderSearchGlobal::check() +{ + if (utility::getOsType() == OS_WINDOWS) + { + return QtProjectWizardContentPaths::check(); + } + + bool hasOtherCompilerConfig = false; + for (const FilePath& headerPath : m_list->getPathsAsDisplayed()) + { + if (headerPath != ResourcePaths::getCxxCompilerHeaderPath() && + headerPath.getCanonical().getConcatenated(L"/stdarg.h").exists()) + { + hasOtherCompilerConfig = true; + break; + } + } + + if (hasOtherCompilerConfig) + { + QMessageBox msgBox; + msgBox.setText("Multiple Compiler Headers"); + msgBox.setInformativeText("Your Global Include Paths contain another path that holds C/C++ compiler headers, " + "probably those of your local C/C++ compiler. They are possibly in conflict with the compiler headers of " + "Sourcetrail's C/C++ indexer. This can lead to compatiblity errors during indexing. Do you want to remove " + "these paths?"); + msgBox.addButton("Remove", QMessageBox::ButtonRole::YesRole); + msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole); + msgBox.setIcon(QMessageBox::Icon::Question); + int ret = msgBox.exec(); + + if (ret == 0) // QMessageBox::Yes + { + std::vector paths; + for (const FilePath& headerPath : m_list->getPathsAsDisplayed()) + { + if (headerPath != ResourcePaths::getCxxCompilerHeaderPath() && + headerPath.getCanonical().getConcatenated(L"/stdarg.h").exists()) + { + continue; + } + paths.push_back(headerPath); + } + setPaths(paths); + } + } + + return QtProjectWizardContentPaths::check(); +} + +void QtProjectWizardContentPathsHeaderSearchGlobal::detectedPaths(const std::vector& paths) +{ + std::vector headerPaths; + for (const FilePath& headerPath : paths) + { + if (headerPath != ResourcePaths::getCxxCompilerHeaderPath()) + { + headerPaths.push_back(headerPath); + } + } + setPaths(headerPaths); +} + +void QtProjectWizardContentPathsHeaderSearchGlobal::setPaths(const std::vector& paths) +{ + m_list->setPaths({}); + m_list->addPaths({ ResourcePaths::getCxxCompilerHeaderPath() }, true); + m_list->addPaths(paths); +} diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.h b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.h new file mode 100644 index 00000000..88ef0b0a --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearchGlobal.h @@ -0,0 +1,26 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATHS_HEADER_SEARCH_GLOBAL_H +#define QT_PROJECT_WIZARD_CONTENT_PATHS_HEADER_SEARCH_GLOBAL_H + +#include "QtProjectWizardContentPaths.h" + +class QtProjectWizardContentPathsHeaderSearchGlobal + : public QtProjectWizardContentPaths +{ + Q_OBJECT +public: + QtProjectWizardContentPathsHeaderSearchGlobal(QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + virtual void load() override; + virtual void save() override; + + virtual bool check() override; + +protected: + virtual void detectedPaths(const std::vector& paths) override; + +private: + void setPaths(const std::vector& paths); +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATHS_HEADER_SEARCH_GLOBAL_H diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.cpp new file mode 100644 index 00000000..e71ab7b5 --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.cpp @@ -0,0 +1,324 @@ +#include "QtProjectWizardContentPathsIndexedHeaders.h" + +#include + +#include "CodeblocksProject.h" +#include "CompilationDatabase.h" +#include "IndexerCommandCxx.h" +#include "logging.h" +#include "OrderedCache.h" +#include "QtPathListDialog.h" +#include "QtSelectPathsDialog.h" +#include "QtTextEditDialog.h" +#include "SonargraphProject.h" +#include "SourceGroupSettingsCxxCdb.h" +#include "SourceGroupSettingsCxxCodeblocks.h" +#include "SourceGroupSettingsCxxSonargraph.h" +#include "utility.h" +#include "utilityFile.h" + +std::vector QtProjectWizardContentPathsIndexedHeaders::getIndexedPathsDerivedFromSonargraphProject( + std::shared_ptr settings) +{ + std::set indexedHeaderPaths; + { + const FilePath sonargraphProjectPath = settings->getSonargraphProjectPathExpandedAndAbsolute(); + if (!sonargraphProjectPath.empty() && sonargraphProjectPath.exists()) + { + if (std::shared_ptr sonargraphProject = Sonargraph::Project::load( + sonargraphProjectPath, settings->getLanguage() + )) + { + for (const FilePath& path : sonargraphProject->getAllSourceFilePathsCanonical()) + { + indexedHeaderPaths.insert(path.getCanonical().getParentDirectory()); + } + utility::append(indexedHeaderPaths, sonargraphProject->getAllCxxHeaderSearchPathsCanonical()); + } + } + else + { + LOG_WARNING("Unable to fetch indexed header paths. The provided Sonargraph project path does not exist."); + } + } + + std::vector topLevelPaths; + for (const FilePath& path : utility::getTopLevelPaths(indexedHeaderPaths)) + { + if (path.exists()) + { + topLevelPaths.push_back(path); + } + } + + return topLevelPaths; +} + +std::vector QtProjectWizardContentPathsIndexedHeaders::getIndexedPathsDerivedFromCodeblocksProject( + std::shared_ptr settings) +{ + const FilePath projectPath = settings->getProjectDirectoryPath(); + std::set indexedHeaderPaths; + { + const FilePath codeblocksProjectPath = settings->getCodeblocksProjectPathExpandedAndAbsolute(); + if (!codeblocksProjectPath.empty() && codeblocksProjectPath.exists()) + { + if (std::shared_ptr codeblocksProject = Codeblocks::Project::load(codeblocksProjectPath)) + { + OrderedCache canonicalDirectoryPathCache([](const FilePath& path) { + return path.getCanonical(); + }); + + for (const FilePath& path : codeblocksProject->getAllSourceFilePathsCanonical(settings->getSourceExtensions())) + { + indexedHeaderPaths.insert(canonicalDirectoryPathCache.getValue(path.getParentDirectory())); + } + utility::append(indexedHeaderPaths, codeblocksProject->getAllCxxHeaderSearchPathsCanonical()); + } + } + else + { + LOG_WARNING("Unable to fetch indexed header paths. The provided Sonargraph project path does not exist."); + } + } + + std::vector topLevelPaths; + for (const FilePath& path : utility::getTopLevelPaths(indexedHeaderPaths)) + { + if (path.exists()) + { + topLevelPaths.push_back(path); + } + } + + return topLevelPaths; +} + +std::vector QtProjectWizardContentPathsIndexedHeaders::getIndexedPathsDerivedFromCDB( + std::shared_ptr settings) +{ + std::set indexedHeaderPaths; + { + const FilePath cdbPath = settings->getCompilationDatabasePathExpandedAndAbsolute(); + if (!cdbPath.empty() && cdbPath.exists()) + { + for (const FilePath& path : IndexerCommandCxx::getSourceFilesFromCDB(cdbPath)) + { + indexedHeaderPaths.insert(path.getCanonical().getParentDirectory()); + } + for (const FilePath& path : utility::CompilationDatabase(cdbPath).getAllHeaderPaths()) + { + if (path.exists()) + { + indexedHeaderPaths.insert(path.getCanonical()); + } + } + } + else + { + LOG_WARNING("Unable to fetch indexed header paths. The provided Compilation Database path does not exist."); + } + } + + std::vector topLevelPaths; + for (const FilePath& path : utility::getTopLevelPaths(indexedHeaderPaths)) + { + if (path.exists()) + { + topLevelPaths.push_back(path); + } + } + + return topLevelPaths; +} + +QtProjectWizardContentPathsIndexedHeaders::QtProjectWizardContentPathsIndexedHeaders( + std::shared_ptr settings, QtProjectWizardWindow* window, std::string projectKindName +) + : QtProjectWizardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_FILES_AND_DIRECTORIES) + , m_projectKindName(projectKindName) +{ + m_showFilesString = ""; + + setTitleString("Header Files & Directories to Index"); + setHelpString(QString::fromStdString( + "The provided " + m_projectKindName + " already specifies which source files are part of your project. But Sourcetrail still " + "needs to know which header files to index as part of your project and which to skip. Choosing to skip indexing " + "your system headers or external frameworks will significantly improve the overall indexing performance.
" + "
" + "Use this list to define which header files should be indexed by Sourcetrail. Provide a directory to recursively " + "add all contained files.
" + "
" + "You can make use of environment variables with ${ENV_VAR}.
" + "
" + "Hint: Just enter the root path of your project if you want Sourcetrail to index all contained headers it " + "encounters.
" + )); +} + +void QtProjectWizardContentPathsIndexedHeaders::populate(QGridLayout* layout, int& row) +{ + QtProjectWizardContentPaths::populate(layout, row); + + QPushButton* button = new QPushButton(QString::fromStdString("Select from " + m_projectKindName)); + button->setObjectName("windowButton"); + connect(button, &QPushButton::clicked, this, &QtProjectWizardContentPathsIndexedHeaders::buttonClicked); + + layout->addWidget(button, row, QtProjectWizardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop); + row++; +} + +void QtProjectWizardContentPathsIndexedHeaders::load() +{ + if (std::shared_ptr cdbSettings = + std::dynamic_pointer_cast(m_settings)) + { + m_list->setPaths(cdbSettings->getIndexedHeaderPaths()); + } +} + +void QtProjectWizardContentPathsIndexedHeaders::save() +{ + if (std::shared_ptr cdbSettings = + std::dynamic_pointer_cast(m_settings)) + { + cdbSettings->setIndexedHeaderPaths(m_list->getPathsAsDisplayed()); + } +} + +bool QtProjectWizardContentPathsIndexedHeaders::check() +{ + if (m_list->getPathsAsDisplayed().empty()) + { + QMessageBox msgBox; + msgBox.setText("You didn't specify any Header Files & Directories to Index."); + msgBox.setInformativeText(QString::fromStdString( + "Sourcetrail will only index the source files listed in the " + m_projectKindName + + " file and none of the included header files." + )); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + return msgBox.exec() == QMessageBox::Ok; + } + else + { + return QtProjectWizardContentPaths::check(); + } +} + +void QtProjectWizardContentPathsIndexedHeaders::buttonClicked() +{ + save(); + + if (!m_filesDialog) + { + if (std::shared_ptr sonargraphSettings = std::dynamic_pointer_cast(m_settings)) + { + const FilePath sonargraphProjectPath = sonargraphSettings->getSonargraphProjectPathExpandedAndAbsolute(); + if (!sonargraphProjectPath.exists()) + { + QMessageBox msgBox; + msgBox.setText("The provided Sonargraph project path does not exist."); + msgBox.setDetailedText(QString::fromStdWString(sonargraphProjectPath.wstr())); + msgBox.exec(); + return; + } + + m_filesDialog = std::make_shared( + "Select from Include Paths", + "The list contains all Include Paths found in the Sonargraph project. Red paths do not exist. Select the " + "paths containing the header files you want to index with Sourcetrail."); + m_filesDialog->setup(); + + connect(m_filesDialog.get(), &QtSelectPathsDialog::finished, this, &QtProjectWizardContentPathsIndexedHeaders::savedFilesDialog); + connect(m_filesDialog.get(), &QtSelectPathsDialog::canceled, this, &QtProjectWizardContentPathsIndexedHeaders::closedFilesDialog); + + const FilePath projectPath = sonargraphSettings->getProjectDirectoryPath(); + + dynamic_cast(m_filesDialog.get())->setPathsList( + utility::convert( + getIndexedPathsDerivedFromSonargraphProject(sonargraphSettings), + [&](const FilePath& path) { return utility::getAsRelativeIfShorter(path, projectPath); } + ), + sonargraphSettings->getIndexedHeaderPaths(), + m_settings->getProjectDirectoryPath() + ); + } + else if (std::shared_ptr codeblocksSettings = std::dynamic_pointer_cast(m_settings)) + { + const FilePath codeblocksProjectPath = codeblocksSettings->getCodeblocksProjectPathExpandedAndAbsolute(); + if (!codeblocksProjectPath.exists()) + { + QMessageBox msgBox; + msgBox.setText("The provided Code::Blocks project path does not exist."); + msgBox.setDetailedText(QString::fromStdWString(codeblocksProjectPath.wstr())); + msgBox.exec(); + return; + } + + m_filesDialog = std::make_shared( + "Select from Include Paths", + "The list contains all Include Paths found in the Code::Blocks project. Red paths do not exist. Select the " + "paths containing the header files you want to index with Sourcetrail."); + m_filesDialog->setup(); + + connect(m_filesDialog.get(), &QtSelectPathsDialog::finished, this, &QtProjectWizardContentPathsIndexedHeaders::savedFilesDialog); + connect(m_filesDialog.get(), &QtSelectPathsDialog::canceled, this, &QtProjectWizardContentPathsIndexedHeaders::closedFilesDialog); + + const FilePath projectPath = codeblocksSettings->getProjectDirectoryPath(); + + dynamic_cast(m_filesDialog.get())->setPathsList( + utility::convert( + getIndexedPathsDerivedFromCodeblocksProject(codeblocksSettings), + [&](const FilePath& path) { return utility::getAsRelativeIfShorter(path, projectPath); } + ), + codeblocksSettings->getIndexedHeaderPaths(), + m_settings->getProjectDirectoryPath() + ); + } + else if (std::shared_ptr cdbSettings = std::dynamic_pointer_cast(m_settings)) + { + const FilePath cdbPath = cdbSettings->getCompilationDatabasePathExpandedAndAbsolute(); + if (!cdbPath.exists()) + { + QMessageBox msgBox; + msgBox.setText("The provided Compilation Database path does not exist."); + msgBox.setDetailedText(QString::fromStdWString(cdbPath.wstr())); + msgBox.exec(); + return; + } + + m_filesDialog = std::make_shared( + "Select from Include Paths", + "The list contains all Include Paths found in the Compilation Database. Red paths do not exist. Select the " + "paths containing the header files you want to index with Sourcetrail."); + m_filesDialog->setup(); + + connect(m_filesDialog.get(), &QtSelectPathsDialog::finished, this, &QtProjectWizardContentPathsIndexedHeaders::savedFilesDialog); + connect(m_filesDialog.get(), &QtSelectPathsDialog::canceled, this, &QtProjectWizardContentPathsIndexedHeaders::closedFilesDialog); + + const FilePath projectPath = cdbSettings->getProjectDirectoryPath(); + + dynamic_cast(m_filesDialog.get())->setPathsList( + utility::convert( + getIndexedPathsDerivedFromCDB(cdbSettings), + [&](const FilePath& path) { return utility::getAsRelativeIfShorter(path, projectPath); } + ), + cdbSettings->getIndexedHeaderPaths(), + m_settings->getProjectDirectoryPath() + ); + } + } + + if (m_filesDialog) + { + m_filesDialog->showWindow(); + m_filesDialog->raise(); + } +} + +void QtProjectWizardContentPathsIndexedHeaders::savedFilesDialog() +{ + m_list->setPaths(dynamic_cast(m_filesDialog.get())->getPathsList()); + closedFilesDialog(); +} diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.h b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.h new file mode 100644 index 00000000..b371e72b --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsIndexedHeaders.h @@ -0,0 +1,39 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATHS_INDEXED_HEADER_PATHS_H +#define QT_PROJECT_WIZARD_CONTENT_PATHS_INDEXED_HEADER_PATHS_H + +#include "QtProjectWizardContentPaths.h" + +class SourceGroupSettingsCxxCdb; +class SourceGroupSettingsCxxCodeblocks; +class SourceGroupSettingsCxxSonargraph; + +class QtProjectWizardContentPathsIndexedHeaders + : public QtProjectWizardContentPaths +{ + Q_OBJECT + +public: + static std::vector getIndexedPathsDerivedFromSonargraphProject(std::shared_ptr settings); + static std::vector getIndexedPathsDerivedFromCodeblocksProject(std::shared_ptr settings); + static std::vector getIndexedPathsDerivedFromCDB(std::shared_ptr settings); + + QtProjectWizardContentPathsIndexedHeaders( + std::shared_ptr settings, QtProjectWizardWindow* window, std::string projectKindName); + + virtual void populate(QGridLayout* layout, int& row) override; + + // QtProjectWizardContent implementation + virtual void load() override; + virtual void save() override; + + virtual bool check() override; + +private slots: + void buttonClicked(); + void savedFilesDialog(); + +private: + const std::string m_projectKindName; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATHS_INDEXED_HEADER_PATHS_H diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.cpp new file mode 100644 index 00000000..ab94c3ac --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.cpp @@ -0,0 +1,84 @@ +#include "QtProjectWizardContentPathsSource.h" + +#include "SourceGroupCustomCommand.h" +#include "SourceGroupCxxEmpty.h" +#include "SourceGroupJavaEmpty.h" +#include "SourceGroupPythonEmpty.h" +#include "SourceGroupSettingsCxx.h" +#include "SourceGroupSettingsCustomCommand.h" +#include "SourceGroupSettingsJavaEmpty.h" +#include "SourceGroupSettingsPythonEmpty.h" +#include "SourceGroupSettingsWithSourcePaths.h" +#include "utility.h" +#include "utilityFile.h" + +QtProjectWizardContentPathsSource::QtProjectWizardContentPathsSource( + std::shared_ptr settings, QtProjectWizardWindow* window +) + : QtProjectWizardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_FILES_AND_DIRECTORIES) +{ + m_showFilesString = "show files"; + + setTitleString("Files & Directories to Index"); + setHelpString( + "These paths define the files and directories that will be indexed by Sourcetrail. Provide a directory to recursively " + "add all contained source and header files.
" + "
" + "If your project's source code resides in one location, but generated source files are kept at a different location, " + "you will also need to add that directory.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); +} + +void QtProjectWizardContentPathsSource::load() +{ + if (std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type + { + m_list->setPaths(pathSettings->getSourcePaths()); + } +} + +void QtProjectWizardContentPathsSource::save() +{ + if (std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type + { + pathSettings->setSourcePaths(m_list->getPathsAsDisplayed()); + } +} + +std::vector QtProjectWizardContentPathsSource::getFilePaths() const +{ + std::set allSourceFilePaths; + if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) + { + allSourceFilePaths = SourceGroupCxxEmpty(settings).getAllSourceFilePaths(); + } + else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) + { + allSourceFilePaths = SourceGroupJavaEmpty(settings).getAllSourceFilePaths(); + } + else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) + { + allSourceFilePaths = SourceGroupPythonEmpty(settings).getAllSourceFilePaths(); + } + else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) + { + allSourceFilePaths = SourceGroupCustomCommand(settings).getAllSourceFilePaths(); + } + + return utility::getAsRelativeIfShorter( + utility::toVector(allSourceFilePaths), + m_settings->getProjectDirectoryPath() + ); +} + +QString QtProjectWizardContentPathsSource::getFileNamesTitle() const +{ + return "Indexed Files"; +} + +QString QtProjectWizardContentPathsSource::getFileNamesDescription() const +{ + return " files will be indexed."; +} diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.h b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.h new file mode 100644 index 00000000..6176c95c --- /dev/null +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsSource.h @@ -0,0 +1,22 @@ +#ifndef QT_PROJECT_WIZARD_CONTENT_PATHS_SOURCE_H +#define QT_PROJECT_WIZARD_CONTENT_PATHS_SOURCE_H + +#include "QtProjectWizardContentPaths.h" + +class QtProjectWizardContentPathsSource + : public QtProjectWizardContentPaths +{ + Q_OBJECT +public: + QtProjectWizardContentPathsSource(std::shared_ptr settings, QtProjectWizardWindow* window); + + // QtProjectWizardContent implementation + virtual void load() override; + virtual void save() override; + + virtual std::vector getFilePaths() const override; + virtual QString getFileNamesTitle() const override; + virtual QString getFileNamesDescription() const override; +}; + +#endif // QT_PROJECT_WIZARD_CONTENT_PATHS_SOURCE_H diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index 8ca2f5d6..1ddc9cfb 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -19,7 +19,7 @@ #include "QtFileDialog.h" #include "utilityQt.h" #include "QtViewWidgetWrapper.h" -#include "QtProjectWizzard.h" +#include "QtProjectWizard.h" #include "QtAbout.h" #include "QtAboutLicense.h" #include "QtEulaWindow.h" @@ -682,19 +682,19 @@ void QtMainWindow::hideStartScreen() void QtMainWindow::newProject() { - QtProjectWizzard* wizzard = createWindow(); - wizzard->newProject(); + QtProjectWizard* wizard = createWindow(); + wizard->newProject(); } void QtMainWindow::newProjectFromCDB(const FilePath& filePath) { - QtProjectWizzard* wizzard = dynamic_cast(m_windowStack.getTopWindow()); - if (!wizzard) + QtProjectWizard* wizard = dynamic_cast(m_windowStack.getTopWindow()); + if (!wizard) { - wizzard = createWindow(); + wizard = createWindow(); } - wizzard->newProjectFromCDB(filePath); + wizard->newProjectFromCDB(filePath); } void QtMainWindow::openProject() @@ -714,9 +714,9 @@ void QtMainWindow::editProject() Project* currentProject = Application::getInstance()->getCurrentProject().get(); if (currentProject) { - QtProjectWizzard* wizzard = createWindow(); + QtProjectWizard* wizard = createWindow(); - wizzard->editProject(currentProject->getProjectSettingsFilePath()); + wizard->editProject(currentProject->getProjectSettingsFilePath()); } } diff --git a/src/lib_gui/qt/window/QtPreferencesWindow.cpp b/src/lib_gui/qt/window/QtPreferencesWindow.cpp index 1ed20f33..d17aba47 100644 --- a/src/lib_gui/qt/window/QtPreferencesWindow.cpp +++ b/src/lib_gui/qt/window/QtPreferencesWindow.cpp @@ -7,13 +7,14 @@ #include "Application.h" #include "DialogView.h" -#include "QtProjectWizzardContentPaths.h" -#include "QtProjectWizzardContentPreferences.h" -#include "QtProjectWizzardContentGroup.h" +#include "QtProjectWizardContentPathsFrameworkSearchGlobal.h" +#include "QtProjectWizardContentPathsHeaderSearchGlobal.h" +#include "QtProjectWizardContentPreferences.h" +#include "QtProjectWizardContentGroup.h" #include "utilityApp.h" QtPreferencesWindow::QtPreferencesWindow(QWidget* parent) - : QtProjectWizzardWindow(parent) + : QtProjectWizardWindow(parent) { // save old application settings so they can be compared later ApplicationSettings* appSettings = ApplicationSettings::getInstance().get(); @@ -27,14 +28,14 @@ QtPreferencesWindow::QtPreferencesWindow(QWidget* parent) m_appSettings.setScreenScaleFactor(appSettings->getScreenScaleFactor()); - QtProjectWizzardContentGroup* summary = new QtProjectWizzardContentGroup(this); + QtProjectWizardContentGroup* summary = new QtProjectWizardContentGroup(this); summary->setIsForm(true); - summary->addContent(new QtProjectWizzardContentPreferences(this)); + summary->addContent(new QtProjectWizardContentPreferences(this)); - summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(this)); + summary->addContent(new QtProjectWizardContentPathsHeaderSearchGlobal(this)); if (utility::getOsType() == OS_MAC) { - summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(this)); + summary->addContent(new QtProjectWizardContentPathsFrameworkSearchGlobal(this)); } setPreferredSize(QSize(750, 500)); @@ -48,7 +49,7 @@ QtPreferencesWindow::~QtPreferencesWindow() void QtPreferencesWindow::windowReady() { - QtProjectWizzardWindow::windowReady(); + QtProjectWizardWindow::windowReady(); updateTitle("PREFERENCES"); updateNextButton("Save"); diff --git a/src/lib_gui/qt/window/QtPreferencesWindow.h b/src/lib_gui/qt/window/QtPreferencesWindow.h index 28e1e5cc..cf00a17e 100644 --- a/src/lib_gui/qt/window/QtPreferencesWindow.h +++ b/src/lib_gui/qt/window/QtPreferencesWindow.h @@ -1,12 +1,12 @@ #ifndef QT_PREFERENCES_WINDOW_H #define QT_PREFERENCES_WINDOW_H -#include "QtProjectWizzardWindow.h" +#include "QtProjectWizardWindow.h" #include "ApplicationSettings.h" class QtPreferencesWindow - : public QtProjectWizzardWindow + : public QtProjectWizardWindow { Q_OBJECT diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h deleted file mode 100644 index 1d9e0cbd..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_FLAGS_H -#define QT_PROJECT_WIZZARD_CONTENT_FLAGS_H - -#include "QtProjectWizzardContent.h" - -class QtStringListBox; -class SourceGroupSettingsCxx; - -class QtProjectWizzardContentFlags - : public QtProjectWizzardContent -{ - Q_OBJECT - -public: - QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional = false); - - // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; - - virtual void load() override; - virtual void save() override; - virtual bool check() override; - -private: - std::shared_ptr m_settings; - const bool m_indicateAsAdditional; - - QtStringListBox* m_list; -}; - -#endif // QT_PROJECT_WIZZARD_CONTENT_FLAGS_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentGroup.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentGroup.cpp deleted file mode 100644 index 6b64aeb5..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentGroup.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "QtProjectWizzardContentGroup.h" - -QtProjectWizzardContentGroup::QtProjectWizzardContentGroup( - QtProjectWizzardWindow* window -) - : QtProjectWizzardContent(window) - , m_isForm(false) -{ -} - -void QtProjectWizzardContentGroup::addContent(QtProjectWizzardContent* content) -{ - m_contents.push_back(content); - - if (content) - { - content->setIsInForm(m_isForm); - } -} - -void QtProjectWizzardContentGroup::addSpace() -{ - m_contents.push_back(nullptr); -} - -void QtProjectWizzardContentGroup::setIsForm(bool isForm) -{ - m_isForm = isForm; -} - -bool QtProjectWizzardContentGroup::hasContents() const -{ - for (QtProjectWizzardContent* content : m_contents) - { - if (content) - { - return true; - } - } - - return false; -} - -void QtProjectWizzardContentGroup::populate(QGridLayout* layout, int& row) -{ - if (m_isForm) - { - populateForm(layout, row); - return; - } - - layout->setRowMinimumHeight(row++, 10); - - for (QtProjectWizzardContent* content : m_contents) - { - if (content) - { - content->populate(layout, row); - } - else - { - layout->setRowMinimumHeight(row++, 20); - } - } - - layout->setRowMinimumHeight(row, 10); - layout->setRowStretch(row, 1); -} - -void QtProjectWizzardContentGroup::populateForm(QGridLayout* layout, int& row) -{ - layout->setRowMinimumHeight(row++, 10); - - for (QtProjectWizzardContent* content : m_contents) - { - if (content) - { - content->populate(layout, row); - } - else - { - layout->setRowMinimumHeight(row++, 15); - } - } - - layout->setRowMinimumHeight(row, 10); - layout->setRowStretch(row, 1); -} - -void QtProjectWizzardContentGroup::load() -{ - for (QtProjectWizzardContent* content : m_contents) - { - if (content) - { - content->load(); - } - } -} - -void QtProjectWizzardContentGroup::save() -{ - for (QtProjectWizzardContent* content : m_contents) - { - if (content) - { - content->save(); - } - } -} - -bool QtProjectWizzardContentGroup::check() -{ - for (QtProjectWizzardContent* content : m_contents) - { - if (content && !content->check()) - { - return false; - } - } - - return true; -} - -bool QtProjectWizzardContentGroup::isScrollAble() const -{ - return true; -} diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentGroup.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentGroup.h deleted file mode 100644 index b044d705..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentGroup.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_GROUP_H -#define QT_PROJECT_WIZZARD_CONTENT_GROUP_H - -#include "QtProjectWizzardContent.h" - -class QCheckBox; - -class QtProjectWizzardContentGroup - : public QtProjectWizzardContent -{ - Q_OBJECT - -public: - QtProjectWizzardContentGroup(QtProjectWizzardWindow* window); - - void addContent(QtProjectWizzardContent* content); - void addSpace(); - - void setIsForm(bool isForm); - bool hasContents() const; - -protected: - // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; - void populateForm(QGridLayout* layout, int& row); - - virtual void load() override; - virtual void save() override; - virtual bool check() override; - - virtual bool isScrollAble() const override; - -private: - std::vector m_contents; - bool m_isForm; -}; - -#endif // QT_PROJECT_WIZZARD_CONTENT_GROUP_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp deleted file mode 100644 index 52c11d39..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp +++ /dev/null @@ -1,815 +0,0 @@ -#include "QtProjectWizzardContentPath.h" - -#include -#include -#include -#include -#include - -#include "Application.h" -#include "ApplicationSettings.h" -#include "FileManager.h" -#include "MessageStatus.h" -#include "QtLocationPicker.h" -#include "QtDialogView.h" -#include "QtProjectWizzardContentPaths.h" -#include "ResourcePaths.h" -#include "ScopedFunctor.h" -#include "SonargraphProject.h" -#include "SourceGroupCxxCdb.h" -#include "SourceGroupCxxCodeblocks.h" -#include "SourceGroupCxxSonargraph.h" -#include "SourceGroupJavaSonargraph.h" -#include "SourceGroupJavaGradle.h" -#include "SourceGroupJavaMaven.h" -#include "SourceGroupSettingsCxxCdb.h" -#include "SourceGroupSettingsCxxCodeblocks.h" -#include "SourceGroupSettingsCxxSonargraph.h" -#include "SourceGroupSettingsJavaMaven.h" -#include "SourceGroupSettingsJavaGradle.h" -#include "SourceGroupSettingsJavaSonargraph.h" -#include "SourceGroupSettingsPythonEmpty.h" -#include "SourceGroupSettingsWithSonargraphProjectPath.h" -#include "utility.h" -#include "utilityApp.h" -#include "utilityFile.h" -#include "utilityGradle.h" -#include "utilityMaven.h" - -QtProjectWizzardContentPath::QtProjectWizzardContentPath(QtProjectWizzardWindow* window) - : QtProjectWizzardContent(window) - , m_makePathRelativeToProjectFileLocation(true) - , m_allowEmpty(false) -{ -} - -void QtProjectWizzardContentPath::populate(QGridLayout* layout, int& row) -{ - QLabel* label = createFormLabel(m_titleString); - layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); - - if (m_helpString.size() > 0) - { - addHelpButton(m_titleString, m_helpString, layout, row); - } - - m_picker = new QtLocationPicker(this); - m_picker->setPickDirectory(true); - m_picker->setPlaceholderText(m_placeholderString); - - if (m_makePathRelativeToProjectFileLocation) - { - m_picker->setRelativeRootDirectory(getSourceGroupSettings()->getProjectDirectoryPath()); - } - - layout->addWidget(m_picker, row, QtProjectWizzardWindow::BACK_COL); - row++; -} - -bool QtProjectWizzardContentPath::check() -{ - QString error; - - while (true) - { - if (m_picker->getText().isEmpty()) - { - if (m_allowEmpty) - { - break; - } - else - { - error = "Please define a path at \"" + m_titleString + "\"."; - break; - } - } - - FilePath path = getSourceGroupSettings()->makePathExpandedAndAbsolute(FilePath(m_picker->getText().toStdWString())); - - if (m_picker->pickDirectory()) - { - break; - } - - if (!path.exists()) - { - error = "The entered path does not exist at \"" + m_titleString + "\"."; - break; - } - - if (m_fileEndings.find(path.extension()) == m_fileEndings.end()) - { - error = "The entered path does have a correct file ending at \"" + m_titleString + "\"."; - break; - } - - break; - } - - if (!error.isEmpty()) - { - QMessageBox msgBox; - msgBox.setText(error); - msgBox.exec(); - return false; - } - - return true; -} - -void QtProjectWizzardContentPath::setTitleString(const QString& title) -{ - m_titleString = title; -} - -void QtProjectWizzardContentPath::setHelpString(const QString& help) -{ - m_helpString = help; -} - -void QtProjectWizzardContentPath::setPlaceholderString(const QString& placeholder) -{ - m_placeholderString = placeholder; -} - -void QtProjectWizzardContentPath::setFileEndings(const std::set& fileEndings) -{ - m_fileEndings = fileEndings; -} - -void QtProjectWizzardContentPath::setAllowEmpty(bool allowEmpty) -{ - m_allowEmpty = allowEmpty; -} - -QtProjectWizzardContentPathCDB::QtProjectWizzardContentPathCDB( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPath(window) - , m_settings(settings) - , m_filePaths([&]() - { - return utility::getAsRelativeIfShorter( - utility::toVector(SourceGroupCxxCdb(m_settings).getAllSourceFilePaths()), - m_settings->getProjectDirectoryPath() - ); - } - ) -{ - setTitleString("Compilation Database (compile_commands.json)"); - setHelpString( - "Select the compilation database file for the project. Sourcetrail will index your project based on the compile " - "commands. This file contains using all include paths and compiler flags of these compile commands. The project " - "will stay up to date with changes in the compilation database on every refresh.
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); - setFileEndings({ L".json" }); -} - -void QtProjectWizzardContentPathCDB::populate(QGridLayout* layout, int& row) -{ - QtProjectWizzardContentPath::populate(layout, row); - m_picker->setPickDirectory(false); - m_picker->setFileFilter("JSON Compilation Database (*.json)"); - connect(m_picker, &QtLocationPicker::locationPicked, this, &QtProjectWizzardContentPathCDB::pickedPath); - - QLabel* description = new QLabel( - "Sourcetrail will use all include paths and compiler flags from the Compilation Database and stay up-to-date " - "with changes on refresh.", this); - description->setObjectName("description"); - description->setWordWrap(true); - layout->addWidget(description, row, QtProjectWizzardWindow::BACK_COL); - row++; - - QLabel* title = createFormLabel("Source Files to Index"); - layout->addWidget(title, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); - layout->setRowStretch(row, 0); - - m_fileCountLabel = new QLabel(""); - m_fileCountLabel->setWordWrap(true); - layout->addWidget(m_fileCountLabel, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignTop); - row++; - - addFilesButton("show source files", layout, row); - row++; -} - -void QtProjectWizzardContentPathCDB::load() -{ - m_picker->setText(QString::fromStdWString(m_settings->getCompilationDatabasePath().wstr())); - - m_filePaths.clear(); - - if (m_fileCountLabel) - { - m_fileCountLabel->setText("" + QString::number(getFilePaths().size()) + " source files were found in the compilation database."); - } -} - -void QtProjectWizzardContentPathCDB::save() -{ - m_settings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdWString())); -} - -std::vector QtProjectWizzardContentPathCDB::getFilePaths() const -{ - return m_filePaths.getValue(); -} - -QString QtProjectWizzardContentPathCDB::getFileNamesTitle() const -{ - return "Source Files"; -} - -QString QtProjectWizzardContentPathCDB::getFileNamesDescription() const -{ - return " source files will be indexed."; -} - -void QtProjectWizzardContentPathCDB::pickedPath() -{ - m_window->saveContent(); - - const FilePath projectPath = m_settings->getProjectDirectoryPath(); - - std::set indexedHeaderPaths; - for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCDB(m_settings)) - { - if (projectPath.contains(path)) - { - indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); // the relative path is always shorter than the absolute path - } - } - m_settings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); - - m_window->loadContent(); -} - -std::shared_ptr QtProjectWizzardContentPathCDB::getSourceGroupSettings() -{ - return m_settings; -} - - -QtProjectWizzardContentCodeblocksProjectPath::QtProjectWizzardContentCodeblocksProjectPath( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPath(window) - , m_settings(settings) - , m_filePaths([&]() - { - return utility::getAsRelativeIfShorter( - utility::toVector(SourceGroupCxxCodeblocks(m_settings).getAllSourceFilePaths()), - m_settings->getProjectDirectoryPath() - ); - } - ) -{ - setTitleString("Code::Blocks Project (.cbp)"); - setHelpString( - "Select the Code::Blocks file for the project. Sourcetrail will index your project based on the settings " - "this file. It contains using all include paths and compiler flags required. The Sourcetrail project " - "will stay up to date with changes in the Code::Blocks project on every refresh.
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); - setFileEndings({ L".cbp" }); -} - -void QtProjectWizzardContentCodeblocksProjectPath::populate(QGridLayout* layout, int& row) -{ - QtProjectWizzardContentPath::populate(layout, row); - m_picker->setPickDirectory(false); - m_picker->setFileFilter("Code::Blocks Project (*.cbp)"); - connect(m_picker, &QtLocationPicker::locationPicked, this, &QtProjectWizzardContentCodeblocksProjectPath::pickedPath); - - QLabel* description = new QLabel( - "Sourcetrail will use all settings from the Code::Blocks project and stay up-to-date with changes on refresh.", this); - description->setObjectName("description"); - description->setWordWrap(true); - layout->addWidget(description, row, QtProjectWizzardWindow::BACK_COL); - row++; - - QLabel* title = createFormLabel("Source Files to Index"); - layout->addWidget(title, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); - layout->setRowStretch(row, 0); - - m_fileCountLabel = new QLabel(""); - m_fileCountLabel->setWordWrap(true); - layout->addWidget(m_fileCountLabel, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignTop); - row++; - - addFilesButton("show source files", layout, row); - row++; -} - -void QtProjectWizzardContentCodeblocksProjectPath::load() -{ - m_picker->setText(QString::fromStdWString(m_settings->getCodeblocksProjectPath().wstr())); - - m_filePaths.clear(); - - if (m_fileCountLabel) - { - m_fileCountLabel->setText("" + QString::number(getFilePaths().size()) + " source files were found in the Code::Blocks project."); - } -} - -void QtProjectWizzardContentCodeblocksProjectPath::save() -{ - m_settings->setCodeblocksProjectPath(FilePath(m_picker->getText().toStdWString())); -} - -std::vector QtProjectWizzardContentCodeblocksProjectPath::getFilePaths() const -{ - return m_filePaths.getValue(); -} - -QString QtProjectWizzardContentCodeblocksProjectPath::getFileNamesTitle() const -{ - return "Source Files"; -} - -QString QtProjectWizzardContentCodeblocksProjectPath::getFileNamesDescription() const -{ - return " source files will be indexed."; -} - -void QtProjectWizzardContentCodeblocksProjectPath::pickedPath() -{ - m_window->saveContent(); - - const FilePath projectPath = m_settings->getProjectDirectoryPath(); - - std::set indexedHeaderPaths; - for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCodeblocksProject(m_settings)) - { - if (projectPath.contains(path)) - { - indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); // the relative path is always shorter than the absolute path - } - } - m_settings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); - - m_window->loadContent(); -} - -std::shared_ptr QtProjectWizzardContentCodeblocksProjectPath::getSourceGroupSettings() -{ - return m_settings; -} - - -QtProjectWizzardContentSonargraphProjectPath::QtProjectWizzardContentSonargraphProjectPath( - std::shared_ptr settings, - std::shared_ptr settingsCxxSonargraph, - std::shared_ptr settingsWithSonargraphProjectPath, - QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPath(window) - , m_settings(settings) - , m_settingsCxxSonargraph(settingsCxxSonargraph) - , m_settingsWithSonargraphProjectPath(settingsWithSonargraphProjectPath) - , m_filePaths([&]() - { - std::set allSourceFilePaths; - if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) - { - allSourceFilePaths = SourceGroupCxxSonargraph(settings).getAllSourceFilePaths(); - } - else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) - { - allSourceFilePaths = SourceGroupJavaSonargraph(settings).getAllSourceFilePaths(); - } - - return utility::getAsRelativeIfShorter( - utility::toVector(allSourceFilePaths), - m_settings->getProjectDirectoryPath() - ); - } - ) -{ - setTitleString("Sonargraph Project (system.sonargraph)"); - setHelpString( - "Select the Sonargraph file for the project. Sourcetrail will index your project based on the settings " - "this file. It contains using all include paths and compiler flags required. The Sourcetrail project " - "will stay up to date with changes in the Sonargraph project on every refresh.
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); - setFileEndings({ L".sonargraph" }); -} - -void QtProjectWizzardContentSonargraphProjectPath::populate(QGridLayout* layout, int& row) -{ - QtProjectWizzardContentPath::populate(layout, row); - m_picker->setPickDirectory(false); - m_picker->setFileFilter("Sonargraph Project (system.sonargraph)"); - connect(m_picker, &QtLocationPicker::locationPicked, this, &QtProjectWizzardContentSonargraphProjectPath::pickedPath); - - QLabel* description = new QLabel( - "Sourcetrail will use all settings from the Sonargraph project and stay up-to-date with changes on refresh.", this); - description->setObjectName("description"); - description->setWordWrap(true); - layout->addWidget(description, row, QtProjectWizzardWindow::BACK_COL); - row++; - - QLabel* title = createFormLabel("Source Files to Index"); - layout->addWidget(title, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); - layout->setRowStretch(row, 0); - - m_fileCountLabel = new QLabel(""); - m_fileCountLabel->setWordWrap(true); - layout->addWidget(m_fileCountLabel, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignTop); - row++; - - addFilesButton("show source files", layout, row); - row++; -} - -void QtProjectWizzardContentSonargraphProjectPath::load() -{ - m_picker->setText(QString::fromStdWString(m_settingsWithSonargraphProjectPath->getSonargraphProjectPath().wstr())); - - m_filePaths.clear(); - - if (m_fileCountLabel) - { - m_fileCountLabel->setText("" + QString::number(getFilePaths().size()) + " source files were found in the Sonargraph project."); - } -} - -void QtProjectWizzardContentSonargraphProjectPath::save() -{ - m_settingsWithSonargraphProjectPath->setSonargraphProjectPath(FilePath(m_picker->getText().toStdWString())); -} - -bool QtProjectWizzardContentSonargraphProjectPath::check() -{ - if (!QtProjectWizzardContentPath::check()) - { - return false; - } - - if (std::shared_ptr sonargraphProject = Sonargraph::Project::load( - m_settingsWithSonargraphProjectPath->getSonargraphProjectPathExpandedAndAbsolute(), m_settings->getLanguage() - )) - { - if (sonargraphProject->getLoadedModuleCount() == 0) - { - - QMessageBox msgBox; - msgBox.setText(QString::fromStdString( - "The Sonargraph project file doesn't seem to contain any supported " + - languageTypeToString(m_settings->getLanguage()) + " modules. Please " + - "consider choosing another project file or removing this sourcegroup." - )); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - return msgBox.exec() == QMessageBox::Ok; - } - } - return true; -} - -std::vector QtProjectWizzardContentSonargraphProjectPath::getFilePaths() const -{ - return m_filePaths.getValue(); -} - -QString QtProjectWizzardContentSonargraphProjectPath::getFileNamesTitle() const -{ - return "Source Files"; -} - -QString QtProjectWizzardContentSonargraphProjectPath::getFileNamesDescription() const -{ - return " source files will be indexed."; -} - -void QtProjectWizzardContentSonargraphProjectPath::pickedPath() -{ - m_window->saveContent(); - - if (m_settingsCxxSonargraph) - { - const FilePath projectPath = m_settings->getProjectDirectoryPath(); - - std::set indexedHeaderPaths; - for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromSonargraphProject(m_settingsCxxSonargraph)) - { - if (projectPath.contains(path)) - { - indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); // the relative path is always shorter than the absolute path - } - } - m_settingsCxxSonargraph->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); - } - m_window->loadContent(); -} - -std::shared_ptr QtProjectWizzardContentSonargraphProjectPath::getSourceGroupSettings() -{ - return m_settings; -} - - -QtProjectWizzardContentPathSourceMaven::QtProjectWizzardContentPathSourceMaven( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPath(window) - , m_settings(settings) -{ - setTitleString("Maven Project File (pom.xml)"); - setHelpString( - "Enter the path to the main pom.xml file of your Maven project.
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); - setFileEndings({ L".xml" }); -} - -void QtProjectWizzardContentPathSourceMaven::populate(QGridLayout* layout, int& row) -{ - QtProjectWizzardContentPath::populate(layout, row); - m_picker->setPickDirectory(false); - m_picker->setFileFilter("POM File (pom.xml)"); - - QPushButton* filesButton = addFilesButton("show source files", nullptr, row); - m_shouldIndexTests = new QCheckBox("Should Index Tests"); - - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setContentsMargins(0, 0, 0, 0); - hlayout->addWidget(m_shouldIndexTests); - hlayout->addStretch(); - hlayout->addWidget(filesButton); - - layout->addLayout(hlayout, row, QtProjectWizzardWindow::BACK_COL); - row++; -} - -void QtProjectWizzardContentPathSourceMaven::load() -{ - m_picker->setText(QString::fromStdWString(m_settings->getMavenProjectFilePath().wstr())); - m_shouldIndexTests->setChecked(m_settings->getShouldIndexMavenTests()); -} - -void QtProjectWizzardContentPathSourceMaven::save() -{ - m_settings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdWString())); - m_settings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked()); -} - -std::vector QtProjectWizzardContentPathSourceMaven::getFilePaths() const -{ - { - const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); - const FilePath mavenProjectRoot = m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory(); - - if (!mavenProjectRoot.exists()) - { - LOG_INFO("Could not find any source file paths because Maven project path does not exist."); - return std::vector(); - } - - QtDialogView* dialogView = dynamic_cast( - Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); - - ScopedFunctor scopedFunctor([&dialogView]() { - dialogView->hideUnknownProgressDialog(); - }); - - dialogView->setParentWindow(m_window); - dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nGenerating Source Files"); - - const std::wstring errorMessage = utility::mavenGenerateSources(mavenPath, mavenProjectRoot); - if (!errorMessage.empty()) - { - MessageStatus(errorMessage, true, false).dispatch(); - Application::getInstance()->handleDialog(errorMessage); - return std::vector(); - } - } - - return utility::getAsRelativeIfShorter( - utility::toVector(SourceGroupJavaMaven(m_settings).getAllSourceFilePaths()), - m_settings->getProjectDirectoryPath() - ); -} - -std::shared_ptr QtProjectWizzardContentPathSourceMaven::getSourceGroupSettings() -{ - return m_settings; -} - - -QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDependenciesMaven( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPath(window) - , m_settings(settings) -{ - setTitleString("Intermediate Dependencies Directory"); - setHelpString( - "This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Maven project while it is indexed.
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); -} - -void QtProjectWizzardContentPathDependenciesMaven::load() -{ - m_picker->setText(QString::fromStdWString(m_settings->getMavenDependenciesDirectory().wstr())); -} - -void QtProjectWizzardContentPathDependenciesMaven::save() -{ - m_settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdWString())); -} - -std::shared_ptr QtProjectWizzardContentPathDependenciesMaven::getSourceGroupSettings() -{ - return m_settings; -} - - -QtProjectWizzardContentPathSourceGradle::QtProjectWizzardContentPathSourceGradle( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPath(window) - , m_settings(settings) -{ - setTitleString("Gradle Project File (build.gradle)"); - setHelpString( - "Enter the path to the main build.gradle file of your Gradle project.
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); - setFileEndings({ L".gradle" }); -} - -void QtProjectWizzardContentPathSourceGradle::populate(QGridLayout* layout, int& row) -{ - QtProjectWizzardContentPath::populate(layout, row); - m_picker->setPickDirectory(false); - m_picker->setFileFilter("Gradle Build File (build.gradle)"); - - QPushButton* filesButton = addFilesButton("show source files", nullptr, row); - m_shouldIndexTests = new QCheckBox("Should Index Tests"); - - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setContentsMargins(0, 0, 0, 0); - hlayout->addWidget(m_shouldIndexTests); - hlayout->addStretch(); - hlayout->addWidget(filesButton); - - layout->addLayout(hlayout, row, QtProjectWizzardWindow::BACK_COL); - row++; -} - -void QtProjectWizzardContentPathSourceGradle::load() -{ - m_picker->setText(QString::fromStdWString(m_settings->getGradleProjectFilePath().wstr())); - m_shouldIndexTests->setChecked(m_settings->getShouldIndexGradleTests()); -} - -void QtProjectWizzardContentPathSourceGradle::save() -{ - m_settings->setGradleProjectFilePath(FilePath(m_picker->getText().toStdWString())); - m_settings->setShouldIndexGradleTests(m_shouldIndexTests->isChecked()); -} - -std::vector QtProjectWizzardContentPathSourceGradle::getFilePaths() const -{ - QtDialogView* dialogView = dynamic_cast( - Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); - dialogView->setParentWindow(m_window); - - return utility::getAsRelativeIfShorter( - utility::toVector(SourceGroupJavaGradle(m_settings).getAllSourceFilePaths()), - m_settings->getProjectDirectoryPath() - ); -} - -std::shared_ptr QtProjectWizzardContentPathSourceGradle::getSourceGroupSettings() -{ - return m_settings; -} - - -QtProjectWizzardContentPathDependenciesGradle::QtProjectWizzardContentPathDependenciesGradle( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPath(window) - , m_settings(settings) -{ - setTitleString("Intermediate Dependencies Directory"); - setHelpString( - "This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Gradle project while it is indexed.
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); -} - -void QtProjectWizzardContentPathDependenciesGradle::load() -{ - m_picker->setText(QString::fromStdWString(m_settings->getGradleDependenciesDirectory().wstr())); -} - -void QtProjectWizzardContentPathDependenciesGradle::save() -{ - m_settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdWString())); -} - -std::shared_ptr QtProjectWizzardContentPathDependenciesGradle::getSourceGroupSettings() -{ - return m_settings; -} - - -QtProjectWizzardContentPathPythonEnvironment::QtProjectWizzardContentPathPythonEnvironment( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPath(window) - , m_settings(settings) -{ - setTitleString("Python Environment"); - setHelpString( - "Here you can specify the path to the directory or to the executable of the (virtual) Python environment that should be used to resolve " - "dependencies within the indexed source code.
" - "
" - "If you would run:
" - "
" - "$ cd C:\\dev\\python\\envs
" - "$ virtualenv py37
" - "
" - "you would set it to \"C:\\dev\\python\\envs\\py37\" or \"C:\\dev\\python\\envs\\py37\\Scripts\\python.exe\".
" - "Leave blank to use the default Python environment. You can make use of environment variables with ${ENV_VAR}." - ); - setPlaceholderString("Use Default"); - setAllowEmpty(true); -} - -void QtProjectWizzardContentPathPythonEnvironment::populate(QGridLayout* layout, int& row) -{ - QtProjectWizzardContentPath::populate(layout, row); - connect( - m_picker, &QtLocationPicker::textChanged, - this, &QtProjectWizzardContentPathPythonEnvironment::onTextChanged - ); - - m_resultLabel = new QLabel(); - m_resultLabel->setWordWrap(true); - layout->addWidget(m_resultLabel, row, QtProjectWizzardWindow::BACK_COL); - row++; -} - -void QtProjectWizzardContentPathPythonEnvironment::load() -{ - m_picker->setText(QString::fromStdWString(m_settings->getEnvironmentPath().wstr())); -} - -void QtProjectWizzardContentPathPythonEnvironment::save() -{ - m_settings->setEnvironmentPath(FilePath(m_picker->getText().toStdWString())); -} - -void QtProjectWizzardContentPathPythonEnvironment::onTextChanged(const QString& text) -{ - if (text.isEmpty()) - { - m_resultLabel->clear(); - } - else - { - m_resultLabel->setText("Checking validity of Python environment..."); - std::thread([=]() { - std::pair out = utility::executeProcess( - "\"" + ResourcePaths::getPythonPath().str() + "SourcetrailPythonIndexer\" check-environment " + - "--environment-path \"" + m_settings->makePathExpandedAndAbsolute(FilePath(text.toStdWString())).str() + "\"", - FilePath(), - 5000 - ); - m_onQtThread( - [=]() - { - if (out.first == 0) - { - m_resultLabel->setText(QString::fromStdString(out.second)); - } - else - { - m_resultLabel->setText("An error occurred while checking environment path. Unable to check validity."); - } - } - ); - }).detach(); - } -} - -std::shared_ptr QtProjectWizzardContentPathPythonEnvironment::getSourceGroupSettings() -{ - return m_settings; -} diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h deleted file mode 100644 index 4948e3e7..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h +++ /dev/null @@ -1,262 +0,0 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_PATH_H -#define QT_PROJECT_WIZZARD_CONTENT_PATH_H - -#include - -#include "QtProjectWizzardContent.h" -#include "QtThreadedFunctor.h" -#include "SingleValueCache.h" - -class QCheckBox; -class QComboBox; -class QPushButton; - -class QtLocationPicker; -class SourceGroupSettings; -class SourceGroupSettingsCxxCdb; -class SourceGroupSettingsCxxCodeblocks; -class SourceGroupSettingsCxxSonargraph; -class SourceGroupSettingsJavaGradle; -class SourceGroupSettingsPythonEmpty; -class SourceGroupSettingsJavaMaven; -class SourceGroupSettingsWithSonargraphProjectPath; - -class QtProjectWizzardContentPath - : public QtProjectWizzardContent -{ - Q_OBJECT - -public: - QtProjectWizzardContentPath(QtProjectWizzardWindow* window); - - // QtSettingsWindow implementation - virtual void populate(QGridLayout* layout, int& row) override; - - virtual bool check() override; - -protected: - void setTitleString(const QString& title); - void setHelpString(const QString& help); - void setPlaceholderString(const QString& placeholder); - - void setFileEndings(const std::set& fileEndings); - void setAllowEmpty(bool allowEmpty); - - QtLocationPicker* m_picker; - - bool m_makePathRelativeToProjectFileLocation; - -private: - virtual std::shared_ptr getSourceGroupSettings() = 0; - - QString m_titleString; - QString m_helpString; - QString m_placeholderString; - std::set m_fileEndings; - bool m_allowEmpty; -}; - - -class QtProjectWizzardContentPathCDB - : public QtProjectWizzardContentPath -{ - Q_OBJECT - -public: - QtProjectWizzardContentPathCDB(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - void populate(QGridLayout* layout, int& row) override; - - void load() override; - void save() override; - - std::vector getFilePaths() const override; - QString getFileNamesTitle() const override; - QString getFileNamesDescription() const override; - -private slots: - void pickedPath(); - -private: - std::shared_ptr getSourceGroupSettings() override; - - std::shared_ptr m_settings; - QLabel* m_fileCountLabel; - mutable SingleValueCache> m_filePaths; -}; - - -class QtProjectWizzardContentCodeblocksProjectPath - : public QtProjectWizzardContentPath -{ - Q_OBJECT - -public: - QtProjectWizzardContentCodeblocksProjectPath( - std::shared_ptr settings, - QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - void populate(QGridLayout* layout, int& row) override; - - void load() override; - void save() override; - - std::vector getFilePaths() const override; - QString getFileNamesTitle() const override; - QString getFileNamesDescription() const override; - -private slots: - void pickedPath(); - -private: - std::shared_ptr getSourceGroupSettings() override; - - std::shared_ptr m_settings; - QLabel* m_fileCountLabel; - mutable SingleValueCache> m_filePaths; -}; - - -class QtProjectWizzardContentSonargraphProjectPath - : public QtProjectWizzardContentPath -{ - Q_OBJECT - -public: - QtProjectWizzardContentSonargraphProjectPath( - std::shared_ptr settings, - std::shared_ptr settingsCxxSonargraph, - std::shared_ptr settingsWithSonargraphProjectPath, - QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - void populate(QGridLayout* layout, int& row) override; - - void load() override; - void save() override; - bool check() override; - - std::vector getFilePaths() const override; - QString getFileNamesTitle() const override; - QString getFileNamesDescription() const override; - -private slots: - void pickedPath(); - -private: - std::shared_ptr getSourceGroupSettings() override; - - std::shared_ptr m_settings; - std::shared_ptr m_settingsCxxSonargraph; - std::shared_ptr m_settingsWithSonargraphProjectPath; - QLabel* m_fileCountLabel; - mutable SingleValueCache> m_filePaths; -}; - - -class QtProjectWizzardContentPathSourceMaven - : public QtProjectWizzardContentPath -{ - Q_OBJECT -public: - QtProjectWizzardContentPathSourceMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - void populate(QGridLayout* layout, int& row) override; - - void load() override; - void save() override; - - std::vector getFilePaths() const override; - -private: - std::shared_ptr getSourceGroupSettings() override; - - std::shared_ptr m_settings; - QCheckBox* m_shouldIndexTests; -}; - - -class QtProjectWizzardContentPathDependenciesMaven - : public QtProjectWizzardContentPath -{ - Q_OBJECT -public: - QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - void load() override; - void save() override; - -private: - std::shared_ptr getSourceGroupSettings() override; - - std::shared_ptr m_settings; -}; - - -class QtProjectWizzardContentPathSourceGradle - : public QtProjectWizzardContentPath -{ - Q_OBJECT -public: - QtProjectWizzardContentPathSourceGradle(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - void populate(QGridLayout* layout, int& row) override; - - void load() override; - void save() override; - - std::vector getFilePaths() const override; - -private: - std::shared_ptr getSourceGroupSettings() override; - - std::shared_ptr m_settings; - QCheckBox* m_shouldIndexTests; -}; - - -class QtProjectWizzardContentPathDependenciesGradle - : public QtProjectWizzardContentPath -{ - Q_OBJECT -public: - QtProjectWizzardContentPathDependenciesGradle(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - void load() override; - void save() override; - -private: - std::shared_ptr getSourceGroupSettings() override; - - std::shared_ptr m_settings; -}; - - -class QtProjectWizzardContentPathPythonEnvironment - : public QtProjectWizzardContentPath -{ - Q_OBJECT -public: - QtProjectWizzardContentPathPythonEnvironment(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - void populate(QGridLayout* layout, int& row) override; - void load() override; - void save() override; - -private: - void onTextChanged(const QString& text); - std::shared_ptr getSourceGroupSettings() override; - - std::shared_ptr m_settings; - QtThreadedLambdaFunctor m_onQtThread; - QLabel* m_resultLabel; -}; - -#endif // QT_PROJECT_WIZZARD_CONTENT_PATH_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp deleted file mode 100644 index b05adcb0..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ /dev/null @@ -1,1231 +0,0 @@ -#include "QtProjectWizzardContentPaths.h" - -#include -#include -#include -#include -#include - -#include "DialogView.h" -#include "IndexerCommandCxx.h" -#include "QtDialogView.h" -#include "QtPathListDialog.h" -#include "QtSelectPathsDialog.h" -#include "SourceGroupCustomCommand.h" -#include "SourceGroupCxxEmpty.h" -#include "SourceGroupJavaEmpty.h" -#include "SourceGroupPythonEmpty.h" -#include "ApplicationSettings.h" -#include "ResourcePaths.h" -#include "SourceGroupSettingsCustomCommand.h" -#include "SourceGroupSettingsCxx.h" -#include "SourceGroupSettingsCxxCdb.h" -#include "SourceGroupSettingsCxxCodeblocks.h" -#include "SourceGroupSettingsCxxSonargraph.h" -#include "SourceGroupSettingsJavaEmpty.h" -#include "SourceGroupSettingsPythonEmpty.h" -#include "SourceGroupSettingsWithClasspath.h" -#include "SourceGroupSettingsWithIndexedHeaderPaths.h" -#include "SourceGroupSettingsWithExcludeFilters.h" -#include "SourceGroupSettingsWithSourceExtensions.h" -#include "SourceGroupSettingsWithSourcePaths.h" -#include "CodeblocksProject.h" -#include "FileManager.h" -#include "SonargraphProject.h" -#include "CompilationDatabase.h" -#include "IncludeDirective.h" -#include "IncludeProcessing.h" -#include "ScopedFunctor.h" -#include "utility.h" -#include "utilityApp.h" -#include "utilityFile.h" -#include "utilityPathDetection.h" -#include "utilityString.h" -#include "Application.h" - -QtProjectWizzardContentPaths::QtProjectWizzardContentPaths( - std::shared_ptr settings, - QtProjectWizzardWindow* window, - QtPathListBox::SelectionPolicyType selectionPolicy, - bool checkMissingPaths -) - : QtProjectWizzardContent(window) - , m_settings(settings) - , m_makePathsRelativeToProjectFileLocation(true) - , m_selectionPolicy(selectionPolicy) - , m_checkMissingPaths(checkMissingPaths) -{ -} - -void QtProjectWizzardContentPaths::populate(QGridLayout* layout, int& row) -{ - QLabel* label = createFormLabel(m_titleString); - layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); - - if (m_helpString.size() > 0) - { - addHelpButton(m_titleString, m_helpString, layout, row); - } - - m_list = new QtPathListBox(this, m_titleString, m_selectionPolicy); - - if (m_makePathsRelativeToProjectFileLocation && m_settings) - { - m_list->setRelativeRootDirectory(m_settings->getProjectDirectoryPath()); - } - - layout->addWidget(m_list, row, QtProjectWizzardWindow::BACK_COL); - row++; - - if (m_showFilesString.size() > 0) - { - addFilesButton(m_showFilesString, layout, row); - row++; - } - - if (m_pathDetector) - { - addDetection(layout, row); - row++; - } -} - -bool QtProjectWizzardContentPaths::check() -{ - if (m_checkMissingPaths) - { - QString missingPaths; - std::vector existingPaths; - - for (const FilePath& path : m_list->getPathsAsDisplayed()) - { - std::vector expandedPaths(1, path); - if (m_settings) - { - expandedPaths = m_settings->makePathsExpandedAndAbsolute(expandedPaths); - } - - size_t existingCount = 0; - for (const FilePath& expandedPath : expandedPaths) - { - if (!expandedPath.exists()) - { - missingPaths.append(QString::fromStdWString(expandedPath.wstr() + L"\n")); - } - else - { - existingCount++; - } - } - - if (!expandedPaths.empty() && expandedPaths.size() == existingCount) - { - existingPaths.push_back(path); - } - } - - if (!missingPaths.isEmpty()) - { - QMessageBox msgBox; - msgBox.setText( - QString( - "Some provided paths do not exist at \"%1\". Do you want to remove them before continuing?" - ).arg(m_titleString) - ); - msgBox.setDetailedText(missingPaths); - QPushButton* removeButton = msgBox.addButton("Remove", QMessageBox::YesRole); - QPushButton* keepButton = msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole); - QPushButton* cancelButton = msgBox.addButton("Cancel", QMessageBox::ButtonRole::RejectRole); - - msgBox.exec(); - - if (msgBox.clickedButton() == removeButton) - { - m_list->setPaths(existingPaths); - save(); - } - else if (msgBox.clickedButton() == keepButton) - { - return true; - } - else if (msgBox.clickedButton() == cancelButton) - { - return false; - } - } - } - return true; -} - -void QtProjectWizzardContentPaths::setTitleString(const QString& title) -{ - m_titleString = title; -} - -void QtProjectWizzardContentPaths::setHelpString(const QString& help) -{ - m_helpString = help; -} - -void QtProjectWizzardContentPaths::addDetection(QGridLayout* layout, int row) -{ - std::vector detectorNames = m_pathDetector->getWorkingDetectorNames(); - if (!detectorNames.size()) - { - return; - } - - QLabel* label = new QLabel("Auto detection from:"); - - m_detectorBox = new QComboBox(); - - for (const std::string& detectorName: detectorNames) - { - m_detectorBox->addItem(detectorName.c_str()); - } - - QPushButton* button = new QPushButton("detect"); - button->setObjectName("windowButton"); - connect(button, &QPushButton::clicked, this, &QtProjectWizzardContentPaths::detectionClicked); - - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setContentsMargins(0, 0, 0, 0); - hlayout->addWidget(label); - hlayout->addWidget(m_detectorBox); - hlayout->addWidget(button); - - QWidget* detectionWidget = new QWidget(); - detectionWidget->setLayout(hlayout); - - layout->addWidget(detectionWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); -} - -void QtProjectWizzardContentPaths::detectionClicked() -{ - std::vector paths = m_pathDetector->getPaths(m_detectorBox->currentText().toStdString()); - std::vector oldPaths = m_list->getPathsAsDisplayed(); - - paths = utility::unique(utility::concat(oldPaths, paths)); - - detectedPaths(paths); -} - -void QtProjectWizzardContentPaths::detectedPaths(const std::vector& paths) -{ - m_list->setPaths(paths); -} - - -QtProjectWizzardContentPathsSource::QtProjectWizzardContentPathsSource( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_FILES_AND_DIRECTORIES) -{ - m_showFilesString = "show files"; - - setTitleString("Files & Directories to Index"); - setHelpString( - "These paths define the files and directories that will be indexed by Sourcetrail. Provide a directory to recursively " - "add all contained source and header files.
" - "
" - "If your project's source code resides in one location, but generated source files are kept at a different location, " - "you will also need to add that directory.
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); -} - -void QtProjectWizzardContentPathsSource::load() -{ - if (std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type - { - m_list->setPaths(pathSettings->getSourcePaths()); - } -} - -void QtProjectWizzardContentPathsSource::save() -{ - if (std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type - { - pathSettings->setSourcePaths(m_list->getPathsAsDisplayed()); - } -} - -std::vector QtProjectWizzardContentPathsSource::getFilePaths() const -{ - std::set allSourceFilePaths; - if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) - { - allSourceFilePaths = SourceGroupCxxEmpty(settings).getAllSourceFilePaths(); - } - else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) - { - allSourceFilePaths = SourceGroupJavaEmpty(settings).getAllSourceFilePaths(); - } - else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) - { - allSourceFilePaths = SourceGroupPythonEmpty(settings).getAllSourceFilePaths(); - } - else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) - { - allSourceFilePaths = SourceGroupCustomCommand(settings).getAllSourceFilePaths(); - } - - return utility::getAsRelativeIfShorter( - utility::toVector(allSourceFilePaths), - m_settings->getProjectDirectoryPath() - ); -} - -QString QtProjectWizzardContentPathsSource::getFileNamesTitle() const -{ - return "Indexed Files"; -} - -QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const -{ - return " files will be indexed."; -} - -std::vector QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromSonargraphProject( - std::shared_ptr settings) -{ - std::set indexedHeaderPaths; - { - const FilePath sonargraphProjectPath = settings->getSonargraphProjectPathExpandedAndAbsolute(); - if (!sonargraphProjectPath.empty() && sonargraphProjectPath.exists()) - { - if (std::shared_ptr sonargraphProject = Sonargraph::Project::load( - sonargraphProjectPath, settings->getLanguage() - )) - { - for (const FilePath& path : sonargraphProject->getAllSourceFilePathsCanonical()) - { - indexedHeaderPaths.insert(path.getCanonical().getParentDirectory()); - } - utility::append(indexedHeaderPaths, sonargraphProject->getAllCxxHeaderSearchPathsCanonical()); - } - } - else - { - LOG_WARNING("Unable to fetch indexed header paths. The provided Sonargraph project path does not exist."); - } - } - - std::vector topLevelPaths; - for (const FilePath& path : utility::getTopLevelPaths(indexedHeaderPaths)) - { - if (path.exists()) - { - topLevelPaths.push_back(path); - } - } - - return topLevelPaths; -} - -std::vector QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCodeblocksProject( - std::shared_ptr settings) -{ - const FilePath projectPath = settings->getProjectDirectoryPath(); - std::set indexedHeaderPaths; - { - const FilePath codeblocksProjectPath = settings->getCodeblocksProjectPathExpandedAndAbsolute(); - if (!codeblocksProjectPath.empty() && codeblocksProjectPath.exists()) - { - if (std::shared_ptr codeblocksProject = Codeblocks::Project::load(codeblocksProjectPath)) - { - OrderedCache canonicalDirectoryPathCache([](const FilePath& path) { - return path.getCanonical(); - }); - - for (const FilePath& path : codeblocksProject->getAllSourceFilePathsCanonical(settings->getSourceExtensions())) - { - indexedHeaderPaths.insert(canonicalDirectoryPathCache.getValue(path.getParentDirectory())); - } - utility::append(indexedHeaderPaths, codeblocksProject->getAllCxxHeaderSearchPathsCanonical()); - } - } - else - { - LOG_WARNING("Unable to fetch indexed header paths. The provided Sonargraph project path does not exist."); - } - } - - std::vector topLevelPaths; - for (const FilePath& path : utility::getTopLevelPaths(indexedHeaderPaths)) - { - if (path.exists()) - { - topLevelPaths.push_back(path); - } - } - - return topLevelPaths; -} - -std::vector QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCDB( - std::shared_ptr settings) -{ - std::set indexedHeaderPaths; - { - const FilePath cdbPath = settings->getCompilationDatabasePathExpandedAndAbsolute(); - if (!cdbPath.empty() && cdbPath.exists()) - { - for (const FilePath& path : IndexerCommandCxx::getSourceFilesFromCDB(cdbPath)) - { - indexedHeaderPaths.insert(path.getCanonical().getParentDirectory()); - } - for (const FilePath& path : utility::CompilationDatabase(cdbPath).getAllHeaderPaths()) - { - if (path.exists()) - { - indexedHeaderPaths.insert(path.getCanonical()); - } - } - } - else - { - LOG_WARNING("Unable to fetch indexed header paths. The provided Compilation Database path does not exist."); - } - } - - std::vector topLevelPaths; - for (const FilePath& path : utility::getTopLevelPaths(indexedHeaderPaths)) - { - if (path.exists()) - { - topLevelPaths.push_back(path); - } - } - - return topLevelPaths; -} - -QtProjectWizzardContentIndexedHeaderPaths::QtProjectWizzardContentIndexedHeaderPaths( - std::shared_ptr settings, QtProjectWizzardWindow* window, std::string projectKindName -) - : QtProjectWizzardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_FILES_AND_DIRECTORIES) - , m_projectKindName(projectKindName) -{ - m_showFilesString = ""; - - setTitleString("Header Files & Directories to Index"); - setHelpString(QString::fromStdString( - "The provided " + m_projectKindName + " already specifies which source files are part of your project. But Sourcetrail still " - "needs to know which header files to index as part of your project and which to skip. Choosing to skip indexing " - "your system headers or external frameworks will significantly improve the overall indexing performance.
" - "
" - "Use this list to define which header files should be indexed by Sourcetrail. Provide a directory to recursively " - "add all contained files.
" - "
" - "You can make use of environment variables with ${ENV_VAR}.
" - "
" - "Hint: Just enter the root path of your project if you want Sourcetrail to index all contained headers it " - "encounters.
" - )); -} - -void QtProjectWizzardContentIndexedHeaderPaths::populate(QGridLayout* layout, int& row) -{ - QtProjectWizzardContentPaths::populate(layout, row); - - QPushButton* button = new QPushButton(QString::fromStdString("Select from " + m_projectKindName)); - button->setObjectName("windowButton"); - connect(button, &QPushButton::clicked, this, &QtProjectWizzardContentIndexedHeaderPaths::buttonClicked); - - layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop); - row++; -} - -void QtProjectWizzardContentIndexedHeaderPaths::load() -{ - if (std::shared_ptr cdbSettings = - std::dynamic_pointer_cast(m_settings)) - { - m_list->setPaths(cdbSettings->getIndexedHeaderPaths()); - } -} - -void QtProjectWizzardContentIndexedHeaderPaths::save() -{ - if (std::shared_ptr cdbSettings = - std::dynamic_pointer_cast(m_settings)) - { - cdbSettings->setIndexedHeaderPaths(m_list->getPathsAsDisplayed()); - } -} - -bool QtProjectWizzardContentIndexedHeaderPaths::check() -{ - if (m_list->getPathsAsDisplayed().empty()) - { - QMessageBox msgBox; - msgBox.setText("You didn't specify any Header Files & Directories to Index."); - msgBox.setInformativeText(QString::fromStdString( - "Sourcetrail will only index the source files listed in the " + m_projectKindName + - " file and none of the included header files." - )); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - return msgBox.exec() == QMessageBox::Ok; - } - else - { - return QtProjectWizzardContentPaths::check(); - } -} - -void QtProjectWizzardContentIndexedHeaderPaths::buttonClicked() -{ - save(); - - if (!m_filesDialog) - { - if (std::shared_ptr sonargraphSettings = std::dynamic_pointer_cast(m_settings)) - { - const FilePath sonargraphProjectPath = sonargraphSettings->getSonargraphProjectPathExpandedAndAbsolute(); - if (!sonargraphProjectPath.exists()) - { - QMessageBox msgBox; - msgBox.setText("The provided Sonargraph project path does not exist."); - msgBox.setDetailedText(QString::fromStdWString(sonargraphProjectPath.wstr())); - msgBox.exec(); - return; - } - - m_filesDialog = std::make_shared( - "Select from Include Paths", - "The list contains all Include Paths found in the Sonargraph project. Red paths do not exist. Select the " - "paths containing the header files you want to index with Sourcetrail."); - m_filesDialog->setup(); - - connect(m_filesDialog.get(), &QtSelectPathsDialog::finished, this, &QtProjectWizzardContentIndexedHeaderPaths::savedFilesDialog); - connect(m_filesDialog.get(), &QtSelectPathsDialog::canceled, this, &QtProjectWizzardContentIndexedHeaderPaths::closedFilesDialog); - - const FilePath projectPath = sonargraphSettings->getProjectDirectoryPath(); - - dynamic_cast(m_filesDialog.get())->setPathsList( - utility::convert( - getIndexedPathsDerivedFromSonargraphProject(sonargraphSettings), - [&](const FilePath& path) { return utility::getAsRelativeIfShorter(path, projectPath); } - ), - sonargraphSettings->getIndexedHeaderPaths(), - m_settings->getProjectDirectoryPath() - ); - } - else if (std::shared_ptr codeblocksSettings = std::dynamic_pointer_cast(m_settings)) - { - const FilePath codeblocksProjectPath = codeblocksSettings->getCodeblocksProjectPathExpandedAndAbsolute(); - if (!codeblocksProjectPath.exists()) - { - QMessageBox msgBox; - msgBox.setText("The provided Code::Blocks project path does not exist."); - msgBox.setDetailedText(QString::fromStdWString(codeblocksProjectPath.wstr())); - msgBox.exec(); - return; - } - - m_filesDialog = std::make_shared( - "Select from Include Paths", - "The list contains all Include Paths found in the Code::Blocks project. Red paths do not exist. Select the " - "paths containing the header files you want to index with Sourcetrail."); - m_filesDialog->setup(); - - connect(m_filesDialog.get(), &QtSelectPathsDialog::finished, this, &QtProjectWizzardContentIndexedHeaderPaths::savedFilesDialog); - connect(m_filesDialog.get(), &QtSelectPathsDialog::canceled, this, &QtProjectWizzardContentIndexedHeaderPaths::closedFilesDialog); - - const FilePath projectPath = codeblocksSettings->getProjectDirectoryPath(); - - dynamic_cast(m_filesDialog.get())->setPathsList( - utility::convert( - getIndexedPathsDerivedFromCodeblocksProject(codeblocksSettings), - [&](const FilePath& path) { return utility::getAsRelativeIfShorter(path, projectPath); } - ), - codeblocksSettings->getIndexedHeaderPaths(), - m_settings->getProjectDirectoryPath() - ); - } - else if (std::shared_ptr cdbSettings = std::dynamic_pointer_cast(m_settings)) - { - const FilePath cdbPath = cdbSettings->getCompilationDatabasePathExpandedAndAbsolute(); - if (!cdbPath.exists()) - { - QMessageBox msgBox; - msgBox.setText("The provided Compilation Database path does not exist."); - msgBox.setDetailedText(QString::fromStdWString(cdbPath.wstr())); - msgBox.exec(); - return; - } - - m_filesDialog = std::make_shared( - "Select from Include Paths", - "The list contains all Include Paths found in the Compilation Database. Red paths do not exist. Select the " - "paths containing the header files you want to index with Sourcetrail."); - m_filesDialog->setup(); - - connect(m_filesDialog.get(), &QtSelectPathsDialog::finished, this, &QtProjectWizzardContentIndexedHeaderPaths::savedFilesDialog); - connect(m_filesDialog.get(), &QtSelectPathsDialog::canceled, this, &QtProjectWizzardContentIndexedHeaderPaths::closedFilesDialog); - - const FilePath projectPath = cdbSettings->getProjectDirectoryPath(); - - dynamic_cast(m_filesDialog.get())->setPathsList( - utility::convert( - getIndexedPathsDerivedFromCDB(cdbSettings), - [&](const FilePath& path) { return utility::getAsRelativeIfShorter(path, projectPath); } - ), - cdbSettings->getIndexedHeaderPaths(), - m_settings->getProjectDirectoryPath() - ); - } - } - - if (m_filesDialog) - { - m_filesDialog->showWindow(); - m_filesDialog->raise(); - } -} - -void QtProjectWizzardContentIndexedHeaderPaths::savedFilesDialog() -{ - m_list->setPaths(dynamic_cast(m_filesDialog.get())->getPathsList()); - closedFilesDialog(); -} - - -QtProjectWizzardContentPathsExclude::QtProjectWizzardContentPathsExclude( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_FILES_AND_DIRECTORIES, false) -{ - setTitleString("Excluded Files & Directories"); - setHelpString( - "

These paths define the files and directories that will be left out from indexing.

" - "

Hints:" - "

    " - "
  • You can use the wildcard \"*\" which represents characters except \"\\\" or \"/\" (e.g. \"src/*/test.h\" matches \"src/app/test.h\" but does not match \"src/app/widget/test.h\" or \"src/test.h\")
  • " - "
  • You can use the wildcard \"**\" which represents arbitrary characters (e.g. \"src**test.h\" matches \"src/app/test.h\" as well as \"src/app/widget/test.h\" or \"src/test.h\")
  • " - "
  • You can make use of environment variables with ${ENV_VAR}
  • " - "

" - ); -} - -void QtProjectWizzardContentPathsExclude::load() -{ - if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type - { - m_list->setPaths(utility::convert(settings->getExcludeFilterStrings(), [](const std::wstring& s) { return FilePath(s); })); - } -} - -void QtProjectWizzardContentPathsExclude::save() -{ - if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type - { - settings->setExcludeFilterStrings(utility::toWStrings(m_list->getPathsAsDisplayed())); - } -} - - -QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSearch( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional -) - : QtProjectWizzardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY) - , m_showDetectedIncludesResultFunctor(std::bind( - &QtProjectWizzardContentPathsHeaderSearch::showDetectedIncludesResult, this, std::placeholders::_1)) - , m_showValidationResultFunctor(std::bind( - &QtProjectWizzardContentPathsHeaderSearch::showValidationResult, this, std::placeholders::_1)) - , m_indicateAsAdditional(indicateAsAdditional) -{ - setTitleString(m_indicateAsAdditional ? "Additional Include Paths" : "Include Paths"); - setHelpString( - ( - (m_indicateAsAdditional ? "Note: Use the Additional Include Paths to add paths that are missing in the " - "referenced project file.

" : "" - ) + std::string( - "Include Paths are used for resolving #include directives in the indexed source and header files. These paths are " - "usually passed to the compiler with the '-I' or '-iquote' flags.
" - "
" - "Add all paths #include directives throughout your project are relative to. If all #include directives are " - "specified relative to the project's root directory, please add that root directory here.
" - "
" - "If your project also includes files from external libraries (e.g. boost), please add these directories as well " - "(e.g. add 'path/to/boost_home/include').
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ) - ).c_str() - ); -} - -void QtProjectWizzardContentPathsHeaderSearch::populate(QGridLayout* layout, int& row) -{ - QtProjectWizzardContentPaths::populate(layout, row); - - if (!m_indicateAsAdditional) - { - { - QPushButton* detectionButton = new QPushButton("auto-detect"); - detectionButton->setObjectName("windowButton"); - connect(detectionButton, &QPushButton::clicked, this, &QtProjectWizzardContentPathsHeaderSearch::detectIncludesButtonClicked); - layout->addWidget(detectionButton, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop); - } - { - QPushButton* validateionButton = new QPushButton("validate include directives"); - validateionButton->setObjectName("windowButton"); - connect(validateionButton, &QPushButton::clicked, this, &QtProjectWizzardContentPathsHeaderSearch::validateIncludesButtonClicked); - layout->addWidget(validateionButton, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop); - } - row++; - } -} - -void QtProjectWizzardContentPathsHeaderSearch::load() -{ - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); - if (cxxSettings) - { - m_list->setPaths(cxxSettings->getHeaderSearchPaths()); - } -} - -void QtProjectWizzardContentPathsHeaderSearch::save() -{ - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); - if (cxxSettings) - { - cxxSettings->setHeaderSearchPaths(m_list->getPathsAsDisplayed()); - } -} - -bool QtProjectWizzardContentPathsHeaderSearch::isScrollAble() const -{ - return true; -} - -void QtProjectWizzardContentPathsHeaderSearch::detectIncludesButtonClicked() -{ - m_window->saveContent(); - - m_pathsDialog = std::make_shared( - "Detect Include Paths", - "

Automatically search for header files in the paths provided below to find missing include paths for " - "unresolved include directives in your source code.

" - "

The \"Files & Directories to Index\" will be searched by default, but you can add further paths, such " - "as directories of third-party libraries, if required.

", - QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY - ); - - m_pathsDialog->setup(); - m_pathsDialog->updateNextButton("Start"); - m_pathsDialog->setCloseVisible(true); - - m_pathsDialog->setRelativeRootDirectory(m_settings->getProjectDirectoryPath()); - if (std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings)) // FIXME: pass msettings as required type - { - m_pathsDialog->setPaths(pathSettings->getSourcePaths(), true); - } - m_pathsDialog->showWindow(); - - connect(m_pathsDialog.get(), &QtPathListDialog::finished, this, &QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootPathsDialog); - connect(m_pathsDialog.get(), &QtPathListDialog::canceled, this, &QtProjectWizzardContentPathsHeaderSearch::closedPathsDialog); -} - -void QtProjectWizzardContentPathsHeaderSearch::validateIncludesButtonClicked() -{ - // TODO: regard Force Includes here, too! - m_window->saveContent(); - - std::thread([&]() - { - std::shared_ptr extensionSettings = std::dynamic_pointer_cast(m_settings); - std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings); - std::shared_ptr excludeFilterSettings = std::dynamic_pointer_cast(m_settings); - - if (extensionSettings && pathSettings && excludeFilterSettings) // FIXME: pass msettings as required type - { - std::vector unresolvedIncludes; - { - QtDialogView* dialogView = dynamic_cast( - Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); - - std::set sourceFilePaths; - std::vector indexedFilePaths; - std::vector headerSearchPaths; - - { - dialogView->setParentWindow(m_window); - dialogView->showUnknownProgressDialog(L"Processing", L"Gathering Source Files"); - ScopedFunctor dialogHider([&dialogView](){ - dialogView->hideUnknownProgressDialog(); - }); - - FileManager fileManager; - fileManager.update( - pathSettings->getSourcePathsExpandedAndAbsolute(), - excludeFilterSettings->getExcludeFiltersExpandedAndAbsolute(), - extensionSettings->getSourceExtensions() - ); - sourceFilePaths = fileManager.getAllSourceFilePaths(); - - indexedFilePaths = pathSettings->getSourcePathsExpandedAndAbsolute(); - - headerSearchPaths = ApplicationSettings::getInstance()->getHeaderSearchPathsExpanded(); - if (std::shared_ptr cxxSettings = - std::dynamic_pointer_cast(m_settings)) - { - utility::append(headerSearchPaths, cxxSettings->getHeaderSearchPathsExpandedAndAbsolute()); - } - } - { - dialogView->setParentWindow(m_window); - ScopedFunctor dialogHider([&dialogView](){ - dialogView->hideProgressDialog(); - }); - - unresolvedIncludes = IncludeProcessing::getUnresolvedIncludeDirectives( - sourceFilePaths, - utility::toSet(indexedFilePaths), - utility::toSet(headerSearchPaths), - log2(sourceFilePaths.size()), - [&](const float progress) - { - dialogView->showProgressDialog( - L"Processing", std::to_wstring(int(progress * sourceFilePaths.size())) + L" Files", - int(progress * 100.0f) - ); - } - ); - } - } - m_showValidationResultFunctor(unresolvedIncludes); - } - }).detach(); -} - - -void QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootPathsDialog() -{ - // TODO: regard Force Includes here, too! - const std::vector searchedPaths = m_settings->makePathsExpandedAndAbsolute(m_pathsDialog->getPaths()); - closedPathsDialog(); - - std::thread([=]() - { - std::shared_ptr extensionSettings = std::dynamic_pointer_cast(m_settings); - std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings); - std::shared_ptr excludeFilterSettings = std::dynamic_pointer_cast(m_settings); - - if (extensionSettings && pathSettings && excludeFilterSettings) // FIXME: pass msettings as required type - { - std::set detectedHeaderSearchPaths; - { - QtDialogView* dialogView = dynamic_cast( - Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); - - std::set sourceFilePaths; - std::vector headerSearchPaths; - { - dialogView->setParentWindow(m_window); - dialogView->showUnknownProgressDialog(L"Processing", L"Gathering Source Files"); - ScopedFunctor dialogHider([&dialogView]() { - dialogView->hideUnknownProgressDialog(); - }); - - FileManager fileManager; - fileManager.update( - pathSettings->getSourcePathsExpandedAndAbsolute(), - excludeFilterSettings->getExcludeFiltersExpandedAndAbsolute(), - extensionSettings->getSourceExtensions() - ); - sourceFilePaths = fileManager.getAllSourceFilePaths(); - - headerSearchPaths = ApplicationSettings::getInstance()->getHeaderSearchPathsExpanded(); - if (std::shared_ptr cxxSettings = - std::dynamic_pointer_cast(m_settings)) - { - utility::append(headerSearchPaths, cxxSettings->getHeaderSearchPathsExpandedAndAbsolute()); - } - } - { - dialogView->setParentWindow(m_window); - ScopedFunctor dialogHider([&dialogView]() { - dialogView->hideProgressDialog(); - }); - - detectedHeaderSearchPaths = IncludeProcessing::getHeaderSearchDirectories( - sourceFilePaths, - utility::toSet(searchedPaths), - utility::toSet(headerSearchPaths), - log2(sourceFilePaths.size()), - [&](const float progress) - { - dialogView->showProgressDialog( - L"Processing", std::to_wstring(int(progress * sourceFilePaths.size())) + L" Files", - int(progress * 100.0f) - ); - } - ); - } - } - - m_showDetectedIncludesResultFunctor(detectedHeaderSearchPaths); - } - }).detach(); -} - -void QtProjectWizzardContentPathsHeaderSearch::finishedAcceptDetectedIncludePathsDialog() -{ - const std::vector detectedPaths = utility::split>(m_filesDialog->getText(), L"\n"); - closedFilesDialog(); - - std::vector headerSearchPaths = m_list->getPathsAsDisplayed(); - - headerSearchPaths.reserve(headerSearchPaths.size() + detectedPaths.size()); - for (const std::wstring& detectedPath : detectedPaths) - { - if (!detectedPath.empty()) - { - headerSearchPaths.push_back(FilePath(detectedPath)); - } - } - - m_list->setPaths(headerSearchPaths); -} - -void QtProjectWizzardContentPathsHeaderSearch::closedPathsDialog() -{ - m_pathsDialog->hide(); - m_pathsDialog.reset(); - - window()->raise(); -} - -void QtProjectWizzardContentPathsHeaderSearch::showDetectedIncludesResult(const std::set& detectedHeaderSearchPaths) -{ - const std::set headerSearchPaths = utility::toSet(m_settings->makePathsExpandedAndAbsolute(m_list->getPathsAsDisplayed())); - - std::vector additionalHeaderSearchPaths; - { - const FilePath relativeRoot = m_list->getRelativeRootDirectory(); - for (const FilePath& detectedHeaderSearchPath : detectedHeaderSearchPaths) - { - if (headerSearchPaths.find(detectedHeaderSearchPath) == headerSearchPaths.end()) - { - additionalHeaderSearchPaths.push_back(utility::getAsRelativeIfShorter(detectedHeaderSearchPath, relativeRoot)); - } - } - } - - if (additionalHeaderSearchPaths.empty()) - { - QMessageBox msgBox; - msgBox.setText("

No additional include paths have been detected while searching the provided paths.

"); - msgBox.exec(); - } - else - { - std::wstring detailedText = L""; - for (const FilePath& path : additionalHeaderSearchPaths) - { - detailedText += path.wstr() + L"\n"; - } - - m_filesDialog = std::make_shared( - "Detected Include Paths", - ( - "

The following " + std::to_string(additionalHeaderSearchPaths.size()) + " include paths have been " - "detected and will be added to the include paths of this Source Group." - ).c_str() - ); - - m_filesDialog->setup(); - m_filesDialog->setReadOnly(true); - m_filesDialog->setCloseVisible(true); - m_filesDialog->updateNextButton("Add"); - - m_filesDialog->setText(detailedText); - m_filesDialog->showWindow(); - - connect(m_filesDialog.get(), &QtTextEditDialog::finished, this, &QtProjectWizzardContentPathsHeaderSearch::finishedAcceptDetectedIncludePathsDialog); - connect(m_filesDialog.get(), &QtTextEditDialog::canceled, this, &QtProjectWizzardContentPathsHeaderSearch::closedFilesDialog); - } -} - -void QtProjectWizzardContentPathsHeaderSearch::showValidationResult(const std::vector& unresolvedIncludes) -{ - if (unresolvedIncludes.empty()) - { - QMessageBox msgBox; - msgBox.setText("

All include directives throughout the indexed files have been resolved.

"); - msgBox.exec(); - } - else - { - std::map> orderedIncludes; - for (const IncludeDirective& unresolvedInclude: unresolvedIncludes) - { - orderedIncludes[unresolvedInclude.getIncludingFile().wstr()].emplace( - unresolvedInclude.getLineNumber(), unresolvedInclude.getDirective()); - } - - std::wstring detailedText = L""; - for (const auto& p: orderedIncludes) - { - detailedText += p.first + L"\n"; - - for (const auto& p2: p.second) - { - detailedText += std::to_wstring(p2.first) + L":\t" + p2.second + L"\n"; - } - - detailedText += L"\n"; - } - - m_filesDialog = std::make_shared("Unresolved Include Directives", - ("

The indexed files contain " + std::to_string(unresolvedIncludes.size()) + " include directive" + - (unresolvedIncludes.size() == 1 ? "" : "s") + " that could not be resolved correctly. Please check the details " - "and add the respective header search paths.

" - "

Note: This is only a quick pass that does not regard block commenting or conditional preprocessor " - "directives. This means that some of the unresolved includes may actually not be required by the indexer.

" - ).c_str()); - - m_filesDialog->setup(); - m_filesDialog->setCloseVisible(false); - m_filesDialog->setReadOnly(true); - - m_filesDialog->setText(detailedText); - m_filesDialog->showWindow(); - - connect(m_filesDialog.get(), &QtTextEditDialog::finished, this, &QtProjectWizzardContentPathsHeaderSearch::closedFilesDialog); - connect(m_filesDialog.get(), &QtTextEditDialog::canceled, this, &QtProjectWizzardContentPathsHeaderSearch::closedFilesDialog); - } -} - -QtProjectWizzardContentPathsHeaderSearchGlobal::QtProjectWizzardContentPathsHeaderSearchGlobal( - QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPaths(std::shared_ptr(), window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY) -{ - setTitleString("Global Include Paths"); - setHelpString( - "The Global Include Paths will be used in all your projects in addition to the project specific Include Paths. " - "These paths are usually passed to the compiler with the '-isystem' flag.
" - "
" - "Use them to add system header paths (See " - "Finding System Header Locations or use the auto detection below)." - ); - - m_pathDetector = utility::getCxxHeaderPathDetector(); - m_makePathsRelativeToProjectFileLocation = false; -} - -void QtProjectWizzardContentPathsHeaderSearchGlobal::load() -{ - setPaths(ApplicationSettings::getInstance()->getHeaderSearchPaths()); -} - -void QtProjectWizzardContentPathsHeaderSearchGlobal::save() -{ - std::vector paths; - for (const FilePath& headerPath : m_list->getPathsAsDisplayed()) - { - if (headerPath != ResourcePaths::getCxxCompilerHeaderPath()) - { - paths.push_back(headerPath); - } - } - - ApplicationSettings::getInstance()->setHeaderSearchPaths(paths); - ApplicationSettings::getInstance()->save(); -} - -bool QtProjectWizzardContentPathsHeaderSearchGlobal::check() -{ - if (utility::getOsType() == OS_WINDOWS) - { - return QtProjectWizzardContentPaths::check(); - } - - bool hasOtherCompilerConfig = false; - for (const FilePath& headerPath : m_list->getPathsAsDisplayed()) - { - if (headerPath != ResourcePaths::getCxxCompilerHeaderPath() && - headerPath.getCanonical().getConcatenated(L"/stdarg.h").exists()) - { - hasOtherCompilerConfig = true; - break; - } - } - - if (hasOtherCompilerConfig) - { - QMessageBox msgBox; - msgBox.setText("Multiple Compiler Headers"); - msgBox.setInformativeText("Your Global Include Paths contain another path that holds C/C++ compiler headers, " - "probably those of your local C/C++ compiler. They are possibly in conflict with the compiler headers of " - "Sourcetrail's C/C++ indexer. This can lead to compatiblity errors during indexing. Do you want to remove " - "these paths?"); - msgBox.addButton("Remove", QMessageBox::ButtonRole::YesRole); - msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole); - msgBox.setIcon(QMessageBox::Icon::Question); - int ret = msgBox.exec(); - - if (ret == 0) // QMessageBox::Yes - { - std::vector paths; - for (const FilePath& headerPath : m_list->getPathsAsDisplayed()) - { - if (headerPath != ResourcePaths::getCxxCompilerHeaderPath() && - headerPath.getCanonical().getConcatenated(L"/stdarg.h").exists()) - { - continue; - } - paths.push_back(headerPath); - } - setPaths(paths); - } - } - - return QtProjectWizzardContentPaths::check(); -} - -void QtProjectWizzardContentPathsHeaderSearchGlobal::detectedPaths(const std::vector& paths) -{ - std::vector headerPaths; - for (const FilePath& headerPath : paths) - { - if (headerPath != ResourcePaths::getCxxCompilerHeaderPath()) - { - headerPaths.push_back(headerPath); - } - } - setPaths(headerPaths); -} - -void QtProjectWizzardContentPathsHeaderSearchGlobal::setPaths(const std::vector& paths) -{ - m_list->setPaths({}); - m_list->addPaths({ ResourcePaths::getCxxCompilerHeaderPath() }, true); - m_list->addPaths(paths); -} - - -QtProjectWizzardContentPathsFrameworkSearch::QtProjectWizzardContentPathsFrameworkSearch( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional -) - : QtProjectWizzardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY) -{ - setTitleString(indicateAsAdditional ? "Additional Framework Search Paths" : "Framework Search Paths"); - setHelpString( - "Framework Search Paths define where MacOS framework containers (.framework), that your project depends on, are " - "found. These paths are usually passed to the compiler with the '-iframework' flag.
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); -} - -void QtProjectWizzardContentPathsFrameworkSearch::load() -{ - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); - if (cxxSettings) - { - m_list->setPaths(cxxSettings->getFrameworkSearchPaths()); - } -} - -void QtProjectWizzardContentPathsFrameworkSearch::save() -{ - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); - if (cxxSettings) - { - cxxSettings->setFrameworkSearchPaths(m_list->getPathsAsDisplayed()); - } -} - -bool QtProjectWizzardContentPathsFrameworkSearch::isScrollAble() const -{ - return true; -} - -QtProjectWizzardContentPathsFrameworkSearchGlobal::QtProjectWizzardContentPathsFrameworkSearchGlobal( - QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPaths(std::shared_ptr(), window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY) -{ - setTitleString("Global Framework Search Paths"); - setHelpString( - "The Global Framework Search Paths will be used in all your projects - in addition to the project specific " - "Framework Search Paths.
" - "
" - "They define where MacOS framework containers (.framework) are found " - "(See " - "Finding System Header Locations or use the auto detection below)." - ); - - m_pathDetector = utility::getCxxFrameworkPathDetector(); - m_makePathsRelativeToProjectFileLocation = false; -} - -void QtProjectWizzardContentPathsFrameworkSearchGlobal::load() -{ - m_list->setPaths(ApplicationSettings::getInstance()->getFrameworkSearchPaths()); -} - -void QtProjectWizzardContentPathsFrameworkSearchGlobal::save() -{ - ApplicationSettings::getInstance()->setFrameworkSearchPaths(m_list->getPathsAsDisplayed()); - ApplicationSettings::getInstance()->save(); -} - - -QtProjectWizzardContentPathsClassJava::QtProjectWizzardContentPathsClassJava( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_FILES_AND_DIRECTORIES) -{ - setTitleString("Class Path"); - setHelpString( - "Enter all the .jar files your project depends on. If your project depends on uncompiled java code that should " - "not be indexed, please add the root directory of those .java files here (the one where all the package names " - "are relative to).
" - "
" - "You can make use of environment variables with ${ENV_VAR}." - ); -} - -void QtProjectWizzardContentPathsClassJava::populate(QGridLayout* layout, int& row) -{ - QtProjectWizzardContentPaths::populate(layout, row); - - QLabel* label = createFormLabel("JRE System Library"); - layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); - - m_useJreSystemLibraryCheckBox = new QCheckBox("Use JRE System Library", this); - - layout->addWidget(m_useJreSystemLibraryCheckBox, row, QtProjectWizzardWindow::BACK_COL); - row++; -} - -void QtProjectWizzardContentPathsClassJava::load() -{ - std::shared_ptr settings = - std::dynamic_pointer_cast(m_settings); - if (settings) - { - m_list->setPaths(settings->getClasspath()); - m_useJreSystemLibraryCheckBox->setChecked(settings->getUseJreSystemLibrary()); - } -} - -void QtProjectWizzardContentPathsClassJava::save() -{ - std::shared_ptr settings = - std::dynamic_pointer_cast(m_settings); - if (settings) - { - settings->setClasspath(m_list->getPathsAsDisplayed()); - settings->setUseJreSystemLibrary(m_useJreSystemLibraryCheckBox->isChecked()); - } -} diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h deleted file mode 100644 index a020ac0f..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h +++ /dev/null @@ -1,225 +0,0 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_PATHS_H -#define QT_PROJECT_WIZZARD_CONTENT_PATHS_H - -#include - -#include "QtPathListBox.h" -#include "QtProjectWizzardContent.h" -#include "CombinedPathDetector.h" - -class IncludeDirective; -class QCheckBox; -class QComboBox; -class QPushButton; -class QtPathListDialog; -class SourceGroupSettings; -class SourceGroupSettingsCxxCdb; -class SourceGroupSettingsCxxCodeblocks; -class SourceGroupSettingsCxxSonargraph; - -class QtProjectWizzardContentPaths - : public QtProjectWizzardContent -{ - Q_OBJECT - -signals: - void showSourceFiles(); - -public: - QtProjectWizzardContentPaths( - std::shared_ptr settings, - QtProjectWizzardWindow* window, - QtPathListBox::SelectionPolicyType selectionPolicy, - bool checkMissingPaths = true); - - // QtSettingsWindow implementation - virtual void populate(QGridLayout* layout, int& row) override; - - virtual bool check() override; - -protected: - void setTitleString(const QString& title); - void setHelpString(const QString& help); - - void addDetection(QGridLayout* layout, int row); - - virtual void detectedPaths(const std::vector& paths); - - std::shared_ptr m_settings; - - QtPathListBox* m_list; - - QString m_showFilesString; - std::shared_ptr m_pathDetector; - - bool m_makePathsRelativeToProjectFileLocation; - -private slots: - void detectionClicked(); - -private: - const QtPathListBox::SelectionPolicyType m_selectionPolicy; - const bool m_checkMissingPaths; - QString m_titleString; - QString m_helpString; - - QComboBox* m_detectorBox; -}; - - -class QtProjectWizzardContentPathsSource - : public QtProjectWizzardContentPaths -{ - Q_OBJECT -public: - QtProjectWizzardContentPathsSource(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - virtual void load() override; - virtual void save() override; - - virtual std::vector getFilePaths() const override; - virtual QString getFileNamesTitle() const override; - virtual QString getFileNamesDescription() const override; -}; - - -class QtProjectWizzardContentIndexedHeaderPaths - : public QtProjectWizzardContentPaths -{ - Q_OBJECT - -public: - static std::vector getIndexedPathsDerivedFromSonargraphProject(std::shared_ptr settings); - static std::vector getIndexedPathsDerivedFromCodeblocksProject(std::shared_ptr settings); - static std::vector getIndexedPathsDerivedFromCDB(std::shared_ptr settings); - - QtProjectWizzardContentIndexedHeaderPaths( - std::shared_ptr settings, QtProjectWizzardWindow* window, std::string projectKindName); - - virtual void populate(QGridLayout* layout, int& row) override; - - // QtProjectWizzardContent implementation - virtual void load() override; - virtual void save() override; - - virtual bool check() override; - -private slots: - void buttonClicked(); - void savedFilesDialog(); - -private: - const std::string m_projectKindName; -}; - - -class QtProjectWizzardContentPathsExclude - : public QtProjectWizzardContentPaths -{ - Q_OBJECT -public: - QtProjectWizzardContentPathsExclude(std::shared_ptr settings, QtProjectWizzardWindow* window); - - virtual void load() override; - virtual void save() override; -}; - - -class QtProjectWizzardContentPathsHeaderSearch - : public QtProjectWizzardContentPaths -{ - Q_OBJECT -public: - QtProjectWizzardContentPathsHeaderSearch( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional = false); - - // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; - virtual void load() override; - virtual void save() override; - virtual bool isScrollAble() const override; - -private slots: - void detectIncludesButtonClicked(); - void validateIncludesButtonClicked(); - void finishedSelectDetectIncludesRootPathsDialog(); - void finishedAcceptDetectedIncludePathsDialog(); - void closedPathsDialog(); - -private: - void showDetectedIncludesResult(const std::set& detectedHeaderSearchPaths); - void showValidationResult(const std::vector& unresolvedIncludes); - - QtThreadedFunctor> m_showDetectedIncludesResultFunctor; - QtThreadedFunctor> m_showValidationResultFunctor; - - std::shared_ptr m_pathsDialog; - const bool m_indicateAsAdditional; -}; - -class QtProjectWizzardContentPathsHeaderSearchGlobal - : public QtProjectWizzardContentPaths -{ - Q_OBJECT -public: - QtProjectWizzardContentPathsHeaderSearchGlobal(QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - virtual void load() override; - virtual void save() override; - - virtual bool check() override; - -protected: - virtual void detectedPaths(const std::vector& paths) override; - -private: - void setPaths(const std::vector& paths); -}; - - -class QtProjectWizzardContentPathsFrameworkSearch - : public QtProjectWizzardContentPaths -{ - Q_OBJECT -public: - QtProjectWizzardContentPathsFrameworkSearch( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional = false); - - // QtProjectWizzardContent implementation - virtual void load() override; - virtual void save() override; - - virtual bool isScrollAble() const override; -}; - -class QtProjectWizzardContentPathsFrameworkSearchGlobal - : public QtProjectWizzardContentPaths -{ - Q_OBJECT -public: - QtProjectWizzardContentPathsFrameworkSearchGlobal(QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - virtual void load() override; - virtual void save() override; -}; - -class QtProjectWizzardContentPathsClassJava - : public QtProjectWizzardContentPaths -{ - Q_OBJECT -public: - QtProjectWizzardContentPathsClassJava(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; - virtual void load() override; - virtual void save() override; - -private: - QCheckBox* m_useJreSystemLibraryCheckBox; -}; - -#endif // QT_PROJECT_WIZZARD_CONTENT_PATHS_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.h deleted file mode 100644 index ef24a930..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceGroupInfoText.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_INFO_TEXT_H -#define QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_INFO_TEXT_H - -#include "QtProjectWizzardContent.h" - -class QtProjectWizzardContentSourceGroupInfoText - : public QtProjectWizzardContent -{ - Q_OBJECT - -public: - QtProjectWizzardContentSourceGroupInfoText(QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; -}; - -#endif // QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_INFO_TEXT_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentVS.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentVS.h deleted file mode 100644 index dec5f836..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentVS.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_VS_H -#define QT_PROJECT_WIZZARD_CONTENT_VS_H - -#include "QtProjectWizzardContent.h" - -class QtProjectWizzardContentVS - : public QtProjectWizzardContent -{ - Q_OBJECT - -public: - QtProjectWizzardContentVS(QtProjectWizzardWindow* window); - - virtual void populate(QGridLayout* layout, int& row) override; - -private slots: - void handleVSCDBClicked(); -}; - -#endif // QT_PROJECT_WIZZARD_CONTENT_VS_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtSourceGroupWizzardPage.h b/src/lib_gui/qt/window/project_wizzard/QtSourceGroupWizzardPage.h deleted file mode 100644 index dbb0dc71..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtSourceGroupWizzardPage.h +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef QT_SOURCE_GROUP_WIZZARD_PAGE_H -#define QT_SOURCE_GROUP_WIZZARD_PAGE_H - -#include -#include -#include - -class QtProjectWizzardWindow; - -enum WizzardContentContextType -{ - WIZZARD_CONTENT_CONTEXT_SETUP = 1, - WIZZARD_CONTENT_CONTEXT_SUMMARY = 2, - WIZZARD_CONTENT_CONTEXT_ALL = 3 -}; - -template -class QtSourceGroupWizzardPage -{ -public: - typedef std::function settings, QtProjectWizzardWindow* window)> ContentCreator; - - QtSourceGroupWizzardPage(const std::string& title, int preferredWidth = 750, int preferredHeight = 600); - - void addContentCreator( - WizzardContentContextType contextType, - ContentCreator contentCreator - ); - - template - void addContentCreatorSimple(WizzardContentContextType contextType); - - template - void addContentCreatorWithSettings(WizzardContentContextType contextType); - - template - void addContentCreatorWithSettings(WizzardContentContextType contextType, ParamTypes ... params); - - bool hasContentForContext(WizzardContentContextType contextType) const; - - std::string getTitle() const; - int getPreferredWidth() const; - int getPreferredHeight() const; - QtProjectWizzardContentGroup* createContentGroup(WizzardContentContextType contextType, std::shared_ptr settings, QtProjectWizzardWindow* window) const; - -private: - const std::string m_title; - const int m_preferredWidth; - const int m_preferredHeight; - std::vector> m_contentCreators; -}; - -template -QtSourceGroupWizzardPage::QtSourceGroupWizzardPage(const std::string& title, int preferredWidth, int preferredHeight) - : m_title(title) - , m_preferredWidth(preferredWidth) - , m_preferredHeight(preferredHeight) -{ -} - -template -void QtSourceGroupWizzardPage::addContentCreator( - WizzardContentContextType contextType, - ContentCreator contentCreator -) -{ - m_contentCreators.push_back(std::make_pair(contextType, contentCreator)); -} - -template -template -void QtSourceGroupWizzardPage::addContentCreatorSimple(WizzardContentContextType contextType) -{ - addContentCreator( - contextType, - [](std::shared_ptr settings, QtProjectWizzardWindow* window) - { - return new ContentType(window); - } - ); -} - -template -template -void QtSourceGroupWizzardPage::addContentCreatorWithSettings(WizzardContentContextType contextType) -{ - addContentCreator( - contextType, - [](std::shared_ptr settings, QtProjectWizzardWindow* window) - { - return new ContentType(settings, window); - } - ); -} - -template -template -void QtSourceGroupWizzardPage::addContentCreatorWithSettings(WizzardContentContextType contextType, ParamTypes ... params) -{ - addContentCreator( - contextType, - [=](std::shared_ptr settings, QtProjectWizzardWindow* window) - { - return new ContentType(settings, window, params...); - } - ); -} - -template -std::string QtSourceGroupWizzardPage::getTitle() const -{ - return m_title; -} - -template -int QtSourceGroupWizzardPage::getPreferredWidth() const -{ - return m_preferredWidth; -} - -template -int QtSourceGroupWizzardPage::getPreferredHeight() const -{ - return m_preferredHeight; -} - -template -bool QtSourceGroupWizzardPage::hasContentForContext(WizzardContentContextType contextType) const -{ - for (const std::pair& contentCreator : m_contentCreators) - { - if (contentCreator.first & contextType) - { - return true; - } - } - return false; -} - -template -QtProjectWizzardContentGroup* QtSourceGroupWizzardPage::createContentGroup(WizzardContentContextType contextType, std::shared_ptr settings, QtProjectWizzardWindow* window) const -{ - QtProjectWizzardContentGroup* contentGroup = new QtProjectWizzardContentGroup(window); - - bool firstContentAdded = false; - for (const std::pair& contentCreator : m_contentCreators) - { - if (contentCreator.first & contextType) - { - if (firstContentAdded) - { - contentGroup->addSpace(); - } - contentGroup->addContent(contentCreator.second(settings, window)); - firstContentAdded = true; - } - } - - return contentGroup; -} - - -#endif // QT_SOURCE_GROUP_WIZZARD_PAGE_H