GUI: Select configuration that is checked

This commit is contained in:
Daniel Marjamäki 2016-08-21 15:57:38 +02:00
parent a94628d8fc
commit bea35ee04c
3 changed files with 29 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include <QAction> #include <QAction>
#include <QActionGroup> #include <QActionGroup>
#include <QFile> #include <QFile>
#include <QInputDialog>
#include "mainwindow.h" #include "mainwindow.h"
#include "cppcheck.h" #include "cppcheck.h"
#include "applicationlist.h" #include "applicationlist.h"
@ -522,6 +523,23 @@ void MainWindow::CheckFiles()
if (file0.endsWith(".sln") || file0.endsWith(".vcxproj") || file0.endsWith("compile_database.json")) { if (file0.endsWith(".sln") || file0.endsWith(".vcxproj") || file0.endsWith("compile_database.json")) {
ImportProject p; ImportProject p;
p.import(selected[0].toStdString()); p.import(selected[0].toStdString());
if (file0.endsWith(".sln")) {
QStringList configs;
for (std::list<ImportProject::FileSettings>::const_iterator it = p.fileSettings.begin(); it != p.fileSettings.end(); ++it) {
const QString cfg(QString::fromStdString(it->cfg));
if (!configs.contains(cfg))
configs.push_back(cfg);
}
configs.sort();
bool ok = false;
const QString cfg = QInputDialog::getItem(this, tr("Select configuration"), tr("Select the configuration that will be checked"), configs, 0, false, &ok);
if (!ok)
return;
p.ignoreOtherConfigs(cfg.toStdString());
}
DoCheckProject(p); DoCheckProject(p);
return; return;
} }

View File

@ -43,6 +43,16 @@ void ImportProject::ignorePaths(std::vector<std::string> &ipaths)
} }
} }
void ImportProject::ignoreOtherConfigs(const std::string &cfg)
{
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
if (it->cfg != cfg)
fileSettings.erase(it++);
else
++it;
}
}
void ImportProject::ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType) void ImportProject::ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType)
{ {
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) { for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {

View File

@ -52,6 +52,7 @@ public:
std::list<FileSettings> fileSettings; std::list<FileSettings> fileSettings;
void ignorePaths(std::vector<std::string> &ipaths); void ignorePaths(std::vector<std::string> &ipaths);
void ignoreOtherConfigs(const std::string &cfg);
void ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType); void ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType);
void import(const std::string &filename); void import(const std::string &filename);