From bea35ee04c6ec4135382fa0981bde5c9ccfe30ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 21 Aug 2016 15:57:38 +0200 Subject: [PATCH] GUI: Select configuration that is checked --- gui/mainwindow.cpp | 18 ++++++++++++++++++ lib/importproject.cpp | 10 ++++++++++ lib/importproject.h | 1 + 3 files changed, 29 insertions(+) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 04b5ff660..21c084d73 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "mainwindow.h" #include "cppcheck.h" #include "applicationlist.h" @@ -522,6 +523,23 @@ void MainWindow::CheckFiles() if (file0.endsWith(".sln") || file0.endsWith(".vcxproj") || file0.endsWith("compile_database.json")) { ImportProject p; p.import(selected[0].toStdString()); + + if (file0.endsWith(".sln")) { + QStringList configs; + for (std::list::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); return; } diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 5d6cc4d8f..7799c0666 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -43,6 +43,16 @@ void ImportProject::ignorePaths(std::vector &ipaths) } } +void ImportProject::ignoreOtherConfigs(const std::string &cfg) +{ + for (std::list::iterator it = fileSettings.begin(); it != fileSettings.end();) { + if (it->cfg != cfg) + fileSettings.erase(it++); + else + ++it; + } +} + void ImportProject::ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType) { for (std::list::iterator it = fileSettings.begin(); it != fileSettings.end();) { diff --git a/lib/importproject.h b/lib/importproject.h index a86442683..48e795c56 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -52,6 +52,7 @@ public: std::list fileSettings; void ignorePaths(std::vector &ipaths); + void ignoreOtherConfigs(const std::string &cfg); void ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType); void import(const std::string &filename);