Skip to content

Commit

Permalink
GUI: Rename Ignore-feature to Exclude-feature.
Browse files Browse the repository at this point in the history
Exclude is the correct term to use when removing paths from the
list of checked items. Ignore as a term was a poor choise to begin
with. XML file reading still recognizes and reads  the 'ignore'
element but writes 'exclude' element.

Ticket: danmar#2995 (GUI: Rename ignore-feature to exclude-feature)
  • Loading branch information
kimmov committed Aug 23, 2011
1 parent c7cb38b commit 4998c91
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 48 deletions.
4 changes: 2 additions & 2 deletions cppcheck.cppcheck
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<dir name="gui/"/>
<dir name="test/"/>
</paths>
<ignore>
<exclude>
<path name="gui/temp/"/>
<path name="test/test.cxx"/>
</ignore>
</exclude>
</project>
20 changes: 10 additions & 10 deletions gui/filelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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;
}
}
Expand Down
18 changes: 9 additions & 9 deletions gui/filelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ class FileList
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:

Expand All @@ -86,23 +86,23 @@ class FileList

/**
* @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
2 changes: 1 addition & 1 deletion gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions gui/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
Expand Down
46 changes: 32 additions & 14 deletions gui/projectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
18 changes: 9 additions & 9 deletions gui/projectfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -75,10 +75,10 @@ class ProjectFile : public QObject
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.
Expand Down Expand Up @@ -117,10 +117,10 @@ class ProjectFile : public QObject
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).
Expand Down Expand Up @@ -164,10 +164,10 @@ class ProjectFile : public QObject
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:

Expand Down Expand Up @@ -200,9 +200,9 @@ class ProjectFile : public QObject
QStringList mPaths;

/**
* @brief Paths ignored from the check.
* @brief Paths excluded from the check.
*/
QStringList mIgnoredPaths;
QStringList mExcludedPaths;
};
/// @}
#endif // PROJECT_FILE_H
2 changes: 1 addition & 1 deletion gui/projectfile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Ignore</string>
<string>Exclude</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
Expand Down

0 comments on commit 4998c91

Please sign in to comment.