From f0178fb3c622ac3f4878a9fb15940b64fdd576ca Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Tue, 23 Feb 2016 16:04:46 +0100 Subject: [PATCH] ui: removed compilation database option as project type --- .../SolutionParserCompilationDatabase.cpp | 31 +++++++- .../SolutionParserCompilationDatabase.h | 3 + src/lib_gui/qt/element/QtDirectoryListBox.cpp | 7 +- .../project_wizzard/QtProjectWizzard.cpp | 67 ++++++++-------- .../QtProjectWizzardContentPaths.cpp | 76 ------------------- .../QtProjectWizzardContentPaths.h | 25 ------ .../QtProjectWizzardContentSelect.cpp | 4 +- 7 files changed, 74 insertions(+), 139 deletions(-) diff --git a/src/lib/utility/solution/SolutionParserCompilationDatabase.cpp b/src/lib/utility/solution/SolutionParserCompilationDatabase.cpp index 13021e97..846bfb0b 100644 --- a/src/lib/utility/solution/SolutionParserCompilationDatabase.cpp +++ b/src/lib/utility/solution/SolutionParserCompilationDatabase.cpp @@ -1,10 +1,14 @@ +/* #include "utility/solution/SolutionParserCompilationDatabase.h" #include -#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 SolutionParserCompilationDatabase::getProjects() std::vector SolutionParserCompilationDatabase::getProjectItems() { - return getDatabase()->getAllFiles(); + std::vector files = getDatabase()->getAllFiles(); + + std::vector extensions = ProjectSettings::getInstance()->getHeaderExtensions(); + std::vector fileInfos = FileSystem::getFileInfosFromPaths(m_headerPaths, extensions); + + for (const FileInfo& info : fileInfos) + { + files.push_back(info.path.str()); + } + + return files; } std::vector SolutionParserCompilationDatabase::getIncludePaths() @@ -43,6 +57,7 @@ void SolutionParserCompilationDatabase::parseDatabase() { std::vector commands = getDatabase()->getAllCompileCommands(); + std::set headerPaths; std::set searchPaths; std::set 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(); } +*/ diff --git a/src/lib/utility/solution/SolutionParserCompilationDatabase.h b/src/lib/utility/solution/SolutionParserCompilationDatabase.h index fc07050b..c1717a3b 100644 --- a/src/lib/utility/solution/SolutionParserCompilationDatabase.h +++ b/src/lib/utility/solution/SolutionParserCompilationDatabase.h @@ -1,3 +1,4 @@ +/* #ifndef COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H #define COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H @@ -36,9 +37,11 @@ private: std::shared_ptr m_database; + std::vector m_headerPaths; std::vector m_searchPaths; std::vector m_frameworkPaths; }; #endif //COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H +*/ \ No newline at end of file diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.cpp b/src/lib_gui/qt/element/QtDirectoryListBox.cpp index 0a3ee811..9f93f8bd 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.cpp +++ b/src/lib_gui/qt/element/QtDirectoryListBox.cpp @@ -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) diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index fe1c345e..da0b70ec 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -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(); - connect(window, SIGNAL(next()), this, SLOT(showSummary())); + editProject(settings); - connect(dynamic_cast(window->content()), - SIGNAL(showSourceFiles()), this, SLOT(showSourceFiles())); + QWidget* window = m_windowStack.getTopWindow(); + + if (window) + { + dynamic_cast(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 sourceFiles = parser.getProjectItems(); - std::vector sourcePaths; - for (const std::string& p : sourceFiles) - { - sourcePaths.push_back(FilePath(p)); - } + // std::vector sourceFiles = parser.getProjectItems(); + // std::vector sourcePaths; + // for (const std::string& p : sourceFiles) + // { + // sourcePaths.push_back(FilePath(p)); + // } - std::vector includePaths = parser.getIncludePaths(); - std::vector headerPaths; - for (const std::string& p : includePaths) - { - headerPaths.push_back(FilePath(p)); - } + // std::vector includePaths = parser.getIncludePaths(); + // std::vector headerPaths; + // for (const std::string& p : includePaths) + // { + // headerPaths.push_back(FilePath(p)); + // } - std::vector frameworkPaths = parser.getFrameworkPaths(); - std::vector frameworkSearchPaths; - for (const std::string& p : frameworkPaths) - { - frameworkSearchPaths.push_back(FilePath(p)); - } + // std::vector frameworkPaths = parser.getFrameworkPaths(); + // std::vector 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; } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index 20ab0bf6..aa45f8d1 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -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(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 headerPaths = m_list->getList(); - std::vector extensions = m_settings->getHeaderExtensions(); - std::vector fileInfos = FileSystem::getFileInfosFromPaths(headerPaths, extensions); - - headerPaths.clear(); - for (const FileInfo& info : fileInfos) - { - headerPaths.push_back(info.path); - } - - std::vector sourcePaths = m_settings->getSourcePaths(); - utility::append(sourcePaths, headerPaths); - m_settings->setSourcePaths(sourcePaths); - - m_list->clear(); -} - - QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSearch( ProjectSettings* settings, QtProjectWizzardWindow* window ) diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h index 41413f44..f0127878 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h @@ -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 { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp index 1f9e9c1e..6738280a 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp @@ -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); }