2020-01-09 10:26:10 +01:00
|
|
|
|
/*
|
2021-02-06 18:33:42 +01:00
|
|
|
|
Copyright 2006-2021 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 ELEMENTS_LOCATION_H
|
|
|
|
|
#define ELEMENTS_LOCATION_H
|
2016-03-15 15:23:11 +00:00
|
|
|
|
|
2020-12-08 19:57:35 +01:00
|
|
|
|
#include "../NameList/nameslist.h"
|
|
|
|
|
#include "../diagramcontext.h"
|
|
|
|
|
#include "../pugixml/pugixml.hpp"
|
|
|
|
|
|
2016-03-15 15:23:11 +00:00
|
|
|
|
#include <QIcon>
|
2020-12-08 19:57:35 +01:00
|
|
|
|
#include <QString>
|
2016-03-15 15:23:11 +00:00
|
|
|
|
|
2020-01-09 10:26:10 +01:00
|
|
|
|
#ifndef Q_OS_LINUX
|
|
|
|
|
#include "sstream"
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
class QETProject;
|
2016-03-15 15:23:11 +00:00
|
|
|
|
class XmlElementCollection;
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
|
@brief The ElementsLocation class
|
2020-08-24 20:48:24 +02:00
|
|
|
|
This class represents the location,
|
|
|
|
|
the location of an element or of a category,
|
|
|
|
|
even of a collection ... in a collection.
|
|
|
|
|
She encapsulates a virtual path.
|
|
|
|
|
\~French
|
2009-04-03 19:30:25 +00:00
|
|
|
|
Cette classe represente la localisation, l'emplacement d'un element ou
|
2020-08-24 20:48:24 +02:00
|
|
|
|
d'une categorie, voire d'une collection... dans une collection.
|
|
|
|
|
Elle encapsule un chemin virtuel.
|
2009-04-03 19:30:25 +00:00
|
|
|
|
*/
|
2016-03-15 15:23:11 +00:00
|
|
|
|
class ElementsLocation
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
public:
|
2016-03-15 15:23:11 +00:00
|
|
|
|
ElementsLocation();
|
2020-08-12 21:53:02 +02:00
|
|
|
|
ElementsLocation(const QString &path,
|
|
|
|
|
QETProject *project = nullptr);
|
2016-03-15 15:23:11 +00:00
|
|
|
|
ElementsLocation(const ElementsLocation &);
|
|
|
|
|
ElementsLocation(const QMimeData *data);
|
|
|
|
|
virtual ~ElementsLocation();
|
|
|
|
|
ElementsLocation &operator=(const ElementsLocation &);
|
|
|
|
|
bool operator==(const ElementsLocation &) const;
|
|
|
|
|
bool operator!=(const ElementsLocation &) const;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2016-03-15 15:23:11 +00:00
|
|
|
|
QString baseName() const;
|
|
|
|
|
|
|
|
|
|
QString collectionPath(bool protocol = true) const;
|
|
|
|
|
QString projectCollectionPath() const;
|
|
|
|
|
QString fileSystemPath() const;
|
|
|
|
|
QString path() const;
|
2016-03-19 14:18:00 +00:00
|
|
|
|
void setPath(const QString &path);
|
2016-03-15 15:23:11 +00:00
|
|
|
|
bool addToPath(const QString &);
|
|
|
|
|
|
|
|
|
|
ElementsLocation parent() const;
|
|
|
|
|
QETProject *project() const;
|
|
|
|
|
void setProject(QETProject *);
|
|
|
|
|
bool isNull() const;
|
|
|
|
|
QString toString() const;
|
|
|
|
|
|
|
|
|
|
bool isElement() const;
|
|
|
|
|
bool isDirectory() const;
|
|
|
|
|
bool isFileSystem() const;
|
2016-05-15 14:46:01 +00:00
|
|
|
|
bool isCommonCollection() const;
|
|
|
|
|
bool isCustomCollection() const;
|
2016-03-15 15:23:11 +00:00
|
|
|
|
bool isProject() const;
|
|
|
|
|
bool exist() const;
|
2016-03-31 17:28:44 +00:00
|
|
|
|
bool isWritable() const;
|
2016-03-15 15:23:11 +00:00
|
|
|
|
|
|
|
|
|
XmlElementCollection *projectCollection() const;
|
|
|
|
|
NamesList nameList();
|
|
|
|
|
|
2016-03-29 17:23:58 +00:00
|
|
|
|
QDomElement xml() const;
|
2020-01-04 11:30:43 +01:00
|
|
|
|
pugi::xml_document pugiXml() const;
|
2016-03-31 17:28:44 +00:00
|
|
|
|
bool setXml(const QDomDocument &xml_document) const;
|
2016-03-29 17:23:58 +00:00
|
|
|
|
QUuid uuid() const;
|
|
|
|
|
QIcon icon() const;
|
|
|
|
|
QString name() const;
|
2016-03-15 15:23:11 +00:00
|
|
|
|
QString fileName() const;
|
2019-01-04 22:06:34 +00:00
|
|
|
|
DiagramContext elementInformations() const;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2016-03-15 15:23:11 +00:00
|
|
|
|
QString m_collection_path;
|
|
|
|
|
QString m_file_system_path;
|
|
|
|
|
QETProject *m_project = nullptr;
|
2020-01-09 10:26:10 +01:00
|
|
|
|
#ifndef Q_OS_LINUX
|
|
|
|
|
mutable std::stringstream m_string_stream;
|
|
|
|
|
#endif
|
2012-02-05 19:24:42 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2016-03-15 15:23:11 +00:00
|
|
|
|
static int MetaTypeId; ///< Id of the corresponding Qt meta type
|
2009-04-03 19:30:25 +00:00
|
|
|
|
};
|
2016-05-05 13:31:04 +00:00
|
|
|
|
|
|
|
|
|
QDebug operator<<(QDebug debug, const ElementsLocation &location);
|
|
|
|
|
|
2012-02-05 19:24:42 +00:00
|
|
|
|
Q_DECLARE_METATYPE(ElementsLocation)
|
2020-01-09 10:26:10 +01:00
|
|
|
|
//uint qHash(const ElementsLocation &);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
#endif
|