diff options
author | Radovan Zivkovic <pivonroll@gmail.com> | 2013-10-14 00:47:36 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-03-11 19:55:01 +0100 |
commit | 689e126bbb81a070734769077143ad29cb8f6f53 (patch) | |
tree | 6faedaa65bc648df4648a32077f98fd12c1b8de7 | |
parent | 5aa4b5353b994b572354115572e9a71de64d35a5 (diff) |
Added FileContainer.
Change-Id: Ia85e311a077267d8e34e60841ca2159057c248b4
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
-rw-r--r-- | src/plugins/vcprojectmanager/interfaces/ifilecontainer.h | 4 | ||||
-rw-r--r-- | src/plugins/vcprojectmanager/vcprojectmodel/filecontainer.cpp (renamed from src/plugins/vcprojectmanager/vcprojectmodel/folder.cpp) | 162 | ||||
-rw-r--r-- | src/plugins/vcprojectmanager/vcprojectmodel/filecontainer.h (renamed from src/plugins/vcprojectmanager/vcprojectmodel/folder.h) | 40 | ||||
-rw-r--r-- | src/plugins/vcprojectmanager/vcprojectmodel/files.cpp | 6 | ||||
-rw-r--r-- | src/plugins/vcprojectmanager/vcprojectmodel/files.h | 3 | ||||
-rw-r--r-- | src/plugins/vcprojectmanager/vcprojectmodel/filter.cpp | 301 | ||||
-rw-r--r-- | src/plugins/vcprojectmanager/vcprojectmodel/filter.h | 90 | ||||
-rw-r--r-- | src/plugins/vcprojectmanager/vcprojectmodel/vcdocprojectnodes.cpp | 25 | ||||
-rw-r--r-- | src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri | 10 |
9 files changed, 103 insertions, 538 deletions
diff --git a/src/plugins/vcprojectmanager/interfaces/ifilecontainer.h b/src/plugins/vcprojectmanager/interfaces/ifilecontainer.h index a2b1946939..0f33186a53 100644 --- a/src/plugins/vcprojectmanager/interfaces/ifilecontainer.h +++ b/src/plugins/vcprojectmanager/interfaces/ifilecontainer.h @@ -56,8 +56,8 @@ public: virtual void removeFileContainer(IFileContainer *fileContainer) = 0; virtual IAttributeContainer *attributeContainer() const = 0; - virtual QString name() const = 0; - virtual void setName(const QString &name) = 0; + virtual QString displayName() const = 0; + virtual void setDisplayName(const QString &displayName) = 0; virtual void allFiles(QStringList &sl) const = 0; virtual bool fileExists(const QString &relativeFilePath) const = 0; diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/folder.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/filecontainer.cpp index a5b9cc85d3..bda9444af8 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/folder.cpp +++ b/src/plugins/vcprojectmanager/vcprojectmodel/filecontainer.cpp @@ -1,35 +1,7 @@ -/************************************************************************** -** -** Copyright (c) 2013 Bojan Petrovic -** Copyright (c) 2013 Radovan Zivkovic -** 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 "folder.h" +#include "filecontainer.h" #include <QFileInfo> +#include <utils/qtcassert.h> #include "vcprojectdocument.h" #include "generalattributecontainer.h" @@ -38,58 +10,62 @@ namespace VcProjectManager { namespace Internal { -Folder::Folder(IVisualStudioProject *parentProjectDoc) - : m_parentProjectDoc(parentProjectDoc) +FileContainer::FileContainer(const QString &containerType, IVisualStudioProject *parentProjectDoc) + : m_parentProjectDoc(parentProjectDoc), + m_containerType(containerType) { m_attributeContainer = new GeneralAttributeContainer; } -Folder::Folder(const Folder &folder) +FileContainer::FileContainer(const FileContainer &fileContainer) { - m_parentProjectDoc = folder.m_parentProjectDoc; - m_name = folder.m_name; + m_parentProjectDoc = fileContainer.m_parentProjectDoc; + m_name = fileContainer.m_name; m_attributeContainer = new GeneralAttributeContainer; - *m_attributeContainer = *(folder.m_attributeContainer); + *m_attributeContainer = *(fileContainer.m_attributeContainer); - foreach (IFile *file, folder.m_files) + foreach (IFile *file, fileContainer.m_files) m_files.append(file->clone()); - foreach (IFileContainer *filter, folder.m_fileContainers) + foreach (IFileContainer *filter, fileContainer.m_fileContainers) m_fileContainers.append(filter->clone()); } -Folder &Folder::operator =(const Folder &folder) +FileContainer &FileContainer::operator=(const FileContainer &fileContainer) { - if (this != &folder) { - m_parentProjectDoc = folder.m_parentProjectDoc; - m_name = folder.m_name; - *m_attributeContainer = *(folder.m_attributeContainer); + if (this != &fileContainer) { + m_parentProjectDoc = fileContainer.m_parentProjectDoc; + m_name = fileContainer.m_name; + *m_attributeContainer = *(fileContainer.m_attributeContainer); qDeleteAll(m_files); qDeleteAll(m_fileContainers); m_files.clear(); m_fileContainers.clear(); - foreach (IFile *file, folder.m_files) + foreach (IFile *file, fileContainer.m_files) m_files.append(file->clone()); - foreach (IFileContainer *filter, folder.m_fileContainers) + foreach (IFileContainer *filter, fileContainer.m_fileContainers) m_fileContainers.append(filter->clone()); } return *this; } -Folder::~Folder() +FileContainer::~FileContainer() { + qDeleteAll(m_files); + qDeleteAll(m_fileContainers); + delete m_attributeContainer; } -QString Folder::containerType() const +QString FileContainer::containerType() const { - return QLatin1String(Constants::VC_PROJECT_FILE_CONTAINER_FOLDER); + return m_containerType; } -void Folder::processNode(const QDomNode &node) +void FileContainer::processNode(const QDomNode &node) { if (node.isNull()) return; @@ -110,14 +86,14 @@ void Folder::processNode(const QDomNode &node) } } -VcNodeWidget *Folder::createSettingsWidget() +VcNodeWidget *FileContainer::createSettingsWidget() { return 0; } -QDomNode Folder::toXMLDomNode(QDomDocument &domXMLDocument) const +QDomNode FileContainer::toXMLDomNode(QDomDocument &domXMLDocument) const { - QDomElement fileNode = domXMLDocument.createElement(QLatin1String("Folder")); + QDomElement fileNode = domXMLDocument.createElement(m_containerType); fileNode.setAttribute(QLatin1String("Name"), m_name); @@ -132,7 +108,7 @@ QDomNode Folder::toXMLDomNode(QDomDocument &domXMLDocument) const return fileNode; } -void Folder::addFile(IFile *file) +void FileContainer::addFile(IFile *file) { if (m_files.contains(file)) return; @@ -144,43 +120,24 @@ void Folder::addFile(IFile *file) m_files.append(file); } -void Folder::removeFile(IFile *file) +void FileContainer::removeFile(IFile *file) { m_files.removeAll(file); + delete file; } -void Folder::removeFile(const QString &relativeFilePath) +IFile *FileContainer::file(int index) const { - foreach (IFile *file, m_files) { - if (file->relativePath() == relativeFilePath) { - removeFile(file); - return; - } - } -} - -IFile *Folder::file(const QString &relativeFilePath) const -{ - foreach (IFile *file, m_files) { - if (file->relativePath() == relativeFilePath) - return file; - } - return 0; + QTC_ASSERT(0 <= index && index < m_files.size(), return 0); + return m_files[index]; } -IFile *Folder::file(int index) const -{ - if (0 <= index && index < m_files.size()) - return m_files[index]; - return 0; -} - -int Folder::fileCount() const +int FileContainer::fileCount() const { return m_files.size(); } -void Folder::addFileContainer(IFileContainer *fileContainer) +void FileContainer::addFileContainer(IFileContainer *fileContainer) { if (!fileContainer && m_fileContainers.contains(fileContainer)) return; @@ -188,29 +145,28 @@ void Folder::addFileContainer(IFileContainer *fileContainer) m_fileContainers.append(fileContainer); } -int Folder::childCount() const +int FileContainer::childCount() const { return m_fileContainers.size(); } -IFileContainer *Folder::fileContainer(int index) const +IFileContainer *FileContainer::fileContainer(int index) const { - if (0 <= index && index < m_fileContainers.size()) - return m_fileContainers[index]; - return 0; + QTC_ASSERT(0 <= index && index < m_fileContainers.size(), return 0); + return m_fileContainers[index]; } -void Folder::removeFileContainer(IFileContainer *fileContainer) +void FileContainer::removeFileContainer(IFileContainer *fileContainer) { m_fileContainers.removeAll(fileContainer); } -IAttributeContainer *Folder::attributeContainer() const +IAttributeContainer *FileContainer::attributeContainer() const { return m_attributeContainer; } -bool Folder::fileExists(const QString &relativeFilePath) const +bool FileContainer::fileExists(const QString &relativeFilePath) const { foreach (IFile *filePtr, m_files) { if (filePtr->relativePath() == relativeFilePath) @@ -225,17 +181,22 @@ bool Folder::fileExists(const QString &relativeFilePath) const return false; } -QString Folder::name() const +IFileContainer *FileContainer::clone() const +{ + return new FileContainer(*this); +} + +QString FileContainer::displayName() const { return m_name; } -void Folder::setName(const QString &name) +void FileContainer::setDisplayName(const QString &name) { m_name = name; } -void Folder::allFiles(QStringList &sl) const +void FileContainer::allFiles(QStringList &sl) const { foreach (IFileContainer *filter, m_fileContainers) filter->allFiles(sl); @@ -244,12 +205,7 @@ void Folder::allFiles(QStringList &sl) const sl.append(file->canonicalPath()); } -IFileContainer *Folder::clone() const -{ - return new Folder(*this); -} - -void Folder::processFile(const QDomNode &fileNode) +void FileContainer::processFile(const QDomNode &fileNode) { IFile *file = new File(m_parentProjectDoc); file->processNode(fileNode); @@ -267,9 +223,10 @@ void Folder::processFile(const QDomNode &fileNode) } } -void Folder::processFilter(const QDomNode &filterNode) +void FileContainer::processFilter(const QDomNode &filterNode) { - IFileContainer *filter = new Filter(m_parentProjectDoc); + IFileContainer *filter = new FileContainer(QLatin1String(Constants::VC_PROJECT_FILE_CONTAINER_FILTER), + m_parentProjectDoc); filter->processNode(filterNode); m_fileContainers.append(filter); @@ -285,9 +242,10 @@ void Folder::processFilter(const QDomNode &filterNode) } } -void Folder::processFolder(const QDomNode &folderNode) +void FileContainer::processFolder(const QDomNode &folderNode) { - IFileContainer *folder = new Folder(m_parentProjectDoc); + IFileContainer *folder = new FileContainer(QLatin1String(Constants::VC_PROJECT_FILE_CONTAINER_FOLDER), + m_parentProjectDoc); folder->processNode(folderNode); m_fileContainers.append(folder); @@ -303,7 +261,7 @@ void Folder::processFolder(const QDomNode &folderNode) } } -void Folder::processNodeAttributes(const QDomElement &element) +void FileContainer::processNodeAttributes(const QDomElement &element) { QDomNamedNodeMap namedNodeMap = element.attributes(); @@ -314,7 +272,7 @@ void Folder::processNodeAttributes(const QDomElement &element) QDomAttr domElement = domNode.toAttr(); if (domElement.name() == QLatin1String("Name")) - setName(domElement.value()); + setDisplayName(domElement.value()); else m_attributeContainer->setAttribute(domElement.name(), domElement.value()); diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/folder.h b/src/plugins/vcprojectmanager/vcprojectmodel/filecontainer.h index 0132229774..3e3d4af0ea 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/folder.h +++ b/src/plugins/vcprojectmanager/vcprojectmodel/filecontainer.h @@ -27,9 +27,10 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ -#ifndef VCPROJECTMANAGER_INTERNAL_FOLDER_H -#define VCPROJECTMANAGER_INTERNAL_FOLDER_H +#ifndef VCPROJECTMANAGER_INTERNAL_FILECONTAINER_H +#define VCPROJECTMANAGER_INTERNAL_FILECONTAINER_H +#include "../interfaces/ivcprojectnodemodel.h" #include "file.h" #include "filter.h" #include "../interfaces/ifilecontainer.h" @@ -37,38 +38,34 @@ namespace VcProjectManager { namespace Internal { -class Folder : public IFileContainer +class FileContainer : public IFileContainer { public: - Folder(IVisualStudioProject *parentProjectDoc); - Folder(const Folder &folder); - Folder& operator=(const Folder &folder); - ~Folder(); + FileContainer(const QString &containerType, IVisualStudioProject *parentProjectDoc); + FileContainer(const FileContainer &fileContainer); + FileContainer& operator=(const FileContainer &folder); + ~FileContainer(); QString containerType() const; - void processNode(const QDomNode &node); - VcNodeWidget* createSettingsWidget(); - QDomNode toXMLDomNode(QDomDocument &domXMLDocument) const; - void addFile(IFile *file); - void removeFile(IFile *file); - void removeFile(const QString &relativeFilePath); - IFile* file(const QString &relativeFilePath) const; IFile *file(int index) const; int fileCount() const; + void removeFile(IFile *file); void addFileContainer(IFileContainer *fileContainer); int childCount() const; - IFileContainer* fileContainer(int index) const; + IFileContainer *fileContainer(int index) const; void removeFileContainer(IFileContainer *fileContainer); IAttributeContainer *attributeContainer() const; + QString displayName() const; + void setDisplayName(const QString &displayName); + void allFiles(QStringList &sl) const; bool fileExists(const QString &relativeFilePath) const; + IFileContainer *clone() const; - QString name() const; - void setName(const QString &name); - - void allFiles(QStringList &sl) const; - IFileContainer* clone() const; + void processNode(const QDomNode &node); + VcNodeWidget *createSettingsWidget(); + QDomNode toXMLDomNode(QDomDocument &domXMLDocument) const; private: void processFile(const QDomNode &fileNode); @@ -82,9 +79,10 @@ private: QString m_name; // required IVisualStudioProject *m_parentProjectDoc; GeneralAttributeContainer *m_attributeContainer; + QString m_containerType; }; } // namespace Internal } // namespace VcProjectManager -#endif // VCPROJECTMANAGER_INTERNAL_FOLDER_H +#endif // VCPROJECTMANAGER_INTERNAL_FILECONTAINER_H diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/files.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/files.cpp index 2b5cd24c55..9fa01d010f 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/files.cpp +++ b/src/plugins/vcprojectmanager/vcprojectmodel/files.cpp @@ -182,7 +182,7 @@ void Files::addFileContainer(IFileContainer *fileContainer) foreach (IFileContainer *fileCont, m_fileContainers) { if (fileCont && fileCont->containerType() == fileContainer->containerType() && - fileCont->name() == fileContainer->name()) + fileCont->displayName() == fileContainer->displayName()) return; } @@ -226,7 +226,7 @@ void Files::processFile(const QDomNode &fileNode) void Files::processFilter(const QDomNode &filterNode) { - IFileContainer *filter = new Filter(m_parentProject); + IFileContainer *filter = new FileContainer(QLatin1String("Filter"), m_parentProject); filter->processNode(filterNode); m_fileContainers.append(filter); @@ -244,7 +244,7 @@ void Files::processFilter(const QDomNode &filterNode) void Files::processFolder(const QDomNode &folderNode) { - IFileContainer *folder = new Folder(m_parentProject); + IFileContainer *folder = new FileContainer(QLatin1String("Folder"), m_parentProject); folder->processNode(folderNode); m_fileContainers.append(folder); diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/files.h b/src/plugins/vcprojectmanager/vcprojectmodel/files.h index cc91317a8b..ac33450f97 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/files.h +++ b/src/plugins/vcprojectmanager/vcprojectmodel/files.h @@ -34,8 +34,7 @@ #include "../interfaces/ifiles.h" #include "file.h" -#include "filter.h" -#include "folder.h" +#include "filecontainer.h" namespace VcProjectManager { namespace Internal { diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/filter.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/filter.cpp deleted file mode 100644 index ade20ff47d..0000000000 --- a/src/plugins/vcprojectmanager/vcprojectmodel/filter.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/************************************************************************** -** -** Copyright (c) 2013 Bojan Petrovic -** Copyright (c) 2013 Radovan Zivkovic -** 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 "filter.h" - -#include <QFileInfo> - -#include "vcprojectdocument.h" -#include "generalattributecontainer.h" -#include "../vcprojectmanagerconstants.h" - -namespace VcProjectManager { -namespace Internal { - -Filter::Filter(IVisualStudioProject *parentProjectDoc) - : m_parentProjectDoc(parentProjectDoc) -{ - m_attributeContainer = new GeneralAttributeContainer; -} - -Filter::Filter(const Filter &filter) -{ - m_parentProjectDoc = filter.m_parentProjectDoc; - m_name = filter.m_name; - m_attributeContainer = new GeneralAttributeContainer; - *(m_attributeContainer) = *(filter.m_attributeContainer); - - foreach (IFile *file, filter.m_files) - m_files.append(file->clone()); - - foreach (IFileContainer *filt, filter.m_fileContainers) - m_fileContainers.append(filt->clone()); -} - -Filter &Filter::operator =(const Filter &filter) -{ - if (this != &filter) { - m_name = filter.m_name; - m_parentProjectDoc = filter.m_parentProjectDoc; - *(m_attributeContainer) = *(filter.m_attributeContainer); - - m_files.clear(); - m_fileContainers.clear(); - - foreach (IFile *file, filter.m_files) - m_files.append(file->clone()); - - foreach (IFileContainer *filt, filter.m_fileContainers) - m_fileContainers.append(filt->clone()); - } - return *this; -} - -Filter::~Filter() -{ - delete m_attributeContainer; -} - -QString Filter::containerType() const -{ - return QLatin1String(Constants::VC_PROJECT_FILE_CONTAINER_FILTER); -} - -void Filter::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); - } - } -} - -VcNodeWidget *Filter::createSettingsWidget() -{ - return 0; -} - -QDomNode Filter::toXMLDomNode(QDomDocument &domXMLDocument) const -{ - QDomElement fileNode = domXMLDocument.createElement(QLatin1String("Filter")); - fileNode.setAttribute(QLatin1String("Name"), m_name); - - m_attributeContainer->appendToXMLNode(fileNode); - - foreach (IFile *file, m_files) - fileNode.appendChild(file->toXMLDomNode(domXMLDocument)); - - foreach (IFileContainer *filter, m_fileContainers) - fileNode.appendChild(filter->toXMLDomNode(domXMLDocument)); - - return fileNode; -} - -QString Filter::name() const -{ - return m_name; -} - -void Filter::setName(const QString &name) -{ - m_name = name; -} - -void Filter::addFile(IFile *file) -{ - if (m_files.contains(file)) - return; - - foreach (IFile *f, m_files) { - if (f->relativePath() == file->relativePath()) - return; - } - - m_files.append(file); -} - -void Filter::removeFile(IFile *file) -{ - m_files.removeAll(file); -} - -void Filter::removeFile(const QString &relativeFilePath) -{ - foreach (IFile *file, m_files) { - if (file->relativePath() == relativeFilePath) { - removeFile(file); - delete file; - return; - } - } -} - -IFile* Filter::file(const QString &relativePath) const -{ - foreach (IFile *file, m_files) { - if (file->relativePath() == relativePath) - return file; - } - return 0; -} - -IFile *Filter::file(int index) const -{ - if (0 <= index && index < m_files.size()) - return m_files[index]; - return 0; -} - -int Filter::fileCount() const -{ - return m_files.size(); -} - -void Filter::addFileContainer(IFileContainer *fileContainer) -{ - if (!fileContainer && m_fileContainers.contains(fileContainer)) - return; - - m_fileContainers.append(fileContainer); -} - -int Filter::childCount() const -{ - return m_fileContainers.size(); -} - -IFileContainer *Filter::fileContainer(int index) const -{ - if (0 <= index && index < m_fileContainers.size()) - return m_fileContainers[index]; - return 0; -} - -void Filter::removeFileContainer(IFileContainer *fileContainer) -{ - m_fileContainers.removeAll(fileContainer); -} - -IAttributeContainer *Filter::attributeContainer() const -{ - return m_attributeContainer; -} - -bool Filter::fileExists(const QString &relativeFilePath) const -{ - foreach (IFile *filePtr, m_files) { - if (filePtr->relativePath() == relativeFilePath) - return true; - } - - foreach (IFileContainer *filterPtr, m_fileContainers) { - if (filterPtr->fileExists(relativeFilePath)) - return true; - } - - return false; -} - -void Filter::allFiles(QStringList &sl) const -{ - foreach (IFileContainer *filter, m_fileContainers) - filter->allFiles(sl); - - foreach (IFile *file, m_files) - sl.append(file->canonicalPath()); -} - -IFileContainer *Filter::clone() const -{ - return new Filter(*this); -} - -void Filter::processFile(const QDomNode &fileNode) -{ - IFile *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) -{ - IFileContainer *filter = new Filter(m_parentProjectDoc); - filter->processNode(filterNode); - addFileContainer(filter); - - // process next sibling - QDomNode nextSibling = filterNode.nextSibling(); - if (!nextSibling.isNull()) { - if (nextSibling.nodeName() == QLatin1String("File")) - processFile(nextSibling); - else - processFilter(nextSibling); - } -} - -void Filter::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_attributeContainer->setAttribute(domElement.name(), domElement.value()); - } - } -} - -} // namespace Internal -} // namespace VcProjectManager diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/filter.h b/src/plugins/vcprojectmanager/vcprojectmodel/filter.h deleted file mode 100644 index 8b796dc6e5..0000000000 --- a/src/plugins/vcprojectmanager/vcprojectmodel/filter.h +++ /dev/null @@ -1,90 +0,0 @@ -/************************************************************************** -** -** Copyright (c) 2013 Bojan Petrovic -** Copyright (c) 2013 Radovan Zivkovic -** 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_FILTER_H -#define VCPROJECTMANAGER_INTERNAL_FILTER_H - -#include "../interfaces/ivcprojectnodemodel.h" -#include "file.h" -#include "../interfaces/ifilecontainer.h" - -namespace VcProjectManager { -namespace Internal { - -class Filter; - -class Filter : public IFileContainer -{ -public: - Filter(IVisualStudioProject *parentProjectDoc); - Filter(const Filter &filter); - Filter& operator=(const Filter &filter); - ~Filter(); - - QString containerType() const; - - void processNode(const QDomNode &node); - VcNodeWidget* createSettingsWidget(); - QDomNode toXMLDomNode(QDomDocument &domXMLDocument) const; - - QString name() const; - void setName(const QString &name); - - void addFile(IFile *file); - void removeFile(IFile *file); - void removeFile(const QString &relativeFilePath); - IFile *file(const QString &relativePath) const; - IFile *file(int index) const; - int fileCount() const; - void addFileContainer(IFileContainer *fileContainer); - int childCount() const; - IFileContainer *fileContainer(int index) const; - void removeFileContainer(IFileContainer *fileContainer); - IAttributeContainer *attributeContainer() const; - - bool fileExists(const QString &relativeFilePath) const; - void allFiles(QStringList &sl) const; - IFileContainer* clone() const; - -private: - void processFile(const QDomNode &fileNode); - void processFilter(const QDomNode &filterNode); - void processNodeAttributes(const QDomElement &element); - - QString m_name; - QList<IFileContainer *> m_fileContainers; - QList<IFile *> m_files; - IVisualStudioProject *m_parentProjectDoc; - GeneralAttributeContainer *m_attributeContainer; -}; - -} // namespace Internal -} // namespace VcProjectManager - -#endif // VCPROJECTMANAGER_INTERNAL_FILTER_H diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/vcdocprojectnodes.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/vcdocprojectnodes.cpp index 1ca463655d..38df7385b1 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/vcdocprojectnodes.cpp +++ b/src/plugins/vcprojectmanager/vcprojectmodel/vcdocprojectnodes.cpp @@ -30,10 +30,9 @@ #include "vcdocprojectnodes.h" #include "vcprojectdocument.h" -#include "folder.h" -#include "filter.h" #include "file.h" #include "files.h" +#include "filecontainer.h" #include "../vcprojectmanagerconstants.h" #include <QFileInfo> @@ -60,7 +59,7 @@ void VcFileNode::readChildren(VcDocProjectNode *vcDocProj) } VcFileContainerNode::VcFileContainerNode(IFileContainer *fileContainerModel, VcDocProjectNode *vcDocProjNode) - : ProjectExplorer::FolderNode(fileContainerModel->name()), + : ProjectExplorer::FolderNode(fileContainerModel->displayName()), m_vcFileContainerModel(fileContainerModel), m_parentVcDocProjNode(vcDocProjNode) { @@ -124,12 +123,14 @@ void VcFileContainerNode::addFileContainerNode(const QString &name, VcContainerT IFileContainer *fileContainerModel = 0; if (type == VcContainerType_Filter) - fileContainerModel = new Filter(m_parentVcDocProjNode->m_vcProjectModel); + fileContainerModel = new FileContainer(QLatin1String(Constants::VC_PROJECT_FILE_CONTAINER_FILTER), + m_parentVcDocProjNode->m_vcProjectModel); else if (type == VcContainerType_Folder) - fileContainerModel = new Folder(m_parentVcDocProjNode->m_vcProjectModel); + fileContainerModel = new FileContainer(QLatin1String(Constants::VC_PROJECT_FILE_CONTAINER_FOLDER), + m_parentVcDocProjNode->m_vcProjectModel); if (fileContainerModel) { - fileContainerModel->setName(name); + fileContainerModel->setDisplayName(name); VcFileContainerNode *folderNode = new VcFileContainerNode(fileContainerModel, m_parentVcDocProjNode); if (!appendFileContainerNode(folderNode)) { @@ -152,7 +153,7 @@ bool VcFileContainerNode::appendFileContainerNode(VcFileContainerNode *fileConta if (vcFileContainerNode && vcFileContainerNode->m_vcFileContainerModel && - vcFileContainerNode->m_vcFileContainerModel->name() == fileContainer->m_vcFileContainerModel->name()) + vcFileContainerNode->m_vcFileContainerModel->displayName() == fileContainer->m_vcFileContainerModel->displayName()) return false; } } @@ -452,11 +453,13 @@ void VcDocProjectNode::addFileContainerNode(const QString &name, VcFileContainer IFileContainer *fileContainer = 0; if (type == VcFileContainerNode::VcContainerType_Filter) - fileContainer = new Filter(m_vcProjectModel); + fileContainer = new FileContainer(QLatin1String(Constants::VC_PROJECT_FILE_CONTAINER_FILTER), + m_vcProjectModel); else - fileContainer = new Folder(m_vcProjectModel); + fileContainer = new FileContainer(QLatin1String(Constants::VC_PROJECT_FILE_CONTAINER_FOLDER), + m_vcProjectModel); - fileContainer->setName(name); + fileContainer->setDisplayName(name); VcFileContainerNode *folderNode = new VcFileContainerNode(fileContainer, this); if (!appendFileContainerNode(folderNode)) { @@ -479,7 +482,7 @@ bool VcDocProjectNode::appendFileContainerNode(VcFileContainerNode *fileContaine if (vcFileContainerNode && vcFileContainerNode->m_vcFileContainerModel && fileContainerNode->m_vcFileContainerModel && - vcFileContainerNode->m_vcFileContainerModel->name() == fileContainerNode->m_vcFileContainerModel->name()) + vcFileContainerNode->m_vcFileContainerModel->displayName() == fileContainerNode->m_vcFileContainerModel->displayName()) return false; } } diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri index 255ac4cf31..671656985c 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri +++ b/src/plugins/vcprojectmanager/vcprojectmodel/vcprojectmodel.pri @@ -11,8 +11,6 @@ HEADERS += \ vcprojectmodel/platform.h \ vcprojectmodel/globals.h \ vcprojectmodel/global.h \ - vcprojectmodel/folder.h \ - vcprojectmodel/filter.h \ vcprojectmodel/files.h \ vcprojectmodel/file.h \ vcprojectmodel/deploymenttool.h \ @@ -45,7 +43,8 @@ HEADERS += \ vcprojectmodel/configurationbuildtools.h \ vcprojectmodel/deploymenttools.h \ vcprojectmodel/tools.h \ - vcprojectmodel/debuggertools.h + vcprojectmodel/debuggertools.h \ + vcprojectmodel/filecontainer.h SOURCES += \ vcprojectmodel/vcprojectdocument.cpp \ @@ -59,8 +58,6 @@ SOURCES += \ vcprojectmodel/platform.cpp \ vcprojectmodel/globals.cpp \ vcprojectmodel/global.cpp \ - vcprojectmodel/folder.cpp \ - vcprojectmodel/filter.cpp \ vcprojectmodel/files.cpp \ vcprojectmodel/file.cpp \ vcprojectmodel/deploymenttool.cpp \ @@ -91,7 +88,8 @@ SOURCES += \ vcprojectmodel/configurationbuildtools.cpp \ vcprojectmodel/deploymenttools.cpp \ vcprojectmodel/tools.cpp \ - vcprojectmodel/debuggertools.cpp + vcprojectmodel/debuggertools.cpp \ + vcprojectmodel/filecontainer.cpp OTHER_FILES += \ vcprojectmodel/tools/xml_definitions/VCXMLDataGeneratorTool.xml \ |