GUI: Rename methods in ProjectFile

This commit is contained in:
Daniel Marjamäki 2017-07-28 05:08:59 +02:00
parent 6c424709b6
commit 8d704f7709
6 changed files with 112 additions and 116 deletions

View File

@ -362,7 +362,7 @@ void MainWindow::DoCheckProject(ImportProject p)
mIsLogfileLoaded = false;
if (mProject) {
std::vector<std::string> v;
foreach (const QString &s, mProject->getProjectFile()->GetExcludedPaths()) {
foreach (const QString &s, mProject->getProjectFile()->getExcludedPaths()) {
v.push_back(s.toStdString());
}
p.ignorePaths(v);
@ -386,7 +386,7 @@ void MainWindow::DoCheckProject(ImportProject p)
checkSettings.force = false;
if (mProject)
qDebug() << "Checking project file" << mProject->getProjectFile()->GetFilename();
qDebug() << "Checking project file" << mProject->getProjectFile()->getFilename();
if (!checkSettings.buildDir.empty()) {
std::list<std::string> sourcefiles;
@ -409,7 +409,7 @@ void MainWindow::DoCheckFiles(const QStringList &files)
FileList pathList;
pathList.AddPathList(files);
if (mProject) {
pathList.AddExcludeList(mProject->getProjectFile()->GetExcludedPaths());
pathList.AddExcludeList(mProject->getProjectFile()->getExcludedPaths());
} else {
EnableProjectActions(false);
}
@ -441,7 +441,7 @@ void MainWindow::DoCheckFiles(const QStringList &files)
Settings checkSettings = GetCppcheckSettings();
if (mProject)
qDebug() << "Checking project file" << mProject->getProjectFile()->GetFilename();
qDebug() << "Checking project file" << mProject->getProjectFile()->getFilename();
if (!checkSettings.buildDir.empty()) {
std::list<std::string> sourcefiles;
@ -642,7 +642,7 @@ Library::Error MainWindow::LoadLibrary(Library *library, QString filename)
// Try to load the library from the project folder..
if (mProject) {
QString path = QFileInfo(mProject->getProjectFile()->GetFilename()).canonicalPath();
QString path = QFileInfo(mProject->getProjectFile()->getFilename()).canonicalPath();
ret = library->load(NULL, (path+"/"+filename).toLatin1());
if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
return ret;
@ -742,24 +742,23 @@ Settings MainWindow::GetCppcheckSettings()
// If project file loaded, read settings from it
if (mProject) {
ProjectFile *pfile = mProject->getProjectFile();
QStringList dirs = pfile->GetIncludeDirs();
QStringList dirs = pfile->getIncludeDirs();
AddIncludeDirs(dirs, result);
const QStringList defines = pfile->GetDefines();
QString define;
foreach (define, defines) {
const QStringList defines = pfile->getDefines();
foreach (QString define, defines) {
if (!result.userDefines.empty())
result.userDefines += ";";
result.userDefines += define.toStdString();
}
const QStringList libraries = pfile->GetLibraries();
const QStringList libraries = pfile->getLibraries();
foreach (QString library, libraries) {
const QString filename = library + ".cfg";
TryLoadLibrary(&result.library, filename);
}
const QStringList suppressions = pfile->GetSuppressions();
const QStringList suppressions = pfile->getSuppressions();
foreach (QString suppression, suppressions) {
result.nomsg.addSuppressionLine(suppression.toStdString());
}
@ -768,9 +767,9 @@ Settings MainWindow::GetCppcheckSettings()
if (!defines.isEmpty())
result.maxConfigs = 1;
QString buildDir = pfile->GetBuildDir();
QString buildDir = pfile->getBuildDir();
if (!buildDir.isEmpty()) {
QString prjpath = QFileInfo(pfile->GetFilename()).absolutePath();
QString prjpath = QFileInfo(pfile->getFilename()).absolutePath();
result.buildDir = (prjpath + '/' + buildDir).toStdString();
}
}
@ -934,7 +933,7 @@ void MainWindow::ReCheckSelected(QStringList files, bool all)
FileList pathList;
pathList.AddPathList(files);
if (mProject)
pathList.AddExcludeList(mProject->getProjectFile()->GetExcludedPaths());
pathList.AddExcludeList(mProject->getProjectFile()->getExcludedPaths());
QStringList fileNames = pathList.GetFileList();
CheckLockDownUI(); // lock UI while checking
mUI.mResults->CheckingStarted(fileNames.size());
@ -965,7 +964,7 @@ void MainWindow::ReCheck(bool all)
mUI.mResults->CheckingStarted(files.size());
if (mProject)
qDebug() << "Rechecking project file" << mProject->getProjectFile()->GetFilename();
qDebug() << "Rechecking project file" << mProject->getProjectFile()->getFilename();
mThread->SetCheckFiles(all);
mThread->Check(GetCppcheckSettings(), all);
@ -1323,7 +1322,7 @@ void MainWindow::CheckProject(Project *project)
}
QFileInfo inf(project->getFilename());
const QString rootpath = project->getProjectFile()->GetRootPath();
const QString rootpath = project->getProjectFile()->getRootPath();
// If the root path is not given or is not "current dir", use project
// file's location directory as root path
@ -1334,15 +1333,15 @@ void MainWindow::CheckProject(Project *project)
else
mCurrentDirectory = rootpath;
if (!project->getProjectFile()->GetImportProject().isEmpty()) {
if (!project->getProjectFile()->getImportProject().isEmpty()) {
ImportProject p;
QString prjfile = inf.canonicalPath() + '/' + project->getProjectFile()->GetImportProject();
QString prjfile = inf.canonicalPath() + '/' + project->getProjectFile()->getImportProject();
p.import(prjfile.toStdString());
DoCheckProject(p);
return;
}
QStringList paths = project->getProjectFile()->GetCheckPaths();
QStringList paths = project->getProjectFile()->getCheckPaths();
// If paths not given then check the root path (which may be the project
// file's location, see above). This is to keep the compatibility with

View File

@ -68,7 +68,7 @@ bool Project::open()
if (!QFile::exists(mFilename))
return false;
if (!mProjectFile->Read()) {
if (!mProjectFile->read()) {
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
tr("Could not read the project file."),
@ -76,7 +76,7 @@ bool Project::open()
mParentWidget);
msg.exec();
mFilename = QString();
mProjectFile->SetFilename(mFilename);
mProjectFile->setFilename(mFilename);
return false;
}
@ -92,7 +92,7 @@ bool Project::edit()
dlg.SaveToProjectFile(mProjectFile);
if (!mProjectFile->Write()) {
if (!mProjectFile->write()) {
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
tr("Could not write the project file."),

View File

@ -62,7 +62,7 @@ ProjectFile::ProjectFile(const QString &filename, QObject *parent) :
{
}
bool ProjectFile::Read(const QString &filename)
bool ProjectFile::read(const QString &filename)
{
if (!filename.isEmpty())
mFilename = filename;
@ -83,43 +83,43 @@ bool ProjectFile::Read(const QString &filename)
}
// Read root path from inside project element
if (insideProject && xmlReader.name() == RootPathName)
ReadRootPath(xmlReader);
readRootPath(xmlReader);
// Read root path from inside project element
if (insideProject && xmlReader.name() == BuildDirElementName)
ReadBuildDir(xmlReader);
readBuildDir(xmlReader);
// Find paths to check from inside project element
if (insideProject && xmlReader.name() == PathsElementName)
ReadCheckPaths(xmlReader);
readCheckPaths(xmlReader);
if (insideProject && xmlReader.name() == ImportProjectElementName)
ReadImportProject(xmlReader);
readImportProject(xmlReader);
// Find include directory from inside project element
if (insideProject && xmlReader.name() == IncludeDirElementName)
ReadIncludeDirs(xmlReader);
readIncludeDirs(xmlReader);
// Find preprocessor define from inside project element
if (insideProject && xmlReader.name() == DefinesElementName)
ReadDefines(xmlReader);
readDefines(xmlReader);
// Find exclude list from inside project element
if (insideProject && xmlReader.name() == ExcludeElementName)
ReadExcludes(xmlReader);
readExcludes(xmlReader);
// Find ignore list from inside project element
// These are read for compatibility
if (insideProject && xmlReader.name() == IgnoreElementName)
ReadExcludes(xmlReader);
readExcludes(xmlReader);
// Find libraries list from inside project element
if (insideProject && xmlReader.name() == LibrariesElementName)
ReadStringList(mLibraries, xmlReader,LibraryElementName);
readStringList(mLibraries, xmlReader,LibraryElementName);
// Find suppressions list from inside project element
if (insideProject && xmlReader.name() == SuppressionsElementName)
ReadStringList(mSuppressions, xmlReader,SuppressionElementName);
readStringList(mSuppressions, xmlReader,SuppressionElementName);
break;
@ -143,13 +143,10 @@ bool ProjectFile::Read(const QString &filename)
}
file.close();
if (projectTagFound)
return true;
else
return false;
return projectTagFound;
}
void ProjectFile::ReadRootPath(QXmlStreamReader &reader)
void ProjectFile::readRootPath(QXmlStreamReader &reader)
{
QXmlStreamAttributes attribs = reader.attributes();
QString name = attribs.value("", RootPathNameAttrib).toString();
@ -157,7 +154,7 @@ void ProjectFile::ReadRootPath(QXmlStreamReader &reader)
mRootPath = name;
}
void ProjectFile::ReadBuildDir(QXmlStreamReader &reader)
void ProjectFile::readBuildDir(QXmlStreamReader &reader)
{
mBuildDir.clear();
do {
@ -182,7 +179,7 @@ void ProjectFile::ReadBuildDir(QXmlStreamReader &reader)
} while (1);
}
void ProjectFile::ReadImportProject(QXmlStreamReader &reader)
void ProjectFile::readImportProject(QXmlStreamReader &reader)
{
mImportProject.clear();
do {
@ -207,7 +204,7 @@ void ProjectFile::ReadImportProject(QXmlStreamReader &reader)
} while (1);
}
void ProjectFile::ReadIncludeDirs(QXmlStreamReader &reader)
void ProjectFile::readIncludeDirs(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
bool allRead = false;
@ -245,7 +242,7 @@ void ProjectFile::ReadIncludeDirs(QXmlStreamReader &reader)
} while (!allRead);
}
void ProjectFile::ReadDefines(QXmlStreamReader &reader)
void ProjectFile::readDefines(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
bool allRead = false;
@ -282,7 +279,7 @@ void ProjectFile::ReadDefines(QXmlStreamReader &reader)
} while (!allRead);
}
void ProjectFile::ReadCheckPaths(QXmlStreamReader &reader)
void ProjectFile::readCheckPaths(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
bool allRead = false;
@ -320,7 +317,7 @@ void ProjectFile::ReadCheckPaths(QXmlStreamReader &reader)
} while (!allRead);
}
void ProjectFile::ReadExcludes(QXmlStreamReader &reader)
void ProjectFile::readExcludes(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
bool allRead = false;
@ -367,7 +364,7 @@ void ProjectFile::ReadExcludes(QXmlStreamReader &reader)
}
void ProjectFile::ReadStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[])
void ProjectFile::readStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[])
{
QXmlStreamReader::TokenType type;
bool allRead = false;
@ -405,37 +402,37 @@ void ProjectFile::ReadStringList(QStringList &stringlist, QXmlStreamReader &read
} while (!allRead);
}
void ProjectFile::SetIncludes(const QStringList &includes)
void ProjectFile::setIncludes(const QStringList &includes)
{
mIncludeDirs = includes;
}
void ProjectFile::SetDefines(const QStringList &defines)
void ProjectFile::setDefines(const QStringList &defines)
{
mDefines = defines;
}
void ProjectFile::SetCheckPaths(const QStringList &paths)
void ProjectFile::setCheckPaths(const QStringList &paths)
{
mPaths = paths;
}
void ProjectFile::SetExcludedPaths(const QStringList &paths)
void ProjectFile::setExcludedPaths(const QStringList &paths)
{
mExcludedPaths = paths;
}
void ProjectFile::SetLibraries(const QStringList &libraries)
void ProjectFile::setLibraries(const QStringList &libraries)
{
mLibraries = libraries;
}
void ProjectFile::SetSuppressions(const QStringList &suppressions)
void ProjectFile::setSuppressions(const QStringList &suppressions)
{
mSuppressions = suppressions;
}
bool ProjectFile::Write(const QString &filename)
bool ProjectFile::write(const QString &filename)
{
if (!filename.isEmpty())
mFilename = filename;
@ -508,12 +505,12 @@ bool ProjectFile::Write(const QString &filename)
xmlWriter.writeEndElement();
}
WriteStringList(xmlWriter,
writeStringList(xmlWriter,
mLibraries,
LibrariesElementName,
LibraryElementName);
WriteStringList(xmlWriter,
writeStringList(xmlWriter,
mSuppressions,
SuppressionsElementName,
SuppressionElementName);
@ -523,7 +520,7 @@ bool ProjectFile::Write(const QString &filename)
return true;
}
void ProjectFile::WriteStringList(QXmlStreamWriter &xmlWriter, const QStringList &stringlist, const char startelementname[], const char stringelementname[])
void ProjectFile::writeStringList(QXmlStreamWriter &xmlWriter, const QStringList &stringlist, const char startelementname[], const char stringelementname[])
{
if (stringlist.isEmpty())
return;

View File

@ -44,21 +44,21 @@ public:
* @brief Read the project file.
* @param filename Filename (can be also given to constructor).
*/
bool Read(const QString &filename = QString());
bool read(const QString &filename = QString());
/**
* @brief Get project root path.
* @return project root path.
*/
QString GetRootPath() const {
QString getRootPath() const {
return mRootPath;
}
QString GetBuildDir() const {
QString getBuildDir() const {
return mBuildDir;
}
QString GetImportProject() const {
QString getImportProject() const {
return mImportProject;
}
@ -66,7 +66,7 @@ public:
* @brief Get list of include directories.
* @return list of directories.
*/
QStringList GetIncludeDirs() const {
QStringList getIncludeDirs() const {
return ProjectFile::fromNativeSeparators(mIncludeDirs);
}
@ -74,7 +74,7 @@ public:
* @brief Get list of defines.
* @return list of defines.
*/
QStringList GetDefines() const {
QStringList getDefines() const {
return mDefines;
}
@ -82,7 +82,7 @@ public:
* @brief Get list of paths to check.
* @return list of paths.
*/
QStringList GetCheckPaths() const {
QStringList getCheckPaths() const {
return ProjectFile::fromNativeSeparators(mPaths);
}
@ -90,7 +90,7 @@ public:
* @brief Get list of paths to exclude from the check.
* @return list of paths.
*/
QStringList GetExcludedPaths() const {
QStringList getExcludedPaths() const {
return ProjectFile::fromNativeSeparators(mExcludedPaths);
}
@ -98,7 +98,7 @@ public:
* @brief Get list libraries.
* @return list of libraries.
*/
QStringList GetLibraries() const {
QStringList getLibraries() const {
return mLibraries;
}
@ -106,7 +106,7 @@ public:
* @brief Get list suppressions.
* @return list of suppressions.
*/
QStringList GetSuppressions() const {
QStringList getSuppressions() const {
return mSuppressions;
}
@ -114,7 +114,7 @@ public:
* @brief Get filename for the project file.
* @return file name.
*/
QString GetFilename() const {
QString getFilename() const {
return mFilename;
}
@ -122,16 +122,16 @@ public:
* @brief Set project root path.
* @param rootpath new project root path.
*/
void SetRootPath(const QString &rootpath) {
void setRootPath(const QString &rootpath) {
mRootPath = rootpath;
}
void SetBuildDir(const QString &buildDir) {
void setBuildDir(const QString &buildDir) {
mBuildDir = buildDir;
}
void SetImportProject(const QString &importProject) {
void setImportProject(const QString &importProject) {
mImportProject = importProject;
}
@ -139,58 +139,49 @@ public:
* @brief Set list of includes.
* @param includes List of defines.
*/
void SetIncludes(const QStringList &includes);
void setIncludes(const QStringList &includes);
/**
* @brief Set list of defines.
* @param defines List of defines.
*/
void SetDefines(const QStringList &defines);
void setDefines(const QStringList &defines);
/**
* @brief Set list of paths to check.
* @param paths List of paths.
*/
void SetCheckPaths(const QStringList &paths);
void setCheckPaths(const QStringList &paths);
/**
* @brief Set list of paths to exclude from the check.
* @param paths List of paths.
*/
void SetExcludedPaths(const QStringList &paths);
void setExcludedPaths(const QStringList &paths);
/**
* @brief Set list of libraries.
* @param libraries List of libraries.
*/
void SetLibraries(const QStringList &libraries);
void setLibraries(const QStringList &libraries);
/**
* @brief Set list of suppressions.
* @param suppressions List of suppressions.
*/
void SetSuppressions(const QStringList &suppressions);
void setSuppressions(const QStringList &suppressions);
/**
* @brief Write project file (to disk).
* @param filename Filename to use.
*/
bool Write(const QString &filename = QString());
/**
* @brief Write string list
* @param xmlWriter xml writer
* @param stringlist string list to write
* @param startelementname name of start element
* @param stringelementname name of each string element
*/
static void WriteStringList(QXmlStreamWriter &xmlWriter, const QStringList &stringlist, const char startelementname[], const char stringelementname[]);
bool write(const QString &filename = QString());
/**
* @brief Set filename for the project file.
* @param filename Filename to use.
*/
void SetFilename(const QString &filename) {
void setFilename(const QString &filename) {
mFilename = filename;
}
@ -200,39 +191,39 @@ protected:
* @brief Read optional root path from XML.
* @param reader XML stream reader.
*/
void ReadRootPath(QXmlStreamReader &reader);
void readRootPath(QXmlStreamReader &reader);
void ReadBuildDir(QXmlStreamReader &reader);
void readBuildDir(QXmlStreamReader &reader);
/**
* @brief Read importproject from XML.
* @param reader XML stream reader.
*/
void ReadImportProject(QXmlStreamReader &reader);
void readImportProject(QXmlStreamReader &reader);
/**
* @brief Read list of include directories from XML.
* @param reader XML stream reader.
*/
void ReadIncludeDirs(QXmlStreamReader &reader);
void readIncludeDirs(QXmlStreamReader &reader);
/**
* @brief Read list of defines from XML.
* @param reader XML stream reader.
*/
void ReadDefines(QXmlStreamReader &reader);
void readDefines(QXmlStreamReader &reader);
/**
* @brief Read list paths to check.
* @param reader XML stream reader.
*/
void ReadCheckPaths(QXmlStreamReader &reader);
void readCheckPaths(QXmlStreamReader &reader);
/**
* @brief Read lists of excluded paths.
* @param reader XML stream reader.
*/
void ReadExcludes(QXmlStreamReader &reader);
void readExcludes(QXmlStreamReader &reader);
/**
* @brief Read string list
@ -240,7 +231,16 @@ protected:
* @param reader XML stream reader
* @param elementname elementname for each string
*/
void ReadStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[]);
void readStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[]);
/**
* @brief Write string list
* @param xmlWriter xml writer
* @param stringlist string list to write
* @param startelementname name of start element
* @param stringelementname name of each string element
*/
static void writeStringList(QXmlStreamWriter &xmlWriter, const QStringList &stringlist, const char startelementname[], const char stringelementname[]);
private:

View File

@ -129,28 +129,28 @@ void ProjectFileDialog::SaveSettings() const
void ProjectFileDialog::LoadFromProjectFile(const ProjectFile *projectFile)
{
SetRootPath(projectFile->GetRootPath());
SetBuildDir(projectFile->GetBuildDir());
SetIncludepaths(projectFile->GetIncludeDirs());
SetDefines(projectFile->GetDefines());
SetCheckPaths(projectFile->GetCheckPaths());
SetImportProject(projectFile->GetImportProject());
SetExcludedPaths(projectFile->GetExcludedPaths());
SetLibraries(projectFile->GetLibraries());
SetSuppressions(projectFile->GetSuppressions());
SetRootPath(projectFile->getRootPath());
SetBuildDir(projectFile->getBuildDir());
SetIncludepaths(projectFile->getIncludeDirs());
SetDefines(projectFile->getDefines());
SetCheckPaths(projectFile->getCheckPaths());
SetImportProject(projectFile->getImportProject());
SetExcludedPaths(projectFile->getExcludedPaths());
SetLibraries(projectFile->getLibraries());
SetSuppressions(projectFile->getSuppressions());
}
void ProjectFileDialog::SaveToProjectFile(ProjectFile *projectFile) const
{
projectFile->SetRootPath(GetRootPath());
projectFile->SetBuildDir(GetBuildDir());
projectFile->SetImportProject(GetImportProject());
projectFile->SetIncludes(GetIncludePaths());
projectFile->SetDefines(GetDefines());
projectFile->SetCheckPaths(GetCheckPaths());
projectFile->SetExcludedPaths(GetExcludedPaths());
projectFile->SetLibraries(GetLibraries());
projectFile->SetSuppressions(GetSuppressions());
projectFile->setRootPath(GetRootPath());
projectFile->setBuildDir(GetBuildDir());
projectFile->setImportProject(GetImportProject());
projectFile->setIncludes(GetIncludePaths());
projectFile->setDefines(GetDefines());
projectFile->setCheckPaths(GetCheckPaths());
projectFile->setExcludedPaths(GetExcludedPaths());
projectFile->setLibraries(GetLibraries());
projectFile->setSuppressions(GetSuppressions());
}
QString ProjectFileDialog::getExistingDirectory(const QString &caption, bool trailingSlash)

View File

@ -44,10 +44,10 @@ void StatsDialog::setProject(const Project& project)
{
ProjectFile *projectFile = project.getProjectFile();
if (projectFile) {
mUI.mProject->setText(projectFile->GetRootPath());
mUI.mPaths->setText(projectFile->GetCheckPaths().join(";"));
mUI.mIncludePaths->setText(projectFile->GetIncludeDirs().join(";"));
mUI.mDefines->setText(projectFile->GetDefines().join(";"));
mUI.mProject->setText(projectFile->getRootPath());
mUI.mPaths->setText(projectFile->getCheckPaths().join(";"));
mUI.mIncludePaths->setText(projectFile->getIncludeDirs().join(";"));
mUI.mDefines->setText(projectFile->getDefines().join(";"));
} else {
mUI.mProject->setText("");
mUI.mPaths->setText("");