GUI: In ProjectFileDialog; updated choice of vs configurations

This commit is contained in:
Daniel Marjamäki 2020-07-20 22:06:07 +02:00
parent 5fca5830c5
commit a68d9e75ef
3 changed files with 42 additions and 38 deletions

View File

@ -62,6 +62,8 @@ static const int numberOfBuiltinPlatforms = sizeof(builtinPlatforms) / sizeof(bu
QStringList ProjectFileDialog::getProjectConfigs(const QString &fileName) QStringList ProjectFileDialog::getProjectConfigs(const QString &fileName)
{ {
if (!fileName.endsWith(".sln") && !fileName.endsWith(".vcxproj"))
return QStringList();
QStringList ret; QStringList ret;
ImportProject importer; ImportProject importer;
Settings projSettings; Settings projSettings;
@ -244,8 +246,12 @@ static void updateAddonCheckBox(QCheckBox *cb, const ProjectFile *projectFile, c
void ProjectFileDialog::checkAllVSConfigs() void ProjectFileDialog::checkAllVSConfigs()
{ {
if (mUI.mChkAllVsConfigs->isChecked()) if (mUI.mChkAllVsConfigs->isChecked()) {
mUI.mListVsConfigs->selectAll(); for (int row = 0; row < mUI.mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI.mListVsConfigs->item(row);
item->setCheckState(Qt::Checked);
}
}
mUI.mListVsConfigs->setEnabled(!mUI.mChkAllVsConfigs->isChecked()); mUI.mListVsConfigs->setEnabled(!mUI.mChkAllVsConfigs->isChecked());
} }
@ -259,6 +265,14 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
setCheckPaths(projectFile->getCheckPaths()); setCheckPaths(projectFile->getCheckPaths());
setImportProject(projectFile->getImportProject()); setImportProject(projectFile->getImportProject());
mUI.mChkAllVsConfigs->setChecked(projectFile->getAnalyzeAllVsConfigs()); mUI.mChkAllVsConfigs->setChecked(projectFile->getAnalyzeAllVsConfigs());
setProjectConfigurations(getProjectConfigs(mUI.mEditImportProject->text()));
for (int row = 0; row < mUI.mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI.mListVsConfigs->item(row);
if (projectFile->getAnalyzeAllVsConfigs() || projectFile->getVsConfigurations().contains(item->text()))
item->setCheckState(Qt::Checked);
else
item->setCheckState(Qt::Unchecked);
}
mUI.mCheckHeaders->setChecked(projectFile->getCheckHeaders()); mUI.mCheckHeaders->setChecked(projectFile->getCheckHeaders());
mUI.mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates()); mUI.mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates());
mUI.mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth()); mUI.mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth());
@ -342,17 +356,6 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
} }
mUI.mEditTags->setText(projectFile->getTags().join(';')); mUI.mEditTags->setText(projectFile->getTags().join(';'));
updatePathsAndDefines(); updatePathsAndDefines();
if (mUI.mEditImportProject->text().endsWith(".sln") || mUI.mEditImportProject->text().endsWith(".vcxproj")) {
setVsConfigurations(getProjectConfigs(mUI.mEditImportProject->text()));
foreach (const QString &cfg, projectFile->getVsConfigurations()) {
QList<QListWidgetItem*> items = mUI.mListVsConfigs->findItems(cfg, Qt::MatchFlag::MatchExactly);
items[0]->setSelected(true);
}
} else {
mUI.mListVsConfigs->clear();
mUI.mListVsConfigs->setEnabled(false);
}
} }
void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
@ -361,6 +364,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
projectFile->setBuildDir(getBuildDir()); projectFile->setBuildDir(getBuildDir());
projectFile->setImportProject(getImportProject()); projectFile->setImportProject(getImportProject());
projectFile->setAnalyzeAllVsConfigs(mUI.mChkAllVsConfigs->isChecked()); projectFile->setAnalyzeAllVsConfigs(mUI.mChkAllVsConfigs->isChecked());
projectFile->setVSConfigurations(getProjectConfigurations());
projectFile->setCheckHeaders(mUI.mCheckHeaders->isChecked()); projectFile->setCheckHeaders(mUI.mCheckHeaders->isChecked());
projectFile->setCheckUnusedTemplates(mUI.mCheckUnusedTemplates->isChecked()); projectFile->setCheckUnusedTemplates(mUI.mCheckUnusedTemplates->isChecked());
projectFile->setMaxCtuDepth(mUI.mMaxCtuDepth->value()); projectFile->setMaxCtuDepth(mUI.mMaxCtuDepth->value());
@ -414,7 +418,6 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
projectFile->setClangAnalyzer(mUI.mToolClangAnalyzer->isChecked()); projectFile->setClangAnalyzer(mUI.mToolClangAnalyzer->isChecked());
projectFile->setClangTidy(mUI.mToolClangTidy->isChecked()); projectFile->setClangTidy(mUI.mToolClangTidy->isChecked());
projectFile->setTags(mUI.mEditTags->text().split(";", QString::SkipEmptyParts)); projectFile->setTags(mUI.mEditTags->text().split(";", QString::SkipEmptyParts));
projectFile->setVSConfigurations(getVsConfigurations());
} }
void ProjectFileDialog::ok() void ProjectFileDialog::ok()
@ -460,6 +463,7 @@ void ProjectFileDialog::updatePathsAndDefines()
{ {
const QString &fileName = mUI.mEditImportProject->text(); const QString &fileName = mUI.mEditImportProject->text();
bool importProject = !fileName.isEmpty(); bool importProject = !fileName.isEmpty();
bool hasConfigs = fileName.endsWith(".sln") || fileName.endsWith(".vcxproj");
mUI.mBtnClearImportProject->setEnabled(importProject); mUI.mBtnClearImportProject->setEnabled(importProject);
mUI.mListCheckPaths->setEnabled(!importProject); mUI.mListCheckPaths->setEnabled(!importProject);
mUI.mListIncludeDirs->setEnabled(!importProject); mUI.mListIncludeDirs->setEnabled(!importProject);
@ -473,9 +477,9 @@ void ProjectFileDialog::updatePathsAndDefines()
mUI.mBtnRemoveInclude->setEnabled(!importProject); mUI.mBtnRemoveInclude->setEnabled(!importProject);
mUI.mBtnIncludeUp->setEnabled(!importProject); mUI.mBtnIncludeUp->setEnabled(!importProject);
mUI.mBtnIncludeDown->setEnabled(!importProject); mUI.mBtnIncludeDown->setEnabled(!importProject);
mUI.mChkAllVsConfigs->setEnabled(fileName.endsWith(".sln") || fileName.endsWith(".vcxproj")); mUI.mChkAllVsConfigs->setEnabled(hasConfigs);
mUI.mListVsConfigs->setEnabled(fileName.endsWith(".sln") || fileName.endsWith(".vcxproj")); mUI.mListVsConfigs->setEnabled(hasConfigs && !mUI.mChkAllVsConfigs->isChecked());
if (!mUI.mListVsConfigs->isEnabled()) if (!hasConfigs)
mUI.mListVsConfigs->clear(); mUI.mListVsConfigs->clear();
} }
@ -499,24 +503,34 @@ void ProjectFileDialog::browseImportProject()
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
mUI.mEditImportProject->setText(dir.relativeFilePath(fileName)); mUI.mEditImportProject->setText(dir.relativeFilePath(fileName));
updatePathsAndDefines(); updatePathsAndDefines();
setVsConfigurations(getProjectConfigs(fileName)); setProjectConfigurations(getProjectConfigs(fileName));
mUI.mListVsConfigs->selectAll(); for (int row = 0; row < mUI.mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI.mListVsConfigs->item(row);
item->setCheckState(Qt::Checked);
}
} }
} }
QStringList ProjectFileDialog::getVsConfigurations() const QStringList ProjectFileDialog::getProjectConfigurations() const
{ {
QStringList configs; QStringList configs;
foreach (QListWidgetItem *item, mUI.mListVsConfigs->selectedItems()) for (int row = 0; row < mUI.mListVsConfigs->count(); ++row) {
QListWidgetItem *item = mUI.mListVsConfigs->item(row);
if (item->checkState() == Qt::Checked)
configs << item->text(); configs << item->text();
}
return configs; return configs;
} }
void ProjectFileDialog::setVsConfigurations(const QStringList &configs) void ProjectFileDialog::setProjectConfigurations(const QStringList &configs)
{ {
mUI.mListVsConfigs->clear(); mUI.mListVsConfigs->clear();
mUI.mListVsConfigs->addItems(configs); mUI.mListVsConfigs->setEnabled(!configs.isEmpty() && !mUI.mChkAllVsConfigs->isChecked());
foreach (const QString &cfg, configs) {
QListWidgetItem* item = new QListWidgetItem(cfg, mUI.mListVsConfigs);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
item->setCheckState(Qt::Unchecked);
}
} }
QString ProjectFileDialog::getImportProject() const QString ProjectFileDialog::getImportProject() const

View File

@ -58,8 +58,8 @@ private:
*/ */
QString getRootPath() const; QString getRootPath() const;
QStringList getVsConfigurations() const; QStringList getProjectConfigurations() const;
void setVsConfigurations(const QStringList &configs); void setProjectConfigurations(const QStringList &configs);
QString getImportProject() const; QString getImportProject() const;

View File

@ -130,17 +130,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QListWidget" name="mListVsConfigs"> <widget class="QListWidget" name="mListVsConfigs"/>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>