From fc64f1a9587f165d13556e3aa24ec8c2e7b65890 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 14 Jan 2019 17:20:37 +0100 Subject: [PATCH] ui: Recommended project setup from CDB and moved empty setup at end of list --- .../QtProjectWizzardContentSelect.cpp | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp index 8901e916..8d943f77 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp @@ -23,26 +23,30 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) { struct SourceGroupInfo { - SourceGroupInfo(SourceGroupType type) :type(type) {} + SourceGroupInfo(SourceGroupType type, bool recommended = false) + : type(type) + , recommended(recommended) + {} const SourceGroupType type; + const bool recommended; }; // define which kind of source groups are available for each language std::map> sourceGroupInfos; - sourceGroupInfos[LANGUAGE_C].push_back(SourceGroupInfo(SOURCE_GROUP_C_EMPTY)); - sourceGroupInfos[LANGUAGE_C].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_CDB)); + sourceGroupInfos[LANGUAGE_C].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_CDB, true)); sourceGroupInfos[LANGUAGE_C].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_VS)); sourceGroupInfos[LANGUAGE_C].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_CODEBLOCKS)); sourceGroupInfos[LANGUAGE_C].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_SONARGRAPH)); - sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CPP_EMPTY)); - sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_CDB)); + sourceGroupInfos[LANGUAGE_C].push_back(SourceGroupInfo(SOURCE_GROUP_C_EMPTY)); + sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_CDB, true)); sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_VS)); sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_CODEBLOCKS)); sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_SONARGRAPH)); - sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_EMPTY)); + sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CPP_EMPTY)); sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_MAVEN)); sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_GRADLE)); sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_SONARGRAPH)); + sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_EMPTY)); sourceGroupInfos[LANGUAGE_CUSTOM].push_back(SourceGroupInfo(SOURCE_GROUP_CUSTOM_COMMAND)); // define which icons should be used for which kind of source group @@ -62,8 +66,8 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) m_sourceGroupTypeDescriptions[SOURCE_GROUP_C_EMPTY] = "Create a new Sourcetrail Source Group by defining which C files will be indexed."; m_sourceGroupTypeDescriptions[SOURCE_GROUP_CPP_EMPTY] = "Create a new Sourcetrail Source Group by defining which C++ files will be indexed."; m_sourceGroupTypeDescriptions[SOURCE_GROUP_CXX_CDB] = - "Create a Source Group from an existing Compilation Database (compile_commands.json). " - "They can be exported from CMake
(-DCMAKE_EXPORT_COMPILE_COMMANDS=1) and Make projects. Have a look at the " + "Create a Source Group from an existing Compilation Database file (compile_commands.json). " + "It can be exported from CMake
(-DCMAKE_EXPORT_COMPILE_COMMANDS=1) and Make projects. Have a look at the " "" "documentation."; m_sourceGroupTypeDescriptions[SOURCE_GROUP_CXX_VS] = @@ -75,7 +79,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) "project file.

Currently manual C/C++ Sonargraph modules are supported as well as Sonargraph modules that are based on CMake JSON Command files.

"; m_sourceGroupTypeDescriptions[SOURCE_GROUP_CXX_CODEBLOCKS] = "

Create a new Source Group from an existing Code::Blocks project file.

" - "

Note: A \".cbp\" file will also be generated by the Qt Creator if a CMakeLists file is imported.

"; + "

Note: A \".cbp\" file will also get generated by the Qt Creator if a CMakeLists file is imported.

"; m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_EMPTY] = "Create a new Sourcetrail Source Group by defining which Java files will be indexed."; m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_MAVEN] = "Create a new Source Group from an existing Maven project."; m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_GRADLE] = "Create a new Source Group from an existing Gradle project."; @@ -114,6 +118,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) selectedLanguage = LanguageType(languageTypeInt); } + bool hasRecommeded = false; for (auto& it: m_buttons) { it.second->setExclusive(false); @@ -121,13 +126,19 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) { button->setChecked(false); button->setVisible(it.first == selectedLanguage); + + if (it.first == selectedLanguage) + { + hasRecommeded = hasRecommeded | button->property("recommended").toBool(); + } } it.second->setExclusive(true); } m_window->setNextEnabled(false); m_title->setText("Source Group Types - " + m_languages->checkedButton()->text()); - m_description->setText(""); + + m_description->setText(hasRecommeded ? "* recommended" : ""); } ); @@ -139,11 +150,24 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) for (auto& sourceGroupIt: languageIt.second) { + std::string name = sourceGroupTypeToProjectSetupString(sourceGroupIt.type); + if (sourceGroupIt.recommended) + { + name += "*"; + } + QToolButton* b = createSourceGroupButton( - utility::insertLineBreaksAtBlankSpaces(sourceGroupTypeToProjectSetupString(sourceGroupIt.type), 15).c_str(), + utility::insertLineBreaksAtBlankSpaces(name, 15).c_str(), QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"icon/" + m_sourceGroupTypeIconName[sourceGroupIt.type] + L".png").wstr()) ); + + if (sourceGroupIt.recommended) + { + b->setStyleSheet("font-weight: bold"); + } + b->setProperty("source_group_type", int(sourceGroupIt.type)); + b->setProperty("recommended", sourceGroupIt.recommended); sourceGroupButtons->addButton(b); flayout->addWidget(b); }