logic: Added compilation database project setup

* Added CDB option to project type selection
* show CDB source files in popup
* define header paths separately
* made generic content summary in wizzard and use it everywhere
* fixed file paths not canonical in analysis
* refactored wizzard content paths to use summary instead of subpaths
* refactored files popup to simpler communication with content

bug id = 35
This commit is contained in:
Eberhard Graether
2016-03-08 13:20:37 +01:00
parent 90c0d15d20
commit 8cc8f5d534
45 changed files with 919 additions and 734 deletions
+2 -1
View File
@@ -1,4 +1,4 @@
ConfigManager.cpp WARNING: value source/header_search_paths/header_search_path is not present in config.
ConfigManager.cpp WARNING: value path/to/nowhere is not present in config.
CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:1:20
CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20
CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:1:20
@@ -66,6 +66,7 @@ NetworkProtocolHelper.cpp ERROR: Failed to parse message, invalid type token
NetworkProtocolHelper.cpp ERROR: Failed to parse setActiveToken message, invalid token count
Settings.cpp WARNING: File for Settings not found: data/SettingsTestSuite/wrong_settings.xml
Settings.cpp WARNING: File for Settings not found: data/SettingsTestSuite/wrong_settings.xml
ConfigManager.cpp WARNING: value NewBool is not present in config.
INFO: file: file.cpp < 0:0 0:0>
TextAccess.cpp ERROR: Could not open file file.cpp
INFO: typedef: type <file.cpp 1:1 1:1>
+53 -8
View File
@@ -2,6 +2,8 @@
#include <sstream>
#include "clang/Tooling/JSONCompilationDatabase.h"
#include "data/parser/cxx/CxxParser.h"
#include "data/parser/ParserClient.h"
#include "utility/file/FileRegister.h"
@@ -19,18 +21,49 @@ TaskParseCxx::TaskParseCxx(
, m_parser(std::make_shared<CxxParser>(client, fileManager))
, m_arguments(arguments)
, m_files(files)
, m_isCDB(false)
{
if (arguments.compilationDatabasePath.exists())
{
m_isCDB = true;
}
}
std::vector<FilePath> TaskParseCxx::getSourceFilesFromCDB(const FilePath& compilationDatabasePath)
{
std::string error;
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
(clang::tooling::JSONCompilationDatabase::loadFromFile(compilationDatabasePath.str(), error));
std::vector<std::string> files = cdb->getAllFiles();
std::vector<FilePath> filePaths;
for (const std::string& file : files)
{
filePaths.push_back(FilePath(file));
}
return filePaths;
}
void TaskParseCxx::enter()
{
m_start = utility::durationStart();
m_parser->setupParsing(m_files, m_arguments);
if (m_isCDB)
{
std::string error;
m_cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
(clang::tooling::JSONCompilationDatabase::loadFromFile(m_arguments.compilationDatabasePath.str(), error));
m_parser->setupParsingCDB(m_files, m_arguments);
}
else
{
m_parser->setupParsing(m_files, m_arguments);
}
for (const FilePath& path : m_parser->getFileRegister()->getUnparsedSourceFilePaths())
{
m_sourcePaths.push(path.absolute());
m_sourcePaths.push_back(path.absolute());
}
m_client->startParsing();
@@ -46,10 +79,10 @@ Task::TaskState TaskParseCxx::update()
if (m_sourcePaths.size())
{
sourcePath = m_sourcePaths.front();
m_sourcePaths.pop();
m_sourcePaths.pop_front();
isSource = true;
}
else
else if (!m_isCDB)
{
std::vector<FilePath> unparsedHeaders = fileRegister->getUnparsedIncludeFilePaths();
if (unparsedHeaders.size())
@@ -65,14 +98,26 @@ Task::TaskState TaskParseCxx::update()
std::stringstream ss;
ss << "analyzing files (ESC to quit): [";
ss << fileRegister->getParsedFilesCount() << "/" << fileRegister->getFilesCount() << "] ";
ss << (m_isCDB ? fileRegister->getParsedSourceFilesCount() : fileRegister->getParsedFilesCount()) + 1 << "/";
ss << (m_isCDB ? fileRegister->getSourceFilesCount() : fileRegister->getFilesCount()) << "] ";
ss << sourcePath.str();
MessageStatus(ss.str(), false, true).dispatch();
m_client->startParsingFile(sourcePath);
m_parser->runTool(std::vector<std::string>(1, sourcePath.str()));
if (m_isCDB)
{
std::vector<clang::tooling::CompileCommand> commands = m_cdb->getCompileCommands(sourcePath.str());
if (commands.size() > 0)
{
m_parser->runTool(commands[0], m_arguments);
}
}
else
{
m_parser->runTool(std::vector<std::string>(1, sourcePath.str()));
}
m_client->finishParsingFile(sourcePath);
@@ -93,8 +138,8 @@ void TaskParseCxx::exit()
FileRegister* fileRegister = m_parser->getFileRegister();
MessageFinishedParsing(
fileRegister->getParsedFilesCount(),
fileRegister->getFilesCount(),
(m_isCDB ? fileRegister->getParsedSourceFilesCount() : fileRegister->getParsedFilesCount()),
(m_isCDB ? fileRegister->getSourceFilesCount() : fileRegister->getFilesCount()),
utility::duration(m_start)
).dispatch();
}
-1
View File
@@ -19,7 +19,6 @@
#include "version.h"
#include "settings/ProjectSettings.h"
#include "utility/solution/SolutionParserCompilationDatabase.h"
void init()
{
-2
View File
@@ -271,8 +271,6 @@ add_files(
utility/solution/ISolutionParser.cpp
utility/solution/ISolutionParser.h
utility/solution/SolutionParserCompilationDatabase.cpp
utility/solution/SolutionParserCompilationDatabase.h
utility/solution/SolutionParserVisualStudio.cpp
utility/solution/SolutionParserVisualStudio.h
+10 -2
View File
@@ -168,12 +168,19 @@ void Project::updateFileManager()
{
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
std::vector<FilePath> sourcePaths(projSettings->getSourcePaths());
std::vector<FilePath> sourcePaths = projSettings->getSourcePaths();
std::vector<FilePath> headerPaths;
if (projSettings->getCompilationDatabasePath().exists())
{
headerPaths = sourcePaths;
sourcePaths = TaskParseCxx::getSourceFilesFromCDB(projSettings->getCompilationDatabasePath());
}
std::vector<std::string> sourceExtensions = projSettings->getSourceExtensions();
std::vector<std::string> includeExtensions = projSettings->getHeaderExtensions();
m_fileManager.setPaths(sourcePaths, sourceExtensions, includeExtensions);
m_fileManager.setPaths(sourcePaths, headerPaths, sourceExtensions, includeExtensions);
}
Parser::Arguments Project::getParserArguments() const
@@ -212,6 +219,7 @@ Parser::Arguments Project::getParserArguments() const
args.language = projSettings->getLanguage();
args.languageStandard = projSettings->getStandard();
args.compilationDatabasePath = projSettings->getCompilationDatabasePath();
return args;
}
+2
View File
@@ -24,6 +24,8 @@ public:
bool logErrors;
std::string language;
std::string languageStandard;
FilePath compilationDatabasePath;
};
Parser(ParserClient* client);
+15 -2
View File
@@ -2,7 +2,7 @@
#define TASK_PARSE_CXX_H
#include <memory>
#include <queue>
#include <deque>
#include "data/parser/Parser.h"
#include "utility/scheduling/Task.h"
@@ -12,6 +12,14 @@ class ParserClient;
class FileManager;
class CxxParser;
namespace clang
{
namespace tooling
{
class JSONCompilationDatabase;
}
}
class TaskParseCxx
: public Task
{
@@ -23,6 +31,8 @@ public:
const std::vector<FilePath>& files
);
static std::vector<FilePath> getSourceFilesFromCDB(const FilePath& compilationDatabasePath);
virtual void enter();
virtual TaskState update();
virtual void exit();
@@ -36,9 +46,12 @@ private:
const Parser::Arguments m_arguments;
const std::vector<FilePath> m_files;
std::queue<FilePath> m_sourcePaths;
std::deque<FilePath> m_sourcePaths;
TimePoint m_start;
bool m_isCDB;
std::shared_ptr<clang::tooling::JSONCompilationDatabase> m_cdb;
};
#endif // TASK_PARSE_CXX_H
+3
View File
@@ -22,10 +22,12 @@ const std::vector<FilePath>& FileManager::getSourcePaths() const
void FileManager::setPaths(
std::vector<FilePath> sourcePaths,
std::vector<FilePath> headerPaths,
std::vector<std::string> sourceExtensions,
std::vector<std::string> includeExtensions
){
m_sourcePaths = sourcePaths;
m_headerPaths = headerPaths;
m_sourceExtensions = sourceExtensions;
m_includeExtensions = includeExtensions;
}
@@ -123,6 +125,7 @@ std::vector<FileInfo> FileManager::getFileInfosInProject() const
std::vector<std::pair<std::vector<FilePath>, std::vector<std::string>>> pathsExtensionsPairs;
pathsExtensionsPairs.push_back(std::make_pair(m_sourcePaths, m_includeExtensions));
pathsExtensionsPairs.push_back(std::make_pair(m_sourcePaths, m_sourceExtensions));
pathsExtensionsPairs.push_back(std::make_pair(m_headerPaths, m_includeExtensions));
for (size_t i = 0; i < pathsExtensionsPairs.size(); i++)
{
+3
View File
@@ -17,6 +17,7 @@ public:
void setPaths(
std::vector<FilePath> sourcePaths,
std::vector<FilePath> headerPaths,
std::vector<std::string> sourceExtensions,
std::vector<std::string> includeExtensions
);
@@ -40,6 +41,8 @@ private:
std::map<FilePath, FileInfo> m_files;
std::vector<FilePath> m_sourcePaths;
std::vector<FilePath> m_headerPaths;
std::vector<std::string> m_sourceExtensions;
std::vector<std::string> m_includeExtensions;
+10
View File
@@ -138,7 +138,17 @@ size_t FileRegister::getFilesCount() const
return m_sourceFilePaths.size() + m_includeFilePaths.size();
}
size_t FileRegister::getSourceFilesCount() const
{
return m_sourceFilePaths.size();
}
size_t FileRegister::getParsedFilesCount() const
{
return getFilesCount() - getUnparsedSourceFilePaths().size() - getUnparsedIncludeFilePaths().size();
}
size_t FileRegister::getParsedSourceFilesCount() const
{
return getSourceFilesCount() - getUnparsedSourceFilePaths().size();
}
+2
View File
@@ -31,7 +31,9 @@ public:
void markParsingIncludeFilesParsed();
size_t getFilesCount() const;
size_t getSourceFilesCount() const;
size_t getParsedFilesCount() const;
size_t getParsedSourceFilesCount() const;
private:
enum ParseState
@@ -1,149 +0,0 @@
/*
#include "utility/solution/SolutionParserCompilationDatabase.h"
#include <set>
#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()
{
}
SolutionParserCompilationDatabase::~SolutionParserCompilationDatabase()
{
}
std::string SolutionParserCompilationDatabase::getSolutionName()
{
return "";
}
std::vector<std::string> SolutionParserCompilationDatabase::getProjects()
{
return std::vector<std::string>();
}
std::vector<std::string> SolutionParserCompilationDatabase::getProjectItems()
{
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()
{
return m_searchPaths;
}
std::vector<std::string> SolutionParserCompilationDatabase::getFrameworkPaths()
{
return m_frameworkPaths;
}
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;
bool insertFramework = false;
for(clang::tooling::CompileCommand command : commands)
{
std::string dir = command.Directory;
for(std::string argument : command.CommandLine)
{
if(insertNext)
{
searchPaths.insert(getIncludePath(argument, command.Directory));
insertNext = false;
}
if(insertFramework)
{
frameworkPaths.insert(getIncludePath(argument,command.Directory));
insertFramework = false;
}
if(argument.substr(0,2) == "-I")
{
std::string includePath = getIncludePath(argument.substr(2), command.Directory);
headerPaths.insert(includePath);
searchPaths.insert(includePath);
}
if(argument == "-isystem")
{
insertNext = true;
}
if (argument == "-iframework")
{
insertFramework = true;
}
}
}
for(std::string p : headerPaths)
{
m_headerPaths.push_back(FilePath(p));
}
for(std::string p : searchPaths)
{
m_searchPaths.push_back(p);
}
for(std::string p : frameworkPaths)
{
m_frameworkPaths.push_back(p);
}
}
std::vector<std::string> SolutionParserCompilationDatabase::getProjectFiles()
{
return std::vector<std::string>();
}
std::string SolutionParserCompilationDatabase::getIncludePath(const std::string& path, const std::string& dir)
{
if (FilePath(path).isAbsolute())
{
return path;
}
return dir + "/" + path;
}
clang::tooling::JSONCompilationDatabase* SolutionParserCompilationDatabase::getDatabase()
{
if(m_database == nullptr)
{
if(m_solutionPath.empty())
{
LOG_ERROR("No compilation database file");
}
else
{
std::string error;
m_database = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
( clang::tooling::JSONCompilationDatabase::loadFromFile(m_solutionPath + m_solutionName,error) );
}
if(m_database == nullptr)
{
LOG_ERROR("Could not load compilation database from file: " + m_solutionPath );
}
}
return m_database.get();
}
*/
@@ -1,47 +0,0 @@
/*
#ifndef COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H
#define COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H
#include "utility/solution/ISolutionParser.h"
#include <memory>
#include <string>
class FilePath;
namespace clang
{
namespace tooling
{
class JSONCompilationDatabase;
}
}
class SolutionParserCompilationDatabase : public ISolutionParser
{
public:
SolutionParserCompilationDatabase();
~SolutionParserCompilationDatabase();
virtual std::string getSolutionName();
virtual std::vector<std::string> getProjects();
virtual std::vector<std::string> getProjectFiles();
virtual std::vector<std::string> getProjectItems();
virtual std::vector<std::string> getIncludePaths();
std::vector<std::string> getFrameworkPaths();
void parseDatabase();
private:
clang::tooling::JSONCompilationDatabase* getDatabase();
std::string getIncludePath(const std::string& argument, const std::string& dir);
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
*/
+1 -1
View File
@@ -43,7 +43,7 @@ namespace utility
bool isPermutation(const std::vector<T>& a, const std::vector<T>& b)
{
return (
a.size() == b.size() &&
a.size() == b.size() &&
std::is_permutation(a.begin(), a.end(), b.begin())
);
}
+2 -2
View File
@@ -107,14 +107,14 @@ add_files(
qt/window/project_wizzard/QtProjectWizzardContent.h
qt/window/project_wizzard/QtProjectWizzardContentBuildFile.cpp
qt/window/project_wizzard/QtProjectWizzardContentBuildFile.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/QtProjectWizzardContentFlags.cpp
qt/window/project_wizzard/QtProjectWizzardContentFlags.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/QtProjectWizzardContentSelect.cpp
qt/window/project_wizzard/QtProjectWizzardContentSelect.h
qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp
+5
View File
@@ -21,6 +21,11 @@ QtWindowStackElement* QtWindowStack::getTopWindow()
return nullptr;
}
size_t QtWindowStack::getWindowCount()
{
return m_stack.size();
}
void QtWindowStack::pushWindow(QtWindowStackElement* window)
{
if (m_stack.size())
+1
View File
@@ -30,6 +30,7 @@ public:
QtWindowStack(QObject* parent = nullptr);
QtWindowStackElement* getTopWindow();
size_t getWindowCount();
public slots:
void pushWindow(QtWindowStackElement* window);
@@ -5,15 +5,16 @@
#include <QSysInfo>
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentData.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentFlags.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSourceList.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/solution/SolutionParserCompilationDatabase.h"
#include "utility/solution/SolutionParserVisualStudio.h"
QtProjectWizzard::QtProjectWizzard(QWidget* parent)
@@ -64,11 +65,15 @@ void QtProjectWizzard::newProjectFromVisualStudioSolution(const std::string& vis
editProject(settings);
QWidget* window = m_windowStack.getTopWindow();
QWidget* widget = m_windowStack.getTopWindow();
if (window)
if (widget)
{
dynamic_cast<QtProjectWizzardWindow*>(window)->updateTitle("NEW PROJECT FROM VS SOLUTION");
QtProjectWizzardWindow* window = dynamic_cast<QtProjectWizzardWindow*>(widget);
window->updateTitle("NEW PROJECT FROM VS SOLUTION");
window->updateNextButton("Create");
window->setPreviousVisible(m_windowStack.getWindowCount() > 0);
}
}
@@ -94,16 +99,9 @@ void QtProjectWizzard::refreshProjectFromVisualStudioSolution(const std::string&
void QtProjectWizzard::newProjectFromCompilationDatabase(const std::string& compilationDatabasePath)
{
ProjectSettings settings = getSettingsForCompilationDatabase(compilationDatabasePath);
m_settings = getSettingsForCompilationDatabase(compilationDatabasePath);
editProject(settings);
QWidget* window = m_windowStack.getTopWindow();
if (window)
{
dynamic_cast<QtProjectWizzardWindow*>(window)->updateTitle("NEW PROJECT FROM COMPILATION DATABASE");
}
headerPathsCDB();
}
void QtProjectWizzard::refreshProjectFromCompilationDatabase(const std::string& compilationDatabasePath)
@@ -141,14 +139,33 @@ void QtProjectWizzard::editProject(const ProjectSettings& settings)
window->updateTitle("EDIT PROJECT");
window->updateNextButton("Save");
window->setPreviousVisible(false);
connect(window, SIGNAL(next()), this, SLOT(createProject()));
}
void QtProjectWizzard::showPreferences()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPreferences>();
QtProjectWizzardWindow* window = createWindowWithSummary(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
{
summary->setIsForm(true);
ProjectSettings* settings = &m_settings;
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, false);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window), false, false);
}
window->setup();
window->updateTitle("PREFERENCES");
window->updateNextButton("Save");
window->setPreviousVisible(false);
}
);
connect(window, SIGNAL(next()), this, SLOT(cancelWizzard()));
}
@@ -157,12 +174,30 @@ QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent()
{
QtProjectWizzardWindow* window = new QtProjectWizzardWindow(parentWidget());
connect(window, SIGNAL(previous()), &m_windowStack, SLOT(popWindow()));
connect(window, SIGNAL(canceled()), this, SLOT(cancelWizzard()));
window->setContent(new T(&m_settings, window));
window->setup();
m_windowStack.pushWindow(window);
return window;
}
QtProjectWizzardWindow* QtProjectWizzard::createWindowWithSummary(
std::function<void(QtProjectWizzardWindow*, QtProjectWizzardContentSummary*)> func
){
QtProjectWizzardWindow* window = new QtProjectWizzardWindow(parentWidget());
connect(window, SIGNAL(previous()), &m_windowStack, SLOT(popWindow()));
connect(window, SIGNAL(canceled()), this, SLOT(cancelWizzard()));
QtProjectWizzardContentSummary* summary = new QtProjectWizzardContentSummary(&m_settings, window);
window->setContent(summary);
func(window, summary);
m_windowStack.pushWindow(window);
return window;
@@ -232,43 +267,17 @@ ProjectSettings QtProjectWizzard::getSettingsForVisualStudioSolution(const std::
ProjectSettings QtProjectWizzard::getSettingsForCompilationDatabase(const std::string& compilationDatabasePath) const
{
// SolutionParserCompilationDatabase parser;
// parser.openSolutionFile(compilationDatabasePath);
// parser.parseDatabase();
ProjectSettings settings;
// 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> 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));
// }
// settings.setSourcePaths(sourcePaths);
// settings.setHeaderSearchPaths(headerPaths);
// settings.setFrameworkSearchPaths(frameworkSearchPaths);
settings.setCompilationDatabasePath(FilePath(compilationDatabasePath));
return settings;
}
void QtProjectWizzard::connectShowFiles(QtProjectWizzardContent* content)
{
connect(content, SIGNAL(filesButtonClicked(QtProjectWizzardContent*)),
this, SLOT(showFiles(QtProjectWizzardContent*)));
}
void QtProjectWizzard::cancelWizzard()
{
m_windowStack.clearWindows();
@@ -360,14 +369,23 @@ void QtProjectWizzard::sourcePaths()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsSource>();
connect(window, SIGNAL(next()), this, SLOT(headerSearchPaths()));
connect(dynamic_cast<QtProjectWizzardContentPathsSource*>(window->content()),
SIGNAL(showSourceFiles()), this, SLOT(showSourceFiles()));
connectShowFiles(window->content());
}
void QtProjectWizzard::headerSearchPaths()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsHeaderSearch>();
QtProjectWizzardWindow* window = createWindowWithSummary(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
{
ProjectSettings* settings = &m_settings;
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(settings, window), false, false);
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, false);
window->setup();
}
);
connect(window, SIGNAL(next()), this, SLOT(headerSearchPathsDone()));
}
@@ -375,14 +393,23 @@ void QtProjectWizzard::simpleSourcePaths()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsSourceSimple>();
connect(window, SIGNAL(next()), this, SLOT(simpleHeaderSearchPaths()));
connect(dynamic_cast<QtProjectWizzardContentPathsSourceSimple*>(window->content()),
SIGNAL(showSourceFiles()), this, SLOT(showSourceFiles()));
connectShowFiles(window->content());
}
void QtProjectWizzard::simpleHeaderSearchPaths()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsHeaderSearchSimple>();
QtProjectWizzardWindow* window = createWindowWithSummary(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
{
ProjectSettings* settings = &m_settings;
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchSimple(settings, window), false, false);
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, false);
window->setup();
}
);
connect(window, SIGNAL(next()), this, SLOT(headerSearchPathsDone()));
}
@@ -400,39 +427,125 @@ void QtProjectWizzard::headerSearchPathsDone()
void QtProjectWizzard::frameworkSearchPaths()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsFrameworkSearch>();
QtProjectWizzardWindow* window = createWindowWithSummary(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
{
ProjectSettings* settings = &m_settings;
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(settings, window), false, false);
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window), false, false);
window->setup();
}
);
connect(window, SIGNAL(next()), this, SLOT(showSummary()));
}
void QtProjectWizzard::showSourceFiles()
void QtProjectWizzard::headerPathsCDB()
{
QWidget* topWindow = m_windowStack.getTopWindow();
if (topWindow)
{
dynamic_cast<QtProjectWizzardWindow*>(topWindow)->content()->save();
}
QtProjectWizzardWindow* window = createWindowWithSummary(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
{
ProjectSettings* settings = &m_settings;
QtProjectWizzardContent* source = new QtProjectWizzardContentCDBSource(settings, window);
summary->addContent(source, false, false);
connectShowFiles(source);
QtProjectWizzardContent* header = new QtProjectWizzardContentPathsCDBHeader(settings, window);
summary->addContent(header, false, false);
connectShowFiles(header);
window->setup();
window->updateTitle("NEW PROJECT FROM COMPILATION DATABASE");
}
);
connect(window, SIGNAL(next()), this, SLOT(headerPathsCDBDone()));
}
void QtProjectWizzard::headerPathsCDBDone()
{
showSummary();
QWidget* widget = m_windowStack.getTopWindow();
if (widget)
{
QtProjectWizzardWindow* window = dynamic_cast<QtProjectWizzardWindow*>(widget);
window->updateTitle("NEW PROJECT FROM COMPILATION DATABASE - SUMMARY");
window->updateNextButton("Create");
window->setPreviousVisible(m_windowStack.getWindowCount() > 0);
}
}
void QtProjectWizzard::showFiles(QtProjectWizzardContent* content)
{
QtProjectWizzardWindow* window = createPopupWithContent<QtProjectWizzardContentSourceList>();
dynamic_cast<QtProjectWizzardContentSourceList*>(window->content())->showFilesFromSourcePaths();
dynamic_cast<QtProjectWizzardContentSourceList*>(window->content())->showFilesFromContent(content);
}
void QtProjectWizzard::showSummary()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentSummary>();
QtProjectWizzardWindow* window = createWindowWithSummary(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
{
summary->setIsForm(true);
ProjectSettings* settings = &m_settings;
QtProjectWizzardContentData* data = new QtProjectWizzardContentData(settings, window);
summary->addContent(data, false, false);
QtProjectWizzardContentBuildFile* buildFile = new QtProjectWizzardContentBuildFile(settings, window);
if (buildFile->getType() != QtProjectWizzardContentSelect::PROJECT_EMPTY)
{
summary->addContent(buildFile, false, true);
connect(dynamic_cast<QtProjectWizzardContentBuildFile*>(buildFile),
SIGNAL(refreshVisualStudioSolution(const std::string&)),
this, SLOT(refreshProjectFromVisualStudioSolution(const std::string&)));
}
if (buildFile->getType() != QtProjectWizzardContentSelect::PROJECT_CDB)
{
QtProjectWizzardContentPathsSource* source = new QtProjectWizzardContentPathsSource(settings, window);
summary->addContent(source, false, true);
connectShowFiles(source);
summary->addContent(new QtProjectWizzardContentSimple(settings, window), false, true);
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(settings, window), false, false);
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, false);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(settings, window), false, true);
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window), false, false);
}
}
else
{
QtProjectWizzardContent* headers = new QtProjectWizzardContentPathsCDBHeader(settings, window);
summary->addContent(headers, false, true);
connectShowFiles(headers);
data->hideLanguage();
}
summary->addContent(new QtProjectWizzardContentFlags(settings, window), true, false);
window->setup();
window->updateTitle("NEW PROJECT - SUMMARY");
window->updateNextButton("Create");
}
);
connect(window, SIGNAL(next()), this, SLOT(createProject()));
QtProjectWizzardContentSummary* summary = dynamic_cast<QtProjectWizzardContentSummary*>(window->content());
connect(dynamic_cast<QtProjectWizzardContentBuildFile*>(summary->contentBuildFile()),
SIGNAL(refreshVisualStudioSolution(const std::string&)),
this, SLOT(refreshProjectFromVisualStudioSolution(const std::string&)));
connect(dynamic_cast<QtProjectWizzardContentBuildFile*>(summary->contentBuildFile()),
SIGNAL(refreshCompilationDatabase(const std::string&)),
this, SLOT(refreshProjectFromCompilationDatabase(const std::string&)));
connect(dynamic_cast<QtProjectWizzardContentPathsSource*>(summary->contentPathsSource()),
SIGNAL(showSourceFiles()), this, SLOT(showSourceFiles()));
}
void QtProjectWizzard::createProject()
@@ -7,6 +7,7 @@
#include "qt/window/QtWindowStack.h"
class ProjectSettings;
class QtProjectWizzardContentSummary;
class QtProjectWizzardWindow;
class QtProjectWizzard
@@ -37,12 +38,16 @@ public slots:
private:
template<typename T>
QtProjectWizzardWindow* createWindowWithContent();
QtProjectWizzardWindow* createWindowWithSummary(
std::function<void(QtProjectWizzardWindow*, QtProjectWizzardContentSummary*)> func);
template<typename T>
QtProjectWizzardWindow* createPopupWithContent();
ProjectSettings getSettingsForVisualStudioSolution(const std::string& visualStudioSolutionPath) const;
ProjectSettings getSettingsForCompilationDatabase(const std::string& compilationDatabasePath) const;
void connectShowFiles(QtProjectWizzardContent* content);
QtWindowStack m_windowStack;
std::shared_ptr<QtProjectWizzardWindow> m_popup;
ProjectSettings m_settings;
@@ -67,7 +72,11 @@ private slots:
void headerSearchPathsDone();
void frameworkSearchPaths();
void showSourceFiles();
void headerPathsCDB();
void headerPathsCDBDone();
void showFiles(QtProjectWizzardContent* content);
void showSummary();
void createProject();
@@ -39,6 +39,10 @@ void QtProjectWizzardContent::populateWindow(QGridLayout* layout)
{
}
void QtProjectWizzardContent::populateWindow(QGridLayout* layout, int& row)
{
}
void QtProjectWizzardContent::populateForm(QGridLayout* layout, int& row)
{
}
@@ -70,6 +74,21 @@ QSize QtProjectWizzardContent::preferredWindowSize() const
return QSize(750, 620);
}
QStringList QtProjectWizzardContent::getFileNames() const
{
return QStringList();
}
QString QtProjectWizzardContent::getFileNamesTitle() const
{
return "File List";
}
QString QtProjectWizzardContent::getFileNamesDescription() const
{
return "files";
}
QLabel* QtProjectWizzardContent::createFormLabel(QString name) const
{
QLabel* label = new QLabel(name);
@@ -97,3 +116,20 @@ QtHelpButton* QtProjectWizzardContent::addHelpButton(QString helpString, QGridLa
layout->addWidget(button, row, QtProjectWizzardWindow::HELP_COL, Qt::AlignTop);
return button;
}
QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout* layout, int row) const
{
QPushButton* button = new QPushButton(name);
button->setObjectName("windowButton");
layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop);
connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
return button;
}
void QtProjectWizzardContent::buttonClicked()
{
save();
emit filesButtonClicked(this);
}
@@ -37,6 +37,7 @@ public:
virtual void populateWindow(QWidget* widget);
virtual void populateWindow(QGridLayout* layout);
virtual void populateWindow(QGridLayout* layout, int& row);
virtual void populateForm(QGridLayout* layout, int& row);
virtual void windowReady();
@@ -48,14 +49,25 @@ public:
virtual QSize preferredWindowSize() const;
virtual QStringList getFileNames() const;
virtual QString getFileNamesTitle() const;
virtual QString getFileNamesDescription() const;
signals:
void filesButtonClicked(QtProjectWizzardContent* content);
protected:
QLabel* createFormLabel(QString name) const;
QToolButton* createProjectButton(QString name, QString iconPath) const;
QtHelpButton* addHelpButton(QString helpString, QGridLayout* layout, int row) const;
QPushButton* addFilesButton(QString name, QGridLayout* layout, int row) const;
ProjectSettings* m_settings;
QtProjectWizzardWindow* m_window;
private slots:
void buttonClicked();
};
#endif // QT_PROJECT_WIZZARD_CONTENT_H
@@ -21,6 +21,11 @@ QtProjectWizzardContentBuildFile::QtProjectWizzardContentBuildFile(
}
}
QtProjectWizzardContentSelect::ProjectType QtProjectWizzardContentBuildFile::getType() const
{
return m_type;
}
void QtProjectWizzardContentBuildFile::populateForm(QGridLayout* layout, int& row)
{
QString name;
@@ -54,6 +59,11 @@ void QtProjectWizzardContentBuildFile::populateForm(QGridLayout* layout, int& ro
button->setToolTip("refresh paths");
connect(button, SIGNAL(clicked()), this, SLOT(refreshClicked()));
if (m_type == QtProjectWizzardContentSelect::PROJECT_CDB)
{
button->hide();
}
m_picker->layout()->addWidget(button);
layout->addWidget(m_picker, row, QtProjectWizzardWindow::BACK_COL);
@@ -76,6 +86,49 @@ void QtProjectWizzardContentBuildFile::load()
}
}
void QtProjectWizzardContentBuildFile::save()
{
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
case QtProjectWizzardContentSelect::PROJECT_VS:
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
{
FilePath path = m_picker->getText().toStdString();
if (!path.exists() || path.extension() != ".json")
{
return;
}
m_settings->setCompilationDatabasePath(m_picker->getText().toStdString());
break;
}
}
}
bool QtProjectWizzardContentBuildFile::check()
{
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
case QtProjectWizzardContentSelect::PROJECT_VS:
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
{
FilePath path = m_picker->getText().toStdString();
if (!path.exists() || path.extension() != ".json")
{
QMessageBox msgBox;
msgBox.setText("Please enter a valid compilation database file (*.json).");
msgBox.exec();
return false;
}
}
}
return true;
}
void QtProjectWizzardContentBuildFile::refreshClicked()
{
FilePath path = FilePath(m_picker->getText().toStdString());
@@ -101,14 +154,10 @@ void QtProjectWizzardContentBuildFile::refreshClicked()
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
case QtProjectWizzardContentSelect::PROJECT_CDB:
break;
case QtProjectWizzardContentSelect::PROJECT_VS:
{
emit refreshVisualStudioSolution(path.str());
break;
}
case QtProjectWizzardContentSelect::PROJECT_CDB:
emit refreshCompilationDatabase(path.str());
break;
}
}
@@ -14,15 +14,18 @@ class QtProjectWizzardContentBuildFile
signals:
void refreshVisualStudioSolution(const std::string&);
void refreshCompilationDatabase(const std::string&);
public:
QtProjectWizzardContentBuildFile(ProjectSettings* settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentSelect::ProjectType getType() const;
// QtProjectWizzardContent implementation
virtual void populateForm(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
private slots:
void refreshClicked();
@@ -0,0 +1,63 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h"
#include "data/parser/cxx/TaskParseCxx.h"
QtProjectWizzardContentCDBSource::QtProjectWizzardContentCDBSource(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(settings, window)
, m_text(nullptr)
{
}
void QtProjectWizzardContentCDBSource::populateWindow(QGridLayout* layout, int& row)
{
layout->setRowMinimumHeight(row++, 10);
QLabel* title = new QLabel("Source Files");
title->setWordWrap(true);
title->setObjectName("section");
layout->addWidget(title, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
layout->setRowStretch(row, 0);
m_text = new QLabel("");
layout->addWidget(m_text, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignTop);
addFilesButton("show source files", layout, row + 1);
row += 2;
layout->setColumnStretch(QtProjectWizzardWindow::FRONT_COL, 1);
layout->setColumnStretch(QtProjectWizzardWindow::BACK_COL, 2);
}
void QtProjectWizzardContentCDBSource::load()
{
std::vector<FilePath> filePaths = TaskParseCxx::getSourceFilesFromCDB(m_settings->getCompilationDatabasePath());
m_fileNames.clear();
for (const FilePath& path : filePaths)
{
m_fileNames << QString::fromStdString(path.str());
}
if (m_text)
{
m_text->setText(QString::number(m_fileNames.size()) + " source files were found in the compilation database.");
}
}
QStringList QtProjectWizzardContentCDBSource::getFileNames() const
{
return m_fileNames;
}
QString QtProjectWizzardContentCDBSource::getFileNamesTitle() const
{
return "Source Files";
}
QString QtProjectWizzardContentCDBSource::getFileNamesDescription() const
{
return "source files will be analyzed.";
}
@@ -0,0 +1,28 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_CDB_SOURCE_H
#define QT_PROJECT_WIZZARD_CONTENT_CDB_SOURCE_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QtProjectWizzardContentCDBSource
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentCDBSource(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populateWindow(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual QStringList getFileNames() const override;
virtual QString getFileNamesTitle() const override;
virtual QString getFileNamesDescription() const override;
private:
QLabel* m_text;
QStringList m_fileNames;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_CDB_SOURCE_H
@@ -5,9 +5,15 @@
QtProjectWizzardContentData::QtProjectWizzardContentData(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
, m_showLanguage(true)
{
}
void QtProjectWizzardContentData::hideLanguage()
{
m_showLanguage = false;
}
void QtProjectWizzardContentData::populateWindow(QGridLayout* layout)
{
int row = 0;
@@ -42,6 +48,7 @@ void QtProjectWizzardContentData::populateForm(QGridLayout* layout, int& row)
layout->addWidget(m_projectFileLocation, row, QtProjectWizzardWindow::BACK_COL);
row++;
QLabel* languageLabel = new QLabel("Language");
languageLabel->setObjectName("label");
m_language = new QComboBox();
@@ -49,13 +56,8 @@ void QtProjectWizzardContentData::populateForm(QGridLayout* layout, int& row)
m_language->insertItem(1, "C");
connect(m_language, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
layout->addWidget(languageLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_language, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
QLabel* standardLabel = createFormLabel("Standard");
layout->addWidget(standardLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
m_cppStandard = new QComboBox();
m_cppStandard->insertItem(0, "1z");
@@ -66,8 +68,6 @@ void QtProjectWizzardContentData::populateForm(QGridLayout* layout, int& row)
m_cppStandard->insertItem(5, "03");
m_cppStandard->insertItem(6, "98");
layout->addWidget(m_cppStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
m_cStandard = new QComboBox();
m_cStandard->insertItem(0, "1x");
m_cStandard->insertItem(1, "11");
@@ -76,7 +76,26 @@ void QtProjectWizzardContentData::populateForm(QGridLayout* layout, int& row)
m_cStandard->insertItem(4, "90");
m_cStandard->insertItem(5, "89");
layout->addWidget(m_cStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
if (m_showLanguage)
{
layout->addWidget(languageLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_language, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
layout->addWidget(standardLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_cppStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
layout->addWidget(m_cStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
}
else
{
languageLabel->hide();
m_language->hide();
standardLabel->hide();
m_cppStandard->hide();
m_cStandard->hide();
}
row++;
}
@@ -158,6 +177,11 @@ QSize QtProjectWizzardContentData::preferredWindowSize() const
void QtProjectWizzardContentData::handleSelectionChanged(int index)
{
if (!m_showLanguage)
{
return;
}
if (index != 0)
{
m_cStandard->show();
@@ -15,6 +15,8 @@ class QtProjectWizzardContentData
public:
QtProjectWizzardContentData(ProjectSettings* settings, QtProjectWizzardWindow* window);
void hideLanguage();
// QtProjectWizzardContent implementation
virtual void populateWindow(QGridLayout* layout) override;
virtual void populateForm(QGridLayout* layout, int& row) override;
@@ -33,6 +35,8 @@ private:
QComboBox* m_cppStandard;
QComboBox* m_cStandard;
bool m_showLanguage;
private slots:
void handleSelectionChanged(int index);
};
@@ -6,47 +6,24 @@
#include "qt/element/QtDirectoryListBox.h"
#include "settings/ApplicationSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/utility.h"
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
, m_subPaths(nullptr)
, m_addShowSourcesButton(false)
{
}
void QtProjectWizzardContentPaths::populateWindow(QGridLayout* layout)
{
int row = 0;
layout->setRowMinimumHeight(row, 10);
row++;
populateLayout(layout, row);
if (m_addShowSourcesButton)
{
layout->setRowStretch(row, 10);
addSourcesButton(layout, row);
}
if (m_subPaths)
{
layout->setRowMinimumHeight(row, 30);
row++;
m_subPaths->populateLayout(layout, row);
layout->setRowMinimumHeight(row, 10);
row++;
}
layout->setColumnStretch(QtProjectWizzardWindow::FRONT_COL, 1);
layout->setColumnStretch(QtProjectWizzardWindow::BACK_COL, 2);
populateWindow(layout, row);
}
void QtProjectWizzardContentPaths::populateLayout(QGridLayout* layout, int& row)
void QtProjectWizzardContentPaths::populateWindow(QGridLayout* layout, int& row)
{
layout->setRowMinimumHeight(row++, 10);
QLabel* title = new QLabel(m_titleString);
title->setWordWrap(true);
title->setObjectName("section");
@@ -63,6 +40,17 @@ void QtProjectWizzardContentPaths::populateLayout(QGridLayout* layout, int& row)
layout->addWidget(m_list, row, QtProjectWizzardWindow::BACK_COL, 2, 1, Qt::AlignTop);
row += 2;
if (m_showFilesString.size() > 0)
{
layout->setRowStretch(row, 10);
addFilesButton(m_showFilesString, layout, row);
}
row++;
layout->setColumnStretch(QtProjectWizzardWindow::FRONT_COL, 1);
layout->setColumnStretch(QtProjectWizzardWindow::BACK_COL, 2);
}
void QtProjectWizzardContentPaths::populateForm(QGridLayout* layout, int& row)
@@ -79,45 +67,11 @@ void QtProjectWizzardContentPaths::populateForm(QGridLayout* layout, int& row)
layout->addWidget(m_list, row, QtProjectWizzardWindow::BACK_COL);
row++;
if (m_addShowSourcesButton)
if (m_showFilesString.size() > 0)
{
addSourcesButton(layout, row);
addFilesButton(m_showFilesString, layout, row);
row++;
}
if (m_subPaths)
{
m_subPaths->populateForm(layout, row);
}
}
void QtProjectWizzardContentPaths::load()
{
loadPaths();
if (m_subPaths)
{
return m_subPaths->loadPaths();
}
}
void QtProjectWizzardContentPaths::save()
{
savePaths();
if (m_subPaths)
{
m_subPaths->savePaths();
}
}
bool QtProjectWizzardContentPaths::check()
{
if (m_subPaths)
{
return checkPaths() && m_subPaths->checkPaths();
}
return checkPaths();
}
QSize QtProjectWizzardContentPaths::preferredWindowSize() const
@@ -125,19 +79,6 @@ QSize QtProjectWizzardContentPaths::preferredWindowSize() const
return QSize(850, 500);
}
void QtProjectWizzardContentPaths::loadPaths()
{
}
void QtProjectWizzardContentPaths::savePaths()
{
}
bool QtProjectWizzardContentPaths::checkPaths()
{
return true;
}
void QtProjectWizzardContentPaths::setInfo(const QString& title, const QString& description, const QString& help)
{
m_titleString = title;
@@ -160,31 +101,12 @@ void QtProjectWizzardContentPaths::setHelpString(const QString& help)
m_helpString = help;
}
void QtProjectWizzardContentPaths::showSourcesClicked()
{
emit showSourceFiles();
}
void QtProjectWizzardContentPaths::addSourcesButton(QGridLayout* layout, int& row)
{
if (!m_addShowSourcesButton)
{
return;
}
QPushButton* button = new QPushButton("show files");
button->setObjectName("windowButton");
layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop);
connect(button, SIGNAL(clicked()), this, SLOT(showSourcesClicked()));
row++;
}
QtProjectWizzardContentPathsSource::QtProjectWizzardContentPathsSource(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPaths(settings, window)
{
m_addShowSourcesButton = true;
m_showFilesString = "show files";
setInfo(
"Project Paths",
@@ -200,17 +122,17 @@ QSize QtProjectWizzardContentPathsSource::preferredWindowSize() const
return QSize(850, 370);
}
void QtProjectWizzardContentPathsSource::loadPaths()
void QtProjectWizzardContentPathsSource::load()
{
m_list->setList(m_settings->getSourcePaths());
}
void QtProjectWizzardContentPathsSource::savePaths()
void QtProjectWizzardContentPathsSource::save()
{
m_settings->setSourcePaths(m_list->getList());
}
bool QtProjectWizzardContentPathsSource::checkPaths()
bool QtProjectWizzardContentPathsSource::check()
{
if (m_list->getList().size() == 0)
{
@@ -223,12 +145,58 @@ bool QtProjectWizzardContentPathsSource::checkPaths()
return true;
}
QStringList QtProjectWizzardContentPathsSource::getFileNames() const
{
return getSourceFileNames(false);
}
QString QtProjectWizzardContentPathsSource::getFileNamesTitle() const
{
return "Analyzed Files";
}
QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const
{
return "files will be analyzed.";
}
QStringList QtProjectWizzardContentPathsSource::getSourceFileNames(bool headersOnly) const
{
std::vector<FilePath> sourcePaths = m_settings->getSourcePaths();
std::vector<std::string> extensions;
if (!headersOnly)
{
utility::append(extensions, m_settings->getSourceExtensions());
}
utility::append(extensions, m_settings->getHeaderExtensions());
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(sourcePaths, extensions);
FilePath projectPath = FilePath(m_settings->getProjectFileLocation());
QStringList list;
for (const FileInfo& info : fileInfos)
{
FilePath path = info.path;
if (projectPath.exists())
{
path = path.relativeTo(projectPath);
}
list << QString::fromStdString(path.str());
}
return list;
}
QtProjectWizzardContentPathsSourceSimple::QtProjectWizzardContentPathsSourceSimple(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPathsSource(settings, window)
{
m_addShowSourcesButton = true;
m_showFilesString = "show files";
setTitleString("Project Paths");
setDescriptionString(
@@ -237,6 +205,43 @@ QtProjectWizzardContentPathsSourceSimple::QtProjectWizzardContentPathsSourceSimp
);
}
QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPathsSource(settings, window)
{
m_showFilesString = "show header files";
setTitleString("Header Paths");
setDescriptionString(
"Add the header files or directories containing the header files of the source files above. These header files "
"will be analyzed if included."
);
setHelpString(
"The compilation database only contains source files. Add the header files or directories containing the header "
"files of these source files. The header files will be analyzed if included."
);
}
bool QtProjectWizzardContentPathsCDBHeader::check()
{
return true;
}
QStringList QtProjectWizzardContentPathsCDBHeader::getFileNames() const
{
return getSourceFileNames(true);
}
QString QtProjectWizzardContentPathsCDBHeader::getFileNamesTitle() const
{
return "Header Files";
}
QString QtProjectWizzardContentPathsCDBHeader::getFileNamesDescription() const
{
return "header files found.";
}
QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSearch(
ProjectSettings* settings, QtProjectWizzardWindow* window
@@ -250,16 +255,14 @@ QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSear
"header files of frameworks or libraries that your project uses. These files won't be analyzed, but Coati needs "
"them for correct analysis."
);
m_subPaths = new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window);
}
void QtProjectWizzardContentPathsHeaderSearch::loadPaths()
void QtProjectWizzardContentPathsHeaderSearch::load()
{
m_list->setList(m_settings->getHeaderSearchPaths());
}
void QtProjectWizzardContentPathsHeaderSearch::savePaths()
void QtProjectWizzardContentPathsHeaderSearch::save()
{
m_settings->setHeaderSearchPaths(m_list->getList());
}
@@ -298,12 +301,12 @@ QtProjectWizzardContentPathsHeaderSearchGlobal::QtProjectWizzardContentPathsHead
);
}
void QtProjectWizzardContentPathsHeaderSearchGlobal::loadPaths()
void QtProjectWizzardContentPathsHeaderSearchGlobal::load()
{
m_list->setList(ApplicationSettings::getInstance()->getHeaderSearchPaths());
}
void QtProjectWizzardContentPathsHeaderSearchGlobal::savePaths()
void QtProjectWizzardContentPathsHeaderSearchGlobal::save()
{
ApplicationSettings::getInstance()->setHeaderSearchPaths(m_list->getList());
ApplicationSettings::getInstance()->save();
@@ -321,16 +324,14 @@ QtProjectWizzardContentPathsFrameworkSearch::QtProjectWizzardContentPathsFramewo
"Framework Search Paths define where MacOS framework containers (.framework), that your project depends on, are "
"found."
);
m_subPaths = new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window);
}
void QtProjectWizzardContentPathsFrameworkSearch::loadPaths()
void QtProjectWizzardContentPathsFrameworkSearch::load()
{
m_list->setList(m_settings->getFrameworkSearchPaths());
}
void QtProjectWizzardContentPathsFrameworkSearch::savePaths()
void QtProjectWizzardContentPathsFrameworkSearch::save()
{
m_settings->setFrameworkSearchPaths(m_list->getList());
}
@@ -356,12 +357,12 @@ QtProjectWizzardContentPathsFrameworkSearchGlobal::QtProjectWizzardContentPathsF
);
}
void QtProjectWizzardContentPathsFrameworkSearchGlobal::loadPaths()
void QtProjectWizzardContentPathsFrameworkSearchGlobal::load()
{
m_list->setList(ApplicationSettings::getInstance()->getFrameworkSearchPaths());
}
void QtProjectWizzardContentPathsFrameworkSearchGlobal::savePaths()
void QtProjectWizzardContentPathsFrameworkSearchGlobal::save()
{
ApplicationSettings::getInstance()->setFrameworkSearchPaths(m_list->getList());
ApplicationSettings::getInstance()->save();
@@ -20,19 +20,11 @@ public:
// QtSettingsWindow implementation
virtual void populateWindow(QGridLayout* layout) override;
void populateLayout(QGridLayout* layout, int& row);
virtual void populateWindow(QGridLayout* layout, int& row) override;
virtual void populateForm(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
virtual QSize preferredWindowSize() const override;
virtual void loadPaths();
virtual void savePaths();
virtual bool checkPaths();
protected:
void setInfo(const QString& title, const QString& description, const QString& help);
void setTitleString(const QString& title);
@@ -40,16 +32,10 @@ protected:
void setHelpString(const QString& help);
QtDirectoryListBox* m_list;
QtProjectWizzardContentPaths* m_subPaths;
bool m_addShowSourcesButton;
private slots:
void showSourcesClicked();
QString m_showFilesString;
private:
void addSourcesButton(QGridLayout* layout, int& row);
QString m_titleString;
QString m_descriptionString;
QString m_helpString;
@@ -65,10 +51,16 @@ public:
// QtProjectWizzardContent implementation
virtual QSize preferredWindowSize() const override;
// QtProjectWizzardContentPaths implementation
virtual void loadPaths() override;
virtual void savePaths() override;
virtual bool checkPaths() override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
virtual QStringList getFileNames() const override;
virtual QString getFileNamesTitle() const override;
virtual QString getFileNamesDescription() const override;
protected:
QStringList getSourceFileNames(bool headersOnly) const;
};
class QtProjectWizzardContentPathsSourceSimple
@@ -78,6 +70,20 @@ public:
QtProjectWizzardContentPathsSourceSimple(ProjectSettings* settings, QtProjectWizzardWindow* window);
};
class QtProjectWizzardContentPathsCDBHeader
: public QtProjectWizzardContentPathsSource
{
public:
QtProjectWizzardContentPathsCDBHeader(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual bool check() override;
virtual QStringList getFileNames() const override;
virtual QString getFileNamesTitle() const override;
virtual QString getFileNamesDescription() const override;
};
class QtProjectWizzardContentPathsHeaderSearch
: public QtProjectWizzardContentPaths
@@ -86,8 +92,8 @@ public:
QtProjectWizzardContentPathsHeaderSearch(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void loadPaths() override;
virtual void savePaths() override;
virtual void load() override;
virtual void save() override;
virtual bool isScrollAble() const override;
};
@@ -106,8 +112,8 @@ public:
QtProjectWizzardContentPathsHeaderSearchGlobal(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void loadPaths() override;
virtual void savePaths() override;
virtual void load() override;
virtual void save() override;
};
@@ -118,8 +124,8 @@ public:
QtProjectWizzardContentPathsFrameworkSearch(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void loadPaths() override;
virtual void savePaths() override;
virtual void load() override;
virtual void save() override;
virtual bool isScrollAble() const override;
};
@@ -131,8 +137,8 @@ public:
QtProjectWizzardContentPathsFrameworkSearchGlobal(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void loadPaths() override;
virtual void savePaths() override;
virtual void load() override;
virtual void save() override;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_PATHS_H
@@ -1,67 +0,0 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h"
#include <QSysInfo>
QtProjectWizzardContentPreferences::QtProjectWizzardContentPreferences(ProjectSettings* settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
, m_headerSearch(nullptr)
, m_frameworkSearch(nullptr)
{
m_headerSearch = new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
m_frameworkSearch = new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window);
}
}
void QtProjectWizzardContentPreferences::populateWindow(QGridLayout* layout)
{
int row = 0;
layout->setRowMinimumHeight(row, 10);
row++;
m_headerSearch->populateForm(layout, row);
if (m_frameworkSearch)
{
m_frameworkSearch->populateForm(layout, row);
}
layout->setRowMinimumHeight(row, 10);
layout->setRowStretch(row, 1);
}
void QtProjectWizzardContentPreferences::windowReady()
{
m_window->updateTitle("PREFERENCES");
m_window->updateNextButton("Save");
m_window->setPreviousVisible(false);
}
void QtProjectWizzardContentPreferences::load()
{
m_headerSearch->load();
if (m_frameworkSearch)
{
m_frameworkSearch->load();
}
}
void QtProjectWizzardContentPreferences::save()
{
m_headerSearch->save();
if (m_frameworkSearch)
{
m_frameworkSearch->save();
}
}
bool QtProjectWizzardContentPreferences::isScrollAble() const
{
return true;
}
@@ -1,28 +0,0 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
#define QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
class QtProjectWizzardContentPreferences
: public QtProjectWizzardContent
{
public:
QtProjectWizzardContentPreferences(ProjectSettings* settings, QtProjectWizzardWindow* window);
protected:
// QtProjectContentWindow implementation
virtual void populateWindow(QGridLayout* layout) override;
virtual void windowReady() override;
virtual void load() override;
virtual void save() override;
virtual bool isScrollAble() const override;
private:
QtProjectWizzardContentPathsHeaderSearchGlobal* m_headerSearch;
QtProjectWizzardContentPathsFrameworkSearchGlobal* m_frameworkSearch;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
@@ -67,8 +67,6 @@ 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);
@@ -3,9 +3,6 @@
#include <QListView>
#include <QStringListModel>
#include "utility/file/FileSystem.h"
#include "utility/utility.h"
QtProjectWizzardContentSourceList::QtProjectWizzardContentSourceList(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
@@ -32,7 +29,6 @@ void QtProjectWizzardContentSourceList::populateWindow(QWidget* widget)
void QtProjectWizzardContentSourceList::windowReady()
{
m_window->updateTitle("Analyzed Files");
}
QSize QtProjectWizzardContentSourceList::preferredWindowSize() const
@@ -40,34 +36,13 @@ QSize QtProjectWizzardContentSourceList::preferredWindowSize() const
return QSize(500, 500);
}
void QtProjectWizzardContentSourceList::showFilesFromSourcePaths()
void QtProjectWizzardContentSourceList::showFilesFromContent(QtProjectWizzardContent* content)
{
std::vector<FilePath> sourcePaths = m_settings->getSourcePaths();
QStringList list = content->getFileNames();
m_text->setText(QString::number(list.size()) + " " + content->getFileNamesDescription());
m_window->updateTitle(content->getFileNamesTitle());
std::vector<std::string> extensions;
utility::append(extensions, m_settings->getSourceExtensions());
utility::append(extensions, m_settings->getHeaderExtensions());
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(sourcePaths, extensions);
FilePath projectPath = FilePath(m_settings->getProjectFileLocation());
QStringList list;
for (const FileInfo& info : fileInfos)
{
FilePath path = info.path;
if (projectPath.exists())
{
path = path.relativeTo(projectPath);
}
list << QString::fromStdString(path.str());
}
m_text->setText(QString::number(list.size()) + " files will be analyzed.");
QStringListModel* model = new QStringListModel(this);
model->setStringList(list);
m_list->setModel(model);
QStringListModel* model = new QStringListModel(this);
model->setStringList(list);
m_list->setModel(model);
}
@@ -18,7 +18,7 @@ public:
virtual QSize preferredWindowSize() const override;
void showFilesFromSourcePaths();
void showFilesFromContent(QtProjectWizzardContent* content);
private:
QLabel* m_text;
@@ -1,143 +1,134 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
#include <QSysInfo>
QtProjectWizzardContentSummary::QtProjectWizzardContentSummary(ProjectSettings* settings, QtProjectWizzardWindow* window)
QtProjectWizzardContentSummary::QtProjectWizzardContentSummary(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(settings, window)
, m_data(nullptr)
, m_buildFile(nullptr)
, m_source(nullptr)
, m_simple(nullptr)
, m_headerSearch(nullptr)
, m_frameworkSearch(nullptr)
, m_isForm(false)
{
m_data = new QtProjectWizzardContentData(settings, window);
m_buildFile = new QtProjectWizzardContentBuildFile(settings, window);
m_source = new QtProjectWizzardContentPathsSource(settings, window);
m_simple = new QtProjectWizzardContentSimple(settings, window);
m_headerSearch = new QtProjectWizzardContentPathsHeaderSearch(settings, window);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
m_frameworkSearch = new QtProjectWizzardContentPathsFrameworkSearch(settings, window);
}
m_compilerFlags = new QtProjectWizzardContentFlags(settings, window);
}
QtProjectWizzardContentBuildFile* QtProjectWizzardContentSummary::contentBuildFile()
void QtProjectWizzardContentSummary::addContent(QtProjectWizzardContent* content, bool advanced, bool gapBefore)
{
return m_buildFile;
Element element;
element.content = content;
element.advanced = advanced;
element.gapBefore = gapBefore;
m_elements.push_back(element);
}
QtProjectWizzardContentPathsSource* QtProjectWizzardContentSummary::contentPathsSource()
void QtProjectWizzardContentSummary::setIsForm(bool isForm)
{
return m_source;
m_isForm = isForm;
}
void QtProjectWizzardContentSummary::populateWindow(QGridLayout* layout)
{
int row = 0;
layout->setRowMinimumHeight(row, 10);
row++;
m_data->populateForm(layout, row);
layout->setRowMinimumHeight(row, 15);
row++;
int row2 = row;
m_buildFile->populateForm(layout, row);
if (row != row2)
if (m_isForm)
{
layout->setRowMinimumHeight(row, 15);
row++;
populateForm(layout, row);
return;
}
m_source->populateForm(layout, row);
layout->setRowMinimumHeight(row, 15);
row++;
layout->setRowMinimumHeight(row++, 10);
m_simple->populateForm(layout, row);
m_headerSearch->populateForm(layout, row);
if (m_frameworkSearch)
for (const Element& element : m_elements)
{
layout->setRowMinimumHeight(row, 15);
row++;
m_frameworkSearch->populateForm(layout, row);
if (element.advanced)
{
continue;
}
if (element.gapBefore)
{
layout->setRowMinimumHeight(row++, 20);
}
element.content->populateWindow(layout, row);
}
layout->setRowMinimumHeight(row, 15);
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);
row++;
QLabel* advancedLabel = createFormLabel("ADVANCED");
layout->addWidget(advancedLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
row++;
m_compilerFlags->populateForm(layout, row);
layout->setRowMinimumHeight(row, 10);
layout->setRowStretch(row, 1);
}
void QtProjectWizzardContentSummary::windowReady()
void QtProjectWizzardContentSummary::populateForm(QGridLayout* layout, int& row)
{
m_window->updateTitle("NEW PROJECT - SUMMARY");
m_window->updateNextButton("Create");
layout->setRowMinimumHeight(row++, 10);
bool hasAdvanced = false;
for (int i = 0; i < 2; i++)
{
bool advanced = i > 0;
for (const Element& element : m_elements)
{
if (element.advanced != advanced)
{
hasAdvanced = true;
continue;
}
if (element.gapBefore)
{
layout->setRowMinimumHeight(row++, 15);
}
element.content->populateForm(layout, row);
}
if (i > 0 || !hasAdvanced)
{
continue;
}
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);
QLabel* advancedLabel = createFormLabel("ADVANCED");
layout->addWidget(advancedLabel, row++, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
layout->setRowMinimumHeight(row++, 15);
}
layout->setRowMinimumHeight(row, 10);
layout->setRowStretch(row, 1);
}
void QtProjectWizzardContentSummary::load()
{
m_data->load();
m_buildFile->load();
m_source->load();
m_simple->load();
m_headerSearch->load();
if (m_frameworkSearch)
for (const Element& element : m_elements)
{
m_frameworkSearch->load();
element.content->load();
}
m_compilerFlags->load();
}
void QtProjectWizzardContentSummary::save()
{
m_data->save();
m_buildFile->save();
m_source->save();
m_simple->save();
m_headerSearch->save();
if (m_frameworkSearch)
for (const Element& element : m_elements)
{
m_frameworkSearch->save();
element.content->save();
}
m_compilerFlags->save();
}
bool QtProjectWizzardContentSummary::check()
{
return
m_data->check() &&
m_buildFile->check() &&
m_source->check() &&
m_simple->check() &&
m_headerSearch->check() &&
(!m_frameworkSearch || m_frameworkSearch->check()) &&
m_compilerFlags->check();
for (const Element& element : m_elements)
{
if (!element.content->check())
{
return false;
}
}
return true;
}
bool QtProjectWizzardContentSummary::isScrollAble() const
@@ -2,25 +2,28 @@
#define QT_PROJECT_WIZZARD_CONTENT_SUMMARY_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentData.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentFlags.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
class QtProjectWizzardContentSummary
: public QtProjectWizzardContent
{
private:
struct Element
{
QtProjectWizzardContent* content;
bool advanced;
bool gapBefore;
};
public:
QtProjectWizzardContentSummary(ProjectSettings* settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentBuildFile* contentBuildFile();
QtProjectWizzardContentPathsSource* contentPathsSource();
void addContent(QtProjectWizzardContent* content, bool advanced, bool gapBefore);
void setIsForm(bool isForm);
protected:
// QtProjectContentWindow implementation
// QtProjectWizzardContent implementation
virtual void populateWindow(QGridLayout* layout) override;
virtual void windowReady() override;
virtual void populateForm(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
@@ -29,13 +32,9 @@ protected:
virtual bool isScrollAble() const override;
private:
QtProjectWizzardContentData* m_data;
QtProjectWizzardContentBuildFile* m_buildFile;
QtProjectWizzardContentPathsSource* m_source;
QtProjectWizzardContentSimple* m_simple;
QtProjectWizzardContentPathsHeaderSearch* m_headerSearch;
QtProjectWizzardContentPathsFrameworkSearch* m_frameworkSearch;
QtProjectWizzardContentFlags* m_compilerFlags;
std::vector<Element> m_elements;
bool m_isForm;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_SUMMARY_H
+2
View File
@@ -21,6 +21,8 @@ add_files(
data/parser/cxx/ASTVisitor.h
data/parser/cxx/CommentHandler.cpp
data/parser/cxx/CommentHandler.h
data/parser/cxx/CxxCompilationDatabaseSingle.cpp
data/parser/cxx/CxxCompilationDatabaseSingle.h
data/parser/cxx/CxxDiagnosticConsumer.cpp
data/parser/cxx/CxxDiagnosticConsumer.h
data/parser/cxx/CxxParser.cpp
+7 -10
View File
@@ -10,7 +10,6 @@
#include "data/parser/ParseLocation.h"
#include "utility/file/FileManager.h"
#include "utility/file/FileSystem.h"
#include "utility/ScopedSwitcher.h"
@@ -1004,9 +1003,7 @@ ParseLocation ASTVisitor::getDeclRefRange(clang::NamedDecl *decl, clang::SourceL
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
if (fileEntry != NULL)
{
std::string fielName = fileEntry->getName();
std::string filePath = FileSystem::absoluteFilePath(fielName);
parseLocation.filePath = FilePath(filePath);
parseLocation.filePath = FilePath(fileEntry->getName()).canonical();
}
}
@@ -1488,9 +1485,9 @@ bool ASTVisitor::isLocatedInUnparsedProjectFile(clang::SourceLocation loc)
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
if (fileEntry != NULL)
{
std::string fielName = fileEntry->getName();
std::string filePath = FileSystem::absoluteFilePath(fielName);
ret = m_fileRegister->includeFileIsParsing(filePath);
std::string fileName = fileEntry->getName();
FilePath filePath = FilePath(fileName).canonical();
ret = m_fileRegister->includeFileIsParsing(filePath.str());
}
}
m_inUnparsedProjectFileMap[fileId] = ret;
@@ -1522,9 +1519,9 @@ bool ASTVisitor::isLocatedInProjectFile(clang::SourceLocation loc)
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
if (fileEntry != NULL)
{
std::string fielName = fileEntry->getName();
std::string filePath = FileSystem::absoluteFilePath(fielName);
bool ret = m_fileRegister->getFileManager()->hasFilePath(filePath);
std::string fileName = fileEntry->getName();
FilePath filePath = FilePath(fileName).canonical();
bool ret = m_fileRegister->getFileManager()->hasFilePath(filePath.str());
m_inProjectFileMap[fileId] = ret;
return ret;
}
@@ -0,0 +1,22 @@
#include "data/parser/cxx/CxxCompilationDatabaseSingle.h"
CxxCompilationDatabaseSingle::CxxCompilationDatabaseSingle(const clang::tooling::CompileCommand& command)
: m_command(command)
{
}
std::vector<clang::tooling::CompileCommand> CxxCompilationDatabaseSingle::getCompileCommands(
llvm::StringRef FilePath
) const {
return getAllCompileCommands();
}
std::vector<std::string> CxxCompilationDatabaseSingle::getAllFiles() const
{
return std::vector<std::string>(1, m_command.Filename);
}
std::vector<clang::tooling::CompileCommand> CxxCompilationDatabaseSingle::getAllCompileCommands() const
{
return std::vector<clang::tooling::CompileCommand>(1, m_command);
}
@@ -0,0 +1,20 @@
#ifndef CXX_COMPILATION_DATABASE_SINGLE_H
#define CXX_COMPILATION_DATABASE_SINGLE_H
#include "clang/Tooling/CompilationDatabase.h"
class CxxCompilationDatabaseSingle
: public clang::tooling::CompilationDatabase
{
public:
CxxCompilationDatabaseSingle(const clang::tooling::CompileCommand& command);
virtual std::vector<clang::tooling::CompileCommand> getCompileCommands(llvm::StringRef FilePath) const override;
virtual std::vector<std::string> getAllFiles() const override;
virtual std::vector<clang::tooling::CompileCommand> getAllCompileCommands() const override;
private:
clang::tooling::CompileCommand m_command;
};
#endif // CXX_COMPILATION_DATABASE_SINGLE_H
+48 -18
View File
@@ -8,6 +8,7 @@
#include "utility/text/TextAccess.h"
#include "data/parser/cxx/ASTActionFactory.h"
#include "data/parser/cxx/CxxCompilationDatabaseSingle.h"
#include "data/parser/cxx/CxxDiagnosticConsumer.h"
namespace
@@ -51,6 +52,7 @@ namespace
}
}
CxxParser::CxxParser(ParserClient* client, const FileManager* fileManager)
: Parser(client)
, m_fileRegister(std::make_shared<FileRegister>(fileManager))
@@ -94,7 +96,7 @@ void CxxParser::parseFile(const FilePath& filePath, std::shared_ptr<TextAccess>
runToolOnCodeWithArgs(diagnostics.get(), actionFactory.create(), textAccess->getText(), args);
}
std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arguments) const
std::vector<std::string> CxxParser::getCommandlineArgumentsEssential(const Arguments& arguments) const
{
std::vector<std::string> args;
@@ -111,6 +113,32 @@ std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arg
// The option -c signals that no executable is built.
args.push_back("-c");
args.insert(args.begin(), arguments.compilerFlags.begin(), arguments.compilerFlags.end());
for (const FilePath& path : arguments.headerSearchPaths)
{
args.push_back("-I" + path.str());
}
for (const FilePath& path : arguments.systemHeaderSearchPaths)
{
args.push_back("-isystem");
args.push_back(path.str());
}
for (const FilePath& path : arguments.frameworkSearchPaths)
{
args.push_back("-iframework");
args.push_back(path.str());
}
return args;
}
std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arguments) const
{
std::vector<std::string> args = getCommandlineArgumentsEssential(arguments);
// The option '-x c++' treats subsequent input files as C++.
args.push_back("-x");
std::string language = getLanguageArgument(arguments.language);
@@ -122,23 +150,6 @@ std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arg
standard += arguments.languageStandard;
args.push_back(standard);
args.insert(args.begin(), arguments.compilerFlags.begin(), arguments.compilerFlags.end());
for (const FilePath& path : arguments.headerSearchPaths)
{
args.push_back("-I" + path.str());
}
for (const FilePath& path : arguments.systemHeaderSearchPaths)
{
args.push_back("-isystem" + path.str());
}
for (const FilePath& path : arguments.frameworkSearchPaths)
{
args.push_back("-iframework" + path.str());
}
return args;
}
@@ -186,6 +197,12 @@ void CxxParser::setupParsing(const std::vector<FilePath>& filePaths, const Argum
m_diagnostics = getDiagnostics(arguments);
}
void CxxParser::setupParsingCDB(const std::vector<FilePath>& filePaths, const Arguments& arguments)
{
m_fileRegister->setFilePaths(filePaths);
m_diagnostics = getDiagnostics(arguments);
}
void CxxParser::runTool(const std::vector<std::string>& files)
{
clang::tooling::ClangTool tool(*m_compilationDatabase, files);
@@ -195,6 +212,19 @@ void CxxParser::runTool(const std::vector<std::string>& files)
tool.run(&actionFactory);
}
void CxxParser::runTool(clang::tooling::CompileCommand command, const Arguments& arguments)
{
std::vector<std::string> args = getCommandlineArgumentsEssential(arguments);
command.CommandLine.insert(command.CommandLine.end(), args.begin(), args.end());
CxxCompilationDatabaseSingle compilationDatabase(command);
clang::tooling::ClangTool tool(compilationDatabase, std::vector<std::string>(1, command.Filename));
tool.setDiagnosticConsumer(m_diagnostics.get());
ASTActionFactory actionFactory(m_client, m_fileRegister.get());
tool.run(&actionFactory);
}
FileRegister* CxxParser::getFileRegister()
{
return m_fileRegister.get();
+6 -9
View File
@@ -1,16 +1,9 @@
#ifndef CXX_PARSER_H
#define CXX_PARSER_H
#include "data/parser/cxx/CxxCompilationDatabaseSingle.h"
#include "data/parser/Parser.h"
namespace clang
{
namespace tooling
{
class FixedCompilationDatabase;
}
}
class CxxDiagnosticConsumer;
class FileManager;
class FileRegister;
@@ -27,6 +20,7 @@ public:
virtual void parseFile(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess, const Arguments& arguments);
private:
std::vector<std::string> getCommandlineArgumentsEssential(const Arguments& arguments) const;
std::vector<std::string> getCommandlineArguments(const Arguments& arguments) const;
std::shared_ptr<clang::tooling::FixedCompilationDatabase> getCompilationDatabase(const Arguments& arguments) const;
@@ -34,7 +28,10 @@ private:
// Accessed by TaskParseCxx
void setupParsing(const std::vector<FilePath>& filePaths, const Arguments& arguments);
void setupParsingCDB(const std::vector<FilePath>& filePaths, const Arguments& arguments);
void runTool(const std::vector<std::string>& files);
void runTool(clang::tooling::CompileCommand command, const Arguments& arguments);
FileRegister* getFileRegister();
ParserClient* getParserClient();
@@ -45,7 +42,7 @@ private:
std::shared_ptr<FileRegister> m_fileRegister;
std::shared_ptr<clang::tooling::FixedCompilationDatabase> m_compilationDatabase;
std::shared_ptr<clang::tooling::CompilationDatabase> m_compilationDatabase;
std::shared_ptr<CxxDiagnosticConsumer> m_diagnostics;
};
@@ -36,6 +36,7 @@ void PreprocessorCallbacks::FileChanged(
}
FilePath filePath(fileEntry->getName());
filePath = filePath.canonical();
if (m_fileRegister->getFileManager()->hasFilePath(filePath.str()))
{
+2 -1
View File
@@ -19,6 +19,7 @@ public:
std::vector<FilePath> sourcePaths;
sourcePaths.push_back("./data/FileManagerTestSuite/src/");
sourcePaths.push_back("./data/FileManagerTestSuite/include/");
std::vector<FilePath> headerPaths;
std::vector<std::string> sourceExtensions;
sourceExtensions.push_back(".cpp");
sourceExtensions.push_back(".c");
@@ -27,7 +28,7 @@ public:
includeExtensions.push_back(".h");
FileManager fm;
fm.setPaths(sourcePaths, sourceExtensions, includeExtensions);
fm.setPaths(sourcePaths, headerPaths, sourceExtensions, includeExtensions);
fm.fetchFilePaths(std::vector<FileInfo>());
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 4);
@@ -14,6 +14,11 @@ TaskParseCxx::TaskParseCxx(
{
}
std::vector<FilePath> TaskParseCxx::getSourceFilesFromCDB(const FilePath& compilationDatabasePath)
{
return std::vector<FilePath>();
}
void TaskParseCxx::enter()
{
m_client->startParsing();