GUI: Open project file and check contained paths.
Now we load user-selected project file and start checking paths it contains. Project file can be anywhere as long as it contains valid path(s) to check.
This commit is contained in:
parent
a82edf5278
commit
c98d398398
|
@ -48,7 +48,8 @@ MainWindow::MainWindow() :
|
||||||
mTranslation(new TranslationHandler(this)),
|
mTranslation(new TranslationHandler(this)),
|
||||||
mLanguages(new QActionGroup(this)),
|
mLanguages(new QActionGroup(this)),
|
||||||
mLogView(NULL),
|
mLogView(NULL),
|
||||||
mExiting(false)
|
mExiting(false),
|
||||||
|
mProject(NULL)
|
||||||
{
|
{
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
mUI.mResults->Initialize(mSettings, mApplications);
|
mUI.mResults->Initialize(mSettings, mApplications);
|
||||||
|
@ -120,6 +121,7 @@ MainWindow::MainWindow() :
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
delete mLogView;
|
delete mLogView;
|
||||||
|
delete mProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::CreateLanguageMenuItems()
|
void MainWindow::CreateLanguageMenuItems()
|
||||||
|
@ -297,25 +299,30 @@ void MainWindow::CheckDirectory()
|
||||||
|
|
||||||
Settings MainWindow::GetCppcheckSettings()
|
Settings MainWindow::GetCppcheckSettings()
|
||||||
{
|
{
|
||||||
ProjectFile pfile;
|
ProjectFile *pfile = NULL;
|
||||||
Settings result;
|
Settings result;
|
||||||
|
bool projectRead = true;
|
||||||
|
|
||||||
if (!mCurrentDirectory.isEmpty())
|
if (!mCurrentDirectory.isEmpty() && !mProject)
|
||||||
{
|
{
|
||||||
// Format project filename (directory name + .cppcheck) and load
|
// Format project filename (directory name + .cppcheck) and load
|
||||||
// the project file if it is found.
|
// the project file if it is found.
|
||||||
QStringList parts = mCurrentDirectory.split("/");
|
QStringList parts = mCurrentDirectory.split("/");
|
||||||
QString projfile = mCurrentDirectory + "/" + parts[parts.count() - 1] + ".cppcheck";
|
QString projfile = mCurrentDirectory + "/" + parts[parts.count() - 1] + ".cppcheck";
|
||||||
bool projectRead = false;
|
|
||||||
if (QFile::exists(projfile))
|
if (QFile::exists(projfile))
|
||||||
{
|
{
|
||||||
qDebug() << "Reading project file " << projfile;
|
qDebug() << "Reading project file " << projfile;
|
||||||
projectRead = pfile.Read(projfile);
|
projectRead = pfile->Read(projfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mProject)
|
||||||
|
{
|
||||||
|
pfile = mProject->GetProjectFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectRead)
|
if (projectRead)
|
||||||
{
|
{
|
||||||
QStringList dirs = pfile.GetIncludeDirs();
|
QStringList dirs = pfile->GetIncludeDirs();
|
||||||
QString dir;
|
QString dir;
|
||||||
foreach(dir, dirs)
|
foreach(dir, dirs)
|
||||||
{
|
{
|
||||||
|
@ -329,9 +336,8 @@ Settings MainWindow::GetCppcheckSettings()
|
||||||
if (!incdir.endsWith("/"))
|
if (!incdir.endsWith("/"))
|
||||||
incdir += "/";
|
incdir += "/";
|
||||||
result._includePaths.push_back(incdir.toStdString());
|
result._includePaths.push_back(incdir.toStdString());
|
||||||
}
|
|
||||||
|
|
||||||
QStringList defines = pfile.GetDefines();
|
QStringList defines = pfile->GetDefines();
|
||||||
QString define;
|
QString define;
|
||||||
foreach(define, defines)
|
foreach(define, defines)
|
||||||
{
|
{
|
||||||
|
@ -673,6 +679,9 @@ void MainWindow::OpenHtmlHelpContents()
|
||||||
|
|
||||||
void MainWindow::OpenProjectFile()
|
void MainWindow::OpenProjectFile()
|
||||||
{
|
{
|
||||||
|
if (mProject != NULL)
|
||||||
|
delete mProject;
|
||||||
|
|
||||||
const QString filter = tr("Project files (*.cppcheck);;All files(*.*)");
|
const QString filter = tr("Project files (*.cppcheck);;All files(*.*)");
|
||||||
QString filepath = QFileDialog::getOpenFileName(this,
|
QString filepath = QFileDialog::getOpenFileName(this,
|
||||||
tr("Select Project File"),
|
tr("Select Project File"),
|
||||||
|
@ -681,9 +690,11 @@ void MainWindow::OpenProjectFile()
|
||||||
|
|
||||||
if (!filepath.isEmpty())
|
if (!filepath.isEmpty())
|
||||||
{
|
{
|
||||||
Project prj(filepath, this);
|
mProject = new Project(filepath, this);
|
||||||
if (prj.Open())
|
mProject->Open();
|
||||||
prj.Edit();
|
QStringList paths = mProject->GetProjectFile()->GetCheckPaths();
|
||||||
|
if (!paths.isEmpty())
|
||||||
|
DoCheckFiles(paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,10 @@
|
||||||
#include "translationhandler.h"
|
#include "translationhandler.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "ui_main.h"
|
#include "ui_main.h"
|
||||||
|
|
||||||
class ThreadHandler;
|
class ThreadHandler;
|
||||||
class LogView;
|
class LogView;
|
||||||
|
class Project;
|
||||||
|
|
||||||
/// @addtogroup GUI
|
/// @addtogroup GUI
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -139,7 +141,7 @@ public slots:
|
||||||
void NewProjectFile();
|
void NewProjectFile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Slot to edit existing project file.
|
* @brief Slot to open project file and start checking contained paths.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void OpenProjectFile();
|
void OpenProjectFile();
|
||||||
|
@ -323,10 +325,15 @@ protected:
|
||||||
QString mCurrentDirectory;
|
QString mCurrentDirectory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Log view..
|
* @brief Log view.
|
||||||
*/
|
*/
|
||||||
LogView *mLogView;
|
LogView *mLogView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Project (file).
|
||||||
|
*/
|
||||||
|
Project *mProject;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,6 +62,15 @@ public:
|
||||||
*/
|
*/
|
||||||
void Create();
|
void Create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return current project file.
|
||||||
|
* @return project file.
|
||||||
|
*/
|
||||||
|
ProjectFile * GetProjectFile() const
|
||||||
|
{
|
||||||
|
return mPFile;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString mFilename;
|
QString mFilename;
|
||||||
|
|
Loading…
Reference in New Issue