logic: Reworked CDB project setup
* added separate step for project name, project location and cdb path * added description that project stays up-to-date under cdb path picker. * added include and framework paths to advanced settings * disregard source extensions for cdb projects bug id = 70
This commit is contained in:
@@ -25,6 +25,10 @@
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
#description {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
#label {
|
||||
font-size: 12pt;
|
||||
font-weight: bold;
|
||||
|
||||
+6
-2
@@ -250,15 +250,19 @@ void Project::updateFileManager()
|
||||
std::vector<FilePath> sourcePaths = projSettings->getAbsoluteSourcePaths();
|
||||
std::vector<FilePath> headerPaths = sourcePaths;
|
||||
|
||||
std::vector<std::string> sourceExtensions;
|
||||
|
||||
if (projSettings->getCompilationDatabasePath().exists())
|
||||
{
|
||||
sourcePaths = TaskParseCxx::getSourceFilesFromCDB(projSettings->getCompilationDatabasePath());
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceExtensions = projSettings->getSourceExtensions();
|
||||
}
|
||||
|
||||
std::vector<FilePath> excludePaths = projSettings->getAbsoluteExcludePaths();
|
||||
|
||||
std::vector<std::string> sourceExtensions = projSettings->getSourceExtensions();
|
||||
|
||||
m_fileManager.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
for (std::map<FilePath, FileInfo>::iterator it = m_files.begin(); it != m_files.end(); it++)
|
||||
{
|
||||
const FilePath& filePath = it->first;
|
||||
if (filePath.exists() && !hasSourceExtension(filePath))
|
||||
if (filePath.exists() && !hasSourceFilePath(filePath))
|
||||
{
|
||||
FileInfo fileInfo = FileSystem::getFileInfoForPath(filePath);
|
||||
|
||||
@@ -63,6 +63,8 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
}
|
||||
}
|
||||
|
||||
m_sourceFiles.clear();
|
||||
|
||||
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions);
|
||||
for (FileInfo fileInfo: fileInfos)
|
||||
{
|
||||
@@ -72,6 +74,8 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
continue;
|
||||
}
|
||||
|
||||
m_sourceFiles.insert(filePath);
|
||||
|
||||
std::map<FilePath, FileInfo>::iterator it = m_files.find(filePath);
|
||||
if (it != m_files.end())
|
||||
{
|
||||
@@ -112,7 +116,7 @@ std::set<FilePath> FileManager::getRemovedFilePaths() const
|
||||
|
||||
bool FileManager::hasFilePath(const FilePath& filePath) const
|
||||
{
|
||||
if (m_files.find(filePath) != m_files.end())
|
||||
if (hasSourceFilePath(filePath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -133,9 +137,14 @@ bool FileManager::hasFilePath(const FilePath& filePath) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileManager::hasSourceExtension(const FilePath& filePath) const
|
||||
bool FileManager::hasSourceFilePath(const FilePath& filePath) const
|
||||
{
|
||||
return filePath.hasExtension(m_sourceExtensions);
|
||||
if (m_sourceFiles.find(filePath) != m_sourceFiles.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const FileInfo FileManager::getFileInfo(const FilePath& filePath) const
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
std::set<FilePath> getRemovedFilePaths() const;
|
||||
|
||||
virtual bool hasFilePath(const FilePath& filePath) const;
|
||||
virtual bool hasSourceExtension(const FilePath& filePath) const;
|
||||
virtual bool hasSourceFilePath(const FilePath& filePath) const;
|
||||
|
||||
virtual const FileInfo getFileInfo(const FilePath& filePath) const;
|
||||
|
||||
@@ -47,6 +47,8 @@ private:
|
||||
std::set<FilePath> m_addedFiles;
|
||||
std::set<FilePath> m_updatedFiles;
|
||||
std::set<FilePath> m_removedFiles;
|
||||
|
||||
std::set<FilePath> m_sourceFiles;
|
||||
};
|
||||
|
||||
#endif // FILE_MANAGER_H
|
||||
|
||||
@@ -19,7 +19,7 @@ void FileRegister::setFilePaths(const std::vector<FilePath>& filePaths)
|
||||
{
|
||||
FilePath path = p.exists() ? p.absolute() : p;
|
||||
|
||||
if (m_fileManager->hasSourceExtension(path))
|
||||
if (m_fileManager->hasSourceFilePath(path))
|
||||
{
|
||||
m_sourceFilePaths.emplace(path, STATE_UNPARSED);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,8 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
|
||||
it.pop();
|
||||
continue;
|
||||
}
|
||||
if (boost::filesystem::is_regular_file(*it) && hasExtension(it->path().string(), fileExtensions))
|
||||
if (boost::filesystem::is_regular_file(*it) &&
|
||||
(!fileExtensions.size() || hasExtension(it->path().string(), fileExtensions)))
|
||||
{
|
||||
std::time_t t = boost::filesystem::last_write_time(*it);
|
||||
boost::posix_time::ptime lastWriteTime = boost::posix_time::from_time_t(t);
|
||||
@@ -89,7 +90,7 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (path.exists() && path.hasExtension(fileExtensions))
|
||||
else if (path.exists() && (!fileExtensions.size() || path.hasExtension(fileExtensions)))
|
||||
{
|
||||
std::time_t t = boost::filesystem::last_write_time(path.path());
|
||||
boost::posix_time::ptime lastWriteTime = boost::posix_time::from_time_t(t);
|
||||
|
||||
@@ -157,8 +157,10 @@ std::vector<std::string> SolutionParserVisualStudio::getCompileFlags()
|
||||
|
||||
std::vector<std::string> validExtensions;
|
||||
validExtensions.push_back(".c");
|
||||
validExtensions.push_back(".cc");
|
||||
validExtensions.push_back(".cpp");
|
||||
validExtensions.push_back(".h");
|
||||
validExtensions.push_back(".hh");
|
||||
validExtensions.push_back(".hpp");
|
||||
|
||||
for (unsigned int i = 0; i < projectFiles.size(); i++)
|
||||
@@ -301,8 +303,10 @@ std::vector<std::string> SolutionParserVisualStudio::findProjectItems()
|
||||
|
||||
std::vector<std::string> validFileExtensions;
|
||||
validFileExtensions.push_back(".c");
|
||||
validFileExtensions.push_back(".cc");
|
||||
validFileExtensions.push_back(".cpp");
|
||||
validFileExtensions.push_back(".h");
|
||||
validFileExtensions.push_back(".hh");
|
||||
validFileExtensions.push_back(".hpp");
|
||||
|
||||
for (unsigned int i = 0; i < projectFilesNames.size(); i++)
|
||||
@@ -460,8 +464,10 @@ std::vector<std::string> SolutionParserVisualStudio::findIncludePaths()
|
||||
|
||||
std::vector<std::string> validExtensions;
|
||||
validExtensions.push_back(".c");
|
||||
validExtensions.push_back(".cc");
|
||||
validExtensions.push_back(".cpp");
|
||||
validExtensions.push_back(".h");
|
||||
validExtensions.push_back(".hh");
|
||||
validExtensions.push_back(".hpp");
|
||||
|
||||
for (unsigned int i = 0; i < projectFiles.size(); i++)
|
||||
|
||||
@@ -81,5 +81,6 @@ void QtLocationPicker::handleButtonPress()
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
m_data->setText(fileName);
|
||||
emit locationPicked();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ public:
|
||||
void setPickDirectory(bool pickDirectory);
|
||||
void setFileFilter(const QString& fileFilter);
|
||||
|
||||
signals:
|
||||
void locationPicked();
|
||||
|
||||
private slots:
|
||||
void handleButtonPress();
|
||||
|
||||
|
||||
@@ -142,34 +142,6 @@ void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, cons
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzard::newProjectFromCompilationDatabase(const std::string& compilationDatabasePath)
|
||||
{
|
||||
m_settings = getSettingsForCompilationDatabase(compilationDatabasePath);
|
||||
|
||||
headerPathsCDB();
|
||||
}
|
||||
|
||||
void QtProjectWizzard::refreshProjectFromCompilationDatabase(const std::string& compilationDatabasePath)
|
||||
{
|
||||
QtProjectWizzardWindow* window = dynamic_cast<QtProjectWizzardWindow*>(m_windowStack.getTopWindow());
|
||||
if (window)
|
||||
{
|
||||
window->content()->save();
|
||||
}
|
||||
|
||||
ProjectSettings settings = getSettingsForCompilationDatabase(compilationDatabasePath);
|
||||
|
||||
m_settings.setSourcePaths(settings.getSourcePaths());
|
||||
m_settings.setHeaderSearchPaths(settings.getHeaderSearchPaths());
|
||||
m_settings.setFrameworkSearchPaths(settings.getFrameworkSearchPaths());
|
||||
m_settings.setCompilationDatabasePath(FilePath(compilationDatabasePath));
|
||||
|
||||
if (window)
|
||||
{
|
||||
window->content()->load();
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzard::editProject(const ProjectSettings& settings)
|
||||
{
|
||||
m_settings = settings;
|
||||
@@ -374,17 +346,7 @@ void QtProjectWizzard::selectedProjectType(QtProjectWizzardContentSelect::Projec
|
||||
}
|
||||
|
||||
case QtProjectWizzardContentSelect::PROJECT_CDB:
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this, tr("Open JSON Compilation Database"), "", "JSON Compilation Database (*.json)"
|
||||
);
|
||||
|
||||
if (!fileName.isNull())
|
||||
{
|
||||
newProjectFromCompilationDatabase(fileName.toStdString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
emptyProjectCDB();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -462,6 +424,15 @@ void QtProjectWizzard::frameworkSearchPaths()
|
||||
connect(window, SIGNAL(next()), this, SLOT(showSummary()));
|
||||
}
|
||||
|
||||
void QtProjectWizzard::emptyProjectCDB()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentDataCDB>();
|
||||
|
||||
window->updateTitle("NEW PROJECT FROM COMPILATION DATABASE");
|
||||
|
||||
connect(window, SIGNAL(next()), this, SLOT(headerPathsCDB()));
|
||||
}
|
||||
|
||||
void QtProjectWizzard::headerPathsCDB()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
@@ -523,22 +494,21 @@ void QtProjectWizzard::showSummary()
|
||||
|
||||
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&, const std::string&)),
|
||||
this, SLOT(refreshProjectFromSolution(const std::string&, const std::string&)));
|
||||
}
|
||||
|
||||
if (buildFile->getType() != QtProjectWizzardContentSelect::PROJECT_CDB)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentData(settings, window), false, false);
|
||||
|
||||
if (buildFile->getType() == QtProjectWizzardContentSelect::PROJECT_MANAGED)
|
||||
{
|
||||
summary->addContent(buildFile, false, true);
|
||||
|
||||
connect(dynamic_cast<QtProjectWizzardContentBuildFile*>(buildFile),
|
||||
SIGNAL(refreshVisualStudioSolution(const std::string&, const std::string&)),
|
||||
this, SLOT(refreshProjectFromSolution(const std::string&, const std::string&)));
|
||||
}
|
||||
|
||||
QtProjectWizzardContentPathsSource* source = new QtProjectWizzardContentPathsSource(settings, window);
|
||||
summary->addContent(source, false, true);
|
||||
connectShowFiles(source);
|
||||
@@ -555,22 +525,22 @@ void QtProjectWizzard::showSummary()
|
||||
}
|
||||
else
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentDataCDB(settings, window), false, false);
|
||||
|
||||
QtProjectWizzardContent* headers = new QtProjectWizzardContentPathsCDBHeader(settings, window);
|
||||
summary->addContent(headers, false, true);
|
||||
connectShowFiles(headers);
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(settings, window), true, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, true);
|
||||
|
||||
if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(settings, window), true, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window), false, false);
|
||||
}
|
||||
|
||||
data->hideLanguage();
|
||||
}
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentFlags(settings, window), true, false);
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(settings, window), true, true);
|
||||
summary->addContent(new QtProjectWizzardContentFlags(settings, window), true, true);
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(settings, window), true, true);
|
||||
|
||||
window->setup();
|
||||
|
||||
@@ -34,11 +34,8 @@ public slots:
|
||||
void newProject();
|
||||
|
||||
void newProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath);
|
||||
|
||||
void refreshProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath);
|
||||
|
||||
void newProjectFromCompilationDatabase(const std::string& compilationDatabasePath);
|
||||
void refreshProjectFromCompilationDatabase(const std::string& compilationDatabasePath);
|
||||
void editProject(const ProjectSettings& settings);
|
||||
void showPreferences();
|
||||
|
||||
@@ -82,6 +79,7 @@ private slots:
|
||||
void headerSearchPathsDone();
|
||||
void frameworkSearchPaths();
|
||||
|
||||
void emptyProjectCDB();
|
||||
void headerPathsCDB();
|
||||
void headerPathsCDBDone();
|
||||
|
||||
|
||||
@@ -144,8 +144,8 @@ void QtProjectWizzardContentBuildFile::refreshClicked()
|
||||
QMessageBox::question(
|
||||
this,
|
||||
"Refresh Paths",
|
||||
"Do you really want to refresh from the given file? All changes you have made to the project's analyzed "
|
||||
"paths and header search paths will be lost.",
|
||||
"Do you really want to refresh from the given file? All changes you have made to the project paths "
|
||||
"and include paths will be lost.",
|
||||
QMessageBox::Yes | QMessageBox::No
|
||||
);
|
||||
|
||||
|
||||
@@ -33,16 +33,35 @@ void QtProjectWizzardContentCDBSource::populateWindow(QGridLayout* layout, int&
|
||||
|
||||
void QtProjectWizzardContentCDBSource::load()
|
||||
{
|
||||
std::vector<FilePath> filePaths = TaskParseCxx::getSourceFilesFromCDB(m_settings->getCompilationDatabasePath());
|
||||
std::vector<std::string> extensions = m_settings->getSourceExtensions();
|
||||
|
||||
m_fileNames.clear();
|
||||
for (const FilePath& path : filePaths)
|
||||
|
||||
FilePath projectPath = m_settings->getProjectFileLocation();
|
||||
std::vector<FilePath> excludePaths = m_settings->getAbsoluteExcludePaths();
|
||||
|
||||
std::vector<FilePath> filePaths = TaskParseCxx::getSourceFilesFromCDB(m_settings->getCompilationDatabasePath());
|
||||
for (FilePath path : filePaths)
|
||||
{
|
||||
if (path.hasExtension(extensions))
|
||||
bool excluded = false;
|
||||
for (FilePath p : excludePaths)
|
||||
{
|
||||
m_fileNames << QString::fromStdString(path.str());
|
||||
if (p == path || p.contains(path))
|
||||
{
|
||||
excluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (excluded)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (projectPath.exists())
|
||||
{
|
||||
path = path.relativeTo(projectPath);
|
||||
}
|
||||
|
||||
m_fileNames << QString::fromStdString(path.str());
|
||||
}
|
||||
|
||||
if (m_text)
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
QtProjectWizzardContentData::QtProjectWizzardContentData(ProjectSettings* settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_showLanguage(true)
|
||||
, m_projectName(nullptr)
|
||||
, m_projectFileLocation(nullptr)
|
||||
, m_language(nullptr)
|
||||
, m_cppStandard(nullptr)
|
||||
, m_cStandard(nullptr)
|
||||
, m_buildFilePicker(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentData::hideLanguage()
|
||||
{
|
||||
m_showLanguage = false;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentData::populateWindow(QGridLayout* layout)
|
||||
{
|
||||
int row = 0;
|
||||
@@ -31,118 +31,71 @@ void QtProjectWizzardContentData::populateWindow(QGridLayout* layout)
|
||||
|
||||
void QtProjectWizzardContentData::populateForm(QGridLayout* layout, int& row)
|
||||
{
|
||||
QLabel* nameLabel = createFormLabel("Name");
|
||||
m_projectName = new QLineEdit();
|
||||
m_projectName->setObjectName("name");
|
||||
m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
|
||||
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_projectName, row, QtProjectWizzardWindow::BACK_COL);
|
||||
row++;
|
||||
|
||||
QLabel* locationLabel = createFormLabel("Location");
|
||||
m_projectFileLocation = new QtLocationPicker(this);
|
||||
m_projectFileLocation->setPickDirectory(true);
|
||||
|
||||
layout->addWidget(locationLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_projectFileLocation, row, QtProjectWizzardWindow::BACK_COL);
|
||||
row++;
|
||||
|
||||
|
||||
QLabel* languageLabel = new QLabel("Language");
|
||||
languageLabel->setObjectName("label");
|
||||
m_language = new QComboBox();
|
||||
m_language->insertItem(0, "C++");
|
||||
m_language->insertItem(1, "C");
|
||||
connect(m_language, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
|
||||
|
||||
|
||||
QLabel* standardLabel = createFormLabel("Standard");
|
||||
|
||||
m_cppStandard = new QComboBox();
|
||||
m_cppStandard->insertItem(0, "1z");
|
||||
m_cppStandard->insertItem(1, "14");
|
||||
m_cppStandard->insertItem(2, "1y");
|
||||
m_cppStandard->insertItem(3, "11");
|
||||
m_cppStandard->insertItem(4, "0x");
|
||||
m_cppStandard->insertItem(5, "03");
|
||||
m_cppStandard->insertItem(6, "98");
|
||||
|
||||
m_cStandard = new QComboBox();
|
||||
m_cStandard->insertItem(0, "1x");
|
||||
m_cStandard->insertItem(1, "11");
|
||||
m_cStandard->insertItem(2, "9x");
|
||||
m_cStandard->insertItem(3, "99");
|
||||
m_cStandard->insertItem(4, "90");
|
||||
m_cStandard->insertItem(5, "89");
|
||||
|
||||
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++;
|
||||
addNameAndLocation(layout, row);
|
||||
addLanguageAndStandard(layout, row);
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentData::load()
|
||||
{
|
||||
m_projectName->setText(QString::fromStdString(m_settings->getProjectName()));
|
||||
m_projectFileLocation->setText(QString::fromStdString(m_settings->getProjectFileLocation().str()));
|
||||
|
||||
if (m_settings->getLanguage().length() > 0)
|
||||
if (m_projectName)
|
||||
{
|
||||
m_language->setCurrentText(QString::fromStdString(m_settings->getLanguage()));
|
||||
m_projectName->setText(QString::fromStdString(m_settings->getProjectName()));
|
||||
m_projectFileLocation->setText(QString::fromStdString(m_settings->getProjectFileLocation().str()));
|
||||
}
|
||||
|
||||
if (m_settings->getStandard().length() > 0)
|
||||
if (m_language)
|
||||
{
|
||||
if (m_language->currentIndex() == 0) // c++
|
||||
if (m_settings->getLanguage().length() > 0)
|
||||
{
|
||||
m_cppStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
|
||||
}
|
||||
else if (m_language->currentIndex() == 1) // c
|
||||
{
|
||||
m_cStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
|
||||
m_language->setCurrentText(QString::fromStdString(m_settings->getLanguage()));
|
||||
}
|
||||
|
||||
handleSelectionChanged(m_language->currentIndex());
|
||||
if (m_settings->getStandard().length() > 0)
|
||||
{
|
||||
if (m_language->currentIndex() == 0) // c++
|
||||
{
|
||||
m_cppStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
|
||||
}
|
||||
else if (m_language->currentIndex() == 1) // c
|
||||
{
|
||||
m_cStandard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
|
||||
}
|
||||
|
||||
handleSelectionChanged(m_language->currentIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentData::save()
|
||||
{
|
||||
m_settings->setProjectName(m_projectName->text().toStdString());
|
||||
m_settings->setProjectFileLocation(m_projectFileLocation->getText().toStdString());
|
||||
m_settings->setLanguage(m_language->currentText().toStdString());
|
||||
|
||||
if (m_cppStandard->isVisible())
|
||||
if (m_projectName)
|
||||
{
|
||||
m_settings->setStandard(m_cppStandard->currentText().toStdString());
|
||||
m_settings->setProjectName(m_projectName->text().toStdString());
|
||||
m_settings->setProjectFileLocation(m_projectFileLocation->getText().toStdString());
|
||||
}
|
||||
else if (m_cStandard->isVisible())
|
||||
|
||||
if (m_language)
|
||||
{
|
||||
m_settings->setStandard(m_cStandard->currentText().toStdString());
|
||||
m_settings->setLanguage(m_language->currentText().toStdString());
|
||||
|
||||
if (m_cppStandard->isVisible())
|
||||
{
|
||||
m_settings->setStandard(m_cppStandard->currentText().toStdString());
|
||||
}
|
||||
else if (m_cStandard->isVisible())
|
||||
{
|
||||
m_settings->setStandard(m_cStandard->currentText().toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool QtProjectWizzardContentData::check()
|
||||
{
|
||||
if (!m_projectName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_projectName->text().isEmpty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
@@ -175,9 +128,99 @@ QSize QtProjectWizzardContentData::preferredWindowSize() const
|
||||
return QSize(580, 340);
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentData::addNameAndLocation(QGridLayout* layout, int& row)
|
||||
{
|
||||
QLabel* nameLabel = createFormLabel("Name");
|
||||
m_projectName = new QLineEdit();
|
||||
m_projectName->setObjectName("name");
|
||||
m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
|
||||
layout->addWidget(nameLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_projectName, row, QtProjectWizzardWindow::BACK_COL);
|
||||
row++;
|
||||
|
||||
|
||||
QLabel* locationLabel = createFormLabel("Location");
|
||||
m_projectFileLocation = new QtLocationPicker(this);
|
||||
m_projectFileLocation->setPickDirectory(true);
|
||||
|
||||
layout->addWidget(locationLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_projectFileLocation, row, QtProjectWizzardWindow::BACK_COL);
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentData::addLanguageAndStandard(QGridLayout* layout, int& row)
|
||||
{
|
||||
QLabel* languageLabel = new QLabel("Language");
|
||||
languageLabel->setObjectName("label");
|
||||
m_language = new QComboBox();
|
||||
m_language->insertItem(0, "C++");
|
||||
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");
|
||||
|
||||
m_cppStandard = new QComboBox();
|
||||
m_cppStandard->insertItem(0, "1z");
|
||||
m_cppStandard->insertItem(1, "14");
|
||||
m_cppStandard->insertItem(2, "1y");
|
||||
m_cppStandard->insertItem(3, "11");
|
||||
m_cppStandard->insertItem(4, "0x");
|
||||
m_cppStandard->insertItem(5, "03");
|
||||
m_cppStandard->insertItem(6, "98");
|
||||
|
||||
m_cStandard = new QComboBox();
|
||||
m_cStandard->insertItem(0, "1x");
|
||||
m_cStandard->insertItem(1, "11");
|
||||
m_cStandard->insertItem(2, "9x");
|
||||
m_cStandard->insertItem(3, "99");
|
||||
m_cStandard->insertItem(4, "90");
|
||||
m_cStandard->insertItem(5, "89");
|
||||
|
||||
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);
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentData::addBuildFilePicker(
|
||||
QGridLayout* layout, int& row, const QString& name, const QString& filter)
|
||||
{
|
||||
QLabel* label = createFormLabel(name);
|
||||
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL);
|
||||
|
||||
m_buildFilePicker = new QtLocationPicker(this);
|
||||
m_buildFilePicker->setFileFilter(filter);
|
||||
|
||||
// QPushButton* button = new QPushButton("", this);
|
||||
// button->setObjectName("refreshButton");
|
||||
// button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
// button->setToolTip("refresh paths");
|
||||
// connect(button, SIGNAL(clicked()), this, SLOT(refreshClicked()));
|
||||
|
||||
// m_buildFilePicker->layout()->addWidget(button);
|
||||
|
||||
layout->addWidget(m_buildFilePicker, row, QtProjectWizzardWindow::BACK_COL);
|
||||
|
||||
row++;
|
||||
|
||||
QLabel* description = new QLabel(
|
||||
"The project will stay up-to-date with changes in the compilation database on refresh.", this);
|
||||
description->setObjectName("description");
|
||||
description->setWordWrap(true);
|
||||
layout->addWidget(description, row, QtProjectWizzardWindow::BACK_COL);
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentData::handleSelectionChanged(int index)
|
||||
{
|
||||
if (!m_showLanguage)
|
||||
if (!m_language)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -193,3 +236,64 @@ void QtProjectWizzardContentData::handleSelectionChanged(int index)
|
||||
m_cStandard->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QtProjectWizzardContentDataCDB::QtProjectWizzardContentDataCDB(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContentData(settings, window)
|
||||
{
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentDataCDB::populateForm(QGridLayout* layout, int& row)
|
||||
{
|
||||
QString name = "Compilation Database";
|
||||
QString filter = "JSON Compilation Database (*.json)";
|
||||
|
||||
addNameAndLocation(layout, row);
|
||||
|
||||
layout->setRowMinimumHeight(row++, 20);
|
||||
|
||||
addBuildFilePicker(layout, row, name, filter);
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentDataCDB::load()
|
||||
{
|
||||
QtProjectWizzardContentData::load();
|
||||
|
||||
m_buildFilePicker->setText(QString::fromStdString(m_settings->getCompilationDatabasePath().str()));
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentDataCDB::save()
|
||||
{
|
||||
QtProjectWizzardContentData::save();
|
||||
|
||||
FilePath path = m_buildFilePicker->getText().toStdString();
|
||||
if (!path.exists() || path.extension() != ".json")
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_settings->setCompilationDatabasePath(path);
|
||||
}
|
||||
|
||||
bool QtProjectWizzardContentDataCDB::check()
|
||||
{
|
||||
if (!QtProjectWizzardContentData::check())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FilePath path = m_buildFilePicker->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 QtProjectWizzardContentDataCDB::refreshClicked()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ 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;
|
||||
@@ -27,7 +25,11 @@ public:
|
||||
|
||||
virtual QSize preferredWindowSize() const override;
|
||||
|
||||
private:
|
||||
protected:
|
||||
virtual void addNameAndLocation(QGridLayout* layout, int& row);
|
||||
virtual void addLanguageAndStandard(QGridLayout* layout, int& row);
|
||||
virtual void addBuildFilePicker(QGridLayout* layout, int& row, const QString& name, const QString& filter);
|
||||
|
||||
QLineEdit* m_projectName;
|
||||
QtLocationPicker* m_projectFileLocation;
|
||||
|
||||
@@ -35,10 +37,29 @@ private:
|
||||
QComboBox* m_cppStandard;
|
||||
QComboBox* m_cStandard;
|
||||
|
||||
bool m_showLanguage;
|
||||
QtLocationPicker* m_buildFilePicker;
|
||||
|
||||
private slots:
|
||||
void handleSelectionChanged(int index);
|
||||
};
|
||||
|
||||
|
||||
class QtProjectWizzardContentDataCDB
|
||||
: public QtProjectWizzardContentData
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentDataCDB(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
|
||||
virtual void populateForm(QGridLayout* layout, int& row) override;
|
||||
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
virtual bool check() override;
|
||||
|
||||
private slots:
|
||||
void refreshClicked();
|
||||
};
|
||||
|
||||
#endif // QT_PROJECT_WIZZARD_CONTENT_DATA_H
|
||||
|
||||
@@ -170,7 +170,10 @@ void QtProjectWizzardContentPaths::addDetection(QString name, QGridLayout* layou
|
||||
hlayout->addWidget(m_detectorBox);
|
||||
hlayout->addWidget(button);
|
||||
|
||||
layout->addLayout(hlayout, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
|
||||
QWidget* detectionWidget = new QWidget();
|
||||
detectionWidget->setLayout(hlayout);
|
||||
|
||||
layout->addWidget(detectionWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPaths::detectionClicked()
|
||||
@@ -208,7 +211,7 @@ QtProjectWizzardContentPathsSource::QtProjectWizzardContentPathsSource(
|
||||
"Project Paths",
|
||||
"Add all directories or files you want to analyse. Usually these are all source and header files of "
|
||||
"your project or a subset of them.",
|
||||
"Project Paths define the source files and directories that will be analyzed by Coati. Usually these are the "
|
||||
"Project Paths define the files and directories that will be analyzed by Coati. Usually these are the "
|
||||
"source and header files of your project or a subset of them."
|
||||
);
|
||||
}
|
||||
@@ -228,19 +231,6 @@ void QtProjectWizzardContentPathsSource::save()
|
||||
m_settings->setSourcePaths(m_list->getList());
|
||||
}
|
||||
|
||||
bool QtProjectWizzardContentPathsSource::check()
|
||||
{
|
||||
if (m_list->getList().size() == 0)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Please add at least one path.");
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
|
||||
return QtProjectWizzardContentPaths::check();
|
||||
}
|
||||
|
||||
QStringList QtProjectWizzardContentPathsSource::getFileNames() const
|
||||
{
|
||||
std::vector<FilePath> sourcePaths = m_settings->getAbsoluteSourcePaths();
|
||||
@@ -300,12 +290,12 @@ QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader(
|
||||
|
||||
setTitleString("Header Paths");
|
||||
setDescriptionString(
|
||||
"Add the header files or directories containing the header files of the source files above. These header files "
|
||||
"or files within these directories will be analyzed if included."
|
||||
"Where are the header files of the source files? Add the directories or files that should be "
|
||||
"analyzed if included by one of the source files."
|
||||
);
|
||||
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."
|
||||
"files here. Header files will be analyzed if included."
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ public:
|
||||
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
virtual bool check() override;
|
||||
|
||||
virtual QStringList getFileNames() const override;
|
||||
virtual QString getFileNamesTitle() const override;
|
||||
|
||||
@@ -70,7 +70,7 @@ void QtProjectWizzardContentSelect::populateWindow(QGridLayout* layout)
|
||||
|
||||
m_solutionDescription.push_back("Create a new Coati project by defining what files will be analyzed and header search paths.");
|
||||
m_solutionDescription.push_back("Create a project from an existing Compilation Database. Compilation Databases can be created from "
|
||||
"cmake projects. Have a look at the "
|
||||
"Make and CMake projects. Have a look at the "
|
||||
"<a href=\"https://staging.coati.io/documentation/#CreateAProjectFromCompilationDatabase\">"
|
||||
"documentation</a> to find out more.");
|
||||
|
||||
|
||||
@@ -9,12 +9,7 @@ bool TestFileManager::hasFilePath(const FilePath& filePath) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TestFileManager::hasSourceExtension(const FilePath& filePath) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TestFileManager::hasIncludeExtension(const FilePath& filePath) const
|
||||
bool TestFileManager::hasSourceFilePath(const FilePath& filePath) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ public:
|
||||
TestFileManager();
|
||||
|
||||
virtual bool hasFilePath(const FilePath& filePath) const;
|
||||
virtual bool hasSourceExtension(const FilePath& filePath) const;
|
||||
virtual bool hasIncludeExtension(const FilePath& filePath) const;
|
||||
virtual bool hasSourceFilePath(const FilePath& filePath) const;
|
||||
|
||||
virtual const FileInfo getFileInfo(const FilePath& filePath) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user