2009-04-03 19:30:25 +00:00
|
|
|
/*
|
2015-02-20 14:56:22 +00:00
|
|
|
Copyright 2006-2015 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
|
|
|
|
|
|
|
#include "nameslist.h"
|
2009-04-03 19:30:25 +00:00
|
|
|
#include <QString>
|
2016-03-15 15:23:11 +00:00
|
|
|
#include <QIcon>
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
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();
|
|
|
|
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;
|
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;
|
|
|
|
bool setPath(const QString &path);
|
|
|
|
bool addToPath(const QString &);
|
|
|
|
|
|
|
|
ElementsLocation parent() const;
|
|
|
|
QETProject *project() const;
|
|
|
|
void setProject(QETProject *);
|
|
|
|
bool isNull() const;
|
|
|
|
QString toString() const;
|
|
|
|
void fromString(const QString &);
|
|
|
|
static ElementsLocation locationFromString(const QString &);
|
|
|
|
|
|
|
|
bool isElement() const;
|
|
|
|
bool isDirectory() const;
|
|
|
|
bool isFileSystem() const;
|
|
|
|
bool isProject() const;
|
|
|
|
bool exist() const;
|
|
|
|
|
|
|
|
XmlElementCollection *projectCollection() const;
|
|
|
|
NamesList nameList();
|
|
|
|
|
|
|
|
QDomElement xml();
|
|
|
|
QUuid uuid();
|
|
|
|
QIcon icon();
|
|
|
|
QString name();
|
|
|
|
QString fileName() 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;
|
|
|
|
QDomElement m_xml;
|
|
|
|
QUuid m_uuid;
|
|
|
|
QIcon m_icon;
|
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
|
|
|
};
|
2012-02-05 19:24:42 +00:00
|
|
|
Q_DECLARE_METATYPE(ElementsLocation)
|
|
|
|
uint qHash(const ElementsLocation &);
|
2009-04-03 19:30:25 +00:00
|
|
|
#endif
|