ui: Extended project setup to support creation and editing of Source Groups (issue #230)

* Turned QtProjectWizzard into window for Source Group ui
* Clicking into FilePicker when empty will open dialog right away
* Fixed environment variable use throughout all Source Group path values
* Moved Preferences to QtPreferencesWindow

bug id = 230

fortune cookie message = Zwischen dir und deinen Freunden besteht echte Freundschaft.
This commit is contained in:
Eberhard Graether
2017-05-29 17:08:28 +02:00
parent 13f7acbb70
commit 9256618f7c
53 changed files with 1666 additions and 1220 deletions
@@ -6,14 +6,15 @@
#include <QMessageBox>
#include <QVBoxLayout>
#include "Application.h"
#include "component/view/DialogView.h"
#include "qt/element/QtLocationPicker.h"
#include "settings/ApplicationSettings.h"
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/SourceGroupSettingsJava.h"
#include "utility/file/FileManager.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/utilityMaven.h"
#include "Application.h"
QtProjectWizzardContentPath::QtProjectWizzardContentPath(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(window)
@@ -46,10 +47,42 @@ void QtProjectWizzardContentPath::populate(QGridLayout* layout, int& row)
bool QtProjectWizzardContentPath::check()
{
if (m_picker->getText().isEmpty())
QString error;
while (true)
{
if (m_picker->getText().isEmpty())
{
error = "Please define a path at \"" + m_titleString + "\".";
break;
}
FilePath path = m_settings->makePathExpandedAndAbsolute(FilePath(m_picker->getText().toStdString()));
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.size())
{
QMessageBox msgBox;
msgBox.setText("Please define the location for the \"" + m_titleString + "\".");
msgBox.setText(error);
msgBox.exec();
return false;
}
@@ -67,17 +100,82 @@ void QtProjectWizzardContentPath::setHelpString(const QString& help)
m_helpString = help;
}
void QtProjectWizzardContentPath::setFileEndings(const std::set<std::string>& fileEndings)
{
m_fileEndings = fileEndings;
}
QtProjectWizzardContentPathCDB::QtProjectWizzardContentPathCDB(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
{
setTitleString("Compilation Database (compile_commands.json)");
setHelpString(
"Sourcetrail will use all include paths and compiler flags from the compilation database and stay up-to-date "
"with changes on refresh.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
setFileEndings({ ".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, SIGNAL(locationPicked()), this, SLOT(pickedCDBPath()));
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++;
}
void QtProjectWizzardContentPathCDB::load()
{
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings =
std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
if (cxxSettings)
{
m_picker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
}
}
void QtProjectWizzardContentPathCDB::save()
{
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings =
std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
if (cxxSettings)
{
cxxSettings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdString()));
}
}
void QtProjectWizzardContentPathCDB::pickedCDBPath()
{
m_window->saveContent();
m_window->loadContent();
}
QtProjectWizzardContentPathSourceMaven::QtProjectWizzardContentPathSourceMaven(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
{
setTitleString("Maven Project File");
setTitleString("Maven Project File (pom.xml)");
setHelpString(
"Enter the path to the main .pom file of your Maven project.<br />"
"Enter the path to the main pom.xml file of your Maven project.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
setFileEndings({ ".xml" });
}
void QtProjectWizzardContentPathSourceMaven::populate(QGridLayout* layout, int& row)
@@ -124,7 +222,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
const FilePath mavenProjectRoot = javaSettings->getAbsoluteMavenProjectFilePath().parentDirectory();
const FilePath mavenProjectRoot = javaSettings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
std::vector<std::string> list;
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
@@ -153,7 +251,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
FileManager fileManager;
fileManager.update(
sourceDirectories,
m_settings->getAbsoluteExcludePaths(),
m_settings->getExcludePathsExpandedAndAbsolute(),
m_settings->getSourceExtensions()
);
@@ -174,6 +272,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
return list;
}
QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDependenciesMaven(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
)