forked from qt-creator/qt-creator
CppCheck: Use more FilePath
Change-Id: I45da67df4b76032303b57f567d73ae01bf9f2e91 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -39,9 +39,10 @@
|
||||
#include <debugger/analyzer/analyzericons.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDir>
|
||||
#include <QFormLayout>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Cppcheck {
|
||||
namespace Internal {
|
||||
|
||||
@@ -102,7 +103,7 @@ OptionsWidget::OptionsWidget(QWidget *parent)
|
||||
|
||||
void OptionsWidget::load(const CppcheckOptions &options)
|
||||
{
|
||||
m_binary->setPath(options.binary);
|
||||
m_binary->setFilePath(options.binary);
|
||||
m_customArguments->setText(options.customArguments);
|
||||
m_ignorePatterns->setText(options.ignoredPatterns);
|
||||
m_warning->setChecked(options.warning);
|
||||
@@ -121,7 +122,7 @@ void OptionsWidget::load(const CppcheckOptions &options)
|
||||
|
||||
void OptionsWidget::save(CppcheckOptions &options) const
|
||||
{
|
||||
options.binary = m_binary->filePath().toString();
|
||||
options.binary = m_binary->filePath();
|
||||
options.customArguments = m_customArguments->text();
|
||||
options.ignoredPatterns = m_ignorePatterns->text();
|
||||
options.warning = m_warning->isChecked();
|
||||
@@ -149,14 +150,13 @@ CppcheckOptionsPage::CppcheckOptionsPage(CppcheckTool &tool, CppcheckTrigger &tr
|
||||
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
||||
|
||||
CppcheckOptions options;
|
||||
if (Utils::HostOsInfo::isAnyUnixHost()) {
|
||||
if (HostOsInfo::isAnyUnixHost()) {
|
||||
options.binary = "cppcheck";
|
||||
} else {
|
||||
QString programFiles = QDir::fromNativeSeparators(
|
||||
QString::fromLocal8Bit(qgetenv("PROGRAMFILES")));
|
||||
FilePath programFiles = FilePath::fromUserInput(qEnvironmentVariable("PROGRAMFILES"));
|
||||
if (programFiles.isEmpty())
|
||||
programFiles = "C:/Program Files";
|
||||
options.binary = programFiles + "/Cppcheck/cppcheck.exe";
|
||||
options.binary = programFiles / "Cppcheck/cppcheck.exe";
|
||||
}
|
||||
|
||||
load(options);
|
||||
@@ -190,7 +190,7 @@ void CppcheckOptionsPage::save(const CppcheckOptions &options) const
|
||||
QSettings *s = Core::ICore::settings();
|
||||
QTC_ASSERT(s, return);
|
||||
s->beginGroup(Constants::SETTINGS_ID);
|
||||
s->setValue(Constants::SETTINGS_BINARY, options.binary);
|
||||
s->setValue(Constants::SETTINGS_BINARY, options.binary.toString());
|
||||
s->setValue(Constants::SETTINGS_CUSTOM_ARGUMENTS, options.customArguments);
|
||||
s->setValue(Constants::SETTINGS_IGNORE_PATTERNS, options.ignoredPatterns);
|
||||
s->setValue(Constants::SETTINGS_WARNING, options.warning);
|
||||
@@ -213,8 +213,8 @@ void CppcheckOptionsPage::load(CppcheckOptions &options) const
|
||||
QSettings *s = Core::ICore::settings();
|
||||
QTC_ASSERT(s, return);
|
||||
s->beginGroup(Constants::SETTINGS_ID);
|
||||
options.binary = s->value(Constants::SETTINGS_BINARY,
|
||||
options.binary).toString();
|
||||
options.binary = FilePath::fromString(s->value(Constants::SETTINGS_BINARY,
|
||||
options.binary.toString()).toString());
|
||||
options.customArguments = s->value(Constants::SETTINGS_CUSTOM_ARGUMENTS,
|
||||
options.customArguments).toString();
|
||||
options.ignoredPatterns = s->value(Constants::SETTINGS_IGNORE_PATTERNS,
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QPointer>
|
||||
@@ -36,9 +37,7 @@ class QLineEdit;
|
||||
class QCheckBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class PathChooser;
|
||||
}
|
||||
namespace Utils { class PathChooser; }
|
||||
|
||||
namespace Cppcheck {
|
||||
namespace Internal {
|
||||
@@ -50,7 +49,7 @@ class OptionsWidget;
|
||||
class CppcheckOptions final
|
||||
{
|
||||
public:
|
||||
QString binary;
|
||||
Utils::FilePath binary;
|
||||
|
||||
bool warning = true;
|
||||
bool style = true;
|
||||
|
||||
@@ -74,7 +74,7 @@ CppcheckRunner::~CppcheckRunner()
|
||||
m_queueTimer.stop();
|
||||
}
|
||||
|
||||
void CppcheckRunner::reconfigure(const QString &binary, const QString &arguments)
|
||||
void CppcheckRunner::reconfigure(const FilePath &binary, const QString &arguments)
|
||||
{
|
||||
m_binary = binary;
|
||||
m_arguments = arguments;
|
||||
@@ -157,7 +157,7 @@ void CppcheckRunner::checkQueued()
|
||||
else
|
||||
m_queue.begin().value() = files;
|
||||
|
||||
m_process->setCommand(CommandLine(FilePath::fromString(m_binary), arguments, CommandLine::Raw));
|
||||
m_process->setCommand(CommandLine(m_binary, arguments, CommandLine::Raw));
|
||||
m_process->start();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
explicit CppcheckRunner(CppcheckTool &tool);
|
||||
~CppcheckRunner() override;
|
||||
|
||||
void reconfigure(const QString &binary, const QString &arguments);
|
||||
void reconfigure(const Utils::FilePath &binary, const QString &arguments);
|
||||
void addToQueue(const Utils::FilePaths &files,
|
||||
const QString &additionalArguments = {});
|
||||
void removeFromQueue(const Utils::FilePaths &files);
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
|
||||
CppcheckTool &m_tool;
|
||||
Utils::QtcProcess *m_process = nullptr;
|
||||
QString m_binary;
|
||||
Utils::FilePath m_binary;
|
||||
QString m_arguments;
|
||||
QHash<QString, Utils::FilePaths> m_queue;
|
||||
Utils::FilePaths m_currentFiles;
|
||||
|
||||
Reference in New Issue
Block a user