ui: removed compilation database option as project type

This commit is contained in:
Eberhard Graether
2016-02-23 16:04:46 +01:00
parent 8633201350
commit f0178fb3c6
7 changed files with 74 additions and 139 deletions
@@ -1,10 +1,14 @@
/*
#include "utility/solution/SolutionParserCompilationDatabase.h"
#include <set>
#include "utility/file/FilePath.h"
#include "utility/logging/logging.h"
#include "clang/Tooling/JSONCompilationDatabase.h"
#include "settings/ProjectSettings.h"
#include "utility/file/FilePath.h"
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
#include "utility/utility.h"
SolutionParserCompilationDatabase::SolutionParserCompilationDatabase()
{
@@ -26,7 +30,17 @@ std::vector<std::string> SolutionParserCompilationDatabase::getProjects()
std::vector<std::string> SolutionParserCompilationDatabase::getProjectItems()
{
return getDatabase()->getAllFiles();
std::vector<std::string> files = getDatabase()->getAllFiles();
std::vector<std::string> extensions = ProjectSettings::getInstance()->getHeaderExtensions();
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(m_headerPaths, extensions);
for (const FileInfo& info : fileInfos)
{
files.push_back(info.path.str());
}
return files;
}
std::vector<std::string> SolutionParserCompilationDatabase::getIncludePaths()
@@ -43,6 +57,7 @@ void SolutionParserCompilationDatabase::parseDatabase()
{
std::vector<clang::tooling::CompileCommand> commands = getDatabase()->getAllCompileCommands();
std::set<std::string> headerPaths;
std::set<std::string> searchPaths;
std::set<std::string> frameworkPaths;
bool insertNext = false;
@@ -64,7 +79,9 @@ void SolutionParserCompilationDatabase::parseDatabase()
}
if(argument.substr(0,2) == "-I")
{
searchPaths.insert(getIncludePath(argument.substr(2), command.Directory));
std::string includePath = getIncludePath(argument.substr(2), command.Directory);
headerPaths.insert(includePath);
searchPaths.insert(includePath);
}
if(argument == "-isystem")
{
@@ -77,6 +94,11 @@ void SolutionParserCompilationDatabase::parseDatabase()
}
}
for(std::string p : headerPaths)
{
m_headerPaths.push_back(FilePath(p));
}
for(std::string p : searchPaths)
{
m_searchPaths.push_back(p);
@@ -124,3 +146,4 @@ clang::tooling::JSONCompilationDatabase* SolutionParserCompilationDatabase::getD
}
return m_database.get();
}
*/
@@ -1,3 +1,4 @@
/*
#ifndef COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H
#define COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H
@@ -36,9 +37,11 @@ private:
std::shared_ptr<clang::tooling::JSONCompilationDatabase> m_database;
std::vector<FilePath> m_headerPaths;
std::vector<std::string> m_searchPaths;
std::vector<std::string> m_frameworkPaths;
};
#endif //COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H
*/
@@ -262,10 +262,15 @@ void QtDirectoryListBox::removeListBoxItem()
return;
}
int rowIndex = m_list->row(m_list->selectedItems().first()) - 1;
int rowIndex = m_list->row(m_list->selectedItems().first());
qDeleteAll(m_list->selectedItems());
if (rowIndex == m_list->count())
{
rowIndex -= 1;
}
resize();
if (rowIndex >= 0)
@@ -94,13 +94,16 @@ void QtProjectWizzard::refreshProjectFromVisualStudioSolution(const std::string&
void QtProjectWizzard::newProjectFromCompilationDatabase(const std::string& compilationDatabasePath)
{
m_settings = getSettingsForCompilationDatabase(compilationDatabasePath);
ProjectSettings settings = getSettingsForCompilationDatabase(compilationDatabasePath);
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsCDBSource>();
connect(window, SIGNAL(next()), this, SLOT(showSummary()));
editProject(settings);
connect(dynamic_cast<QtProjectWizzardContentPathsCDBSource*>(window->content()),
SIGNAL(showSourceFiles()), this, SLOT(showSourceFiles()));
QWidget* window = m_windowStack.getTopWindow();
if (window)
{
dynamic_cast<QtProjectWizzardWindow*>(window)->updateTitle("NEW PROJECT FROM COMPILATION DATABASE");
}
}
void QtProjectWizzard::refreshProjectFromCompilationDatabase(const std::string& compilationDatabasePath)
@@ -229,39 +232,39 @@ ProjectSettings QtProjectWizzard::getSettingsForVisualStudioSolution(const std::
ProjectSettings QtProjectWizzard::getSettingsForCompilationDatabase(const std::string& compilationDatabasePath) const
{
SolutionParserCompilationDatabase parser;
parser.openSolutionFile(compilationDatabasePath);
parser.parseDatabase();
// SolutionParserCompilationDatabase parser;
// parser.openSolutionFile(compilationDatabasePath);
// parser.parseDatabase();
ProjectSettings settings;
settings.setProjectName(parser.getSolutionName());
settings.setProjectFileLocation(parser.getSolutionPath());
settings.setCompilationDatabasePath(FilePath(compilationDatabasePath));
// settings.setProjectName(parser.getSolutionName());
// settings.setProjectFileLocation(parser.getSolutionPath());
// settings.setCompilationDatabasePath(FilePath(compilationDatabasePath));
std::vector<std::string> sourceFiles = parser.getProjectItems();
std::vector<FilePath> sourcePaths;
for (const std::string& p : sourceFiles)
{
sourcePaths.push_back(FilePath(p));
}
// std::vector<std::string> sourceFiles = parser.getProjectItems();
// std::vector<FilePath> sourcePaths;
// for (const std::string& p : sourceFiles)
// {
// sourcePaths.push_back(FilePath(p));
// }
std::vector<std::string> includePaths = parser.getIncludePaths();
std::vector<FilePath> headerPaths;
for (const std::string& p : includePaths)
{
headerPaths.push_back(FilePath(p));
}
// std::vector<std::string> includePaths = parser.getIncludePaths();
// std::vector<FilePath> headerPaths;
// for (const std::string& p : includePaths)
// {
// headerPaths.push_back(FilePath(p));
// }
std::vector<std::string> frameworkPaths = parser.getFrameworkPaths();
std::vector<FilePath> frameworkSearchPaths;
for (const std::string& p : frameworkPaths)
{
frameworkSearchPaths.push_back(FilePath(p));
}
// std::vector<std::string> frameworkPaths = parser.getFrameworkPaths();
// std::vector<FilePath> frameworkSearchPaths;
// for (const std::string& p : frameworkPaths)
// {
// frameworkSearchPaths.push_back(FilePath(p));
// }
settings.setSourcePaths(sourcePaths);
settings.setHeaderSearchPaths(headerPaths);
settings.setFrameworkSearchPaths(frameworkSearchPaths);
// settings.setSourcePaths(sourcePaths);
// settings.setHeaderSearchPaths(headerPaths);
// settings.setFrameworkSearchPaths(frameworkSearchPaths);
return settings;
}
@@ -6,8 +6,6 @@
#include "qt/element/QtDirectoryListBox.h"
#include "settings/ApplicationSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/utility.h"
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(ProjectSettings* settings, QtProjectWizzardWindow* window)
@@ -109,11 +107,6 @@ void QtProjectWizzardContentPaths::save()
if (m_subPaths)
{
m_subPaths->savePaths();
if (dynamic_cast<QtProjectWizzardContentPathsCDBHeaders*>(m_subPaths))
{
loadPaths();
}
}
}
@@ -245,75 +238,6 @@ QtProjectWizzardContentPathsSourceSimple::QtProjectWizzardContentPathsSourceSimp
}
QtProjectWizzardContentPathsCDBSource::QtProjectWizzardContentPathsCDBSource(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPaths(settings, window)
{
m_addShowSourcesButton = true;
setInfo(
"Compilation Database Files",
"These files were found within the provided compilation database. You can add or remove files here.",
""
);
m_subPaths = new QtProjectWizzardContentPathsCDBHeaders(settings, window);
}
void QtProjectWizzardContentPathsCDBSource::loadPaths()
{
m_list->setList(m_settings->getSourcePaths());
}
void QtProjectWizzardContentPathsCDBSource::savePaths()
{
m_settings->setSourcePaths(m_list->getList());
}
bool QtProjectWizzardContentPathsCDBSource::isScrollAble() const
{
return true;
}
QtProjectWizzardContentPathsCDBHeaders::QtProjectWizzardContentPathsCDBHeaders(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPaths(settings, window)
{
setTitleString("Header Files");
setDescriptionString(
"Coati works best if you analyze both your source and header files, but the Compilation Database only contains "
"source files. Add the header files, or the directories containing them here. They will be added to the source "
"files above"
);
}
void QtProjectWizzardContentPathsCDBHeaders::loadPaths()
{
m_list->clear();
}
void QtProjectWizzardContentPathsCDBHeaders::savePaths()
{
std::vector<FilePath> headerPaths = m_list->getList();
std::vector<std::string> extensions = m_settings->getHeaderExtensions();
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(headerPaths, extensions);
headerPaths.clear();
for (const FileInfo& info : fileInfos)
{
headerPaths.push_back(info.path);
}
std::vector<FilePath> sourcePaths = m_settings->getSourcePaths();
utility::append(sourcePaths, headerPaths);
m_settings->setSourcePaths(sourcePaths);
m_list->clear();
}
QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSearch(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
@@ -80,31 +80,6 @@ public:
};
class QtProjectWizzardContentPathsCDBSource
: public QtProjectWizzardContentPaths
{
public:
QtProjectWizzardContentPathsCDBSource(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContentPaths implementation
virtual void loadPaths() override;
virtual void savePaths() override;
virtual bool isScrollAble() const override;
};
class QtProjectWizzardContentPathsCDBHeaders
: public QtProjectWizzardContentPaths
{
public:
QtProjectWizzardContentPathsCDBHeaders(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContentPaths implementation
virtual void loadPaths() override;
virtual void savePaths() override;
};
class QtProjectWizzardContentPathsHeaderSearch
: public QtProjectWizzardContentPaths
{
@@ -67,6 +67,8 @@ void QtProjectWizzardContentSelect::populateWindow(QGridLayout* layout)
QToolButton* c = createProjectButton(
"from Compilation\nDatabase", (ResourcePaths::getGuiPath() + "icon/project_cdb_256_256.png").c_str());
c->hide();
m_buttons = new QButtonGroup(this);
m_buttons->addButton(a);
m_buttons->addButton(b);
@@ -161,5 +163,5 @@ bool QtProjectWizzardContentSelect::check()
QSize QtProjectWizzardContentSelect::preferredWindowSize() const
{
return QSize(700, 380);
return QSize(570, 380);
}