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
+10 -2
View File
@@ -156,24 +156,30 @@ add_files(
qt/window/project_wizzard/QtProjectWizzardContent.h
qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp
qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h
qt/window/project_wizzard/QtProjectWizzardContentData.cpp
qt/window/project_wizzard/QtProjectWizzardContentData.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/QtProjectWizzardContentLanguageAndStandard.cpp
qt/window/project_wizzard/QtProjectWizzardContentLanguageAndStandard.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/QtProjectWizzardContentSimple.cpp
qt/window/project_wizzard/QtProjectWizzardContentSimple.h
qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.cpp
qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h
qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp
qt/window/project_wizzard/QtProjectWizzardContentSummary.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
@@ -193,6 +199,8 @@ add_files(
qt/window/QtLicense.h
qt/window/QtMainWindow.cpp
qt/window/QtMainWindow.h
qt/window/QtPreferencesWindow.cpp
qt/window/QtPreferencesWindow.h
qt/window/QtSelectPathsDialog.cpp
qt/window/QtSelectPathsDialog.h
qt/window/QtSplashScreen.cpp
@@ -26,6 +26,7 @@ QtLocationPicker::QtLocationPicker(QWidget *parent)
m_data->setAttribute(Qt::WA_MacShowFocusRect, 0);
m_data->setObjectName("locationField");
layout->addWidget(m_data);
connect(m_data, SIGNAL(focus()), this, SLOT(handleFocus()));
m_button = new QtIconButton(
(ResourcePaths::getGuiPath().str() + "window/dots.png").c_str(),
@@ -68,6 +69,11 @@ void QtLocationPicker::clearText()
m_data->clear();
}
bool QtLocationPicker::pickDirectory() const
{
return m_pickDirectory;
}
void QtLocationPicker::setPickDirectory(bool pickDirectory)
{
m_pickDirectory = pickDirectory;
@@ -119,3 +125,11 @@ void QtLocationPicker::handleButtonPress()
emit locationPicked();
}
}
void QtLocationPicker::handleFocus()
{
if (!m_data->text().size())
{
handleButtonPress();
}
}
@@ -21,7 +21,9 @@ public:
void setText(QString text);
void clearText();
bool pickDirectory() const;
void setPickDirectory(bool pickDirectory);
void setFileFilter(const QString& fileFilter);
void setRelativeRootDirectory(const FilePath& dir);
@@ -34,6 +36,7 @@ protected:
private slots:
void handleButtonPress();
void handleFocus();
private:
QPushButton* m_button;
+54 -73
View File
@@ -3,15 +3,6 @@
#include "qt/window/QtMainWindow.h"
QtMainView::QtMainView()
: m_editProjectFunctor(std::bind(&QtMainView::doEditProject, this))
, m_createNewProjectFromSolutionFunctor(std::bind(&QtMainView::doCreateNewProjectFromSolution, this, std::placeholders::_1, std::placeholders::_2))
, m_createNewProjectFromCDBFunctor(std::bind(&QtMainView::doCreateNewProjectFromCDB, this, std::placeholders::_1, std::placeholders::_2))
, m_showStartScreenFunctor(std::bind(&QtMainView::doShowStartScreen, this))
, m_hideStartScreenFunctor(std::bind(&QtMainView::doHideStartScreen, this))
, m_setTitleFunctor(std::bind(&QtMainView::doSetTitle, this, std::placeholders::_1))
, m_activateWindowFunctor(std::bind(&QtMainView::doActivateWindow, this))
, m_updateRecentProjectMenuFunctor(std::bind(&QtMainView::doUpdateRecentProjectMenu, this))
, m_forceLicenseScreenFunctor(std::bind(&QtMainView::doForceLicenseScreen, this, std::placeholders::_1))
{
m_window = std::make_shared<QtMainWindow>();
m_window->show();
@@ -86,22 +77,45 @@ void QtMainView::setStatusBar(QStatusBar* statusbar)
void QtMainView::hideStartScreen()
{
m_hideStartScreenFunctor();
m_onQtThread(
[=]()
{
m_window->hideStartScreen();
}
);
}
void QtMainView::setTitle(const std::string& title)
{
m_setTitleFunctor(title);
m_onQtThread(
[=]()
{
m_window->setWindowTitle(QString::fromStdString(title));
}
);
}
void QtMainView::activateWindow()
{
m_activateWindowFunctor();
m_onQtThread(
[=]()
{
// It's platform dependent which of these commands does the right thing, for now we just use them all at once.
m_window->setEnabled(true);
m_window->raise();
m_window->setFocus(Qt::ActiveWindowFocusReason);
}
);
}
void QtMainView::updateRecentProjectMenu()
{
m_updateRecentProjectMenuFunctor();
m_onQtThread(
[=]()
{
m_window->updateRecentProjectMenu();
}
);
}
void QtMainView::updateHistoryMenu(const std::vector<SearchMatch>& history)
@@ -116,78 +130,45 @@ void QtMainView::updateHistoryMenu(const std::vector<SearchMatch>& history)
void QtMainView::handleMessage(MessageForceEnterLicense* message)
{
m_forceLicenseScreenFunctor(message->licenseExpired);
bool expired = message->licenseExpired;
m_onQtThread(
[=]()
{
m_window->forceEnterLicense(expired);
}
);
}
void QtMainView::handleMessage(MessageProjectEdit* message)
{
m_editProjectFunctor();
m_onQtThread(
[=]()
{
m_window->editProject();
}
);
}
void QtMainView::handleMessage(MessageProjectNew* message)
{
if (message->ideId.size() != 0 && message->solutionPath.size() != 0)
{
if (message->fromCDB() == false)
std::string cdbPath = message->cdbPath;
std::vector<std::string> headerPaths = message->headerPaths;
m_onQtThread(
[=]()
{
m_createNewProjectFromSolutionFunctor(message->ideId, message->solutionPath);
m_window->newProjectFromCDB(cdbPath, headerPaths);
}
else
{
m_createNewProjectFromCDBFunctor(message->solutionPath, message->headerPaths);
}
}
);
}
void QtMainView::handleMessage(MessageShowStartScreen* message)
{
m_showStartScreenFunctor();
}
void QtMainView::doEditProject()
{
m_window->editProject();
}
void QtMainView::doCreateNewProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
{
m_window->newProjectFromSolution(ideId, solutionPath);
}
void QtMainView::doCreateNewProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths)
{
m_window->newProjectFromCDB(filePath, headerPaths);
}
void QtMainView::doShowStartScreen()
{
m_window->showStartScreen();
}
void QtMainView::doHideStartScreen()
{
m_window->hideStartScreen();
}
void QtMainView::doSetTitle(const std::string& title)
{
m_window->setWindowTitle(QString::fromStdString(title));
}
void QtMainView::doActivateWindow()
{
// It's platform dependent which of these commands does the right thing, for now we just use them all at once.
m_window->setEnabled(true);
m_window->raise();
m_window->setFocus(Qt::ActiveWindowFocusReason);
}
void QtMainView::doUpdateRecentProjectMenu()
{
m_window->updateRecentProjectMenu();
}
void QtMainView::doForceLicenseScreen(bool expired)
{
m_window->forceEnterLicense(expired);
m_onQtThread(
[=]()
{
m_window->showStartScreen();
}
);
}
-20
View File
@@ -57,29 +57,9 @@ private:
void handleMessage(MessageProjectNew* message);
void handleMessage(MessageShowStartScreen* message);
void doEditProject();
void doCreateNewProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
void doCreateNewProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths);
void doShowStartScreen();
void doHideStartScreen();
void doSetTitle(const std::string& title);
void doActivateWindow();
void doUpdateRecentProjectMenu();
void doForceLicenseScreen(bool expired);
std::shared_ptr<QtMainWindow> m_window;
std::vector<View*> m_views;
QtThreadedFunctor<> m_editProjectFunctor;
QtThreadedFunctor<const std::string&, const std::string&> m_createNewProjectFromSolutionFunctor;
QtThreadedFunctor<const std::string&, const std::vector<std::string>&> m_createNewProjectFromCDBFunctor;
QtThreadedFunctor<> m_showStartScreenFunctor;
QtThreadedFunctor<> m_hideStartScreenFunctor;
QtThreadedFunctor<const std::string&> m_setTitleFunctor;
QtThreadedFunctor<> m_activateWindowFunctor;
QtThreadedFunctor<> m_updateRecentProjectMenuFunctor;
QtThreadedFunctor<bool> m_forceLicenseScreenFunctor;
QtThreadedLambdaFunctor m_onQtThread;
};
+13 -14
View File
@@ -11,20 +11,21 @@
#include <QTimer>
#include "Application.h"
#include "component/view/View.h"
#include "component/controller/LogController.h"
#include "component/view/CompositeView.h"
#include "component/view/TabbedView.h"
#include "component/controller/LogController.h"
#include "component/view/View.h"
#include "LicenseChecker.h"
#include "qt/utility/QtContextMenu.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "qt/window/project_wizzard/QtProjectWizzard.h"
#include "qt/window/QtStartScreen.h"
#include "qt/window/QtAboutLicense.h"
#include "qt/window/QtAbout.h"
#include "qt/window/QtAboutLicense.h"
#include "qt/window/QtKeyboardShortcuts.h"
#include "qt/window/QtLicense.h"
#include "qt/window/QtPreferencesWindow.h"
#include "qt/window/QtStartScreen.h"
#include "settings/ApplicationSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
@@ -312,8 +313,8 @@ void QtMainWindow::about()
void QtMainWindow::openSettings()
{
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
wizzard->showPreferences();
QtPreferencesWindow* window = createWindow<QtPreferencesWindow>();
window->setup();
}
void QtMainWindow::showDocumentation()
@@ -421,17 +422,15 @@ void QtMainWindow::newProject()
wizzard->newProject();
}
void QtMainWindow::newProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
{
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
wizzard->newProjectFromSolution(ideId, FilePath(solutionPath));
}
void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths)
{
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
QtProjectWizzard* wizzard = dynamic_cast<QtProjectWizzard*>(m_windowStack.getTopWindow());
if (!wizzard)
{
wizzard = createWindow<QtProjectWizzard>();
}
std::vector<FilePath> headerFilePaths(headerPaths.size());
std::vector<FilePath> headerFilePaths;
for (const std::string& s: headerPaths)
{
headerFilePaths.push_back(FilePath(s));
-1
View File
@@ -94,7 +94,6 @@ public slots:
void hideStartScreen();
void newProject();
void newProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
void newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths);
void openProject();
void editProject();
@@ -0,0 +1,93 @@
#include "qt/window/QtPreferencesWindow.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessagePluginPortChange.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageScrollSpeedChange.h"
#include "Application.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
QtPreferencesWindow::QtPreferencesWindow(QWidget* parent)
: QtProjectWizzardWindow(parent)
{
// save old application settings so they can be compared later
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
m_appSettings.setHeaderSearchPaths(appSettings->getHeaderSearchPaths());
m_appSettings.setFrameworkSearchPaths(appSettings->getFrameworkSearchPaths());
m_appSettings.setScrollSpeed(appSettings->getScrollSpeed());
m_appSettings.setSourcetrailPort(appSettings->getSourcetrailPort());
m_appSettings.setPluginPort(appSettings->getPluginPort());
QtProjectWizzardContentSummary* summary = new QtProjectWizzardContentSummary(this);
summary->setIsForm(true);
summary->addContent(new QtProjectWizzardContentPreferences(this));
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(this));
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(this));
}
setPreferredSize(QSize(750, 500));
setContent(summary);
setScrollAble(content()->isScrollAble());
}
QtPreferencesWindow::~QtPreferencesWindow()
{
}
void QtPreferencesWindow::windowReady()
{
QtProjectWizzardWindow::windowReady();
updateTitle("PREFERENCES");
updateNextButton("Save");
setPreviousVisible(false);
loadContent();
}
void QtPreferencesWindow::handleNext()
{
if (!content()->check())
{
return;
}
saveContent();
bool appSettingsChanged = !(m_appSettings == *ApplicationSettings::getInstance().get());
if (m_appSettings.getScrollSpeed() != ApplicationSettings::getInstance()->getScrollSpeed())
{
MessageScrollSpeedChange(ApplicationSettings::getInstance()->getScrollSpeed()).dispatch();
}
if (m_appSettings.getSourcetrailPort() != ApplicationSettings::getInstance()->getSourcetrailPort() ||
m_appSettings.getPluginPort() != ApplicationSettings::getInstance()->getPluginPort())
{
MessagePluginPortChange().dispatch();
}
Application::getInstance()->loadSettings();
if (appSettingsChanged)
{
Project* currentProject = Application::getInstance()->getCurrentProject().get();
if (currentProject)
{
MessageLoadProject(currentProject->getProjectSettingsFilePath(), true).dispatch();
}
}
else
{
MessageRefresh().refreshUiOnly().dispatch();
}
QtWindow::handleNext();
}
@@ -0,0 +1,25 @@
#ifndef QT_PREFERENCES_WINDOW_H
#define QT_PREFERENCES_WINDOW_H
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include "settings/ApplicationSettings.h"
class QtPreferencesWindow
: public QtProjectWizzardWindow
{
Q_OBJECT
public:
QtPreferencesWindow(QWidget* parent = 0);
virtual ~QtPreferencesWindow();
protected:
virtual void windowReady() override;
virtual void handleNext() override;
private:
ApplicationSettings m_appSettings;
};
#endif // QT_PREFERENCES_WINDOW_H
@@ -1,5 +1,7 @@
#include "qt/window/QtSelectPathsDialog.h"
#include <set>
#include <QLabel>
#include <QListWidget>
#include <QPushButton>
@@ -28,12 +30,14 @@ std::vector<FilePath> QtSelectPathsDialog::getPathsList() const
void QtSelectPathsDialog::setPathsList(const std::vector<FilePath>& paths, const std::vector<FilePath>& checkedPaths)
{
std::set<FilePath> checked(checkedPaths.begin(), checkedPaths.end());
for (FilePath s : paths)
{
QListWidgetItem* item = new QListWidgetItem(s.str().c_str(), m_list);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
if (std::find(checkedPaths.begin(), checkedPaths.end(), s) == checkedPaths.end())
if (checked.find(s) == checked.end())
{
item->setCheckState(Qt::Unchecked); // AND initialize check state
}
+8
View File
@@ -186,6 +186,14 @@ void QtWindow::updateNextButton(QString text)
}
}
void QtWindow::updatePreviousButton(QString text)
{
if (m_previousButton)
{
m_previousButton->setText(text);
}
}
void QtWindow::updateCloseButton(QString text)
{
if (m_closeButton)
+1
View File
@@ -35,6 +35,7 @@ public:
void updateSubTitle(QString subTitle);
void updateNextButton(QString text);
void updatePreviousButton(QString text);
void updateCloseButton(QString text);
void setNextEnabled(bool enabled);
File diff suppressed because it is too large Load Diff
@@ -3,41 +3,41 @@
#include <QWidget>
#include "qt/window/QtWindowStack.h"
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include "qt/window/QtWindow.h"
#include "settings/ApplicationSettings.h"
#include "settings/ProjectSettings.h"
class QListWidget;
class QPushButton;
class QtProjectWizzardContent;
class QtProjectWizzardContentSummary;
class QtProjectWizzardWindow;
class QtProjectWizzard
: public QtWindowStackElement
: public QtProjectWizzardWindow
{
Q_OBJECT
signals:
void finished();
void canceled();
public:
QtProjectWizzard(QWidget* parent = nullptr);
// QtWindowStackElement implementation
virtual void showWindow() override;
virtual void hideWindow() override;
virtual QSize sizeHint() const override;
public slots:
void newProject();
void newProjectFromSolution(const std::string& ideId, const FilePath& solutionPath);
void newProjectFromCDB(const FilePath& filePath, const std::vector<FilePath>& headerPaths);
void refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
void editProject(const FilePath& settingsPath);
void editProject(std::shared_ptr<ProjectSettings> settings);
void showPreferences();
protected:
virtual void populateWindow(QWidget* widget) override;
virtual void windowReady() override;
virtual void handlePrevious() override;
private:
static bool applicationSettingsContainVisualStudioHeaderSearchPaths();
@@ -48,26 +48,44 @@ private:
QtProjectWizzardWindow* createWindowWithSummary(
std::function<void(QtProjectWizzardWindow*, QtProjectWizzardContentSummary*)> func);
void updateSourceGroupList();
bool canExitContent();
QtWindowStack m_windowStack;
std::shared_ptr<ProjectSettings> m_projectSettings;
std::shared_ptr<SourceGroupSettings> m_sourceGroupSettings;
std::vector<std::shared_ptr<SourceGroupSettings>> m_allSourceGroupSettings;
std::shared_ptr<SourceGroupSettings> m_newSourceGroupSettings;
ApplicationSettings m_appSettings;
bool m_editing;
QPushButton* m_generalButton;
QPushButton* m_removeButton;
QPushButton* m_duplicateButton;
QListWidget* m_sourceGroupList;
QWidget* m_contentWidget;
private slots:
void generalButtonClicked();
void selectedSourceGroupChanged(int index);
void selectedSourceGroupNameChanged(QString name);
void removeSelectedSourceGroup();
void duplicateSelectedSourceGroup();
void cancelSourceGroup();
void cancelWizzard();
void finishWizzard();
void windowStackChanged();
void newSourceGroup();
void selectedProjectType(SourceGroupType sourceGroupType);
void emptyProject();
void emptyProjectCDBVS();
void emptyProjectCDB();
void emptyProjectJavaMaven();
void emptySourceGroup();
void emptySourceGroupCDBVS();
void emptySourceGroupCDB();
void sourcePaths();
void headerSearchPaths();
@@ -75,19 +93,14 @@ private slots:
void headerSearchPathsDone();
void frameworkSearchPaths();
void headerPathsCDB();
void sourcePathsJava();
void sourcePathsJavaMaven();
void advancedSettingsCxx();
void advancedSettingsJava();
void showSummary();
void showSummaryJava();
void createSourceGroup();
void createProject();
void savePreferences();
};
#endif // QT_PROJECT_WIZZARD_H
@@ -67,7 +67,7 @@ void QtProjectWizzardContent::setIsInForm(bool isInForm)
QLabel* QtProjectWizzardContent::createFormLabel(QString name) const
{
QLabel* label = new QLabel(name);
label->setAlignment(Qt::AlignRight);
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
label->setObjectName("label");
label->setWordWrap(true);
return label;
@@ -81,10 +81,10 @@ QLabel* QtProjectWizzardContent::createFormTitle(QString name) const
return label;
}
QToolButton* QtProjectWizzardContent::createProjectButton(QString name, QString iconPath) const
QToolButton* QtProjectWizzardContent::createSourceGroupButton(QString name, QString iconPath) const
{
QToolButton* button = new QToolButton();
button->setObjectName("projectButton");
button->setObjectName("sourceGroupButton");
button->setText(name);
button->setIcon(QPixmap(iconPath));
button->setIconSize(QSize(64, 64));
@@ -104,6 +104,7 @@ QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout*
{
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);
@@ -113,6 +114,19 @@ QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout*
return button;
}
QFrame* QtProjectWizzardContent::addSeparator(QGridLayout* layout, int row) const
{
QFrame* separator = new QFrame();
separator->setFrameShape(QFrame::HLine);
QPalette palette = separator->palette();
palette.setColor(QPalette::WindowText, Qt::lightGray);
separator->setPalette(palette);
layout->addWidget(separator, row, 0, 1, -1);
return separator;
}
void QtProjectWizzardContent::filesButtonClicked()
{
m_window->saveContent();
@@ -39,10 +39,11 @@ public:
protected:
QLabel* createFormLabel(QString name) const;
QLabel* createFormTitle(QString name) const;
QToolButton* createProjectButton(QString name, QString iconPath) const;
QToolButton* createSourceGroupButton(QString name, QString iconPath) const;
QtHelpButton* addHelpButton(QString helpString, QGridLayout* layout, int row) const;
QPushButton* addFilesButton(QString name, QGridLayout* layout, int row) const;
QFrame* addSeparator(QGridLayout* layout, int row) const;
QtProjectWizzardWindow* m_window;
@@ -20,6 +20,7 @@ void QtProjectWizzardContentCDBSource::populate(QGridLayout* layout, int& row)
layout->setRowStretch(row, 0);
m_text = new QLabel("");
m_text->setWordWrap(true);
layout->addWidget(m_text, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignTop);
addFilesButton("show source files", layout, row + 1);
@@ -32,42 +33,47 @@ void QtProjectWizzardContentCDBSource::load()
m_fileNames.clear();
const FilePath projectPath = m_settings->getProjectFileLocation();
std::vector<FilePath> excludePaths = m_settings->getAbsoluteExcludePaths();
std::vector<FilePath> excludePaths = m_settings->getExcludePathsExpandedAndAbsolute();
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
if (cxxSettings)
{
std::vector<FilePath> filePaths =
IndexerCommandCxxCdb::getSourceFilesFromCDB(cxxSettings->getAbsoluteCompilationDatabasePath());
for (FilePath path : filePaths)
FilePath cdbPath = cxxSettings->getCompilationDatabasePathExpandedAndAbsolute();
if (!cdbPath.empty() && cdbPath.exists())
{
bool excluded = false;
for (FilePath p : excludePaths)
std::vector<FilePath> filePaths =
IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath);
for (FilePath path : filePaths)
{
if (p == path || p.contains(path))
bool excluded = false;
for (FilePath p : excludePaths)
{
excluded = true;
break;
if (p == path || p.contains(path))
{
excluded = true;
break;
}
}
}
if (excluded)
{
continue;
}
if (excluded)
{
continue;
}
if (projectPath.exists())
{
path = path.relativeTo(projectPath);
}
if (projectPath.exists())
{
path = path.relativeTo(projectPath);
}
m_fileNames.push_back(path.str());
m_fileNames.push_back(path.str());
}
}
}
if (m_text)
{
m_text->setText(QString::number(m_fileNames.size()) + " source files were found in the compilation database.");
m_text->setText("<b>" + QString::number(m_fileNames.size()) + "</b> source files were found in the compilation database.");
}
}
@@ -1,373 +0,0 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentData.h"
#include <QFormLayout>
#include <QMessageBox>
#include "settings/SourceGroupSettingsCxx.h"
#include "utility/messaging/type/MessageIDECreateCDB.h"
#include "utility/logging/logging.h"
QtProjectWizzardContentData::QtProjectWizzardContentData(
std::shared_ptr<ProjectSettings> projectSettings,
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window,
bool disableNameEditing
)
: QtProjectWizzardContent(window)
, m_projectSettings(projectSettings)
, m_sourceGroupSettings(sourceGroupSettings)
, m_disableNameEditing(disableNameEditing)
, m_projectName(nullptr)
, m_projectFileLocation(nullptr)
, m_language(nullptr)
, m_standard(nullptr)
, m_buildFilePicker(nullptr)
{
}
void QtProjectWizzardContentData::populate(QGridLayout* layout, int& row)
{
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
row++;
}
addNameAndLocation(layout, row);
if (!isInForm())
{
layout->setRowMinimumHeight(row++, 20);
}
addLanguageAndStandard(layout, row);
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
layout->setRowStretch(row, 1);
}
}
void QtProjectWizzardContentData::load()
{
if (m_projectName)
{
m_projectName->setText(QString::fromStdString(m_projectSettings->getProjectName()));
m_projectFileLocation->setText(QString::fromStdString(m_projectSettings->getProjectFileLocation().str()));
}
if (m_language)
{
LanguageType type = getLanguageTypeForSourceGroupType(m_sourceGroupSettings->getType());
if (type == LANGUAGE_UNKNOWN)
{
LOG_ERROR("No language type defined");
return;
}
m_language->setText(languageTypeToString(type).c_str());
m_standard->clear();
std::vector<std::string> standards = m_sourceGroupSettings->getAvailableLanguageStandards();
for (size_t i = 0; i < standards.size(); i++)
{
m_standard->insertItem(i, standards[i].c_str());
}
m_standard->setCurrentText(QString::fromStdString(m_sourceGroupSettings->getStandard()));
}
}
void QtProjectWizzardContentData::save()
{
if (m_projectName)
{
m_projectSettings->setProjectName(m_projectName->text().toStdString());
m_projectSettings->setProjectFileLocation(FilePath(m_projectFileLocation->getText().toStdString()));
}
if (m_standard)
{
m_sourceGroupSettings->setStandard(m_standard->currentText().toStdString());
}
}
bool QtProjectWizzardContentData::check()
{
if (!m_projectName)
{
return true;
}
if (m_projectName->text().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please enter a project name.");
msgBox.exec();
return false;
}
if (m_projectFileLocation->getText().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please define the location for the Sourcetrail project file.");
msgBox.exec();
return false;
}
std::vector<FilePath> paths = FilePath(m_projectFileLocation->getText().toStdString()).expandEnvironmentVariables();
if (paths.size() != 1 || !paths[0].exists())
{
QMessageBox msgBox;
msgBox.setText("The specified location does not exist.");
msgBox.exec();
return false;
}
return true;
}
void QtProjectWizzardContentData::addNameAndLocation(QGridLayout* layout, int& row)
{
QLabel* nameLabel = createFormLabel("Sourcetrail Project Name");
m_projectName = new QLineEdit();
m_projectName->setObjectName("name");
m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0);
m_projectName->setEnabled(!m_disableNameEditing);
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_projectName, row, QtProjectWizzardWindow::BACK_COL);
layout->setRowMinimumHeight(row, 30);
row++;
QLabel* locationLabel = createFormLabel("Sourcetrail Project Location");
m_projectFileLocation = new QtLocationPicker(this);
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);
addHelpButton("The directory where Sourcetrail project files will be saved to.", layout, row);
layout->setRowMinimumHeight(row, 30);
row++;
}
void QtProjectWizzardContentData::addLanguageAndStandard(QGridLayout* layout, int& row)
{
m_language = new QLabel();
layout->addWidget(createFormLabel("Language"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_language, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
m_standard = new QComboBox();
layout->addWidget(createFormLabel("Standard"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_standard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
}
void QtProjectWizzardContentData::addBuildFilePicker(
QGridLayout* layout, int& row, const QString& name, const QString& filter)
{
QLabel* label = createFormLabel(name);
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL);
m_buildFilePicker = new QtLocationPicker(this);
m_buildFilePicker->setFileFilter(filter);
connect(m_buildFilePicker, SIGNAL(locationPicked()), this, SLOT(pickedCDBPath()));
layout->addWidget(m_buildFilePicker, row, QtProjectWizzardWindow::BACK_COL);
row++;
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++;
}
QtProjectWizzardContentDataCDB::QtProjectWizzardContentDataCDB(
std::shared_ptr<ProjectSettings> projectSettings,
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window,
bool disableNameEditing
)
: QtProjectWizzardContentData(projectSettings, sourceGroupSettings, window, disableNameEditing)
{
}
void QtProjectWizzardContentDataCDB::populate(QGridLayout* layout, int& row)
{
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
row++;
}
addNameAndLocation(layout, row);
layout->setRowMinimumHeight(row++, 20);
QString name = "Compilation Database (compile_commands.json)";
QString filter = "JSON Compilation Database (*.json)";
addBuildFilePicker(layout, row, name, filter);
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
layout->setRowStretch(row, 1);
}
}
void QtProjectWizzardContentDataCDB::load()
{
QtProjectWizzardContentData::load();
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings);
if (cxxSettings)
{
m_buildFilePicker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
}
}
void QtProjectWizzardContentDataCDB::save()
{
QtProjectWizzardContentData::save();
FilePath path(m_buildFilePicker->getText().toStdString());
FilePath absPath = m_projectSettings->makePathAbsolute(m_projectSettings->expandPath(path)); // maybe we can use SourceGroupSettings for this... that's where the the cdb path is stored.
if (!absPath.exists() || absPath.extension() != ".json")
{
return;
}
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings);
if (cxxSettings)
{
cxxSettings->setCompilationDatabasePath(path);
}
}
bool QtProjectWizzardContentDataCDB::check()
{
if (!QtProjectWizzardContentData::check())
{
return false;
}
FilePath path(m_buildFilePicker->getText().toStdString());
FilePath absPath = m_projectSettings->makePathAbsolute(m_projectSettings->expandPath(path));
if (!absPath.exists() || absPath.extension() != ".json")
{
QMessageBox msgBox;
msgBox.setText("Please enter a valid compilation database file (*.json).");
msgBox.exec();
return false;
}
return true;
}
void QtProjectWizzardContentDataCDB::pickedCDBPath()
{
FilePath projectPath = m_projectSettings->getProjectFileLocation();
if (m_projectFileLocation)
{
projectPath = FilePath(m_projectFileLocation->getText().toStdString());
}
FilePath cdbPath(m_buildFilePicker->getText().toStdString());
if (!projectPath.empty() && !cdbPath.empty())
{
FilePath relPath(cdbPath.relativeTo(projectPath));
if (relPath.str().size() < cdbPath.str().size())
{
m_buildFilePicker->setText(relPath.str().c_str());
}
}
m_window->saveContent();
m_window->loadContent();
}
QtProjectWizzardContentDataCDBVS::QtProjectWizzardContentDataCDBVS(
std::shared_ptr<ProjectSettings> projectSettings,
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window
)
: QtProjectWizzardContentDataCDB(projectSettings, sourceGroupSettings, window, false)
{
}
void QtProjectWizzardContentDataCDBVS::populate(QGridLayout* layout, int& row)
{
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
row++;
}
QLabel* nameLabel = createFormLabel("Create Compilation Database");
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL);
addHelpButton("To create a new Compilation Database from a Visual Studio Solution, this Solution has to be open in Visual Studio.\n\
Sourcetrail will call Visual Studio to open the 'Create Compilation Database' dialog.\
Please follow the instructions in Visual Studio to complete the process.\n\
Note: Sourcetrail's Visual Studio plugin has to be installed. Visual Studio has to be running with an eligible Solution, containing C/C++ projects, loaded.", layout, row);
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);
row++;
QPushButton* button = new QPushButton("Create CDB");
button->setObjectName("windowButton");
layout->addWidget(button, row, QtProjectWizzardWindow::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);
row++;
QFrame* separator = new QFrame();
separator->setFrameShape(QFrame::HLine);
QPalette palette = separator->palette();
palette.setColor(QPalette::WindowText, Qt::lightGray);
separator->setPalette(palette);
layout->addWidget(separator, row++, 0, 1, -1);
connect(button, SIGNAL(clicked()), this, SLOT(handleVSCDBClicked()));
addNameAndLocation(layout, row);
layout->setRowMinimumHeight(row++, 20);
QString name = "Compilation Database";
QString filter = "JSON Compilation Database (*.json)";
addBuildFilePicker(layout, row, name, filter);
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
layout->setRowStretch(row, 1);
}
}
void QtProjectWizzardContentDataCDBVS::handleVSCDBClicked()
{
MessageIDECreateCDB().dispatch();
}
@@ -1,91 +0,0 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_DATA_H
#define QT_PROJECT_WIZZARD_CONTENT_DATA_H
#include <QComboBox>
#include <QLabel>
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "qt/element/QtLocationPicker.h"
class ProjectSettings;
class SourceGroupSettings;
class QtProjectWizzardContentData
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentData(
std::shared_ptr<ProjectSettings> projectSettings,
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window,
bool disableNameEditing = false);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
protected:
virtual void addNameAndLocation(QGridLayout* layout, int& row);
virtual void addLanguageAndStandard(QGridLayout* layout, int& row);
virtual void addBuildFilePicker(QGridLayout* layout, int& row, const QString& name, const QString& filter);
std::shared_ptr<ProjectSettings> m_projectSettings;
std::shared_ptr<SourceGroupSettings> m_sourceGroupSettings;
bool m_disableNameEditing;
QLineEdit* m_projectName;
QtLocationPicker* m_projectFileLocation;
QLabel* m_language;
QComboBox* m_standard;
QtLocationPicker* m_buildFilePicker;
};
class QtProjectWizzardContentDataCDB
: public QtProjectWizzardContentData
{
Q_OBJECT
public:
QtProjectWizzardContentDataCDB(
std::shared_ptr<ProjectSettings> projectSettings,
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window,
bool disableNameEditing = false);
virtual void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
private slots:
void pickedCDBPath();
};
class QtProjectWizzardContentDataCDBVS
: public QtProjectWizzardContentDataCDB
{
Q_OBJECT
public:
QtProjectWizzardContentDataCDBVS(
std::shared_ptr<ProjectSettings> projectSettings,
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window);
virtual void populate(QGridLayout* layout, int& row) override;
private slots:
void handleVSCDBClicked();
};
#endif // QT_PROJECT_WIZZARD_CONTENT_DATA_H
@@ -16,8 +16,7 @@ QtProjectWizzardContentExtensions::QtProjectWizzardContentExtensions(
void QtProjectWizzardContentExtensions::populate(QGridLayout* layout, int& row)
{
QLabel* sourceLabel = createFormLabel("Source File Extensions");
sourceLabel->setObjectName("label");
layout->addWidget(sourceLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(sourceLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
addHelpButton("Define extensions for source files including the dot e.g. .cpp", layout, row);
@@ -14,8 +14,7 @@ QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(std::shared_ptr<Sourc
void QtProjectWizzardContentFlags::populate(QGridLayout* layout, int& row)
{
QLabel* label = createFormLabel("Compiler Flags");
label->setObjectName("label");
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
addHelpButton("Define compiler flags used during indexing including the dash (e.g. use \"-D RELEASE\" to add a #define for \"RELEASE\").", layout, row);
@@ -0,0 +1,75 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentLanguageAndStandard.h"
#include <QComboBox>
#include <QLabel>
#include "settings/SourceGroupSettings.h"
#include "utility/logging/logging.h"
QtProjectWizzardContentLanguageAndStandard::QtProjectWizzardContentLanguageAndStandard(
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(window)
, m_sourceGroupSettings(sourceGroupSettings)
, m_language(nullptr)
, m_standard(nullptr)
{
}
void QtProjectWizzardContentLanguageAndStandard::populate(QGridLayout* layout, int& row)
{
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
row++;
}
m_language = new QLabel();
layout->addWidget(createFormLabel("Language"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_language, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
m_standard = new QComboBox();
layout->addWidget(createFormLabel("Standard"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_standard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
layout->setRowStretch(row, 1);
}
}
void QtProjectWizzardContentLanguageAndStandard::load()
{
LanguageType type = getLanguageTypeForSourceGroupType(m_sourceGroupSettings->getType());
if (type == LANGUAGE_UNKNOWN)
{
LOG_ERROR("No language type defined");
return;
}
m_language->setText(languageTypeToString(type).c_str());
m_standard->clear();
std::vector<std::string> standards = m_sourceGroupSettings->getAvailableLanguageStandards();
for (size_t i = 0; i < standards.size(); i++)
{
m_standard->insertItem(i, standards[i].c_str());
}
m_standard->setCurrentText(QString::fromStdString(m_sourceGroupSettings->getStandard()));
}
void QtProjectWizzardContentLanguageAndStandard::save()
{
m_sourceGroupSettings->setStandard(m_standard->currentText().toStdString());
}
bool QtProjectWizzardContentLanguageAndStandard::check()
{
return true;
}
@@ -0,0 +1,34 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_LANGUAGE_AND_STANDARD
#define QT_PROJECT_WIZZARD_CONTENT_LANGUAGE_AND_STANDARD
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QComboBox;
class QLabel;
class SourceGroupSettings;
class QtProjectWizzardContentLanguageAndStandard
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentLanguageAndStandard(
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window);
// 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<SourceGroupSettings> m_sourceGroupSettings;
QLabel* m_language;
QComboBox* m_standard;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_LANGUAGE_AND_STANDARD
@@ -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
)
@@ -1,6 +1,8 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_PATH_H
#define QT_PROJECT_WIZZARD_CONTENT_PATH_H
#include <set>
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QCheckBox;
@@ -27,6 +29,8 @@ protected:
void setTitleString(const QString& title);
void setHelpString(const QString& help);
void setFileEndings(const std::set<std::string>& fileEndings);
std::shared_ptr<SourceGroupSettings> m_settings;
QtLocationPicker* m_picker;
@@ -36,18 +40,38 @@ protected:
private:
QString m_titleString;
QString m_helpString;
std::set<std::string> m_fileEndings;
};
class QtProjectWizzardContentPathCDB
: public QtProjectWizzardContentPath
{
Q_OBJECT
public:
QtProjectWizzardContentPathCDB(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
private slots:
void pickedCDBPath();
};
class QtProjectWizzardContentPathSourceMaven
: public QtProjectWizzardContentPath
{
public:
QtProjectWizzardContentPathSourceMaven(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
// QtSettingsWindow implementation
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
// QtProjectWizzardContent implementation
virtual void load() override;
virtual void save() override;
@@ -57,6 +81,7 @@ private:
QCheckBox* m_shouldIndexTests;
};
class QtProjectWizzardContentPathDependenciesMaven
: public QtProjectWizzardContentPath
{
@@ -34,7 +34,7 @@ void QtProjectWizzardContentPaths::populate(QGridLayout* layout, int& row)
m_list = new QtDirectoryListBox(this, m_titleString);
if (m_makePathsRelativeToProjectFileLocation)
if (m_makePathsRelativeToProjectFileLocation && m_settings)
{
m_list->setRelativeRootDirectory(m_settings->getProjectFileLocation());
}
@@ -59,29 +59,26 @@ bool QtProjectWizzardContentPaths::check()
{
QString missingPaths;
for (const FilePath& path : m_list->getList())
std::vector<FilePath> paths = m_list->getList();
if (m_settings)
{
std::vector<FilePath> expandedPaths = path.expandEnvironmentVariables();
for (FilePath expandedPath: path.expandEnvironmentVariables())
{
if (m_settings)
{
expandedPath = m_settings->makePathAbsolute(expandedPath);
}
paths = m_settings->makePathsExpandedAndAbsolute(paths);
}
if (!expandedPath.exists())
{
missingPaths.append(expandedPath.str().c_str());
missingPaths.append("\n");
break;
}
for (const FilePath& path : paths)
{
if (!path.exists())
{
missingPaths.append(path.str().c_str());
missingPaths.append("\n");
break;
}
}
if (!missingPaths.isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Some provided paths do not exist.");
msgBox.setText("Some provided paths do not exist at \"" + m_titleString + "\".");
msgBox.setDetailedText(missingPaths);
msgBox.exec();
return false;
@@ -174,8 +171,8 @@ std::vector<std::string> QtProjectWizzardContentPathsSource::getFileNames() cons
{
FileManager fileManager;
fileManager.update(
m_settings->getAbsoluteSourcePaths(),
m_settings->getAbsoluteExcludePaths(),
m_settings->getSourcePathsExpandedAndAbsolute(),
m_settings->getExcludePathsExpandedAndAbsolute(),
m_settings->getSourceExtensions()
);
@@ -263,7 +260,15 @@ void QtProjectWizzardContentPathsCDBHeader::buttonClicked()
if (!m_filesDialog)
{
std::vector<std::string> fileNames = getFileNames();
FilePath cdbPath = dynamic_cast<SourceGroupSettingsCxx*>(m_settings.get())->getCompilationDatabasePathExpandedAndAbsolute();
if (!cdbPath.exists())
{
QMessageBox msgBox;
msgBox.setText("The provided Compilation Database path does not exist.");
msgBox.setDetailedText(QString::fromStdString(cdbPath.str()));
msgBox.exec();
return;
}
m_filesDialog = std::make_shared<QtSelectPathsDialog>(
"Select from Include Paths",
@@ -271,19 +276,16 @@ void QtProjectWizzardContentPathsCDBHeader::buttonClicked()
"paths containing the header files you want to index with Sourcetrail.");
m_filesDialog->setup();
utility::CompilationDatabase cdb(
dynamic_cast<SourceGroupSettingsCxx*>(m_settings.get())->getAbsoluteCompilationDatabasePath().str());
std::vector<FilePath> cdbHeaderPaths = cdb.getAllHeaderPaths();
std::vector<FilePath> sourcePaths = m_settings->getSourcePaths();
cdbHeaderPaths = utility::unique(utility::concat(sourcePaths, cdbHeaderPaths));
dynamic_cast<QtSelectPathsDialog*>(m_filesDialog.get())->setPathsList(cdbHeaderPaths, sourcePaths);
connect(m_filesDialog.get(), SIGNAL(finished()), this, SLOT(savedFilesDialog()));
connect(m_filesDialog.get(), SIGNAL(canceled()), this, SLOT(closedFilesDialog()));
utility::CompilationDatabase cdb(cdbPath.str());
std::vector<FilePath> sourcePaths = m_settings->getSourcePaths();
std::vector<FilePath> cdbHeaderPaths = utility::unique(utility::concat(sourcePaths, cdb.getAllHeaderPaths()));
dynamic_cast<QtSelectPathsDialog*>(m_filesDialog.get())->setPathsList(cdbHeaderPaths, sourcePaths);
}
m_filesDialog->showWindow();
@@ -339,6 +339,8 @@ void QtProjectWizzardContentPreferences::save()
{
appSettings->setMavenPath(FilePath(m_mavenPath->getText().toStdString()));
}
appSettings->save();
}
bool QtProjectWizzardContentPreferences::check()
@@ -0,0 +1,97 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentProjectData.h"
#include <QMessageBox>
#include "settings/ProjectSettings.h"
QtProjectWizzardContentProjectData::QtProjectWizzardContentProjectData(
std::shared_ptr<ProjectSettings> projectSettings,
QtProjectWizzardWindow* window,
bool disableNameEditing
)
: QtProjectWizzardContent(window)
, m_projectSettings(projectSettings)
, m_disableNameEditing(disableNameEditing)
, m_projectName(nullptr)
, m_projectFileLocation(nullptr)
{
}
void QtProjectWizzardContentProjectData::populate(QGridLayout* layout, int& row)
{
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
row++;
}
QLabel* nameLabel = createFormLabel("Sourcetrail Project Name");
m_projectName = new QLineEdit();
m_projectName->setObjectName("name");
m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0);
m_projectName->setEnabled(!m_disableNameEditing);
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_projectName, row, QtProjectWizzardWindow::BACK_COL);
layout->setRowMinimumHeight(row, 30);
row++;
QLabel* locationLabel = createFormLabel("Sourcetrail Project Location");
m_projectFileLocation = new QtLocationPicker(this);
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);
addHelpButton("The directory where Sourcetrail project files will be saved to.", layout, row);
layout->setRowMinimumHeight(row, 30);
row++;
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
layout->setRowStretch(row, 1);
}
}
void QtProjectWizzardContentProjectData::load()
{
m_projectName->setText(QString::fromStdString(m_projectSettings->getProjectName()));
m_projectFileLocation->setText(QString::fromStdString(m_projectSettings->getProjectFileLocation().str()));
}
void QtProjectWizzardContentProjectData::save()
{
m_projectSettings->setProjectName(m_projectName->text().toStdString());
m_projectSettings->setProjectFileLocation(FilePath(m_projectFileLocation->getText().toStdString()));
}
bool QtProjectWizzardContentProjectData::check()
{
if (m_projectName->text().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please enter a project name.");
msgBox.exec();
return false;
}
if (m_projectFileLocation->getText().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please define the location for the Sourcetrail project file.");
msgBox.exec();
return false;
}
std::vector<FilePath> paths = FilePath(m_projectFileLocation->getText().toStdString()).expandEnvironmentVariables();
if (paths.size() != 1 || !paths[0].exists())
{
QMessageBox msgBox;
msgBox.setText("The specified location does not exist.");
msgBox.exec();
return false;
}
return true;
}
@@ -0,0 +1,35 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_PROJECT_DATA_H
#define QT_PROJECT_WIZZARD_CONTENT_PROJECT_DATA_H
#include "qt/element/QtLocationPicker.h"
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class ProjectSettings;
class QtProjectWizzardContentProjectData
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentProjectData(
std::shared_ptr<ProjectSettings> projectSettings,
QtProjectWizzardWindow* window,
bool disableNameEditing = 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<ProjectSettings> m_projectSettings;
bool m_disableNameEditing;
QLineEdit* m_projectName;
QtLocationPicker* m_projectFileLocation;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_PROJECT_DATA_H
@@ -19,49 +19,49 @@ QtProjectWizzardContentSelect::QtProjectWizzardContentSelect(
void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
{
struct ProjectInfo
struct SourceGroupInfo
{
ProjectInfo(SourceGroupType type) :type(type) {}
SourceGroupInfo(SourceGroupType type) :type(type) {}
const SourceGroupType type;
};
// define which kind of projects are available for each language
std::map<LanguageType, std::vector<ProjectInfo>> projectInfos;
projectInfos[LANGUAGE_C].push_back(ProjectInfo(SOURCE_GROUP_C_EMPTY));
projectInfos[LANGUAGE_C].push_back(ProjectInfo(SOURCE_GROUP_CXX_CDB));
projectInfos[LANGUAGE_C].push_back(ProjectInfo(SOURCE_GROUP_CXX_VS));
projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(SOURCE_GROUP_CPP_EMPTY));
projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(SOURCE_GROUP_CXX_CDB));
projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(SOURCE_GROUP_CXX_VS));
projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(SOURCE_GROUP_JAVA_EMPTY));
projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(SOURCE_GROUP_JAVA_MAVEN));
// 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_VS));
sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CPP_EMPTY));
sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_CDB));
sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_VS));
sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_EMPTY));
sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_MAVEN));
// define which icons should be used for which kind of project
m_projectTypeIconName[SOURCE_GROUP_C_EMPTY] = "empty_icon";
m_projectTypeIconName[SOURCE_GROUP_CPP_EMPTY] = "empty_icon";
m_projectTypeIconName[SOURCE_GROUP_CXX_CDB] = "cdb_icon";
m_projectTypeIconName[SOURCE_GROUP_CXX_VS] = "vs_icon";
m_projectTypeIconName[SOURCE_GROUP_JAVA_EMPTY] = "empty_icon";
m_projectTypeIconName[SOURCE_GROUP_JAVA_MAVEN] = "mvn_icon";
// define which icons should be used for which kind of source group
m_sourceGroupTypeIconName[SOURCE_GROUP_C_EMPTY] = "empty_icon";
m_sourceGroupTypeIconName[SOURCE_GROUP_CPP_EMPTY] = "empty_icon";
m_sourceGroupTypeIconName[SOURCE_GROUP_CXX_CDB] = "cdb_icon";
m_sourceGroupTypeIconName[SOURCE_GROUP_CXX_VS] = "vs_icon";
m_sourceGroupTypeIconName[SOURCE_GROUP_JAVA_EMPTY] = "empty_icon";
m_sourceGroupTypeIconName[SOURCE_GROUP_JAVA_MAVEN] = "mvn_icon";
// define descriptions for each kind of project
m_projectTypeDescriptions[SOURCE_GROUP_C_EMPTY] = "Create a new Sourcetrail project by defining which C files will be indexed.";
m_projectTypeDescriptions[SOURCE_GROUP_CPP_EMPTY] = "Create a new Sourcetrail project by defining which C++ files will be indexed.";
m_projectTypeDescriptions[SOURCE_GROUP_CXX_CDB] = "Create a project from an existing Compilation Database (compile_commands.json). They can be created from Make and "
// define descriptions for each kind of Source Group
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 created from Make and "
"CMake projects. Have a look at the <a href=\"https://sourcetrail.com/documentation/#CreateAProjectFromCompilationDatabase\">"
"documentation</a> to find out more.";
m_projectTypeDescriptions[SOURCE_GROUP_CXX_VS] = "Create a new project from an existing Visual Studio Solution file. "
m_sourceGroupTypeDescriptions[SOURCE_GROUP_CXX_VS] = "Create a new Source Group from an existing Visual Studio Solution file. "
"<b>Note: Requires a running Visual Studio instance with the "
"<a href=\"https://sourcetrail.com/documentation/index.html#VisualStudio\">Visual Studio plugin</a> installed.";
m_projectTypeDescriptions[SOURCE_GROUP_JAVA_EMPTY] = "Create a new Sourcetrail project by defining which Java files will be indexed.";
m_projectTypeDescriptions[SOURCE_GROUP_JAVA_MAVEN] = "Create a new project from an existing Maven project.";
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.";
QVBoxLayout* vlayout = new QVBoxLayout();
vlayout->setContentsMargins(0, 30, 0, 0);
vlayout->setSpacing(10);
m_languages = new QButtonGroup();
for (auto it: projectInfos)
for (auto it: sourceGroupInfos)
{
QPushButton* b = new QPushButton(languageTypeToString(it.first).c_str(), this);
b->setObjectName("menuButton");
@@ -97,29 +97,29 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
}
m_window->setNextEnabled(false);
m_title->setText("Project Types - " + m_languages->checkedButton()->text());
m_title->setText("Source Group Types - " + m_languages->checkedButton()->text());
m_description->setText("");
}
);
QHBoxLayout* hlayout = new QHBoxLayout();
for (auto languageIt: projectInfos)
for (auto languageIt: sourceGroupInfos)
{
QButtonGroup* projectButtons = new QButtonGroup(this);
QButtonGroup* sourceGroupButtons = new QButtonGroup(this);
for (auto projectIt: languageIt.second)
for (auto sourceGroupIt: languageIt.second)
{
QToolButton* b = createProjectButton(
utility::insertLineBreaksAtBlankSpaces(sourceGroupTypeToProjectSetupString(projectIt.type), 15).c_str(),
(ResourcePaths::getGuiPath().str() + "icon/" + m_projectTypeIconName[projectIt.type] + ".png").c_str()
QToolButton* b = createSourceGroupButton(
utility::insertLineBreaksAtBlankSpaces(sourceGroupTypeToProjectSetupString(sourceGroupIt.type), 15).c_str(),
(ResourcePaths::getGuiPath().str() + "icon/" + m_sourceGroupTypeIconName[sourceGroupIt.type] + ".png").c_str()
);
b->setProperty("source_group_type", int(projectIt.type));
projectButtons->addButton(b);
b->setProperty("source_group_type", int(sourceGroupIt.type));
sourceGroupButtons->addButton(b);
hlayout->addWidget(b);
}
m_buttons[languageIt.first] = projectButtons;
m_buttons[languageIt.first] = sourceGroupButtons;
}
for (auto it: m_buttons)
@@ -135,7 +135,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
selectedType = SourceGroupType(selectedTypeInt);
}
m_description->setText(m_projectTypeDescriptions[selectedType].c_str());
m_description->setText(m_sourceGroupTypeDescriptions[selectedType].c_str());
m_window->setNextEnabled(true);
}
@@ -144,7 +144,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
QFrame* container = new QFrame();
container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
container->setObjectName("projectContainer");
container->setObjectName("sourceGroupContainer");
container->setLayout(hlayout);
layout->addWidget(container, 0, QtProjectWizzardWindow::BACK_COL);
@@ -152,11 +152,11 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
m_description = new QLabel(" \n \n");
m_description->setWordWrap(true);
m_description->setOpenExternalLinks(true);
m_description->setObjectName("projectDescription");
m_description->setObjectName("sourceGroupDescription");
layout->addWidget(m_description, 1, QtProjectWizzardWindow::BACK_COL);
m_title = new QLabel("Project Types");
m_title->setObjectName("projectTitle");
m_title = new QLabel("Source Group Types");
m_title->setObjectName("sourceGroupTitle");
layout->addWidget(m_title, 0, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
@@ -191,21 +191,21 @@ void QtProjectWizzardContentSelect::save()
bool QtProjectWizzardContentSelect::check()
{
bool projectChosen = false;
bool sourceGroupChosen = false;
for (auto it: m_buttons)
{
if (it.second->checkedId() != -1)
{
projectChosen = true;
sourceGroupChosen = true;
break;
}
}
if (!projectChosen)
if (!sourceGroupChosen)
{
QMessageBox msgBox;
msgBox.setText("Please choose a method of creating a new project.");
msgBox.setText("Please choose a method of creating a new Source Group.");
msgBox.exec();
return false;
}
@@ -32,8 +32,8 @@ private:
QLabel* m_title;
QLabel* m_description;
std::map<SourceGroupType, std::string> m_projectTypeIconName;
std::map<SourceGroupType, std::string> m_projectTypeDescriptions;
std::map<SourceGroupType, std::string> m_sourceGroupTypeIconName;
std::map<SourceGroupType, std::string> m_sourceGroupTypeDescriptions;
std::vector<std::string> m_solutionDescription;
};
@@ -0,0 +1,70 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h"
#include <QLineEdit>
#include <QMessageBox>
#include "settings/SourceGroupSettings.h"
QtProjectWizzardContentSourceGroupData::QtProjectWizzardContentSourceGroupData(
std::shared_ptr<SourceGroupSettings> settings,
QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(window)
, m_settings(settings)
, m_name(nullptr)
{
}
void QtProjectWizzardContentSourceGroupData::populate(QGridLayout* layout, int& row)
{
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
row++;
}
QLabel* nameLabel = createFormLabel("Source Group Name");
m_name = new QLineEdit();
m_name->setObjectName("name");
m_name->setAttribute(Qt::WA_MacShowFocusRect, 0);
connect(m_name, SIGNAL(textEdited(QString)), this, SLOT(editedName(QString)));
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_name, row, QtProjectWizzardWindow::BACK_COL);
layout->setRowMinimumHeight(row, 30);
row++;
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
layout->setRowStretch(row, 1);
}
}
void QtProjectWizzardContentSourceGroupData::load()
{
m_name->setText(QString::fromStdString(m_settings->getName()));
}
void QtProjectWizzardContentSourceGroupData::save()
{
m_settings->setName(m_name->text().toStdString());
}
bool QtProjectWizzardContentSourceGroupData::check()
{
if (m_name->text().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please enter a source group name.");
msgBox.exec();
return false;
}
return true;
}
void QtProjectWizzardContentSourceGroupData::editedName(QString name)
{
emit nameUpdated(name);
}
@@ -0,0 +1,38 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H
#define QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QLineEdit;
class SourceGroupSettings;
class QtProjectWizzardContentSourceGroupData
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentSourceGroupData(
std::shared_ptr<SourceGroupSettings> settings,
QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
signals:
void nameUpdated(QString);
private slots:
void editedName(QString name);
private:
std::shared_ptr<SourceGroupSettings> m_settings;
QLineEdit* m_name;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_SOURCE_GROUP_DATA_H
@@ -36,7 +36,7 @@ void QtProjectWizzardContentSummary::populate(QGridLayout* layout, int& row)
return;
}
layout->setRowMinimumHeight(row++, 20);
layout->setRowMinimumHeight(row++, 10);
for (QtProjectWizzardContent* content : m_contents)
{
@@ -50,7 +50,7 @@ void QtProjectWizzardContentSummary::populate(QGridLayout* layout, int& row)
}
}
layout->setRowMinimumHeight(row, 20);
layout->setRowMinimumHeight(row, 10);
layout->setRowStretch(row, 1);
}
@@ -0,0 +1,45 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentVS.h"
#include "utility/messaging/type/MessageIDECreateCDB.h"
QtProjectWizzardContentVS::QtProjectWizzardContentVS(QtProjectWizzardWindow* window)
: QtProjectWizzardContent(window)
{
}
void QtProjectWizzardContentVS::populate(QGridLayout* layout, int& row)
{
QLabel* nameLabel = createFormLabel("Create Compilation Database");
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL);
addHelpButton("To create a new Compilation Database from a Visual Studio Solution, this Solution has to be open in Visual Studio.\n\
Sourcetrail will call Visual Studio to open the 'Create Compilation Database' dialog.\
Please follow the instructions in Visual Studio to complete the process.\n\
Note: Sourcetrail's Visual Studio plugin has to be installed. Visual Studio has to be running with an eligible Solution, containing C/C++ projects, loaded.", layout, row);
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);
row++;
QPushButton* button = new QPushButton("Create CDB");
button->setObjectName("windowButton");
layout->addWidget(button, row, QtProjectWizzardWindow::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);
row++;
addSeparator(layout, row++);
connect(button, SIGNAL(clicked()), this, SLOT(handleVSCDBClicked()));
}
void QtProjectWizzardContentVS::handleVSCDBClicked()
{
MessageIDECreateCDB().dispatch();
}
@@ -0,0 +1,20 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_VS_H
#define QT_PROJECT_WIZZARD_CONTENT_VS_H
#include "qt/window/project_wizzard/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
@@ -8,9 +8,10 @@
#include "qt/utility/utilityQt.h"
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
QtProjectWizzardWindow::QtProjectWizzardWindow(QWidget *parent)
QtProjectWizzardWindow::QtProjectWizzardWindow(QWidget *parent, bool showSeparator)
: QtWindow(parent)
, m_content(nullptr)
, m_showSeparator(showSeparator)
{
}
@@ -31,7 +32,6 @@ QtProjectWizzardContent* QtProjectWizzardWindow::content() const
void QtProjectWizzardWindow::setContent(QtProjectWizzardContent* content)
{
m_content = content;
setScrollAble(content->isScrollAble());
}
void QtProjectWizzardWindow::setPreferredSize(QSize size)
@@ -67,7 +67,7 @@ void QtProjectWizzardWindow::populateWindow(QWidget* widget)
separator->setFrameShape(QFrame::VLine);
QPalette palette = separator->palette();
palette.setColor(QPalette::WindowText, Qt::lightGray);
palette.setColor(QPalette::WindowText, m_showSeparator ? Qt::lightGray : Qt::transparent);
separator->setPalette(palette);
layout->addWidget(separator, 0, LINE_COL, -1, 1);
@@ -82,24 +82,32 @@ void QtProjectWizzardWindow::populateWindow(QWidget* widget)
void QtProjectWizzardWindow::windowReady()
{
updateTitle("NEW PROJECT");
updateTitle("NEW SOURCE GROUP");
m_content->windowReady();
}
void QtProjectWizzardWindow::handleNext()
{
saveContent();
if (m_content->check())
if (m_content)
{
emit next();
saveContent();
if (!m_content->check())
{
return;
}
}
emit next();
}
void QtProjectWizzardWindow::handlePrevious()
{
m_content->save();
if (m_content)
{
m_content->save();
}
emit previous();
}
@@ -11,7 +11,7 @@ class QtProjectWizzardWindow
Q_OBJECT
public:
QtProjectWizzardWindow(QWidget *parent);
QtProjectWizzardWindow(QWidget* parent, bool showSeparator = true);
virtual QSize sizeHint() const override;
QtProjectWizzardContent* content() const;
@@ -38,6 +38,7 @@ protected:
private:
QtProjectWizzardContent* m_content;
QSize m_preferredSize;
bool m_showSeparator;
};
#endif // QT_PROJECT_WIZZARD_WINDOW_H