ui: Recommended project setup from CDB and moved empty setup at end of list

This commit is contained in:
Eberhard Graether
2019-01-14 17:20:37 +01:00
parent 21ac50c204
commit fc64f1a958
@@ -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<LanguageType, std::vector<SourceGroupInfo>> 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<br />(-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<br />(-DCMAKE_EXPORT_COMPILE_COMMANDS=1) and Make projects. Have a look at the "
"<a href=\"https://sourcetrail.com/documentation/#CreateAProjectFromCompilationDatabase\">"
"documentation</a>.";
m_sourceGroupTypeDescriptions[SOURCE_GROUP_CXX_VS] =
@@ -75,7 +79,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
"project file.</p><p>Currently manual C/C++ Sonargraph modules are supported as well as Sonargraph modules that are based on CMake JSON Command files.</p>";
m_sourceGroupTypeDescriptions[SOURCE_GROUP_CXX_CODEBLOCKS] =
"<p>Create a new Source Group from an existing Code::Blocks project file.</p>"
"<p><b>Note</b>: A \".cbp\" file will also be generated by the <b>Qt Creator</b> if a CMakeLists file is imported.</p>";
"<p><b>Note</b>: A \".cbp\" file will also get generated by the <b>Qt Creator</b> if a CMakeLists file is imported.</p>";
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 ? "<b>* recommended</b>" : "");
}
);
@@ -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);
}