2009-04-03 19:30:25 +00:00
|
|
|
/*
|
2014-01-29 18:37:45 +00:00
|
|
|
Copyright 2006-2014 The QElectroTech Team
|
2009-04-03 19:30:25 +00:00
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
#ifndef ELEMENT_DEFINITION_H
|
|
|
|
#define ELEMENT_DEFINITION_H
|
|
|
|
#include <QtXml>
|
|
|
|
#include "elementscategory.h"
|
|
|
|
class ElementsCollection;
|
|
|
|
class MoveElementsHandler;
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This abstract class represents a way to access the XML definition of an
|
|
|
|
element, be it from a .elmt file or from a QET project file.
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
class ElementDefinition : public ElementsCollectionItem {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
Constructor
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
ElementDefinition(ElementsCategory *category = 0, ElementsCollection *collection = 0) : ElementsCollectionItem(category), parent_category_(category), parent_collection_(collection) {};
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
Destructor
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
virtual ~ElementDefinition() {};
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return the XML definition of a particular element
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
virtual QDomElement xml() = 0;
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
Specify the XML definition of a particular element
|
|
|
|
@param xml_element New XML definition
|
|
|
|
@return true if everything went well, false otherwise
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
2009-11-22 16:12:22 +00:00
|
|
|
virtual bool setXml(const QDomElement &xml_element) = 0;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return true if the definition is not available
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
virtual bool isNull() const = 0;
|
|
|
|
|
|
|
|
virtual ElementsCategory *parentCategory();
|
|
|
|
virtual QList<ElementsCategory *> parentCategories();
|
|
|
|
virtual bool hasParentCategory();
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return whether the element is attached to an elements collection
|
|
|
|
An elemet which belongs to a collection always has a virtual path.
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
virtual bool hasParentCollection();
|
|
|
|
virtual bool isChildOf(ElementsCollectionItem *);
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return the elements collections this element belongs to
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
virtual ElementsCollection *parentCollection();
|
|
|
|
|
|
|
|
virtual QETProject *project();
|
|
|
|
virtual void setProject(QETProject *);
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return the "protocol" used by the parent collection
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
virtual QString protocol();
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
Has no effect.
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
virtual void setProtocol(const QString &);
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return the full virtual path for this element (i.e. "protocol" + path)
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
virtual QString fullVirtualPath();
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return the location of this element, as an ElementsLocation object.
|
|
|
|
@see ElementsLocation
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
virtual ElementsLocation location();
|
|
|
|
|
|
|
|
virtual QList<ElementsCategory *> categories();
|
|
|
|
virtual ElementsCategory *category(const QString &);
|
|
|
|
virtual ElementsCategory *createCategory(const QString &);
|
|
|
|
|
|
|
|
virtual QList<ElementDefinition *> elements();
|
|
|
|
virtual ElementDefinition *element(const QString &);
|
|
|
|
virtual ElementDefinition *createElement(const QString &);
|
2011-03-15 18:32:52 +00:00
|
|
|
virtual bool isEmpty();
|
|
|
|
virtual int count();
|
2009-04-03 19:30:25 +00:00
|
|
|
virtual ElementsCollectionItem *copy(ElementsCategory *, MoveElementsHandler *, bool = true);
|
|
|
|
virtual ElementsCollectionItem *move(ElementsCategory *, MoveElementsHandler *);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
virtual bool isCollection() const { return(false); } ///< @return always false
|
|
|
|
virtual bool isRootCategory() const { return(false); } ///< @return always false
|
|
|
|
virtual bool isCategory() const { return(false); } ///< @return always false
|
|
|
|
virtual bool isElement() const { return(true ); } ///< @return always true
|
2009-04-03 19:30:25 +00:00
|
|
|
virtual ElementsCollection *toCollection();
|
|
|
|
virtual ElementsCategory *toCategory();
|
|
|
|
virtual ElementsCategory *toPureCategory();
|
|
|
|
virtual ElementDefinition *toElement();
|
|
|
|
virtual bool equals(ElementDefinition &);
|
|
|
|
virtual bool removeContent();
|
2011-09-13 21:46:10 +00:00
|
|
|
virtual QDateTime modificationTime() const = 0;
|
2009-04-03 19:30:25 +00:00
|
|
|
void copy(MoveElementsDescription *);
|
|
|
|
void move(MoveElementsDescription *);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2009-04-03 19:30:25 +00:00
|
|
|
private:
|
|
|
|
ElementsCategory *parent_category_;
|
|
|
|
ElementsCollection *parent_collection_;
|
|
|
|
};
|
|
|
|
#endif
|