60 m_collection_path(other.m_collection_path),
61 m_file_system_path(other.m_file_system_path),
62 m_project(other.m_project)
74 if (data->hasFormat(
"application/x-qet-element-uri") || data->hasFormat(
"application/x-qet-category-uri"))
121 QRegExp regexp(
"^.*([^/]+)\\.elmt$");
123 return(regexp.capturedTexts().at(1));
153 return path.remove(QRegularExpression(
"common://|custom://|embed://"));
200 QString tmp_path =
path;
203 tmp_path = QDir::fromNativeSeparators(
path);
212 if (!
path.startsWith(
"embed://"))
218 else if (tmp_path.startsWith(
"project"))
220 QRegExp rx(
"^project([0-9]+)\\+(embed:\\/\\/.*)$", Qt::CaseInsensitive);
221 if (rx.exactMatch(tmp_path))
224 uint project_id = rx.capturedTexts().at(1).toUInt(&conv_ok);
238 else if (
path.startsWith(
"common://") ||
path.startsWith(
"custom://"))
241 if (
path.startsWith(
"common://"))
243 tmp_path.remove(
"common://");
248 tmp_path.remove(
"custom://");
258 QString path_ =
path;
259 if(path_.endsWith(
".elmt"))
265 path_.prepend(
"common://");
271 path_.prepend(
"custom://");
281 path_.prepend(
"common://");
287 path_.prepend(
"custom://");
304 qDebug() <<
"ElementsLocation::addToPath : Can't add string to the path of an element";
308 QString added_path = string;
311 added_path.prepend(
"/");
326 QRegExp re1(
"^([a-z]+://)(.*)/*$");
328 QString path_proto = re1.capturedTexts().at(1);
329 QString path_path = re1.capturedTexts().at(2);
330 QString parent_path = path_path.remove(QRegExp(
"/*[^/]+$"));
331 copy.
setPath(path_proto + parent_path);
366 if (project_id != -1) {
367 result +=
"project" + QString().setNum(project_id) +
"+";
508 if (dir_conf.exists() && dir_conf.open(QIODevice::ReadOnly | QIODevice::Text))
511 QDomDocument document;
512 if (document.setContent(&dir_conf))
514 QDomElement root = document.documentElement();
515 if (root.tagName() ==
"qet-directory")
536 if (docu.setContent(&file))
537 return docu.documentElement();
545 return element.firstChildElement(
"definition");
554 return QDomElement();
570 if (xml_document.documentElement().tagName() !=
"definition")
572 qDebug() <<
"ElementsLocation::setXml : tag name of document element isn't 'definition'";
581 if (!error.isEmpty()) {
582 qDebug() <<
"ElementsLocation::setXml error : " << error;
594 QDomElement dom_element =
xml();
595 QDomNode parent_node = dom_element.parentNode();
596 parent_node.removeChild(dom_element);
597 parent_node.appendChild(xml_document.documentElement().cloneNode(
true));
604 QRegExp rx (
"^(.*)/(.*\\.elmt)$");
606 if (rx.exactMatch(path_)) {
610 qDebug() <<
"ElementsLocation::setXml : rx don't match";
629 if (!list_.isEmpty())
630 return QUuid(list_.first().attribute(
"uuid"));
647 return QIcon(cache->
pixmap());
680 if (qsl.isEmpty())
return QString();
681 else return qsl.last();
696 QDomElement dom = this->
xml().firstChildElement(
"elementInformations");
697 context.
fromXml(dom,
"elementInformation");
711 QDebugStateSaver saver(debug);
713 #if QT_VERSION >= 0x050400 720 msg +=
"ElementsLocation(";
722 msg += location.
exist()?
", true" :
", false";
QString m_collection_path
QString projectCollectionPath() const
ElementsLocation::projectCollectionPath.
int projectId() const
ElementsLocation::projectId This method is used to know if an element belongs to a project or not...
QString baseName() const
ElementsLocation::baseName.
bool isProject() const
ElementsLocation::isProject.
NamesList nameList()
ElementsLocation::nameList.
void setProject(QETProject *)
static ElementPictureFactory * instance()
instance
bool isFileSystem() const
ElementsLocation::isFileSystem.
QString fileName() const
ElementLocation::fileName.
static ElementsCollectionCache * collectionCache()
static int projectId(const QETProject *)
static QETProject * project(const uint &)
QDomElement element(const QString &path) const
XmlElementCollection::element.
QIcon icon() const
ElementLocation::icon.
static int MetaTypeId
Id of the corresponding Qt meta type.
QDebug operator<<(QDebug debug, const ElementsLocation &location)
ElementsLocation & operator=(const ElementsLocation &)
bool addToPath(const QString &)
ElementsLocation::addToPath Add a string to the actual path of this location.
XmlElementCollection * embeddedElementCollection() const
QETProject::embeddedCollection.
DiagramContext elementInformations() const
ElementsLocation::elementInformations.
QString m_file_system_path
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...
bool exist(const QString &path) const
XmlElementCollection::exist Return true if the path exist in this collection.
void fromXml(const QDomElement &, const QString &="property")
QUuid uuid() const
ElementsLocation::uuid.
XmlElementCollection * projectCollection() const
ElementsLocation::projectCollection.
bool setXml(const QDomDocument &xml_document) const
ElementsLocation::setXml Replace the current xml description by ; The document element of must have ...
void setPath(const QString &path)
ElementsLocation::setPath Set the path of this item. The path can be relative to a collection (start ...
bool operator!=(const ElementsLocation &) const
bool operator==(const ElementsLocation &) const
QDomElement directory(const QString &path) const
XmlElementCollection::directory.
QETProject * project() const
QString collectionPath(bool protocol=true) const
QList< QDomElement > findInDomElement(const QDomElement &, const QString &)
QDomElement xml() const
ElementsLocation::xml.
QString name() const
ElementLocation::name.
ElementsLocation()
ElementsLocation::ElementsLocation Constructor.
bool exist() const
ElementsLocation::exist.
uint qHash(const ElementsLocation &location)
QString fileSystemPath() const
ElementsLocation::fileSystemPath.
bool isDirectory() const
ElementsLocation::isDirectory.
bool fetchElement(ElementsLocation &location)
ElementsCollectionCache::fetchElement Retrieve the data for a given element, using the cache if avail...
bool addElementDefinition(const QString &dir_path, const QString &elmt_name, const QDomElement &xml_definition)
XmlElementCollection::addElementDefinition Add the élément defintion in the directory at path with ...
static QString customElementsDirN()
QETApp::customElementsDirN like QString QETApp::customElementsDir but without "/" at the end...
virtual ~ElementsLocation()
bool isElement() const
ElementsLocation::isElement.
bool isCommonCollection() const
ElementsLocation::isCommonCollection.
bool isCustomCollection() const
ElementsLocation::isCustomCollection.
static QString commonElementsDirN()
QETApp::commonElementsDirN like QString QETApp::commonElementsDir but without "/" at the end...
QString path() const
ElementsLocation::path.
bool isWritable() const
ElementsLocation::isWritable.
ElementsLocation parent() const
The XmlElementCollection class This class represent a collection of elements stored to xml...