aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadovan Zivkovic <pivonroll@gmail.com>2013-08-05 01:23:25 +0200
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-03-11 19:54:55 +0100
commit717556e1c1df101c743837d7228d4987a1601f36 (patch)
tree9c573b29b8917df78b4ef9446f33f0345d90eb61
parent02d8fb1f5f42f11c1a8b2ee4887ef72a6f94cd2d (diff)
Removed FilterType class.
Change-Id: Ifb307410b2f315dcd6c8d77865a616ce542c3640 Reviewed-by: Bojan Petrovic <bojan85@gmail.com>
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/filter.cpp184
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/filter.h14
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/filtertype.cpp281
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/filtertype.h90
-rw-r--r--src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri2
5 files changed, 162 insertions, 409 deletions
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/filter.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/filter.cpp
index b9f3afabc8..5a5b13431e 100644
--- a/src/plugins/vcprojectmanager/vcprojectmodel/filter.cpp
+++ b/src/plugins/vcprojectmanager/vcprojectmodel/filter.cpp
@@ -37,19 +37,38 @@ namespace VcProjectManager {
namespace Internal {
Filter::Filter(VcProjectDocument *parentProjectDoc)
- : m_filterType(FilterType::Ptr(new FilterType(parentProjectDoc)))
+ : m_parentProjectDoc(parentProjectDoc)
{
}
Filter::Filter(const Filter &filter)
{
- m_filterType = filter.m_filterType->clone();
+ m_parentProjectDoc = filter.m_parentProjectDoc;
+ m_anyAttribute = filter.m_anyAttribute;
+ m_name = filter.m_name;
+
+ foreach (const File::Ptr &file, filter.m_files)
+ m_files.append(File::Ptr(new File(*file)));
+
+ foreach (const Filter::Ptr &filt, filter.m_filters)
+ m_filters.append(Filter::Ptr(new Filter(*filt)));
}
Filter &Filter::operator =(const Filter &filter)
{
- if (this != &filter)
- m_filterType = filter.m_filterType->clone();
+ if (this != &filter) {
+ m_name = filter.m_name;
+ m_parentProjectDoc = filter.m_parentProjectDoc;
+ m_anyAttribute = filter.m_anyAttribute;
+ m_files.clear();
+ m_filters.clear();
+
+ foreach (const File::Ptr &file, filter.m_files)
+ m_files.append(File::Ptr(new File(*file)));
+
+ foreach (const Filter::Ptr &filt, filter.m_filters)
+ m_filters.append(Filter::Ptr(new Filter(*filt)));
+ }
return *this;
}
@@ -59,12 +78,40 @@ Filter::~Filter()
void Filter::processNode(const QDomNode &node)
{
- m_filterType->processNode(node);
+ if (node.isNull())
+ return;
+
+ if (node.nodeType() == QDomNode::ElementNode)
+ processNodeAttributes(node.toElement());
+
+ if (node.hasChildNodes()) {
+ QDomNode firstChild = node.firstChild();
+ if (!firstChild.isNull()) {
+ if (firstChild.nodeName() == QLatin1String("Filter"))
+ processFilter(firstChild);
+ else if (firstChild.nodeName() == QLatin1String("File"))
+ processFile(firstChild);
+ }
+ }
}
void Filter::processNodeAttributes(const QDomElement &element)
{
- Q_UNUSED(element)
+ QDomNamedNodeMap namedNodeMap = element.attributes();
+
+ for (int i = 0; i < namedNodeMap.size(); ++i) {
+ QDomNode domNode = namedNodeMap.item(i);
+
+ if (domNode.nodeType() == QDomNode::AttributeNode) {
+ QDomAttr domElement = domNode.toAttr();
+
+ if (domElement.name() == QLatin1String("Name"))
+ m_name = domElement.value();
+
+ else
+ m_anyAttribute.insert(domElement.name(), domElement.value());
+ }
+ }
}
VcNodeWidget *Filter::createSettingsWidget()
@@ -74,76 +121,117 @@ VcNodeWidget *Filter::createSettingsWidget()
QDomNode Filter::toXMLDomNode(QDomDocument &domXMLDocument) const
{
- return m_filterType->toXMLDomNode(domXMLDocument);
+ QDomElement fileNode = domXMLDocument.createElement(QLatin1String("Filter"));
+ fileNode.setAttribute(QLatin1String("Name"), m_name);
+ QHashIterator<QString, QString> it(m_anyAttribute);
+
+ while (it.hasNext()) {
+ it.next();
+ fileNode.setAttribute(it.key(), it.value());
+ }
+
+ foreach (const File::Ptr &file, m_files)
+ fileNode.appendChild(file->toXMLDomNode(domXMLDocument));
+
+ foreach (const Filter::Ptr &filter, m_filters)
+ fileNode.appendChild(filter->toXMLDomNode(domXMLDocument));
+
+ return fileNode;
}
QString Filter::name() const
{
- return m_filterType->name();
+ return m_name;
}
void Filter::setName(const QString &name)
{
- m_filterType->setName(name);
+ m_name = name;
}
void Filter::addFilter(Filter::Ptr filter)
{
- m_filterType->addFilter(filter);
+ if (m_filters.contains(filter))
+ return;
+
+ foreach (const Filter::Ptr &filt, m_filters) {
+ if (filt->name() == filter->name())
+ return;
+ }
+
+ m_filters.append(filter);
}
void Filter::removeFilter(Filter::Ptr filter)
{
- m_filterType->removeFilter(filter);
+ m_filters.removeAll(filter);
}
void Filter::removeFilter(const QString &filterName)
{
- m_filterType->removeFilter(filterName);
+ foreach (const Filter::Ptr &filter, m_filters) {
+ if (filter->name() == filterName) {
+ removeFilter(filter);
+ return;
+ }
+ }
}
QList<Filter::Ptr> Filter::filters() const
{
- return m_filterType->filters();
+ return m_filters;
}
void Filter::addFile(File::Ptr file)
{
- m_filterType->addFile(file);
+ if (m_files.contains(file))
+ return;
+
+ foreach (const File::Ptr &f, m_files) {
+ if (f->relativePath() == file->relativePath())
+ return;
+ }
+
+ m_files.append(file);
}
void Filter::removeFile(File::Ptr file)
{
- m_filterType->removeFile(file);
+ m_files.removeAll(file);
}
void Filter::removeFile(const QString &relativeFilePath)
{
- m_filterType->removeFile(relativeFilePath);
+ foreach (const File::Ptr &file, m_files) {
+ if (file->relativePath() == relativeFilePath) {
+ removeFile(file);
+ return;
+ }
+ }
}
File::Ptr Filter::file(const QString &relativePath) const
{
- return m_filterType->file(relativePath);
+ foreach (const File::Ptr &file, m_files) {
+ if (file->relativePath() == relativePath)
+ return file;
+ }
+ return File::Ptr();
}
QList<File::Ptr> Filter::files() const
{
- return m_filterType->files();
+ return m_files;
}
bool Filter::fileExists(const QString &relativeFilePath)
{
- QList<File::Ptr> files = m_filterType->files();
-
- foreach (const File::Ptr &filePtr, files) {
+ foreach (const File::Ptr &filePtr, m_files) {
if (filePtr->relativePath() == relativeFilePath)
return true;
}
- QList<Filter::Ptr> filters = m_filterType->filters();
-
- foreach (const Filter::Ptr &filterPtr, filters) {
+ foreach (const Filter::Ptr &filterPtr, m_filters) {
if (filterPtr->fileExists(relativeFilePath))
return true;
}
@@ -153,35 +241,65 @@ bool Filter::fileExists(const QString &relativeFilePath)
QString Filter::attributeValue(const QString &attributeName) const
{
- return m_filterType->attributeValue(attributeName);
+ return m_anyAttribute.value(attributeName);
}
void Filter::setAttribute(const QString &attributeName, const QString &attributeValue)
{
- m_filterType->setAttribute(attributeName, attributeValue);
+ m_anyAttribute.insert(attributeName, attributeValue);
}
void Filter::clearAttribute(const QString &attributeName)
{
- m_filterType->clearAttribute(attributeName);
+ if (m_anyAttribute.contains(attributeName))
+ m_anyAttribute.insert(attributeName, QString());
}
void Filter::removeAttribute(const QString &attributeName)
{
- m_filterType->removeAttribute(attributeName);
+ m_anyAttribute.remove(attributeName);
}
void Filter::allFiles(QStringList &sl) const
{
- QList<Filter::Ptr> filters = m_filterType->filters();
- QList<File::Ptr> files = m_filterType->files();
-
- foreach (const Filter::Ptr &filter, filters)
+ foreach (const Filter::Ptr &filter, m_filters)
filter->allFiles(sl);
- foreach (const File::Ptr &file, files)
+ foreach (const File::Ptr &file, m_files)
sl.append(file->canonicalPath());
}
+void Filter::processFile(const QDomNode &fileNode)
+{
+ File::Ptr file(new File(m_parentProjectDoc));
+ file->processNode(fileNode);
+ addFile(file);
+
+ // process next sibling
+ QDomNode nextSibling = fileNode.nextSibling();
+ if (!nextSibling.isNull()) {
+ if (nextSibling.nodeName() == QLatin1String("File"))
+ processFile(nextSibling);
+ else
+ processFilter(nextSibling);
+ }
+}
+
+void Filter::processFilter(const QDomNode &filterNode)
+{
+ Filter::Ptr filter(new Filter(m_parentProjectDoc));
+ filter->processNode(filterNode);
+ addFilter(filter);
+
+ // process next sibling
+ QDomNode nextSibling = filterNode.nextSibling();
+ if (!nextSibling.isNull()) {
+ if (nextSibling.nodeName() == QLatin1String("File"))
+ processFile(nextSibling);
+ else
+ processFilter(nextSibling);
+ }
+}
+
} // namespace Internal
} // namespace VcProjectManager
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/filter.h b/src/plugins/vcprojectmanager/vcprojectmodel/filter.h
index 84c99f4ffe..5fdb80530d 100644
--- a/src/plugins/vcprojectmanager/vcprojectmodel/filter.h
+++ b/src/plugins/vcprojectmanager/vcprojectmodel/filter.h
@@ -31,12 +31,13 @@
#define VCPROJECTMANAGER_INTERNAL_FILTER_H
#include "ivcprojectnodemodel.h"
-
-#include "filtertype.h"
+#include "file.h"
namespace VcProjectManager {
namespace Internal {
+class Filter;
+
class Filter : public IVcProjectXMLNode
{
public:
@@ -75,7 +76,14 @@ public:
void allFiles(QStringList &sl) const;
private:
- FilterType::Ptr m_filterType;
+ void processFile(const QDomNode &fileNode);
+ void processFilter(const QDomNode &filterNode);
+
+ QString m_name;
+ QHash<QString, QString> m_anyAttribute;
+ QList<QSharedPointer<Filter> > m_filters;
+ QList<File::Ptr> m_files;
+ VcProjectDocument *m_parentProjectDoc;
};
} // namespace Internal
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/filtertype.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/filtertype.cpp
deleted file mode 100644
index b7c7ddac5f..0000000000
--- a/src/plugins/vcprojectmanager/vcprojectmodel/filtertype.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/**************************************************************************
-**
-** Copyright (c) 2013 Bojan Petrovic
-** Copyright (c) 2013 Radovan Zivkvoic
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-#include "filtertype.h"
-
-#include "filter.h"
-
-namespace VcProjectManager {
-namespace Internal {
-
-FilterType::~FilterType()
-{
- m_filters.clear();
- m_files.clear();
-}
-
-void FilterType::processNode(const QDomNode &node)
-{
- if (node.isNull())
- return;
-
- if (node.nodeType() == QDomNode::ElementNode)
- processNodeAttributes(node.toElement());
-
- if (node.hasChildNodes()) {
- QDomNode firstChild = node.firstChild();
- if (!firstChild.isNull()) {
- if (firstChild.nodeName() == QLatin1String("Filter"))
- processFilter(firstChild);
- else if (firstChild.nodeName() == QLatin1String("File"))
- processFile(firstChild);
- }
- }
-}
-
-QDomNode FilterType::toXMLDomNode(QDomDocument &domXMLDocument) const
-{
- QDomElement fileNode = domXMLDocument.createElement(QLatin1String("Filter"));
- fileNode.setAttribute(QLatin1String("Name"), m_name);
- QHashIterator<QString, QString> it(m_anyAttribute);
-
- while (it.hasNext()) {
- it.next();
- fileNode.setAttribute(it.key(), it.value());
- }
-
- foreach (const File::Ptr &file, m_files)
- fileNode.appendChild(file->toXMLDomNode(domXMLDocument));
-
- foreach (const Filter::Ptr &filter, m_filters)
- fileNode.appendChild(filter->toXMLDomNode(domXMLDocument));
-
- return fileNode;
-}
-
-QString FilterType::name() const
-{
- return m_name;
-}
-
-void FilterType::setName(const QString &name)
-{
- m_name = name;
-}
-
-void FilterType::addFilter(QSharedPointer<VcProjectManager::Internal::Filter> filter)
-{
- if (m_filters.contains(filter))
- return;
-
- foreach (const Filter::Ptr &filt, m_filters) {
- if (filt->name() == filter->name())
- return;
- }
-
- m_filters.append(filter);
-}
-
-void FilterType::removeFilter(QSharedPointer<VcProjectManager::Internal::Filter> filter)
-{
- m_filters.removeAll(filter);
-}
-
-void FilterType::removeFilter(const QString &filterName)
-{
- foreach (const Filter::Ptr &filter, m_filters) {
- if (filter->name() == filterName) {
- removeFilter(filter);
- return;
- }
- }
-}
-
-QList<QSharedPointer<VcProjectManager::Internal::Filter> > FilterType::filters() const
-{
- return m_filters;
-}
-
-void FilterType::addFile(File::Ptr file)
-{
- if (m_files.contains(file))
- return;
-
- foreach (const File::Ptr &f, m_files) {
- if (f->relativePath() == file->relativePath())
- return;
- }
-
- m_files.append(file);
-}
-
-void FilterType::removeFile(File::Ptr file)
-{
- m_files.removeAll(file);
-}
-
-void FilterType::removeFile(const QString &relativeFilePath)
-{
- foreach (const File::Ptr &file, m_files) {
- if (file->relativePath() == relativeFilePath) {
- removeFile(file);
- return;
- }
- }
-}
-
-File::Ptr FilterType::file(const QString &relativePath) const
-{
- foreach (const File::Ptr &file, m_files) {
- if (file->relativePath() == relativePath)
- return file;
- }
- return File::Ptr();
-}
-
-QList<File::Ptr> FilterType::files() const
-{
- return m_files;
-}
-
-QString FilterType::attributeValue(const QString &attributeName) const
-{
- return m_anyAttribute.value(attributeName);
-}
-
-void FilterType::setAttribute(const QString &attributeName, const QString &attributeValue)
-{
- m_anyAttribute.insert(attributeName, attributeValue);
-}
-
-void FilterType::clearAttribute(const QString &attributeName)
-{
- if (m_anyAttribute.contains(attributeName))
- m_anyAttribute.insert(attributeName, QString());
-}
-
-void FilterType::removeAttribute(const QString &attributeName)
-{
- m_anyAttribute.remove(attributeName);
-}
-
-FilterType::Ptr FilterType::clone() const
-{
- return FilterType::Ptr(new FilterType(*this));
-}
-
-FilterType::FilterType(VcProjectDocument *parentProjectDoc)
- : m_parentProjectDoc(parentProjectDoc)
-{
-}
-
-FilterType::FilterType(const FilterType &filterType)
-{
- m_parentProjectDoc = filterType.m_parentProjectDoc;
- m_anyAttribute = filterType.m_anyAttribute;
- m_name = filterType.m_name;
-
- foreach (const File::Ptr &file, filterType.m_files)
- m_files.append(File::Ptr(new File(*file)));
-
- foreach (const Filter::Ptr &filter, filterType.m_filters)
- m_filters.append(Filter::Ptr(new Filter(*filter)));
-}
-
-FilterType &FilterType::operator =(const FilterType &filterType)
-{
- if (this != &filterType) {
- m_name = filterType.m_name;
- m_parentProjectDoc = filterType.m_parentProjectDoc;
- m_anyAttribute = filterType.m_anyAttribute;
- m_files.clear();
- m_filters.clear();
-
- foreach (const File::Ptr &file, filterType.m_files)
- m_files.append(File::Ptr(new File(*file)));
-
- foreach (const Filter::Ptr &file, filterType.m_filters)
- m_filters.append(Filter::Ptr(new Filter(*file)));
- }
- return *this;
-}
-
-void FilterType::processNodeAttributes(const QDomElement &element)
-{
- QDomNamedNodeMap namedNodeMap = element.attributes();
-
- for (int i = 0; i < namedNodeMap.size(); ++i) {
- QDomNode domNode = namedNodeMap.item(i);
-
- if (domNode.nodeType() == QDomNode::AttributeNode) {
- QDomAttr domElement = domNode.toAttr();
-
- if (domElement.name() == QLatin1String("Name"))
- m_name = domElement.value();
-
- else
- m_anyAttribute.insert(domElement.name(), domElement.value());
- }
- }
-}
-
-void FilterType::processFile(const QDomNode &fileNode)
-{
- File::Ptr file(new File(m_parentProjectDoc));
- file->processNode(fileNode);
- addFile(file);
-
- // process next sibling
- QDomNode nextSibling = fileNode.nextSibling();
- if (!nextSibling.isNull()) {
- if (nextSibling.nodeName() == QLatin1String("File"))
- processFile(nextSibling);
- else
- processFilter(nextSibling);
- }
-}
-
-void FilterType::processFilter(const QDomNode &filterNode)
-{
- Filter::Ptr filter(new Filter(m_parentProjectDoc));
- filter->processNode(filterNode);
- addFilter(filter);
-
- // process next sibling
- QDomNode nextSibling = filterNode.nextSibling();
- if (!nextSibling.isNull()) {
- if (nextSibling.nodeName() == QLatin1String("File"))
- processFile(nextSibling);
- else
- processFilter(nextSibling);
- }
-}
-
-} // namespace Internal
-} // namespace VcProjectManager
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/filtertype.h b/src/plugins/vcprojectmanager/vcprojectmodel/filtertype.h
deleted file mode 100644
index 8aa5d26431..0000000000
--- a/src/plugins/vcprojectmanager/vcprojectmodel/filtertype.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/**************************************************************************
-**
-** Copyright (c) 2013 Bojan Petrovic
-** Copyright (c) 2013 Radovan Zivkvoic
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-#ifndef VCPROJECTMANAGER_INTERNAL_FILTERTYPE_H
-#define VCPROJECTMANAGER_INTERNAL_FILTERTYPE_H
-
-#include "file.h"
-
-namespace VcProjectManager {
-namespace Internal {
-
-class Filter;
-
-class FilterType
-{
- friend class Filter;
-
-public:
- typedef QSharedPointer<FilterType> Ptr;
-
- ~FilterType();
- void processNode(const QDomNode &node);
- QDomNode toXMLDomNode(QDomDocument &domXMLDocument) const;
-
- QString name() const;
- void setName(const QString &name);
-
- void addFilter(QSharedPointer<Filter> filter);
- void removeFilter(QSharedPointer<Filter> filter);
- void removeFilter(const QString &filterName);
- QList<QSharedPointer<Filter> > filters() const;
-
- void addFile(File::Ptr file);
- void removeFile(File::Ptr file);
- void removeFile(const QString &relativeFilePath);
- File::Ptr file(const QString &relativePath) const;
- QList<File::Ptr> files() const;
-
- QString attributeValue(const QString &attributeName) const;
- void setAttribute(const QString &attributeName, const QString &attributeValue);
- void clearAttribute(const QString &attributeName);
- void removeAttribute(const QString &attributeName);
-
- FilterType::Ptr clone() const;
-
-private:
- FilterType(VcProjectDocument *parentProjectDoc);
- FilterType(const FilterType &filterType);
- FilterType& operator=(const FilterType &filterType);
- void processNodeAttributes(const QDomElement &element);
- void processFile(const QDomNode &fileNode);
- void processFilter(const QDomNode &filterNode);
-
- QString m_name;
- QHash<QString, QString> m_anyAttribute;
- QList<QSharedPointer<Filter> > m_filters;
- QList<File::Ptr> m_files;
- VcProjectDocument *m_parentProjectDoc;
-};
-
-} // namespace Internal
-} // namespace VcProjectManager
-
-#endif // VCPROJECTMANAGER_INTERNAL_FILTERTYPE_H
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri
index aa4fd77149..cdb84fa171 100644
--- a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri
+++ b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri
@@ -16,7 +16,6 @@ HEADERS += \
vcprojectmodel/global.h \
vcprojectmodel/foldertype.h \
vcprojectmodel/folder.h \
- vcprojectmodel/filtertype.h \
vcprojectmodel/filter.h \
vcprojectmodel/files_private.h \
vcprojectmodel/files.h \
@@ -70,7 +69,6 @@ SOURCES += \
vcprojectmodel/global.cpp \
vcprojectmodel/foldertype.cpp \
vcprojectmodel/folder.cpp \
- vcprojectmodel/filtertype.cpp \
vcprojectmodel/filter.cpp \
vcprojectmodel/files_private.cpp \
vcprojectmodel/files.cpp \