diff --git a/cppcheck.cppcheck b/cppcheck.cppcheck index ecddb402b..29c14bc9a 100644 --- a/cppcheck.cppcheck +++ b/cppcheck.cppcheck @@ -13,8 +13,8 @@ - + - + diff --git a/gui/filelist.cpp b/gui/filelist.cpp index 4e26eb1f3..9f3ef8985 100644 --- a/gui/filelist.cpp +++ b/gui/filelist.cpp @@ -96,7 +96,7 @@ void FileList::AddPathList(const QStringList &paths) QStringList FileList::GetFileList() const { - if (mIgnoredPaths.empty()) + if (mExcludedPaths.empty()) { QStringList names; foreach(QFileInfo item, mFileList) @@ -108,16 +108,16 @@ QStringList FileList::GetFileList() const } else { - return ApplyIgnoreList(); + return ApplyExcludeList(); } } -void FileList::AddIngoreList(const QStringList &paths) +void FileList::AddExcludeList(const QStringList &paths) { - mIgnoredPaths = paths; + mExcludedPaths = paths; } -QStringList FileList::ApplyIgnoreList() const +QStringList FileList::ApplyExcludeList() const { QStringList paths; foreach(QFileInfo item, mFileList) @@ -131,17 +131,17 @@ QStringList FileList::ApplyIgnoreList() const bool FileList::Match(const QString &path) const { - for (int i = 0; i < mIgnoredPaths.size(); i++) + for (int i = 0; i < mExcludedPaths.size(); i++) { - if (mIgnoredPaths[i].endsWith('/')) + if (mExcludedPaths[i].endsWith('/')) { - const QString pathignore("/" + mIgnoredPaths[i]); - if (path.indexOf(pathignore) != -1) + const QString pathexclude("/" + mExcludedPaths[i]); + if (path.indexOf(pathexclude) != -1) return true; } else { - if (path.endsWith(mIgnoredPaths[i])) + if (path.endsWith(mExcludedPaths[i])) return true; } } diff --git a/gui/filelist.h b/gui/filelist.h index a896e6070..2fd00915f 100644 --- a/gui/filelist.h +++ b/gui/filelist.h @@ -65,10 +65,10 @@ public: QStringList GetFileList() const; /** - * @brief Add list of paths to ignore list. - * @param paths Paths to ignore. + * @brief Add list of paths to exclusion list. + * @param paths Paths to exclude. */ - void AddIngoreList(const QStringList &paths); + void AddExcludeList(const QStringList &paths); protected: @@ -86,23 +86,23 @@ protected: /** * @brief Get filtered list of paths. - * This method takes the list of paths and applies the ignore lists to + * This method takes the list of paths and applies the exclude lists to * it. And then returns the list of paths that did not match the - * ignore filters. + * exclude filters. * @return Filtered list of paths. */ - QStringList ApplyIgnoreList() const; + QStringList ApplyExcludeList() const; /** - * @brief Test if path matches any of the ignore filters. - * @param path Path to test against filters. + * @brief Test if path matches any of the exclude filters. + * @param path Path to test against exclude filters. * @return true if any of the filters matches, false otherwise. */ bool Match(const QString &path) const; private: QFileInfoList mFileList; - QStringList mIgnoredPaths; + QStringList mExcludedPaths; }; #endif // FILELIST_H diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index fc7da48e0..57dc37998 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -267,7 +267,7 @@ void MainWindow::DoCheckFiles(const QStringList &files) FileList pathList; pathList.AddPathList(files); if (mProject) - pathList.AddIngoreList(mProject->GetProjectFile()->GetIgnoredPaths()); + pathList.AddExcludeList(mProject->GetProjectFile()->GetExcludedPaths()); QStringList fileNames = pathList.GetFileList(); mUI.mResults->Clear(); diff --git a/gui/project.cpp b/gui/project.cpp index 3467da289..856255117 100644 --- a/gui/project.cpp +++ b/gui/project.cpp @@ -85,7 +85,7 @@ void Project::Edit() dlg.SetDefines(defines); QStringList paths = mPFile->GetCheckPaths(); dlg.SetPaths(paths); - QStringList ignorepaths = mPFile->GetIgnoredPaths(); + QStringList ignorepaths = mPFile->GetExcludedPaths(); dlg.SetIgnorePaths(ignorepaths); int rv = dlg.exec(); @@ -100,7 +100,7 @@ void Project::Edit() QStringList paths = dlg.GetPaths(); mPFile->SetCheckPaths(paths); QStringList ignorepaths = dlg.GetIgnorePaths(); - mPFile->SetIgnoredPaths(ignorepaths); + mPFile->SetExcludedPaths(ignorepaths); bool writeSuccess = mPFile->Write(); if (!writeSuccess) diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index f227cdfa4..c1d84e4b5 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -41,6 +41,9 @@ static const char RootPathNameAttrib[] = "name"; static const char IgnoreElementName[] = "ignore"; static const char IgnorePathName[] = "path"; static const char IgnorePathNameAttrib[] = "name"; +static const char ExcludeElementName[] = "exclude"; +static const char ExcludePathName[] = "path"; +static const char ExcludePathNameAttrib[] = "name"; ProjectFile::ProjectFile(QObject *parent) : QObject(parent) @@ -91,9 +94,14 @@ bool ProjectFile::Read(const QString &filename) if (insideProject && xmlReader.name() == DefinesElementName) ReadDefines(xmlReader); + // Find exclude list from inside project element + if (insideProject && xmlReader.name() == ExcludeElementName) + ReadExcludes(xmlReader); + // Find ignore list from inside project element + // These are read for compatibility if (insideProject && xmlReader.name() == IgnoreElementName) - ReadIgnores(xmlReader); + ReadExcludes(xmlReader); break; @@ -148,10 +156,10 @@ QStringList ProjectFile::GetCheckPaths() const return paths; } -QStringList ProjectFile::GetIgnoredPaths() const +QStringList ProjectFile::GetExcludedPaths() const { QStringList paths; - foreach(QString path, mIgnoredPaths) + foreach(QString path, mExcludedPaths) { paths << QDir::fromNativeSeparators(path); } @@ -291,7 +299,7 @@ void ProjectFile::ReadCheckPaths(QXmlStreamReader &reader) while (!allRead); } -void ProjectFile::ReadIgnores(QXmlStreamReader &reader) +void ProjectFile::ReadExcludes(QXmlStreamReader &reader) { QXmlStreamReader::TokenType type; bool allRead = false; @@ -301,19 +309,29 @@ void ProjectFile::ReadIgnores(QXmlStreamReader &reader) switch (type) { case QXmlStreamReader::StartElement: - // Read define-elements - if (reader.name().toString() == IgnorePathName) + // Read exclude-elements + if (reader.name().toString() == ExcludePathName) + { + QXmlStreamAttributes attribs = reader.attributes(); + QString name = attribs.value("", ExcludePathNameAttrib).toString(); + if (!name.isEmpty()) + mExcludedPaths << name; + } + // Read ignore-elements - deprecated but support reading them + else if (reader.name().toString() == IgnorePathName) { QXmlStreamAttributes attribs = reader.attributes(); QString name = attribs.value("", IgnorePathNameAttrib).toString(); if (!name.isEmpty()) - mIgnoredPaths << name; + mExcludedPaths << name; } break; case QXmlStreamReader::EndElement: if (reader.name().toString() == IgnoreElementName) allRead = true; + if (reader.name().toString() == ExcludeElementName) + allRead = true; break; // Not handled @@ -347,9 +365,9 @@ void ProjectFile::SetCheckPaths(const QStringList &paths) mPaths = paths; } -void ProjectFile::SetIgnoredPaths(const QStringList &paths) +void ProjectFile::SetExcludedPaths(const QStringList &paths) { - mIgnoredPaths = paths; + mExcludedPaths = paths; } bool ProjectFile::Write(const QString &filename) @@ -410,13 +428,13 @@ bool ProjectFile::Write(const QString &filename) xmlWriter.writeEndElement(); } - if (!mIgnoredPaths.isEmpty()) + if (!mExcludedPaths.isEmpty()) { - xmlWriter.writeStartElement(IgnoreElementName); - foreach(QString path, mIgnoredPaths) + xmlWriter.writeStartElement(ExcludeElementName); + foreach(QString path, mExcludedPaths) { - xmlWriter.writeStartElement(IgnorePathName); - xmlWriter.writeAttribute(IgnorePathNameAttrib, path); + xmlWriter.writeStartElement(ExcludePathName); + xmlWriter.writeAttribute(ExcludePathNameAttrib, path); xmlWriter.writeEndElement(); } xmlWriter.writeEndElement(); diff --git a/gui/projectfile.h b/gui/projectfile.h index fea732587..b6d264044 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -29,7 +29,7 @@ /** -* @brief A class that reads and writes (TODO) project files. +* @brief A class that reads and writes project files. * The project files contain project-specific settings for checking. For * example a list of include paths. */ @@ -75,10 +75,10 @@ public: QStringList GetCheckPaths() const; /** - * @brief Get list of paths to ignore. + * @brief Get list of paths to exclude from the check. * @return list of paths. */ - QStringList GetIgnoredPaths() const; + QStringList GetExcludedPaths() const; /** * @brief Get filename for the project file. @@ -117,10 +117,10 @@ public: void SetCheckPaths(const QStringList &paths); /** - * @brief Set list of paths to ignore. + * @brief Set list of paths to exclude from the check. * @param defines List of paths. */ - void SetIgnoredPaths(const QStringList &paths); + void SetExcludedPaths(const QStringList &paths); /** * @brief Write project file (to disk). @@ -164,10 +164,10 @@ protected: void ReadCheckPaths(QXmlStreamReader &reader); /** - * @brief Read lists of ignores. + * @brief Read lists of excluded paths. * @param reader XML stream reader. */ - void ReadIgnores(QXmlStreamReader &reader); + void ReadExcludes(QXmlStreamReader &reader); private: @@ -200,9 +200,9 @@ private: QStringList mPaths; /** - * @brief Paths ignored from the check. + * @brief Paths excluded from the check. */ - QStringList mIgnoredPaths; + QStringList mExcludedPaths; }; /// @} #endif // PROJECT_FILE_H diff --git a/gui/projectfile.ui b/gui/projectfile.ui index 75c5be046..e5be7cf7e 100644 --- a/gui/projectfile.ui +++ b/gui/projectfile.ui @@ -212,7 +212,7 @@ - Ignore + Exclude