mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Rapatriement de la branche 0.2 dans le trunk
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@558 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
135
sources/xmlelementscollection.cpp
Normal file
135
sources/xmlelementscollection.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "xmlelementscollection.h"
|
||||
#include "xmlelementscategory.h"
|
||||
#include "qetproject.h"
|
||||
|
||||
/**
|
||||
Construit une collection vide
|
||||
@param parent Item parent
|
||||
*/
|
||||
XmlElementsCollection::XmlElementsCollection(ElementsCollectionItem *parent) :
|
||||
ElementsCollection(parent)
|
||||
{
|
||||
protocol_ = "unknown";
|
||||
project_ = 0;
|
||||
// cree une categorie racine vide
|
||||
root = new XmlElementsCategory(0, this);
|
||||
connect(root, SIGNAL(written()), this, SLOT(componentWritten()));
|
||||
}
|
||||
|
||||
/**
|
||||
Construit une collection a partir d'un element XML suppose la decrire
|
||||
@param xml_element Element XML decrivant la collection
|
||||
@param parent Item parent
|
||||
*/
|
||||
XmlElementsCollection::XmlElementsCollection(const QDomElement &xml_element, ElementsCollectionItem *parent) :
|
||||
ElementsCollection(parent)
|
||||
{
|
||||
protocol_ = "unknown";
|
||||
project_ = 0;
|
||||
// cree sa categorie racine a partir de l'element XML
|
||||
root = new XmlElementsCategory(xml_element, 0, this);
|
||||
connect(root, SIGNAL(written()), this, SLOT(componentWritten()));
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
XmlElementsCollection::~XmlElementsCollection() {
|
||||
deleteContent();
|
||||
}
|
||||
|
||||
ElementsCategory *XmlElementsCollection::rootCategory() {
|
||||
return(root);
|
||||
}
|
||||
|
||||
/**
|
||||
@return toujours false ; une collection XML n'est representee nul part sur
|
||||
le systeme de fichiers.
|
||||
*/
|
||||
bool XmlElementsCollection::hasFilePath() {
|
||||
return(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@return le chemin du repertoire representant cette collection
|
||||
*/
|
||||
QString XmlElementsCollection::filePath() {
|
||||
return(QString());
|
||||
}
|
||||
|
||||
/**
|
||||
Ne fait rien - une collection XML n'est representee nul part sur le systeme
|
||||
de fichiers.
|
||||
*/
|
||||
void XmlElementsCollection::setFilePath(const QString &) {
|
||||
}
|
||||
|
||||
void XmlElementsCollection::reload() {
|
||||
if (root) root -> reload();
|
||||
}
|
||||
|
||||
/**
|
||||
@return toujours true
|
||||
*/
|
||||
bool XmlElementsCollection::exists() {
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si la collection est accessible en lecture
|
||||
*/
|
||||
bool XmlElementsCollection::isReadable() {
|
||||
// une collection XML n'a aucune raison de ne pas etre accessible en lecture
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool XmlElementsCollection::isWritable() {
|
||||
// une collection XML peut etre en lecture seule si le projet auquel elle
|
||||
// appartient l'est
|
||||
if (QETProject *parent_project = project()) {
|
||||
return(!parent_project -> isReadOnly());
|
||||
} else {
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool XmlElementsCollection::write() {
|
||||
emit(written());
|
||||
return(true);
|
||||
}
|
||||
|
||||
QDomElement XmlElementsCollection::writeXml(QDomDocument &xml_doc) const {
|
||||
QDomElement collection_elmt = root -> writeXml(xml_doc);
|
||||
collection_elmt.setTagName("collection");
|
||||
xml_doc.appendChild(collection_elmt);
|
||||
return(collection_elmt);
|
||||
}
|
||||
|
||||
void XmlElementsCollection::componentWritten() {
|
||||
write();
|
||||
}
|
||||
|
||||
/**
|
||||
Supprime le contenu en memoire de cette collection
|
||||
*/
|
||||
void XmlElementsCollection::deleteContent() {
|
||||
delete root;
|
||||
root = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user