diff options
Diffstat (limited to 'src/plugins/vcprojectmanager/vcprojectmodel/activexreference.cpp')
-rw-r--r-- | src/plugins/vcprojectmanager/vcprojectmodel/activexreference.cpp | 317 |
1 files changed, 45 insertions, 272 deletions
diff --git a/src/plugins/vcprojectmanager/vcprojectmodel/activexreference.cpp b/src/plugins/vcprojectmanager/vcprojectmodel/activexreference.cpp index d03af533a0..36ed79ab49 100644 --- a/src/plugins/vcprojectmanager/vcprojectmodel/activexreference.cpp +++ b/src/plugins/vcprojectmanager/vcprojectmodel/activexreference.cpp @@ -31,13 +31,38 @@ #include <QVariant> #include "configurationsfactory.h" +#include "generalattributecontainer.h" +#include "configurationcontainer.h" namespace VcProjectManager { namespace Internal { +ActiveXReference::ActiveXReference() +{ +} + +ActiveXReference::ActiveXReference(const ActiveXReference &ref) +{ + m_attributeContainer = new GeneralAttributeContainer; + m_configurations = new ConfigurationContainer; + *m_attributeContainer = *ref.m_attributeContainer; + *m_configurations = *ref.m_configurations; +} + +IReference &ActiveXReference::operator =(const IReference &ref) +{ + if (this != &ref) { + *m_attributeContainer = *ref.attributeContainer(); + *m_configurations = *ref.configurations(); + } + + return *this; +} + ActiveXReference::~ActiveXReference() { - qDeleteAll(m_referenceConfigurations); + delete m_attributeContainer; + delete m_configurations; } void ActiveXReference::processNode(const QDomNode &node) @@ -65,14 +90,16 @@ void ActiveXReference::processNodeAttributes(const QDomElement &element) if (domNode.nodeType() == QDomNode::AttributeNode) { QDomAttr domElement = domNode.toAttr(); - if (domElement.name() == QLatin1String("ControlGUID")) - m_controlGUID = domElement.value(); - - else if (domElement.name() == QLatin1String("ControlVersion")) - m_controlVersion = domElement.value(); - - else if (domElement.name() == QLatin1String("WrapperTool")) - m_wrapperTool = domElement.value(); + if (domElement.name() == QLatin1String(VcDocConstants::ACTIVEX_REFERENCE_CONTROL_GUID) || + domElement.name() == QLatin1String(VcDocConstants::ACTIVEX_REFERENCE_CONTROL_VERSION) || + domElement.name() == QLatin1String(VcDocConstants::ACTIVEX_REFERENCE_WRAPPER_TOOL) || + domElement.name() == QLatin1String(VcDocConstants::ACTIVEX_REFERENCE_LOCAL_ID) || + domElement.name() == QLatin1String(VcDocConstants::ACTIVEX_REFERENCE_USE_IN_BUILD) || + domElement.name() == QLatin1String(VcDocConstants::ACTIVEX_REFERENCE_COPY_LOCAL) || + domElement.name() == QLatin1String(VcDocConstants::ACTIVEX_REFERENCE_COPY_LOCAL_DEPENDENCIES) || + domElement.name() == QLatin1String(VcDocConstants::ACTIVEX_REFERENCE_COPY_LOCAL_SATELITE_ASSEMBLIES) || + domElement.name() == QLatin1String(VcDocConstants::ACTIVEX_REFERENCE_USE_DEPENDENCIES_IN_BUILD)) + m_attributeContainer->setAttribute(domElement.name(), domElement.value()); } } } @@ -86,122 +113,32 @@ VcNodeWidget *ActiveXReference::createSettingsWidget() QDomNode ActiveXReference::toXMLDomNode(QDomDocument &domXMLDocument) const { QDomElement activeXNode = domXMLDocument.createElement(QLatin1String("ActiveXReference")); - - activeXNode.setAttribute(QLatin1String("ControlGUID"), m_controlGUID); - activeXNode.setAttribute(QLatin1String("ControlVersion"), m_controlVersion); - activeXNode.setAttribute(QLatin1String("WrapperTool"), m_wrapperTool); - - foreach (const IConfiguration *refConfig, m_referenceConfigurations) - activeXNode.appendChild(refConfig->toXMLDomNode(domXMLDocument)); + m_attributeContainer->appendToXMLNode(activeXNode); + m_configurations->appendToXMLNode(activeXNode, domXMLDocument); return activeXNode; } -void ActiveXReference::addReferenceConfiguration(IConfiguration *refConfig) -{ - if (m_referenceConfigurations.contains(refConfig)) - return; - - // Don't add configuration with the same name - foreach (const IConfiguration *refConf, m_referenceConfigurations) { - if (refConfig->fullName() == refConf->fullName()) - return; - } - - m_referenceConfigurations.append(refConfig); -} - -void ActiveXReference::removeReferenceConfiguration(IConfiguration *refConfig) -{ - m_referenceConfigurations.removeAll(refConfig); -} - -void ActiveXReference::removeReferenceConfiguration(const QString &refConfigName) -{ - foreach (IConfiguration *refConfig, m_referenceConfigurations) { - if (refConfig->fullName() == refConfigName) { - m_referenceConfigurations.removeOne(refConfig); - delete refConfig; - return; - } - } -} - -IConfiguration* ActiveXReference::referenceConfiguration(const QString &refConfigName) const -{ - foreach (IConfiguration *refConfig, m_referenceConfigurations) { - if (refConfig->fullName() == refConfigName) - return refConfig; - } - - return 0; -} - -QString ActiveXReference::controlGUID() const +IAttributeContainer *ActiveXReference::attributeContainer() const { - return m_controlGUID; + return m_attributeContainer; } -void ActiveXReference::setControlGUID(const QString &ctrlGUID) +ConfigurationContainer *ActiveXReference::configurations() const { - m_controlGUID = ctrlGUID; + return m_configurations; } -QString ActiveXReference::controlVersion() const +QString ActiveXReference::type() const { - return m_controlVersion; -} - -void ActiveXReference::setControlVersion(const QString &ctrlVersion) -{ - m_controlVersion = ctrlVersion; -} - -QString ActiveXReference::wrapperTool() const -{ - return m_wrapperTool; -} - -void ActiveXReference::setWrapperTool(const QString &wrapperTool) -{ - m_wrapperTool = wrapperTool; -} - -ActiveXReference::ActiveXReference() -{ -} - -ActiveXReference::ActiveXReference(const ActiveXReference &ref) -{ - m_controlGUID = ref.m_controlGUID; - m_controlVersion = ref.m_controlVersion; - m_wrapperTool = ref.m_wrapperTool; - - foreach (const IConfiguration *refConf, ref.m_referenceConfigurations) - m_referenceConfigurations.append(refConf->clone()); -} - -ActiveXReference &ActiveXReference::operator =(const ActiveXReference &ref) -{ - if (this != &ref) { - m_controlGUID = ref.m_controlGUID; - m_controlVersion = ref.m_controlVersion; - m_wrapperTool = ref.m_wrapperTool; - - m_referenceConfigurations.clear(); - - foreach (const IConfiguration *refConf, ref.m_referenceConfigurations) - m_referenceConfigurations.append(refConf->clone()); - } - - return *this; + return QLatin1String(VcDocConstants::ACTIVEX_REFERENCE); } void ActiveXReference::processReferenceConfig(const QDomNode &referenceConfig) { IConfiguration *referenceConfiguration = createReferenceConfiguration(); referenceConfiguration->processNode(referenceConfig); - m_referenceConfigurations.append(referenceConfiguration); + m_configurations->addConfiguration(referenceConfiguration); // process next sibling QDomNode nextSibling = referenceConfig.nextSibling(); @@ -214,12 +151,6 @@ ActiveXReference2003::ActiveXReference2003(const ActiveXReference2003 &ref) { } -ActiveXReference2003 &ActiveXReference2003::operator =(const ActiveXReference2003 &ref) -{ - ActiveXReference::operator =(ref); - return *this; -} - ActiveXReference2003::~ActiveXReference2003() { } @@ -244,90 +175,15 @@ ActiveXReference2005::ActiveXReference2005(const ActiveXReference2005 &ref) { } -ActiveXReference2005 &ActiveXReference2005::operator =(const ActiveXReference2005 &ref) -{ - ActiveXReference2003::operator =(ref); - return *this; -} - ActiveXReference2005::~ActiveXReference2005() { } -void ActiveXReference2005::processNodeAttributes(const QDomElement &element) -{ - ActiveXReference2003::processNodeAttributes(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("LocaleID")) - m_localeID = domElement.value(); - - else if (domElement.name() == QLatin1String("CopyLocal")) - m_copyLocal = domElement.value(); - - else if (domElement.name() == QLatin1String("UseInBuild")) { - if (domElement.value() == QLatin1String("false")) - m_useInBuild = false; - else - m_useInBuild = true; - } - } - } -} - -QDomNode ActiveXReference2005::toXMLDomNode(QDomDocument &domXMLDocument) const -{ - QDomElement activeXNode = ActiveXReference2003::toXMLDomNode(domXMLDocument).toElement(); - - activeXNode.setAttribute(QLatin1String("LocaleID"), m_localeID); - activeXNode.setAttribute(QLatin1String("CopyLocal"), m_copyLocal); - activeXNode.setAttribute(QLatin1String("UseInBuild"), QVariant(m_useInBuild).toString()); - - return activeXNode; -} - ActiveXReference::Ptr ActiveXReference2005::clone() const { return ActiveXReference::Ptr(new ActiveXReference2005(*this)); } -QString ActiveXReference2005::localeID() const -{ - return m_localeID; -} - -void ActiveXReference2005::setLocaleID(const QString &localeID) -{ - m_localeID = localeID; -} - -QString ActiveXReference2005::copyLocal() const -{ - return m_copyLocal; -} - -void ActiveXReference2005::setCopyLocal(const QString ©Local) -{ - m_copyLocal = copyLocal; -} - -bool ActiveXReference2005::useInBuild() const -{ - return m_useInBuild; -} - -void ActiveXReference2005::setUseInBuild(bool useInBuild) -{ - m_useInBuild = useInBuild; -} - ActiveXReference2005::ActiveXReference2005() { } @@ -343,98 +199,15 @@ ActiveXReference2008::ActiveXReference2008(const ActiveXReference2008 &ref) { } -ActiveXReference2008 &ActiveXReference2008::operator =(const ActiveXReference2008 &ref) -{ - ActiveXReference2005::operator =(ref); - return *this; -} - ActiveXReference2008::~ActiveXReference2008() { } -void ActiveXReference2008::processNodeAttributes(const QDomElement &element) -{ - ActiveXReference2005::processNodeAttributes(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("CopyLocalDependencies")) { - if (domElement.value() == QLatin1String("false")) - m_copyLocalDependencies = false; - else - m_copyLocalDependencies = true; - } - - else if (domElement.name() == QLatin1String("CopyLocalSatelliteAssemblies")) { - if (domElement.value() == QLatin1String("false")) - m_copyLocalSatelliteAssemblies = false; - else - m_copyLocalSatelliteAssemblies = true; - } - - else if (domElement.name() == QLatin1String("UseDependenciesInBuild")) { - if (domElement.value() == QLatin1String("false")) - m_useDependenciesInBuild = false; - else - m_useDependenciesInBuild = true; - } - } - } -} - -QDomNode ActiveXReference2008::toXMLDomNode(QDomDocument &domXMLDocument) const -{ - QDomElement activeXNode = ActiveXReference2005::toXMLDomNode(domXMLDocument).toElement(); - - activeXNode.setAttribute(QLatin1String("CopyLocalDependencies"), QVariant(m_copyLocalDependencies).toString()); - activeXNode.setAttribute(QLatin1String("CopyLocalSatelliteAssemblies"), QVariant(m_copyLocalSatelliteAssemblies).toString()); - activeXNode.setAttribute(QLatin1String("UseDependenciesInBuild"), QVariant(m_useDependenciesInBuild).toString()); - - return activeXNode; -} - ActiveXReference::Ptr ActiveXReference2008::clone() const { return ActiveXReference::Ptr(new ActiveXReference2005(*this)); } -bool ActiveXReference2008::copyLocalDependencies() const -{ - return m_copyLocalDependencies; -} - -void ActiveXReference2008::setCopyLocalDependencies(bool copyLocalDependencies) -{ - m_copyLocalDependencies = copyLocalDependencies; -} - -bool ActiveXReference2008::copyLocalSatelliteAssemblies() const -{ - return m_copyLocalSatelliteAssemblies; -} - -void ActiveXReference2008::setCopyLocalSatelliteAssemblies(bool copyLocalSatelliteAssemblies) -{ - m_copyLocalSatelliteAssemblies = copyLocalSatelliteAssemblies; -} - -bool ActiveXReference2008::useDependenciesInBuild() const -{ - return m_useDependenciesInBuild; -} - -void ActiveXReference2008::setUseDependenciesInBuild(bool useDependenciesInBuild) -{ - m_useDependenciesInBuild = useDependenciesInBuild; -} - ActiveXReference2008::ActiveXReference2008() { } |