GUI: Rename

This commit is contained in:
Daniel Marjamäki 2016-11-19 21:12:32 +01:00
parent 84e6163cb8
commit 2b767d3f6f
3 changed files with 37 additions and 33 deletions

View File

@ -29,7 +29,7 @@
Project::Project(QWidget *parent) : Project::Project(QWidget *parent) :
QObject(parent), QObject(parent),
mPFile(NULL), mProjectFile(NULL),
mParentWidget(parent) mParentWidget(parent)
{ {
} }
@ -37,14 +37,14 @@ Project::Project(QWidget *parent) :
Project::Project(const QString &filename, QWidget *parent) : Project::Project(const QString &filename, QWidget *parent) :
QObject(parent), QObject(parent),
mFilename(filename), mFilename(filename),
mPFile(NULL), mProjectFile(NULL),
mParentWidget(parent) mParentWidget(parent)
{ {
} }
Project::~Project() Project::~Project()
{ {
delete mPFile; delete mProjectFile;
} }
QString Project::Filename() const QString Project::Filename() const
@ -59,16 +59,16 @@ void Project::SetFilename(const QString &filename)
bool Project::IsOpen() const bool Project::IsOpen() const
{ {
return mPFile != NULL; return mProjectFile != NULL;
} }
bool Project::Open() bool Project::Open()
{ {
mPFile = new ProjectFile(mFilename, this); mProjectFile = new ProjectFile(mFilename, this);
if (!QFile::exists(mFilename)) if (!QFile::exists(mFilename))
return false; return false;
if (!mPFile->Read()) { if (!mProjectFile->Read()) {
QMessageBox msg(QMessageBox::Critical, QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"), tr("Cppcheck"),
tr("Could not read the project file."), tr("Could not read the project file."),
@ -76,7 +76,7 @@ bool Project::Open()
mParentWidget); mParentWidget);
msg.exec(); msg.exec();
mFilename = QString(); mFilename = QString();
mPFile->SetFilename(mFilename); mProjectFile->SetFilename(mFilename);
return false; return false;
} }
@ -86,30 +86,30 @@ bool Project::Open()
bool Project::Edit() bool Project::Edit()
{ {
ProjectFileDialog dlg(mFilename, mParentWidget); ProjectFileDialog dlg(mFilename, mParentWidget);
dlg.SetRootPath(mPFile->GetRootPath()); dlg.SetRootPath(mProjectFile->GetRootPath());
dlg.SetBuildDir(mPFile->GetBuildDir()); dlg.SetBuildDir(mProjectFile->GetBuildDir());
dlg.SetIncludepaths(mPFile->GetIncludeDirs()); dlg.SetIncludepaths(mProjectFile->GetIncludeDirs());
dlg.SetDefines(mPFile->GetDefines()); dlg.SetDefines(mProjectFile->GetDefines());
dlg.SetPaths(mPFile->GetCheckPaths()); dlg.SetPaths(mProjectFile->GetCheckPaths());
dlg.SetImportProject(mPFile->GetImportProject()); dlg.SetImportProject(mProjectFile->GetImportProject());
dlg.SetExcludedPaths(mPFile->GetExcludedPaths()); dlg.SetExcludedPaths(mProjectFile->GetExcludedPaths());
dlg.SetLibraries(mPFile->GetLibraries()); dlg.SetLibraries(mProjectFile->GetLibraries());
dlg.SetSuppressions(mPFile->GetSuppressions()); dlg.SetSuppressions(mProjectFile->GetSuppressions());
if (dlg.exec() != QDialog::Accepted) if (dlg.exec() != QDialog::Accepted)
return false; return false;
mPFile->SetRootPath(dlg.GetRootPath()); mProjectFile->SetRootPath(dlg.GetRootPath());
mPFile->SetBuildDir(dlg.GetBuildDir()); mProjectFile->SetBuildDir(dlg.GetBuildDir());
mPFile->SetImportProject(dlg.GetImportProject()); mProjectFile->SetImportProject(dlg.GetImportProject());
mPFile->SetIncludes(dlg.GetIncludePaths()); mProjectFile->SetIncludes(dlg.GetIncludePaths());
mPFile->SetDefines(dlg.GetDefines()); mProjectFile->SetDefines(dlg.GetDefines());
mPFile->SetCheckPaths(dlg.GetPaths()); mProjectFile->SetCheckPaths(dlg.GetPaths());
mPFile->SetExcludedPaths(dlg.GetExcludedPaths()); mProjectFile->SetExcludedPaths(dlg.GetExcludedPaths());
mPFile->SetLibraries(dlg.GetLibraries()); mProjectFile->SetLibraries(dlg.GetLibraries());
mPFile->SetSuppressions(dlg.GetSuppressions()); mProjectFile->SetSuppressions(dlg.GetSuppressions());
if (!mPFile->Write()) { if (!mProjectFile->Write()) {
QMessageBox msg(QMessageBox::Critical, QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"), tr("Cppcheck"),
tr("Could not write the project file."), tr("Could not write the project file."),
@ -124,5 +124,5 @@ bool Project::Edit()
void Project::Create() void Project::Create()
{ {
mPFile = new ProjectFile(mFilename, this); mProjectFile = new ProjectFile(mFilename, this);
} }

View File

@ -80,13 +80,13 @@ public:
* @return project file. * @return project file.
*/ */
ProjectFile * GetProjectFile() const { ProjectFile * GetProjectFile() const {
return mPFile; return mProjectFile;
} }
private: private:
QString mFilename; QString mFilename;
ProjectFile *mPFile; ProjectFile *mProjectFile;
QWidget *mParentWidget; QWidget *mParentWidget;
}; };

View File

@ -121,7 +121,8 @@ void ProjectFileDialog::SaveSettings() const
} }
QString ProjectFileDialog::getExistingDirectory(const QString &caption, bool trailingSlash) { QString ProjectFileDialog::getExistingDirectory(const QString &caption, bool trailingSlash)
{
const QFileInfo inf(mFilePath); const QFileInfo inf(mFilePath);
const QString rootpath = inf.absolutePath(); const QString rootpath = inf.absolutePath();
QString selectedDir = QFileDialog::getExistingDirectory(this, QString selectedDir = QFileDialog::getExistingDirectory(this,
@ -213,7 +214,8 @@ QString ProjectFileDialog::GetRootPath() const
return root; return root;
} }
QString ProjectFileDialog::GetBuildDir() const { QString ProjectFileDialog::GetBuildDir() const
{
return mUI.buildDirEdit->text(); return mUI.buildDirEdit->text();
} }
@ -290,11 +292,13 @@ QStringList ProjectFileDialog::GetSuppressions() const
return suppressions; return suppressions;
} }
void ProjectFileDialog::SetRootPath(const QString &root) { void ProjectFileDialog::SetRootPath(const QString &root)
{
mUI.mEditProjectRoot->setText(QDir::toNativeSeparators(root)); mUI.mEditProjectRoot->setText(QDir::toNativeSeparators(root));
} }
void ProjectFileDialog::SetBuildDir(const QString &buildDir) { void ProjectFileDialog::SetBuildDir(const QString &buildDir)
{
mUI.buildDirEdit->setText(buildDir); mUI.buildDirEdit->setText(buildDir);
} }