GUI: Cleanup duplicate code.
This commit is contained in:
parent
2dfa1d540e
commit
14ee95eab7
|
@ -338,6 +338,24 @@ bool MainWindow::GetCheckProject()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::AddIncludeDirs(const QStringList &includeDirs, Settings &result)
|
||||||
|
{
|
||||||
|
QString dir;
|
||||||
|
foreach(dir, includeDirs)
|
||||||
|
{
|
||||||
|
QString incdir;
|
||||||
|
if (!QDir::isAbsolutePath(dir))
|
||||||
|
incdir = mCurrentDirectory + "/";
|
||||||
|
incdir += dir;
|
||||||
|
incdir = QDir::cleanPath(incdir);
|
||||||
|
|
||||||
|
// include paths must end with '/'
|
||||||
|
if (!incdir.endsWith("/"))
|
||||||
|
incdir += "/";
|
||||||
|
result._includePaths.push_back(incdir.toStdString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Settings MainWindow::GetCppcheckSettings()
|
Settings MainWindow::GetCppcheckSettings()
|
||||||
{
|
{
|
||||||
Settings result;
|
Settings result;
|
||||||
|
@ -346,20 +364,7 @@ Settings MainWindow::GetCppcheckSettings()
|
||||||
if (!globalIncludes.isEmpty())
|
if (!globalIncludes.isEmpty())
|
||||||
{
|
{
|
||||||
QStringList includes = globalIncludes.split(";");
|
QStringList includes = globalIncludes.split(";");
|
||||||
QString dir;
|
AddIncludeDirs(includes, result);
|
||||||
foreach(dir, includes)
|
|
||||||
{
|
|
||||||
QString incdir;
|
|
||||||
if (!QDir::isAbsolutePath(dir))
|
|
||||||
incdir = mCurrentDirectory + "/";
|
|
||||||
incdir += dir;
|
|
||||||
incdir = QDir::cleanPath(incdir);
|
|
||||||
|
|
||||||
// include paths must end with '/'
|
|
||||||
if (!incdir.endsWith("/"))
|
|
||||||
incdir += "/";
|
|
||||||
result._includePaths.push_back(incdir.toStdString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool projectRead = GetCheckProject();
|
bool projectRead = GetCheckProject();
|
||||||
|
@ -367,20 +372,8 @@ Settings MainWindow::GetCppcheckSettings()
|
||||||
{
|
{
|
||||||
ProjectFile *pfile = mProject->GetProjectFile();
|
ProjectFile *pfile = mProject->GetProjectFile();
|
||||||
QStringList dirs = pfile->GetIncludeDirs();
|
QStringList dirs = pfile->GetIncludeDirs();
|
||||||
QString dir;
|
AddIncludeDirs(dirs, result);
|
||||||
foreach(dir, dirs)
|
|
||||||
{
|
|
||||||
QString incdir;
|
|
||||||
if (!QDir::isAbsolutePath(dir))
|
|
||||||
incdir = mCurrentDirectory + "/";
|
|
||||||
incdir += dir;
|
|
||||||
incdir = QDir::cleanPath(incdir);
|
|
||||||
|
|
||||||
// include paths must end with '/'
|
|
||||||
if (!incdir.endsWith("/"))
|
|
||||||
incdir += "/";
|
|
||||||
result._includePaths.push_back(incdir.toStdString());
|
|
||||||
}
|
|
||||||
QStringList defines = pfile->GetDefines();
|
QStringList defines = pfile->GetDefines();
|
||||||
QString define;
|
QString define;
|
||||||
foreach(define, defines)
|
foreach(define, defines)
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include "resultsview.h"
|
#include "resultsview.h"
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
@ -346,6 +347,13 @@ protected:
|
||||||
*/
|
*/
|
||||||
void EnableProjectOpenActions(bool enable);
|
void EnableProjectOpenActions(bool enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add include directories.
|
||||||
|
* @param includeDirs List of include directories to add.
|
||||||
|
* @param result Settings class where include directories are added.
|
||||||
|
*/
|
||||||
|
void AddIncludeDirs(const QStringList &includeDirs, Settings &result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Program settings
|
* @brief Program settings
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue