GUI: Rename Ignore-feature to Exclude-feature.

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: #2995 (GUI: Rename ignore-feature to exclude-feature)
This commit is contained in:
Kimmo Varis 2011-08-23 19:54:53 +03:00
parent c7cb38b0b5
commit 4998c913da
8 changed files with 66 additions and 48 deletions

View File

@ -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>

View File

@ -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;
}
}

View File

@ -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

View File

@ -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();

View File

@ -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)

View File

@ -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();

View File

@ -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

View File

@ -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>