logic: cleaned up code for SourceGroupSettings and Wizzard

* Flattened sourcegroupsettings class hierarchy by moving cross compilation options to own base class
* QtProjectWizzardContentFlags constructor required correct settings object to reduce the need for type casting
* QtProjectWizzardContentPath constructors required correct settings objects
* moved SourcePaths from SourceGroupSettingsJava to SourceGroupSettingsJavaEmpty because they are not required for Gradle and Maven projects
* removed classpath from maven and gradle source group settings
* reuse code of SourceGroup for "show source files" in wizard
This commit is contained in:
mlangkabel
2018-06-12 21:16:51 +02:00
parent dca4c3c16b
commit c65a5d04b1
34 changed files with 697 additions and 570 deletions
@@ -441,15 +441,15 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
{
if (std::shared_ptr<SourceGroupSettingsJavaGradle> settingsJavaGradle = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(group))
{
summary->addContent(new QtProjectWizzardContentPathSourceGradle(group, this));
summary->addContent(new QtProjectWizzardContentPathSourceGradle(settingsJavaGradle, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathDependenciesGradle(group, this));
summary->addContent(new QtProjectWizzardContentPathDependenciesGradle(settingsJavaGradle, this));
}
else if (std::shared_ptr<SourceGroupSettingsJavaMaven> settingsJavaMaven = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(group))
{
summary->addContent(new QtProjectWizzardContentPathSourceMaven(group, this));
summary->addContent(new QtProjectWizzardContentPathSourceMaven(settingsJavaMaven, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(group, this));
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(settingsJavaMaven, this));
}
summary->addSpace();
@@ -462,44 +462,44 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
{
summary->addContent(new QtProjectWizzardContentJavaStandard(settingsJavaSonargraph, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentSonargraphProjectPath(group, this));
summary->addContent(new QtProjectWizzardContentSonargraphProjectPath(
settingsJavaSonargraph, std::shared_ptr<SourceGroupSettingsCxxSonargraph>(), settingsJavaSonargraph, this
));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsClassJava(group, this));
summary->addSpace();
}
else if (std::shared_ptr<SourceGroupSettingsCxx> settingsCxx = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(group))
{
bool indicateSearchPathsAsAdditional = false;
if (std::shared_ptr<SourceGroupSettingsCxxEmpty> settingsCxxEmpty = std::dynamic_pointer_cast<SourceGroupSettingsCxxEmpty>(group))
if (std::shared_ptr<SourceGroupSettingsCEmpty> settingsCEmpty = std::dynamic_pointer_cast<SourceGroupSettingsCEmpty>(group))
{
if (std::shared_ptr<SourceGroupSettingsCEmpty> settingsCEmpty = std::dynamic_pointer_cast<SourceGroupSettingsCEmpty>(group))
{
summary->addContent(new QtProjectWizzardContentCStandard(settingsCEmpty, this));
}
else if (std::shared_ptr<SourceGroupSettingsCppEmpty> settingsCppEmpty = std::dynamic_pointer_cast<SourceGroupSettingsCppEmpty>(group))
{
summary->addContent(new QtProjectWizzardContentCppStandard(settingsCppEmpty, this));
}
summary->addContent(new QtProjectWizzardContentCStandard(settingsCEmpty, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentCrossCompilationOptions(group, this));
summary->addContent(new QtProjectWizzardContentCrossCompilationOptions(settingsCEmpty, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsSource(group, this));
summary->addContent(new QtProjectWizzardContentPathsExclude(group, this));
summary->addContent(new QtProjectWizzardContentExtensions(settingsCxxEmpty, this));
summary->addContent(new QtProjectWizzardContentExtensions(settingsCEmpty, this));
}
else if (std::shared_ptr<SourceGroupSettingsCppEmpty> settingsCppEmpty = std::dynamic_pointer_cast<SourceGroupSettingsCppEmpty>(group))
{
summary->addContent(new QtProjectWizzardContentCppStandard(settingsCppEmpty, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentCrossCompilationOptions(settingsCppEmpty, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsSource(group, this));
summary->addContent(new QtProjectWizzardContentPathsExclude(group, this));
summary->addContent(new QtProjectWizzardContentExtensions(settingsCppEmpty, this));
}
else if (std::shared_ptr<SourceGroupSettingsCxxCdb> settingsCxxCdb = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(group))
{
indicateSearchPathsAsAdditional = true;
summary->addContent(new QtProjectWizzardContentPathCDB(group, this));
summary->addContent(new QtProjectWizzardContentPathCDB(settingsCxxCdb, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", group, this));
summary->addContent(new QtProjectWizzardContentPathsExclude(group, this));
summary->addSpace();
}
else if (std::shared_ptr<SourceGroupSettingsCxxCodeblocks> settingsCxxCodeblocks = std::dynamic_pointer_cast<SourceGroupSettingsCxxCodeblocks>(group))
{
@@ -513,7 +513,6 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
summary->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Code::Blocks project", settingsCxxCodeblocks, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentExtensions(settingsCxxCodeblocks, this));
summary->addSpace();
}
else if (std::shared_ptr<SourceGroupSettingsCxxSonargraph> settingsCxxSonargraph = std::dynamic_pointer_cast<SourceGroupSettingsCxxSonargraph>(group))
{
@@ -521,12 +520,12 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
summary->addContent(new QtProjectWizzardContentCppStandard(settingsCxxSonargraph, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentSonargraphProjectPath(group, this));
summary->addContent(new QtProjectWizzardContentSonargraphProjectPath(settingsCxxSonargraph, settingsCxxSonargraph, settingsCxxSonargraph, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Sonargraph project", group, this));
summary->addSpace();
}
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(group, this, indicateSearchPathsAsAdditional));
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(this));
@@ -539,7 +538,7 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
summary->addSpace();
}
summary->addContent(new QtProjectWizzardContentFlags(group, this, indicateSearchPathsAsAdditional));
summary->addContent(new QtProjectWizzardContentFlags(settingsCxx, this, indicateSearchPathsAsAdditional));
}
setContent(summary);
@@ -822,10 +821,11 @@ void QtProjectWizzard::emptySourceGroup()
{
contentGroup->addContent(new QtProjectWizzardContentJavaStandard(settingsJavaEmpty, this));
}
if (m_newSourceGroupSettings->getType() == SOURCE_GROUP_C_EMPTY ||
m_newSourceGroupSettings->getType() == SOURCE_GROUP_CPP_EMPTY)
if (std::shared_ptr<SourceGroupSettingsWithCxxCrossCompilationOptions> settingsCrossCompile =
std::dynamic_pointer_cast<SourceGroupSettingsWithCxxCrossCompilationOptions>(m_newSourceGroupSettings))
{
contentGroup->addContent(new QtProjectWizzardContentCrossCompilationOptions(m_newSourceGroupSettings, window));
contentGroup->addContent(new QtProjectWizzardContentCrossCompilationOptions(settingsCrossCompile, window));
window->setPreferredSize(QSize(470, 460));
}
else
@@ -852,12 +852,15 @@ void QtProjectWizzard::emptySourceGroupCDBVS()
QtProjectWizzardWindow* window = createWindowWithContentGroup(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup)
{
contentGroup->addContent(new QtProjectWizzardContentVS(window));
contentGroup->addContent(new QtProjectWizzardContentPathCDB(m_newSourceGroupSettings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", m_newSourceGroupSettings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathsExclude(m_newSourceGroupSettings, window));
if (std::shared_ptr<SourceGroupSettingsCxxCdb> settings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_newSourceGroupSettings))
{
contentGroup->addContent(new QtProjectWizzardContentVS(window));
contentGroup->addContent(new QtProjectWizzardContentPathCDB(settings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", m_newSourceGroupSettings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathsExclude(m_newSourceGroupSettings, window));
}
}
);
@@ -870,11 +873,14 @@ void QtProjectWizzard::emptySourceGroupCDB()
QtProjectWizzardWindow* window = createWindowWithContentGroup(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup)
{
contentGroup->addContent(new QtProjectWizzardContentPathCDB(m_newSourceGroupSettings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", m_newSourceGroupSettings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathsExclude(m_newSourceGroupSettings, window));
if (std::shared_ptr<SourceGroupSettingsCxxCdb> settings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_newSourceGroupSettings))
{
contentGroup->addContent(new QtProjectWizzardContentPathCDB(settings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", m_newSourceGroupSettings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathsExclude(m_newSourceGroupSettings, window));
}
}
);
@@ -914,7 +920,7 @@ void QtProjectWizzard::emptySourceGroupCxxSonargraph()
{
contentGroup->addContent(new QtProjectWizzardContentCppStandard(settings, this));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentSonargraphProjectPath(m_newSourceGroupSettings, window));
contentGroup->addContent(new QtProjectWizzardContentSonargraphProjectPath(settings, settings, settings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Sonargraph project", m_newSourceGroupSettings, window));
}
@@ -934,12 +940,14 @@ void QtProjectWizzard::emptySourceGroupJavaSonargraph()
{
contentGroup->addContent(new QtProjectWizzardContentJavaStandard(settings, this));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentSonargraphProjectPath(m_newSourceGroupSettings, window));
contentGroup->addContent(new QtProjectWizzardContentSonargraphProjectPath(
settings, std::shared_ptr<SourceGroupSettingsCxxSonargraph>(), settings, window)
);
}
}
);
connect(window, &QtProjectWizzardWindow::next, this, &QtProjectWizzard::createSourceGroup);
connect(window, &QtProjectWizzardWindow::next, this, &QtProjectWizzard::dependenciesJava);
window->updateSubTitle("Sonargraph Project Path");
}
@@ -953,12 +961,12 @@ void QtProjectWizzard::sourcePaths()
contentGroup->addContent(new QtProjectWizzardContentPathsSource(settingsCxx, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathsExclude(settingsCxx, window));
if (std::shared_ptr<SourceGroupSettingsWithSourceExtensions> settingsSourceExtension =
std::dynamic_pointer_cast<SourceGroupSettingsWithSourceExtensions>(m_newSourceGroupSettings))
{
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentExtensions(settingsSourceExtension, window));
}
}
if (std::shared_ptr<SourceGroupSettingsWithSourceExtensions> settingsSourceExtension =
std::dynamic_pointer_cast<SourceGroupSettingsWithSourceExtensions>(m_newSourceGroupSettings))
{
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentExtensions(settingsSourceExtension, window));
}
}
);
@@ -1044,21 +1052,29 @@ void QtProjectWizzard::dependenciesJava()
void QtProjectWizzard::sourcePathsJavaMaven()
{
std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_newSourceGroupSettings)->setMavenDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) +
L"/maven"
)
);
if (std::shared_ptr<SourceGroupSettingsJavaMaven> settingsJavaMaven = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_newSourceGroupSettings))
{
settingsJavaMaven->setMavenDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) +
L"/maven"
)
);
}
QtProjectWizzardWindow* window = createWindowWithContentGroup(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup)
{
contentGroup->addContent(new QtProjectWizzardContentPathSourceMaven(m_newSourceGroupSettings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_newSourceGroupSettings, window));
if (std::shared_ptr<SourceGroupSettingsJavaMaven> settingsJavaMaven = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_newSourceGroupSettings))
{
contentGroup->addContent(new QtProjectWizzardContentJavaStandard(settingsJavaMaven, this));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathSourceMaven(settingsJavaMaven, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathDependenciesMaven(settingsJavaMaven, window));
}
}
);
@@ -1068,21 +1084,29 @@ void QtProjectWizzard::sourcePathsJavaMaven()
void QtProjectWizzard::sourcePathsJavaGradle()
{
std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_newSourceGroupSettings)->setGradleDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) +
L"/gradle"
)
);
if (std::shared_ptr<SourceGroupSettingsJavaGradle> settingsJavaGradle = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_newSourceGroupSettings))
{
settingsJavaGradle->setGradleDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) +
L"/gradle"
)
);
}
QtProjectWizzardWindow* window = createWindowWithContentGroup(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup)
{
contentGroup->addContent(new QtProjectWizzardContentPathSourceGradle(m_newSourceGroupSettings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathDependenciesGradle(m_newSourceGroupSettings, window));
if (std::shared_ptr<SourceGroupSettingsJavaGradle> settingsJavaGradle = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_newSourceGroupSettings))
{
contentGroup->addContent(new QtProjectWizzardContentJavaStandard(settingsJavaGradle, this));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathSourceGradle(settingsJavaGradle, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathDependenciesGradle(settingsJavaGradle, window));
}
}
);
@@ -1095,7 +1119,10 @@ void QtProjectWizzard::advancedSettingsCxx()
QtProjectWizzardWindow* window = createWindowWithContentGroup(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup)
{
contentGroup->addContent(new QtProjectWizzardContentFlags(m_newSourceGroupSettings, window));
if (std::shared_ptr<SourceGroupSettingsCxx> settings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_newSourceGroupSettings))
{
contentGroup->addContent(new QtProjectWizzardContentFlags(settings, window));
}
}
);
@@ -4,11 +4,11 @@
#include <QComboBox>
#include <QLabel>
#include "settings/SourceGroupSettingsCxxEmpty.h"
#include "settings/SourceGroupSettingsWithCxxCrossCompilationOptions.h"
#include "utility/logging/logging.h"
QtProjectWizzardContentCrossCompilationOptions::QtProjectWizzardContentCrossCompilationOptions(
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<SourceGroupSettingsWithCxxCrossCompilationOptions> sourceGroupSettings,
QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(window)
@@ -61,7 +61,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
QLabel* label = new QLabel("Architecture:");
m_arch = new QComboBox();
std::vector<std::wstring> archTypes = SourceGroupSettingsCxxEmpty::getAvailableArchTypes();
std::vector<std::wstring> archTypes = SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableArchTypes();
std::sort(archTypes.begin(), archTypes.end());
for (size_t i = 0; i < archTypes.size(); i++)
{
@@ -77,7 +77,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
QLabel* label = new QLabel("Vendor:");
m_vendor = new QComboBox();
std::vector<std::wstring> vendorTypes = SourceGroupSettingsCxxEmpty::getAvailableVendorTypes();
std::vector<std::wstring> vendorTypes = SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableVendorTypes();
std::sort(vendorTypes.begin() + 1, vendorTypes.end());
for (size_t i = 0; i < vendorTypes.size(); i++)
{
@@ -92,7 +92,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
QLabel* label = new QLabel("OS:");
m_sys = new QComboBox();
std::vector<std::wstring> osTypes = SourceGroupSettingsCxxEmpty::getAvailableOsTypes();
std::vector<std::wstring> osTypes = SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableOsTypes();
std::sort(osTypes.begin() + 1, osTypes.end());
for (size_t i = 0; i < osTypes.size(); i++)
{
@@ -107,7 +107,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
QLabel* label = new QLabel("Environment:");
m_abi = new QComboBox();
std::vector<std::wstring> environmentTypes = SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTypes();
std::vector<std::wstring> environmentTypes = SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableEnvironmentTypes();
std::sort(environmentTypes.begin() + 1, environmentTypes.end());
for (size_t i = 0; i < environmentTypes.size(); i++)
{
@@ -129,28 +129,22 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
void QtProjectWizzardContentCrossCompilationOptions::load()
{
if (std::shared_ptr<SourceGroupSettingsCxxEmpty> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxEmpty>(m_sourceGroupSettings))
{
m_useTargetOptions->setChecked(cxxSettings->getTargetOptionsEnabled());
m_arch->setCurrentText(QString::fromStdWString(cxxSettings->getTargetArch()));
m_vendor->setCurrentText(QString::fromStdWString(cxxSettings->getTargetVendor()));
m_sys->setCurrentText(QString::fromStdWString(cxxSettings->getTargetSys()));
m_abi->setCurrentText(QString::fromStdWString(cxxSettings->getTargetAbi()));
}
m_useTargetOptions->setChecked(m_sourceGroupSettings->getTargetOptionsEnabled());
m_arch->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getTargetArch()));
m_vendor->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getTargetVendor()));
m_sys->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getTargetSys()));
m_abi->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getTargetAbi()));
updateTargetOptionsEnabled();
}
void QtProjectWizzardContentCrossCompilationOptions::save()
{
if (std::shared_ptr<SourceGroupSettingsCxxEmpty> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxEmpty>(m_sourceGroupSettings))
{
cxxSettings->setTargetOptionsEnabled(m_useTargetOptions->isChecked());
cxxSettings->setTargetArch(m_arch->currentText().toStdWString());
cxxSettings->setTargetVendor(m_vendor->currentText().toStdWString());
cxxSettings->setTargetSys(m_sys->currentText().toStdWString());
cxxSettings->setTargetAbi(m_abi->currentText().toStdWString());
}
m_sourceGroupSettings->setTargetOptionsEnabled(m_useTargetOptions->isChecked());
m_sourceGroupSettings->setTargetArch(m_arch->currentText().toStdWString());
m_sourceGroupSettings->setTargetVendor(m_vendor->currentText().toStdWString());
m_sourceGroupSettings->setTargetSys(m_sys->currentText().toStdWString());
m_sourceGroupSettings->setTargetAbi(m_abi->currentText().toStdWString());
}
bool QtProjectWizzardContentCrossCompilationOptions::check()
@@ -6,7 +6,7 @@
class QCheckBox;
class QComboBox;
class QLabel;
class SourceGroupSettings;
class SourceGroupSettingsWithCxxCrossCompilationOptions;
class QtProjectWizzardContentCrossCompilationOptions
: public QtProjectWizzardContent
@@ -15,7 +15,7 @@ class QtProjectWizzardContentCrossCompilationOptions
public:
QtProjectWizzardContentCrossCompilationOptions(
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<SourceGroupSettingsWithCxxCrossCompilationOptions> sourceGroupSettings,
QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
@@ -29,7 +29,7 @@ private:
void onUseTargetOptionsChanged();
void updateTargetOptionsEnabled();
std::shared_ptr<SourceGroupSettings> m_sourceGroupSettings;
std::shared_ptr<SourceGroupSettingsWithCxxCrossCompilationOptions> m_sourceGroupSettings;
QCheckBox* m_useTargetOptions;
QComboBox* m_arch;
@@ -6,7 +6,8 @@
#include "qt/element/QtStringListBox.h"
QtProjectWizzardContentExtensions::QtProjectWizzardContentExtensions(
std::shared_ptr<SourceGroupSettingsWithSourceExtensions> settings, QtProjectWizzardWindow* window
std::shared_ptr<SourceGroupSettingsWithSourceExtensions> settings,
QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(window)
, m_settings(settings)
@@ -14,7 +14,10 @@ class QtProjectWizzardContentExtensions
Q_OBJECT
public:
QtProjectWizzardContentExtensions(std::shared_ptr<SourceGroupSettingsWithSourceExtensions> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentExtensions(
std::shared_ptr<SourceGroupSettingsWithSourceExtensions> settings,
QtProjectWizzardWindow* window
);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
@@ -6,7 +6,7 @@
#include "qt/element/QtStringListBox.h"
#include "settings/SourceGroupSettingsCxx.h"
QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window, bool indicateAsAdditional)
QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(std::shared_ptr<SourceGroupSettingsCxx> settings, QtProjectWizzardWindow* window, bool indicateAsAdditional)
: QtProjectWizzardContent(window)
, m_settings(settings)
, m_indicateAsAdditional(indicateAsAdditional)
@@ -35,20 +35,12 @@ void QtProjectWizzardContentFlags::populate(QGridLayout* layout, int& row)
void QtProjectWizzardContentFlags::load()
{
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
if (cxxSettings)
{
m_list->setStrings(cxxSettings->getCompilerFlags());
}
m_list->setStrings(m_settings->getCompilerFlags());
}
void QtProjectWizzardContentFlags::save()
{
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
if (cxxSettings)
{
cxxSettings->setCompilerFlags(m_list->getStrings());
}
m_settings->setCompilerFlags(m_list->getStrings());
}
bool QtProjectWizzardContentFlags::check()
@@ -4,7 +4,7 @@
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QtStringListBox;
class SourceGroupSettings;
class SourceGroupSettingsCxx;
class QtProjectWizzardContentFlags
: public QtProjectWizzardContent
@@ -12,7 +12,7 @@ class QtProjectWizzardContentFlags
Q_OBJECT
public:
QtProjectWizzardContentFlags(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window, bool indicateAsAdditional = false);
QtProjectWizzardContentFlags(std::shared_ptr<SourceGroupSettingsCxx> settings, QtProjectWizzardWindow* window, bool indicateAsAdditional = false);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
@@ -22,7 +22,7 @@ public:
virtual bool check() override;
private:
std::shared_ptr<SourceGroupSettings> m_settings;
std::shared_ptr<SourceGroupSettingsCxx> m_settings;
const bool m_indicateAsAdditional;
QtStringListBox* m_list;
@@ -8,6 +8,11 @@
#include "data/indexer/IndexerCommandCxxCdb.h"
#include "project/SourceGroupCxxCdb.h"
#include "project/SourceGroupCxxCodeblocks.h"
#include "project/SourceGroupCxxSonargraph.h"
#include "project/SourceGroupJavaSonargraph.h"
#include "project/SourceGroupJavaGradle.h"
#include "project/SourceGroupJavaMaven.h"
#include "qt/element/QtLocationPicker.h"
#include "qt/view/QtDialogView.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
@@ -16,21 +21,20 @@
#include "settings/SourceGroupSettingsCxxSonargraph.h"
#include "settings/SourceGroupSettingsJavaMaven.h"
#include "settings/SourceGroupSettingsJavaGradle.h"
#include "settings/SourceGroupSettingsJavaSonargraph.h"
#include "settings/SourceGroupSettingsWithSonargraphProjectPath.h"
#include "settings/SourceGroupSettingsCxxCodeblocks.h"
#include "utility/file/FileManager.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/sonargraph/SonargraphProject.h"
#include "utility/codeblocks/CodeblocksProject.h"
#include "utility/ScopedFunctor.h"
#include "utility/utility.h"
#include "utility/utilityGradle.h"
#include "utility/utilityMaven.h"
#include "Application.h"
QtProjectWizzardContentPath::QtProjectWizzardContentPath(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window)
QtProjectWizzardContentPath::QtProjectWizzardContentPath(QtProjectWizzardWindow* window)
: QtProjectWizzardContent(window)
, m_settings(settings)
, m_makePathRelativeToProjectFileLocation(true)
{
}
@@ -50,7 +54,7 @@ void QtProjectWizzardContentPath::populate(QGridLayout* layout, int& row)
if (m_makePathRelativeToProjectFileLocation)
{
m_picker->setRelativeRootDirectory(m_settings->getProjectDirectoryPath());
m_picker->setRelativeRootDirectory(getSourceGroupSettings()->getProjectDirectoryPath());
}
layout->addWidget(m_picker, row, QtProjectWizzardWindow::BACK_COL);
@@ -69,7 +73,7 @@ bool QtProjectWizzardContentPath::check()
break;
}
FilePath path = m_settings->makePathExpandedAndAbsolute(FilePath(m_picker->getText().toStdWString()));
FilePath path = getSourceGroupSettings()->makePathExpandedAndAbsolute(FilePath(m_picker->getText().toStdWString()));
if (m_picker->pickDirectory())
{
@@ -119,9 +123,10 @@ void QtProjectWizzardContentPath::setFileEndings(const std::set<std::wstring>& f
QtProjectWizzardContentPathCDB::QtProjectWizzardContentPathCDB(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
std::shared_ptr<SourceGroupSettingsCxxCdb> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
: QtProjectWizzardContentPath(window)
, m_settings(settings)
{
setTitleString("Compilation Database (compile_commands.json)");
setHelpString(
@@ -164,39 +169,30 @@ void QtProjectWizzardContentPathCDB::populate(QGridLayout* layout, int& row)
void QtProjectWizzardContentPathCDB::load()
{
m_picker->setText(QString::fromStdWString(m_settings->getCompilationDatabasePath().wstr()));
m_filePaths.clear();
const FilePath projectPath = m_settings->getProjectDirectoryPath();
if (std::shared_ptr<SourceGroupSettingsCxxCdb> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings))
for (FilePath path : SourceGroupCxxCdb(m_settings).getAllSourceFilePaths())
{
m_picker->setText(QString::fromStdWString(cxxSettings->getCompilationDatabasePath().wstr()));
for (FilePath path : SourceGroupCxxCdb(cxxSettings).getAllSourceFilePaths())
if (projectPath.exists())
{
if (projectPath.exists())
{
path.makeRelativeTo(projectPath);
}
m_filePaths.push_back(path);
path.makeRelativeTo(projectPath);
}
if (m_fileCountLabel)
{
m_fileCountLabel->setText("<b>" + QString::number(m_filePaths.size()) + "</b> source files were found in the compilation database.");
}
m_filePaths.push_back(path);
}
if (m_fileCountLabel)
{
m_fileCountLabel->setText("<b>" + QString::number(m_filePaths.size()) + "</b> source files were found in the compilation database.");
}
}
void QtProjectWizzardContentPathCDB::save()
{
std::shared_ptr<SourceGroupSettingsCxxCdb> settings =
std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings);
if (settings)
{
settings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdWString()));
}
m_settings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdWString()));
}
std::vector<FilePath> QtProjectWizzardContentPathCDB::getFilePaths() const
@@ -220,29 +216,32 @@ void QtProjectWizzardContentPathCDB::pickedPath()
{
m_window->saveContent();
if (std::shared_ptr<SourceGroupSettingsCxxCdb> cdbSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings))
{
const FilePath projectPath = m_settings->getProjectDirectoryPath();
const FilePath projectPath = m_settings->getProjectDirectoryPath();
std::set<FilePath> indexedHeaderPaths;
for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCDB(cdbSettings))
std::set<FilePath> indexedHeaderPaths;
for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCDB(m_settings))
{
if (projectPath.contains(path))
{
if (projectPath.contains(path))
{
indexedHeaderPaths.insert(path.getRelativeTo(projectPath));
}
indexedHeaderPaths.insert(path.getRelativeTo(projectPath));
}
cdbSettings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths));
}
m_settings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths));
m_window->loadContent();
}
std::shared_ptr<SourceGroupSettings> QtProjectWizzardContentPathCDB::getSourceGroupSettings()
{
return m_settings;
}
QtProjectWizzardContentCodeblocksProjectPath::QtProjectWizzardContentCodeblocksProjectPath(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
std::shared_ptr<SourceGroupSettingsCxxCodeblocks> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
: QtProjectWizzardContentPath(window)
, m_settings(settings)
{
setTitleString("Code::Blocks Project (.cbp)");
setHelpString(
@@ -284,40 +283,30 @@ void QtProjectWizzardContentCodeblocksProjectPath::populate(QGridLayout* layout,
void QtProjectWizzardContentCodeblocksProjectPath::load()
{
m_picker->setText(QString::fromStdWString(m_settings->getCodeblocksProjectPath().wstr()));
m_filePaths.clear();
std::shared_ptr<SourceGroupSettingsCxxCodeblocks> settings =
std::dynamic_pointer_cast<SourceGroupSettingsCxxCodeblocks>(m_settings);
if (settings)
const FilePath projectPath = m_settings->getProjectDirectoryPath();
for (FilePath path : SourceGroupCxxCodeblocks(m_settings).getAllSourceFilePaths())
{
m_picker->setText(QString::fromStdWString(settings->getCodeblocksProjectPath().wstr()));
const FilePath codeblocksProjectPath = settings->getCodeblocksProjectPathExpandedAndAbsolute();
if (!codeblocksProjectPath.empty() && codeblocksProjectPath.exists())
if (projectPath.exists())
{
if (std::shared_ptr<Codeblocks::Project> codeblocksProject = Codeblocks::Project::load(
codeblocksProjectPath
))
{
m_filePaths = utility::toVector(codeblocksProject->getAllSourceFilePathsCanonical(settings));
}
path.makeRelativeTo(projectPath);
}
if (m_fileCountLabel)
{
m_fileCountLabel->setText("<b>" + QString::number(m_filePaths.size()) + "</b> source files were found in the Code::Blocks project.");
}
m_filePaths.push_back(path);
}
if (m_fileCountLabel)
{
m_fileCountLabel->setText("<b>" + QString::number(m_filePaths.size()) + "</b> source files were found in the Code::Blocks project.");
}
}
void QtProjectWizzardContentCodeblocksProjectPath::save()
{
std::shared_ptr<SourceGroupSettingsCxxCodeblocks> settings =
std::dynamic_pointer_cast<SourceGroupSettingsCxxCodeblocks>(m_settings);
if (settings)
{
settings->setCodeblocksProjectPath(FilePath(m_picker->getText().toStdWString()));
}
m_settings->setCodeblocksProjectPath(FilePath(m_picker->getText().toStdWString()));
}
bool QtProjectWizzardContentCodeblocksProjectPath::check()
@@ -346,29 +335,37 @@ void QtProjectWizzardContentCodeblocksProjectPath::pickedPath()
{
m_window->saveContent();
if (std::shared_ptr<SourceGroupSettingsCxxCodeblocks> codeblocksSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCodeblocks>(m_settings))
{
const FilePath projectPath = m_settings->getProjectDirectoryPath();
const FilePath projectPath = m_settings->getProjectDirectoryPath();
std::set<FilePath> indexedHeaderPaths;
for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCodeblocksProject(codeblocksSettings))
std::set<FilePath> indexedHeaderPaths;
for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCodeblocksProject(m_settings))
{
if (projectPath.contains(path))
{
if (projectPath.contains(path))
{
indexedHeaderPaths.insert(path.getRelativeTo(projectPath));
}
indexedHeaderPaths.insert(path.getRelativeTo(projectPath));
}
codeblocksSettings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths));
}
m_settings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths));
m_window->loadContent();
}
std::shared_ptr<SourceGroupSettings> QtProjectWizzardContentCodeblocksProjectPath::getSourceGroupSettings()
{
return m_settings;
}
QtProjectWizzardContentSonargraphProjectPath::QtProjectWizzardContentSonargraphProjectPath(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
std::shared_ptr<SourceGroupSettings> settings,
std::shared_ptr<SourceGroupSettingsCxxSonargraph> settingsCxxSonargraph,
std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> settingsWithSonargraphProjectPath,
QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
: QtProjectWizzardContentPath(window)
, m_settings(settings)
, m_settingsCxxSonargraph(settingsCxxSonargraph)
, m_settingsWithSonargraphProjectPath(settingsWithSonargraphProjectPath)
{
setTitleString("Sonargraph Project (system.sonargraph)");
setHelpString(
@@ -410,65 +407,59 @@ void QtProjectWizzardContentSonargraphProjectPath::populate(QGridLayout* layout,
void QtProjectWizzardContentSonargraphProjectPath::load()
{
m_picker->setText(QString::fromStdWString(m_settingsWithSonargraphProjectPath->getSonargraphProjectPath().wstr()));
m_filePaths.clear();
std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> settings =
std::dynamic_pointer_cast<SourceGroupSettingsWithSonargraphProjectPath>(m_settings);
if (settings)
std::set<FilePath> allSourceFilePaths;
if (std::shared_ptr<SourceGroupSettingsCxxSonargraph> settings = std::dynamic_pointer_cast<SourceGroupSettingsCxxSonargraph>(m_settings))
{
m_picker->setText(QString::fromStdWString(settings->getSonargraphProjectPath().wstr()));
const FilePath sonargraphProjectPath = settings->getSonargraphProjectPathExpandedAndAbsolute();
if (!sonargraphProjectPath.empty() && sonargraphProjectPath.exists())
allSourceFilePaths = SourceGroupCxxSonargraph(settings).getAllSourceFilePaths();
}
else if (std::shared_ptr<SourceGroupSettingsJavaSonargraph> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaSonargraph>(m_settings))
{
allSourceFilePaths = SourceGroupJavaSonargraph(settings).getAllSourceFilePaths();
}
const FilePath projectPath = m_settings->getProjectDirectoryPath();
for (FilePath path : allSourceFilePaths)
{
if (projectPath.exists())
{
if (std::shared_ptr<Sonargraph::Project> sonargraphProject = Sonargraph::Project::load(
sonargraphProjectPath, m_settings->getLanguage()
))
{
m_filePaths = utility::toVector(sonargraphProject->getAllSourceFilePathsCanonical());
}
path.makeRelativeTo(projectPath);
}
m_filePaths.push_back(path);
}
if (m_fileCountLabel)
{
m_fileCountLabel->setText("<b>" + QString::number(m_filePaths.size()) + "</b> source files were found in the Sonargraph project.");
}
if (m_fileCountLabel)
{
m_fileCountLabel->setText("<b>" + QString::number(m_filePaths.size()) + "</b> source files were found in the Sonargraph project.");
}
}
void QtProjectWizzardContentSonargraphProjectPath::save()
{
std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> settings =
std::dynamic_pointer_cast<SourceGroupSettingsWithSonargraphProjectPath>(m_settings);
if (settings)
{
settings->setSonargraphProjectPath(FilePath(m_picker->getText().toStdWString()));
}
m_settingsWithSonargraphProjectPath->setSonargraphProjectPath(FilePath(m_picker->getText().toStdWString()));
}
bool QtProjectWizzardContentSonargraphProjectPath::check()
{
std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> settings =
std::dynamic_pointer_cast<SourceGroupSettingsWithSonargraphProjectPath>(m_settings);
if (settings)
if (std::shared_ptr<Sonargraph::Project> sonargraphProject = Sonargraph::Project::load(
m_settingsWithSonargraphProjectPath->getSonargraphProjectPathExpandedAndAbsolute(), m_settings->getLanguage()
))
{
if (std::shared_ptr<Sonargraph::Project> sonargraphProject = Sonargraph::Project::load(
settings->getSonargraphProjectPathExpandedAndAbsolute(), m_settings->getLanguage()
))
if (sonargraphProject->getLoadedModuleCount() == 0)
{
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;
}
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;
@@ -495,30 +486,34 @@ void QtProjectWizzardContentSonargraphProjectPath::pickedPath()
{
m_window->saveContent();
if (std::shared_ptr<SourceGroupSettingsCxxSonargraph> sonargraphSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxSonargraph>(m_settings))
if (m_settingsCxxSonargraph)
{
const FilePath projectPath = m_settings->getProjectDirectoryPath();
std::set<FilePath> indexedHeaderPaths;
for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromSonargraphProject(sonargraphSettings))
for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromSonargraphProject(m_settingsCxxSonargraph))
{
std::string asdasd = path.str();
if (projectPath.contains(path))
{
indexedHeaderPaths.insert(path.getRelativeTo(projectPath));
}
}
sonargraphSettings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths));
m_settingsCxxSonargraph->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths));
}
m_window->loadContent();
}
std::shared_ptr<SourceGroupSettings> QtProjectWizzardContentSonargraphProjectPath::getSourceGroupSettings()
{
return m_settings;
}
QtProjectWizzardContentPathSourceMaven::QtProjectWizzardContentPathSourceMaven(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
: QtProjectWizzardContentPath(window)
, m_settings(settings)
{
setTitleString("Maven Project File (pom.xml)");
setHelpString(
@@ -550,88 +545,77 @@ void QtProjectWizzardContentPathSourceMaven::populate(QGridLayout* layout, int&
void QtProjectWizzardContentPathSourceMaven::load()
{
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
if (settings)
{
m_picker->setText(QString::fromStdWString(settings->getMavenProjectFilePath().wstr()));
m_shouldIndexTests->setChecked(settings->getShouldIndexMavenTests());
}
m_picker->setText(QString::fromStdWString(m_settings->getMavenProjectFilePath().wstr()));
m_shouldIndexTests->setChecked(m_settings->getShouldIndexMavenTests());
}
void QtProjectWizzardContentPathSourceMaven::save()
{
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
if (settings)
{
settings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdWString()));
settings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked());
}
m_settings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdWString()));
m_settings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked());
}
std::vector<FilePath> QtProjectWizzardContentPathSourceMaven::getFilePaths() const
{
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
{
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
const FilePath mavenProjectRoot = m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory();
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
const FilePath mavenProjectRoot = 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<FilePath>();
}
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
ScopedFunctor scopedFunctor([&dialogView]() {
dialogView->hideUnknownProgressDialog();
});
std::dynamic_pointer_cast<QtDialogView>(dialogView)->setParentWindow(m_window);
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nGenerating Source Files");
const bool success = utility::mavenGenerateSources(mavenPath, mavenProjectRoot);
if (!success)
{
const std::wstring dialogMessage =
L"Sourcetrail was unable to locate Maven on this machine.\n"
"Please make sure to provide the correct Maven Path in the preferences.";
MessageStatus(dialogMessage, true, false).dispatch();
Application::getInstance()->handleDialog(dialogMessage);
return std::vector<FilePath>();
}
}
std::vector<FilePath> list;
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
ScopedFunctor scopedFunctor([&dialogView](){
dialogView->hideUnknownProgressDialog();
});
std::dynamic_pointer_cast<QtDialogView>(dialogView)->setParentWindow(m_window);
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nGenerating Source Files");
const bool success = utility::mavenGenerateSources(mavenPath, mavenProjectRoot);
if (!success)
const FilePath projectPath = m_settings->getProjectDirectoryPath();
for (FilePath path : SourceGroupJavaMaven(m_settings).getAllSourceFilePaths())
{
const std::wstring dialogMessage =
L"Sourcetrail was unable to locate Maven on this machine.\n"
"Please make sure to provide the correct Maven Path in the preferences.";
MessageStatus(dialogMessage, true, false).dispatch();
Application::getInstance()->handleDialog(dialogMessage);
}
else
{
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nFetching Source Directories");
const std::vector<FilePath> sourceDirectories = utility::mavenGetAllDirectoriesFromEffectivePom(
mavenPath,
mavenProjectRoot,
settings->getShouldIndexMavenTests()
);
FileManager fileManager;
fileManager.update(
sourceDirectories,
settings->getExcludeFiltersExpandedAndAbsolute(),
settings->getSourceExtensions()
);
const FilePath projectPath = m_settings->getProjectDirectoryPath();
for (FilePath path : fileManager.getAllSourceFilePaths())
if (projectPath.exists())
{
if (projectPath.exists())
{
path.makeRelativeTo(projectPath);
}
list.push_back(path);
path.makeRelativeTo(projectPath);
}
list.push_back(path);
}
return list;
}
std::shared_ptr<SourceGroupSettings> QtProjectWizzardContentPathSourceMaven::getSourceGroupSettings()
{
return m_settings;
}
QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDependenciesMaven(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
: QtProjectWizzardContentPath(window)
, m_settings(settings)
{
setTitleString("Intermediate Dependencies Directory");
setHelpString(
@@ -643,27 +627,25 @@ QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDepende
void QtProjectWizzardContentPathDependenciesMaven::load()
{
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
if (settings)
{
m_picker->setText(QString::fromStdWString(settings->getMavenDependenciesDirectory().wstr()));
}
m_picker->setText(QString::fromStdWString(m_settings->getMavenDependenciesDirectory().wstr()));
}
void QtProjectWizzardContentPathDependenciesMaven::save()
{
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
if (settings)
{
settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdWString()));
}
m_settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdWString()));
}
std::shared_ptr<SourceGroupSettings> QtProjectWizzardContentPathDependenciesMaven::getSourceGroupSettings()
{
return m_settings;
}
QtProjectWizzardContentPathSourceGradle::QtProjectWizzardContentPathSourceGradle(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
std::shared_ptr<SourceGroupSettingsJavaGradle> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
: QtProjectWizzardContentPath(window)
, m_settings(settings)
{
setTitleString("Gradle Project File (build.gradle)");
setHelpString(
@@ -695,74 +677,43 @@ void QtProjectWizzardContentPathSourceGradle::populate(QGridLayout* layout, int&
void QtProjectWizzardContentPathSourceGradle::load()
{
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
if (settings)
{
m_picker->setText(QString::fromStdWString(settings->getGradleProjectFilePath().wstr()));
m_shouldIndexTests->setChecked(settings->getShouldIndexGradleTests());
}
m_picker->setText(QString::fromStdWString(m_settings->getGradleProjectFilePath().wstr()));
m_shouldIndexTests->setChecked(m_settings->getShouldIndexGradleTests());
}
void QtProjectWizzardContentPathSourceGradle::save()
{
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
if (settings)
{
settings->setGradleProjectFilePath(FilePath(m_picker->getText().toStdWString()));
settings->setShouldIndexGradleTests(m_shouldIndexTests->isChecked());
}
m_settings->setGradleProjectFilePath(FilePath(m_picker->getText().toStdWString()));
m_settings->setShouldIndexGradleTests(m_shouldIndexTests->isChecked());
}
std::vector<FilePath> QtProjectWizzardContentPathSourceGradle::getFilePaths() const
{
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
const FilePath gradleProjectRoot = settings->getGradleProjectFilePathExpandedAndAbsolute().getParentDirectory();
std::vector<FilePath> list;
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
ScopedFunctor scopedFunctor([&dialogView]() {
dialogView->hideUnknownProgressDialog();
});
std::dynamic_pointer_cast<QtDialogView>(dialogView)->setParentWindow(m_window);
const FilePath projectPath = m_settings->getProjectDirectoryPath();
for (FilePath path : SourceGroupJavaGradle(m_settings).getAllSourceFilePaths())
{
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Gradle\nFetching Source Directories");
const std::vector<FilePath> sourceDirectories = utility::gradleGetAllSourceDirectories(
gradleProjectRoot,
settings->getShouldIndexGradleTests()
);
FileManager fileManager;
fileManager.update(
sourceDirectories,
settings->getExcludeFiltersExpandedAndAbsolute(),
settings->getSourceExtensions()
);
const FilePath projectPath = settings->getProjectDirectoryPath();
for (FilePath path : fileManager.getAllSourceFilePaths())
if (projectPath.exists())
{
if (projectPath.exists())
{
path.makeRelativeTo(projectPath);
}
list.push_back(path);
path.makeRelativeTo(projectPath);
}
list.push_back(path);
}
return list;
}
std::shared_ptr<SourceGroupSettings> QtProjectWizzardContentPathSourceGradle::getSourceGroupSettings()
{
return m_settings;
}
QtProjectWizzardContentPathDependenciesGradle::QtProjectWizzardContentPathDependenciesGradle(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
std::shared_ptr<SourceGroupSettingsJavaGradle> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
: QtProjectWizzardContentPath(window)
, m_settings(settings)
{
setTitleString("Intermediate Dependencies Directory");
setHelpString(
@@ -774,18 +725,15 @@ QtProjectWizzardContentPathDependenciesGradle::QtProjectWizzardContentPathDepend
void QtProjectWizzardContentPathDependenciesGradle::load()
{
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
if (settings)
{
m_picker->setText(QString::fromStdWString(settings->getGradleDependenciesDirectory().wstr()));
}
m_picker->setText(QString::fromStdWString(m_settings->getGradleDependenciesDirectory().wstr()));
}
void QtProjectWizzardContentPathDependenciesGradle::save()
{
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
if (settings)
{
settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdWString()));
}
m_settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdWString()));
}
std::shared_ptr<SourceGroupSettings> QtProjectWizzardContentPathDependenciesGradle::getSourceGroupSettings()
{
return m_settings;
}
@@ -11,6 +11,12 @@ class QPushButton;
class QtLocationPicker;
class SourceGroupSettings;
class SourceGroupSettingsCxxCdb;
class SourceGroupSettingsCxxCodeblocks;
class SourceGroupSettingsCxxSonargraph;
class SourceGroupSettingsJavaGradle;
class SourceGroupSettingsJavaMaven;
class SourceGroupSettingsWithSonargraphProjectPath;
class QtProjectWizzardContentPath
: public QtProjectWizzardContent
@@ -18,7 +24,7 @@ class QtProjectWizzardContentPath
Q_OBJECT
public:
QtProjectWizzardContentPath(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentPath(QtProjectWizzardWindow* window);
// QtSettingsWindow implementation
virtual void populate(QGridLayout* layout, int& row) override;
@@ -31,13 +37,13 @@ protected:
void setFileEndings(const std::set<std::wstring>& fileEndings);
std::shared_ptr<SourceGroupSettings> m_settings;
QtLocationPicker* m_picker;
bool m_makePathRelativeToProjectFileLocation;
private:
virtual std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() = 0;
QString m_titleString;
QString m_helpString;
std::set<std::wstring> m_fileEndings;
@@ -50,22 +56,25 @@ class QtProjectWizzardContentPathCDB
Q_OBJECT
public:
QtProjectWizzardContentPathCDB(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentPathCDB(std::shared_ptr<SourceGroupSettingsCxxCdb> settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
void load() override;
void save() override;
virtual std::vector<FilePath> getFilePaths() const override;
virtual QString getFileNamesTitle() const override;
virtual QString getFileNamesDescription() const override;
std::vector<FilePath> getFilePaths() const override;
QString getFileNamesTitle() const override;
QString getFileNamesDescription() const override;
private slots:
void pickedPath();
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsCxxCdb> m_settings;
QLabel* m_fileCountLabel;
std::vector<FilePath> m_filePaths;
};
@@ -77,23 +86,28 @@ class QtProjectWizzardContentCodeblocksProjectPath
Q_OBJECT
public:
QtProjectWizzardContentCodeblocksProjectPath(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentCodeblocksProjectPath(
std::shared_ptr<SourceGroupSettingsCxxCodeblocks> settings,
QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
void load() override;
void save() override;
bool check() override;
virtual std::vector<FilePath> getFilePaths() const override;
virtual QString getFileNamesTitle() const override;
virtual QString getFileNamesDescription() const override;
std::vector<FilePath> getFilePaths() const override;
QString getFileNamesTitle() const override;
QString getFileNamesDescription() const override;
private slots:
void pickedPath();
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsCxxCodeblocks> m_settings;
QLabel* m_fileCountLabel;
std::vector<FilePath> m_filePaths;
};
@@ -105,23 +119,32 @@ class QtProjectWizzardContentSonargraphProjectPath
Q_OBJECT
public:
QtProjectWizzardContentSonargraphProjectPath(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentSonargraphProjectPath(
std::shared_ptr<SourceGroupSettings> settings,
std::shared_ptr<SourceGroupSettingsCxxSonargraph> settingsCxxSonargraph,
std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> settingsWithSonargraphProjectPath,
QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
void load() override;
void save() override;
bool check() override;
virtual std::vector<FilePath> getFilePaths() const override;
virtual QString getFileNamesTitle() const override;
virtual QString getFileNamesDescription() const override;
std::vector<FilePath> getFilePaths() const override;
QString getFileNamesTitle() const override;
QString getFileNamesDescription() const override;
private slots:
void pickedPath();
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettings> m_settings;
std::shared_ptr<SourceGroupSettingsCxxSonargraph> m_settingsCxxSonargraph;
std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> m_settingsWithSonargraphProjectPath;
QLabel* m_fileCountLabel;
std::vector<FilePath> m_filePaths;
};
@@ -132,17 +155,20 @@ class QtProjectWizzardContentPathSourceMaven
{
Q_OBJECT
public:
QtProjectWizzardContentPathSourceMaven(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentPathSourceMaven(std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
void load() override;
void save() override;
virtual std::vector<FilePath> getFilePaths() const override;
std::vector<FilePath> getFilePaths() const override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsJavaMaven> m_settings;
QCheckBox* m_shouldIndexTests;
};
@@ -152,11 +178,16 @@ class QtProjectWizzardContentPathDependenciesMaven
{
Q_OBJECT
public:
QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void load() override;
virtual void save() override;
void load() override;
void save() override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsJavaMaven> m_settings;
};
@@ -165,17 +196,20 @@ class QtProjectWizzardContentPathSourceGradle
{
Q_OBJECT
public:
QtProjectWizzardContentPathSourceGradle(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentPathSourceGradle(std::shared_ptr<SourceGroupSettingsJavaGradle> settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
void load() override;
void save() override;
virtual std::vector<FilePath> getFilePaths() const override;
std::vector<FilePath> getFilePaths() const override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsJavaGradle> m_settings;
QCheckBox* m_shouldIndexTests;
};
@@ -185,11 +219,16 @@ class QtProjectWizzardContentPathDependenciesGradle
{
Q_OBJECT
public:
QtProjectWizzardContentPathDependenciesGradle(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentPathDependenciesGradle(std::shared_ptr<SourceGroupSettingsJavaGradle> settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void load() override;
virtual void save() override;
void load() override;
void save() override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsJavaGradle> m_settings;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_PATH_H
@@ -6,18 +6,19 @@
#include <QMessageBox>
#include <QVBoxLayout>
#include "Application.h"
#include "component/view/DialogView.h"
#include "data/indexer/IndexerCommandCxxCdb.h"
#include "utility/IncludeDirective.h"
#include "utility/IncludeProcessing.h"
#include "project/SourceGroupCxxEmpty.h"
#include "project/SourceGroupJavaEmpty.h"
#include "qt/view/QtDialogView.h"
#include "qt/window/QtPathListDialog.h"
#include "qt/window/QtSelectPathsDialog.h"
#include "settings/ApplicationSettings.h"
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/SourceGroupSettingsCxxCdb.h"
#include "settings/SourceGroupSettingsCxxCodeblocks.h"
#include "settings/SourceGroupSettingsCxxSonargraph.h"
#include "settings/SourceGroupSettingsJavaEmpty.h"
#include "settings/SourceGroupSettingsWithClasspath.h"
#include "settings/SourceGroupSettingsWithIndexedHeaderPaths.h"
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
@@ -27,11 +28,14 @@
#include "utility/file/FileManager.h"
#include "utility/sonargraph/SonargraphProject.h"
#include "utility/CompilationDatabase.h"
#include "utility/IncludeDirective.h"
#include "utility/IncludeProcessing.h"
#include "utility/ScopedFunctor.h"
#include "utility/utility.h"
#include "utility/utilityFile.h"
#include "utility/utilityPathDetection.h"
#include "utility/utilityString.h"
#include "Application.h"
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(
std::shared_ptr<SourceGroupSettings> settings,
@@ -235,32 +239,29 @@ void QtProjectWizzardContentPathsSource::save()
std::vector<FilePath> QtProjectWizzardContentPathsSource::getFilePaths() const
{
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
ScopedFunctor scopedFunctor([&dialogView](){
dialogView->hideUnknownProgressDialog();
});
std::dynamic_pointer_cast<QtDialogView>(dialogView)->setParentWindow(m_window);
dialogView->showUnknownProgressDialog(L"Processing", L"Gathering Source Files");
std::shared_ptr<SourceGroupSettingsWithSourceExtensions> extensionSettings = std::dynamic_pointer_cast<SourceGroupSettingsWithSourceExtensions>(m_settings);
std::shared_ptr<SourceGroupSettingsWithSourcePaths> pathSettings = std::dynamic_pointer_cast<SourceGroupSettingsWithSourcePaths>(m_settings);
std::shared_ptr<SourceGroupSettingsWithExcludeFilters> excludeFilterSettings = std::dynamic_pointer_cast<SourceGroupSettingsWithExcludeFilters>(m_settings);
if (extensionSettings && pathSettings && excludeFilterSettings) // FIXME: pass msettings as required type
std::set<FilePath> allSourceFilePaths;
if (std::shared_ptr<SourceGroupSettingsCxx> settings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings))
{
FileManager fileManager;
fileManager.update(
pathSettings->getSourcePathsExpandedAndAbsolute(),
excludeFilterSettings->getExcludeFiltersExpandedAndAbsolute(),
extensionSettings->getSourceExtensions()
);
const std::set<FilePath> filePaths = fileManager.getAllSourceFilePathsRelative(m_settings->getProjectDirectoryPath());
return utility::toVector(filePaths);
allSourceFilePaths = SourceGroupCxxEmpty(settings).getAllSourceFilePaths();
}
return std::vector<FilePath>();
else if (std::shared_ptr<SourceGroupSettingsJavaEmpty> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaEmpty>(m_settings))
{
allSourceFilePaths = SourceGroupJavaEmpty(settings).getAllSourceFilePaths();
}
std::vector<FilePath> filePaths;
const FilePath projectPath = m_settings->getProjectDirectoryPath();
for (FilePath path : allSourceFilePaths)
{
if (projectPath.exists())
{
path.makeRelativeTo(projectPath);
}
filePaths.push_back(path);
}
return filePaths;
}
QString QtProjectWizzardContentPathsSource::getFileNamesTitle() const