File: elementslocation.h

package info (click to toggle)
qelectrotech 1%3A0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 91,680 kB
  • sloc: cpp: 62,335; xml: 750; sh: 264; perl: 258; makefile: 6
file content (96 lines) | stat: -rw-r--r-- 2,798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
	Copyright 2006-2019 The QElectroTech Team
	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

#include "nameslist.h"
#include "diagramcontext.h"
#include <QString>
#include <QIcon>

class QETProject;
class XmlElementCollection;

/**
	Cette classe represente la localisation, l'emplacement d'un element ou
	d'une categorie, voire d'une collection... dans une collection. Elle
	encapsule un chemin virtuel.
*/
class ElementsLocation
{
	public:
		ElementsLocation();
		ElementsLocation(const QString &path, QETProject *project = nullptr);
		ElementsLocation(const ElementsLocation &);
		ElementsLocation(const QMimeData *data);
		virtual ~ElementsLocation();
		ElementsLocation &operator=(const ElementsLocation &);
		bool operator==(const ElementsLocation &) const;
		bool operator!=(const ElementsLocation &) const;
	
	public:
		QString baseName() const;
		int projectId() const;

		QString collectionPath(bool protocol = true) const;
		QString projectCollectionPath() const;
		QString fileSystemPath() const;
		QString path() const;
		void setPath(const QString &path);
		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;
		bool isCommonCollection() const;
		bool isCustomCollection() const;
		bool isProject() const;
		bool exist() const;
		bool isWritable() const;

		XmlElementCollection *projectCollection() const;
		NamesList nameList();

		QDomElement xml() const;
		bool setXml(const QDomDocument &xml_document) const;
		QUuid uuid() const;
		QIcon icon() const;
		QString name() const;
		QString fileName() const;
		DiagramContext elementInformations() const;
	
	private:
		QString m_collection_path;
		QString m_file_system_path;
		QETProject *m_project = nullptr;
	
	public:
		static int MetaTypeId; ///< Id of the corresponding Qt meta type
};

QDebug operator<<(QDebug debug, const ElementsLocation &location);

Q_DECLARE_METATYPE(ElementsLocation)
uint qHash(const ElementsLocation &);
#endif