QElectroTech  0.8-dev
elementslocation.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef ELEMENTS_LOCATION_H
19 #define ELEMENTS_LOCATION_H
20 
21 #include "nameslist.h"
22 #include "diagramcontext.h"
23 #include "pugixml.hpp"
24 #include <QString>
25 #include <QIcon>
26 
27 #ifndef Q_OS_LINUX
28 #include "sstream"
29 #endif
30 
31 class QETProject;
33 
46 {
47  public:
49  ElementsLocation(const QString &path,
50  QETProject *project = nullptr);
52  ElementsLocation(const QMimeData *data);
53  virtual ~ElementsLocation();
55  bool operator==(const ElementsLocation &) const;
56  bool operator!=(const ElementsLocation &) const;
57 
58  public:
59  QString baseName() const;
60 
61  QString collectionPath(bool protocol = true) const;
62  QString projectCollectionPath() const;
63  QString fileSystemPath() const;
64  QString path() const;
65  void setPath(const QString &path);
66  bool addToPath(const QString &);
67 
68  ElementsLocation parent() const;
69  QETProject *project() const;
70  void setProject(QETProject *);
71  bool isNull() const;
72  QString toString() const;
73 
74  bool isElement() const;
75  bool isDirectory() const;
76  bool isFileSystem() const;
77  bool isCommonCollection() const;
78  bool isCustomCollection() const;
79  bool isProject() const;
80  bool exist() const;
81  bool isWritable() const;
82 
85 
86  QDomElement xml() const;
87  pugi::xml_document pugiXml() const;
88  bool setXml(const QDomDocument &xml_document) const;
89  QUuid uuid() const;
90  QIcon icon() const;
91  QString name() const;
92  QString fileName() const;
94 
95  private:
98  QETProject *m_project = nullptr;
99 #ifndef Q_OS_LINUX
100  mutable std::stringstream m_string_stream;
101 #endif
102 
103  public:
104  static int MetaTypeId;
105 };
106 
107 QDebug operator<<(QDebug debug, const ElementsLocation &location);
108 
110 //uint qHash(const ElementsLocation &);
111 #endif
ElementsLocation::MetaTypeId
static int MetaTypeId
Id of the corresponding Qt meta type.
Definition: elementslocation.h:104
ElementsLocation::exist
bool exist() const
ElementsLocation::exist.
Definition: elementslocation.cpp:472
ElementsCollectionCache::fetchElement
bool fetchElement(ElementsLocation &location)
ElementsCollectionCache::fetchElement Retrieve the data for a given element, using the cache if avail...
Definition: elementscollectioncache.cpp:161
QETApp::collectionCache
static ElementsCollectionCache * collectionCache()
QETApp::collectionCache.
Definition: qetapp.cpp:358
QETProject::embeddedElementCollection
XmlElementCollection * embeddedElementCollection() const
QETProject::embeddedCollection.
Definition: qetproject.cpp:236
ElementsLocation::setXml
bool setXml(const QDomDocument &xml_document) const
ElementsLocation::setXml Replace the current xml description by xml_document; The document element of...
Definition: elementslocation.cpp:667
DiagramContext::fromXml
void fromXml(const QDomElement &, const QString &="property")
Definition: diagramcontext.cpp:157
nameslist.h
QETProject::isReadOnly
bool isReadOnly() const
QETProject::isReadOnly.
Definition: qetproject.cpp:924
elementscollectioncache.h
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(NamesList)
elementpicturefactory.h
QET::Icons::nl
QIcon nl
Definition: qeticons.cpp:203
ElementsLocation::path
QString path() const
ElementsLocation::path.
Definition: elementslocation.cpp:206
ElementsLocation::fileName
QString fileName() const
ElementLocation::fileName.
Definition: elementslocation.cpp:793
ElementsLocation::ElementsLocation
ElementsLocation()
ElementsLocation::ElementsLocation Constructor.
Definition: elementslocation.cpp:36
ElementsLocation::m_collection_path
QString m_collection_path
Definition: elementslocation.h:96
ElementsCollectionCache
Definition: elementscollectioncache.h:31
ElementsLocation::isWritable
bool isWritable() const
ElementsLocation::isWritable.
Definition: elementslocation.cpp:499
XmlElementCollection
The XmlElementCollection class This class represent a collection of elements stored to xml.
Definition: xmlelementcollection.h:34
xmlelementcollection.h
ElementsLocation::uuid
QUuid uuid() const
ElementsLocation::uuid.
Definition: elementslocation.cpp:737
XmlElementCollection::exist
bool exist(const QString &path) const
XmlElementCollection::exist Return true if the path path exist in this collection.
Definition: xmlelementcollection.cpp:569
ElementsLocation::isFileSystem
bool isFileSystem() const
ElementsLocation::isFileSystem.
Definition: elementslocation.cpp:428
ElementsLocation::setProject
void setProject(QETProject *)
ElementsLocation::setProject.
Definition: elementslocation.cpp:377
ElementsLocation::operator!=
bool operator!=(const ElementsLocation &) const
ElementsLocation::operator != Operateur de comparaison.
Definition: elementslocation.cpp:127
QETXML::writeXmlFile
bool writeXmlFile(const QDomDocument &xml_document, const QString &file_path, QString *error_message=nullptr)
QETXML::writeXmlFile Export an XML document to an UTF-8 text file indented with 4 spaces,...
Definition: qetxml.cpp:257
XmlElementCollection::element
QDomElement element(const QString &path) const
XmlElementCollection::element.
Definition: xmlelementcollection.cpp:291
qetapp.h
ElementsLocation::isElement
bool isElement() const
ElementsLocation::isElement.
Definition: elementslocation.cpp:412
ElementsLocation::baseName
QString baseName() const
ElementsLocation::baseName.
Definition: elementslocation.cpp:142
ElementsLocation::icon
QIcon icon() const
ElementLocation::icon.
Definition: elementslocation.cpp:756
ElementsLocation::parent
ElementsLocation parent() const
ElementsLocation::parent.
Definition: elementslocation.cpp:346
ElementsLocation::~ElementsLocation
virtual ~ElementsLocation()
ElementsLocation::~ElementsLocation Destructeur.
Definition: elementslocation.cpp:56
ElementsLocation::isNull
bool isNull() const
ElementsLocation::isNull.
Definition: elementslocation.cpp:387
ElementsLocation::xml
QDomElement xml() const
ElementsLocation::xml.
Definition: elementslocation.cpp:575
ElementsLocation::addToPath
bool addToPath(const QString &)
ElementsLocation::addToPath Add a string to the actual path of this location.
Definition: elementslocation.cpp:320
elementslocation.h
ElementsLocation::isDirectory
bool isDirectory() const
ElementsLocation::isDirectory.
Definition: elementslocation.cpp:420
XmlElementCollection::addElementDefinition
bool addElementDefinition(const QString &dir_path, const QString &elmt_name, const QDomElement &xml_definition)
XmlElementCollection::addElementDefinition Add the élément defintion xml_definition in the directory ...
Definition: xmlelementcollection.cpp:477
ElementsLocation::projectCollectionPath
QString projectCollectionPath() const
ElementsLocation::projectCollectionPath.
Definition: elementslocation.cpp:176
ElementsLocation::pugiXml
pugi::xml_document pugiXml() const
ElementsLocation::pugiXml.
Definition: elementslocation.cpp:610
element.h
QETApp::projectId
static int projectId(const QETProject *)
QETApp::projectId.
Definition: qetapp.cpp:2433
ElementsLocation::fileSystemPath
QString fileSystemPath() const
ElementsLocation::fileSystemPath.
Definition: elementslocation.cpp:193
ElementsLocation::m_file_system_path
QString m_file_system_path
Definition: elementslocation.h:97
QETApp::customElementsDirN
static QString customElementsDirN()
QETApp::customElementsDirN like QString QETApp::customElementsDir but without "/" at the end.
Definition: qetapp.cpp:705
ElementsLocation::isProject
bool isProject() const
ElementsLocation::isProject.
Definition: elementslocation.cpp:459
operator<<
QDebug operator<<(QDebug debug, const ElementsLocation &location)
operator << debug for processing ElementsLocation
Definition: elementslocation.cpp:830
XmlElementCollection::directory
QDomElement directory(const QString &path) const
XmlElementCollection::directory.
Definition: xmlelementcollection.cpp:309
qetproject.h
ElementPictureFactory::instance
static ElementPictureFactory * instance()
instance
Definition: elementpicturefactory.h:55
ElementsLocation::operator=
ElementsLocation & operator=(const ElementsLocation &)
ElementsLocation::operator = Assignment operator.
Definition: elementslocation.cpp:96
ElementsLocation::collectionPath
QString collectionPath(bool protocol=true) const
ElementsLocation::collectionPath Return the path of the represented element relative to collection if...
Definition: elementslocation.cpp:160
ElementsLocation::nameList
NamesList nameList()
ElementsLocation::nameList.
Definition: elementslocation.cpp:532
ElementsLocation
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition: elementslocation.h:46
ElementsLocation::isCommonCollection
bool isCommonCollection() const
ElementsLocation::isCommonCollection.
Definition: elementslocation.cpp:440
ElementsLocation::m_string_stream
std::stringstream m_string_stream
Definition: elementslocation.h:100
QETProject
Definition: qetproject.h:51
QETApp::commonElementsDirN
static QString commonElementsDirN()
QETApp::commonElementsDirN like QString QETApp::commonElementsDir but without "/" at the end.
Definition: qetapp.cpp:693
NamesList
Definition: nameslist.h:30
ElementsLocation::m_project
QETProject * m_project
Definition: elementslocation.h:98
ElementsLocation::name
QString name() const
ElementLocation::name.
Definition: elementslocation.cpp:776
QETApp::project
static QETProject * project(const uint &)
QETApp::project.
Definition: qetapp.cpp:2416
ElementsLocation::projectCollection
XmlElementCollection * projectCollection() const
ElementsLocation::projectCollection.
Definition: elementslocation.cpp:519
ElementsCollectionCache::pixmap
QPixmap pixmap() const
Definition: elementscollectioncache.cpp:200
qetxml.h
ElementsLocation::elementInformations
DiagramContext elementInformations() const
ElementsLocation::elementInformations.
Definition: elementslocation.cpp:811
ElementsLocation::toString
QString toString() const
ElementsLocation::toString.
Definition: elementslocation.cpp:396
diagramcontext.h
operator<<
QDebug operator<<(QDebug debug, const ElementsLocation &location)
operator << debug for processing ElementsLocation
Definition: elementslocation.cpp:830
ElementsLocation::project
QETProject * project() const
ElementsLocation::project.
Definition: elementslocation.cpp:365
ElementsLocation::setPath
void setPath(const QString &path)
ElementsLocation::setPath Set the path of this item. The path can be relative to a collection (start ...
Definition: elementslocation.cpp:217
ElementsLocation::isCustomCollection
bool isCustomCollection() const
ElementsLocation::isCustomCollection.
Definition: elementslocation.cpp:450
DiagramContext
Definition: diagramcontext.h:56
ElementsLocation::operator==
bool operator==(const ElementsLocation &) const
ElementsLocation::operator ==.
Definition: elementslocation.cpp:113