mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
New element panel: User can now drop an item from custom or common collection, inside an item of embedded collection of a project
(drag an item from an embedded collection to another embedded collection don't work yet) git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4352 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -266,7 +266,7 @@ bool ElementLocation::isProject() const
|
||||
*/
|
||||
bool ElementLocation::exist() const
|
||||
{
|
||||
if (isProject())
|
||||
if (m_project)
|
||||
return m_project->embeddedElementCollection()->exist(collectionPath(false));
|
||||
else
|
||||
{
|
||||
@@ -282,6 +282,56 @@ bool ElementLocation::exist() const
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementLocation::projectCollection
|
||||
* @return If this location represente a item in an embedded project collection, return this collection
|
||||
* else return nullptr.
|
||||
*/
|
||||
XmlElementCollection *ElementLocation::projectCollection() const
|
||||
{
|
||||
if (m_project)
|
||||
return m_project->embeddedElementCollection();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementLocation::nameList
|
||||
* @return the namelist of the represented element or directory.
|
||||
* If namelist can't be set, return a empty namelist
|
||||
*/
|
||||
NamesList ElementLocation::nameList()
|
||||
{
|
||||
NamesList nl;
|
||||
|
||||
if (isElement())
|
||||
nl.fromXml(xml());
|
||||
|
||||
if (isDirectory())
|
||||
{
|
||||
if (m_project)
|
||||
nl.fromXml(m_project->embeddedElementCollection()->directory(collectionPath(false)));
|
||||
else
|
||||
{
|
||||
//Open the qet_directory file, to get the traductions name of this dir
|
||||
QFile dir_conf(fileSystemPath() + "/qet_directory");
|
||||
if (dir_conf.exists() && dir_conf.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
//Get the content of the file
|
||||
QDomDocument document;
|
||||
if (document.setContent(&dir_conf))
|
||||
{
|
||||
QDomElement root = document.documentElement();
|
||||
if (root.tagName() == "qet-directory")
|
||||
nl.fromXml(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementLocation::collectionPath
|
||||
* Return the path of the represented element relative to collection
|
||||
@@ -301,6 +351,19 @@ QString ElementLocation::collectionPath(bool protocol) const
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementLocation::projectCollectionPath
|
||||
* @return The path is in form : project0+embed://dir/subdir/myElement.elmt
|
||||
* If this item represent a file system thing, return a null QString;
|
||||
*/
|
||||
QString ElementLocation::projectCollectionPath() const
|
||||
{
|
||||
if (isFileSystem())
|
||||
return QString();
|
||||
else
|
||||
return QString("project" + QString::number(QETApp::projectId(m_project)) + "+" + collectionPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementLocation::fileSystemPath
|
||||
* @return The file system path of this element, (the separator is always '/' see QDir::toNativeSeparators())
|
||||
|
||||
Reference in New Issue
Block a user