mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
Mod doc, Improve code style
This commit is contained in:
@@ -29,16 +29,18 @@
|
|||||||
int ElementsLocation::MetaTypeId = qRegisterMetaType<ElementsLocation>("ElementsLocation");
|
int ElementsLocation::MetaTypeId = qRegisterMetaType<ElementsLocation>("ElementsLocation");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::ElementsLocation
|
@brief ElementsLocation::ElementsLocation
|
||||||
* Constructor
|
Constructor
|
||||||
*/
|
*/
|
||||||
ElementsLocation::ElementsLocation()
|
ElementsLocation::ElementsLocation()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
@brief ElementsLocation::ElementsLocation
|
||||||
@param p Chemin de l'emplacement de l'element
|
@param path :
|
||||||
@param pr Projet de l'emplacement de l'element
|
Chemin de l'emplacement de l'element
|
||||||
|
@param project :
|
||||||
|
Projet de l'emplacement de l'element
|
||||||
*/
|
*/
|
||||||
ElementsLocation::ElementsLocation(const QString &path, QETProject *project) :
|
ElementsLocation::ElementsLocation(const QString &path, QETProject *project) :
|
||||||
m_project(project)
|
m_project(project)
|
||||||
@@ -63,15 +65,17 @@ ElementsLocation::ElementsLocation(const ElementsLocation &other) :
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::ElementLocation
|
@brief ElementsLocation::ElementLocation
|
||||||
* Constructor, build an ElementLocation from a QMimeData, the mime data format
|
Constructor, build an ElementLocation from a QMimeData,
|
||||||
* must be "application/x-qet-element-uri" or "application/x-qet-category-uri".
|
the mime data format must be "application/x-qet-element-uri"
|
||||||
* This location can be null even if format is valid.
|
or "application/x-qet-category-uri".
|
||||||
* @param data
|
This location can be null even if format is valid.
|
||||||
|
@param data
|
||||||
*/
|
*/
|
||||||
ElementsLocation::ElementsLocation(const QMimeData *data)
|
ElementsLocation::ElementsLocation(const QMimeData *data)
|
||||||
{
|
{
|
||||||
if (data->hasFormat("application/x-qet-element-uri") || data->hasFormat("application/x-qet-category-uri"))
|
if (data->hasFormat("application/x-qet-element-uri")
|
||||||
|
|| data->hasFormat("application/x-qet-category-uri"))
|
||||||
setPath(data->text());
|
setPath(data->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,9 +91,11 @@ ElementsLocation &ElementsLocation::operator=(const ElementsLocation &other) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief ElementsLocation::operator ==
|
||||||
Operateur de comparaison
|
Operateur de comparaison
|
||||||
@param other Autre emplacement d'element a comparer
|
@param other Autre emplacement d'element a comparer
|
||||||
@return true si other et cet ElementsLocation sont identiques, false sinon
|
@return true si other et cet ElementsLocation sont identiques,
|
||||||
|
false sinon
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::operator==(const ElementsLocation &other) const {
|
bool ElementsLocation::operator==(const ElementsLocation &other) const {
|
||||||
return(
|
return(
|
||||||
@@ -99,9 +105,11 @@ bool ElementsLocation::operator==(const ElementsLocation &other) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief ElementsLocation::operator !=
|
||||||
Operateur de comparaison
|
Operateur de comparaison
|
||||||
@param other Autre emplacement d'element a comparer
|
@param other Autre emplacement d'element a comparer
|
||||||
@return true si other et cet ElementsLocation sont differents, false sinon
|
@return true si other et cet ElementsLocation sont differents,
|
||||||
|
false sinon
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::operator!=(const ElementsLocation &other) const {
|
bool ElementsLocation::operator!=(const ElementsLocation &other) const {
|
||||||
return(
|
return(
|
||||||
@@ -111,11 +119,12 @@ bool ElementsLocation::operator!=(const ElementsLocation &other) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::baseName
|
@brief ElementsLocation::baseName
|
||||||
* @return The base name of the element or directory.
|
@return The base name of the element or directory.
|
||||||
* Unlike ElementsLocation::fileName , this method don't return the extension name.
|
Unlike ElementsLocation::fileName,
|
||||||
* For exemple if this location represent an element they return myElement.
|
this method don't return the extension name.
|
||||||
* @see fileName()
|
For exemple if this location represent an element they return myElement.
|
||||||
|
@see fileName()
|
||||||
*/
|
*/
|
||||||
QString ElementsLocation::baseName() const {
|
QString ElementsLocation::baseName() const {
|
||||||
QRegExp regexp("^.*([^/]+)\\.elmt$");
|
QRegExp regexp("^.*([^/]+)\\.elmt$");
|
||||||
@@ -126,12 +135,14 @@ QString ElementsLocation::baseName() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::collectionPath
|
@brief ElementsLocation::collectionPath
|
||||||
* Return the path of the represented element relative to collection
|
Return the path of the represented element relative to collection
|
||||||
* if @protocol is true the path is prepended by the collection type (common://, custom:// or embed://)
|
if protocol is true the path is prepended by
|
||||||
* else if false, only the collection path is returned without the collection type.
|
the collection type (common://, custom:// or embed://)
|
||||||
* @param protocol
|
else if false,
|
||||||
* @return the path
|
only the collection path is returned without the collection type.
|
||||||
|
@param protocol
|
||||||
|
@return the path
|
||||||
*/
|
*/
|
||||||
QString ElementsLocation::collectionPath(bool protocol) const
|
QString ElementsLocation::collectionPath(bool protocol) const
|
||||||
{
|
{
|
||||||
@@ -145,22 +156,26 @@ QString ElementsLocation::collectionPath(bool protocol) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::projectCollectionPath
|
@brief ElementsLocation::projectCollectionPath
|
||||||
* @return The path is in form : project0+embed://dir/subdir/myElement.elmt
|
@return The path is in form : project0+embed://dir/subdir/myElement.elmt
|
||||||
* If this item represent a file system thing, return a null QString;
|
If this item represent a file system thing, return a null QString;
|
||||||
*/
|
*/
|
||||||
QString ElementsLocation::projectCollectionPath() const
|
QString ElementsLocation::projectCollectionPath() const
|
||||||
{
|
{
|
||||||
if (isFileSystem())
|
if (isFileSystem())
|
||||||
return QString();
|
return QString();
|
||||||
else
|
else
|
||||||
return QString("project" + QString::number(QETApp::projectId(m_project)) + "+" + collectionPath());
|
return QString("project"
|
||||||
|
+ QString::number(QETApp::projectId(m_project))
|
||||||
|
+ "+"
|
||||||
|
+ collectionPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::fileSystemPath
|
@brief ElementsLocation::fileSystemPath
|
||||||
* @return The file system path of this element, (the separator is always '/' see QDir::toNativeSeparators())
|
@return The file system path of this element,
|
||||||
* If this element is embedded in a project return an empty string;
|
(the separator is always '/' see QDir::toNativeSeparators())
|
||||||
|
If this element is embedded in a project return an empty string;
|
||||||
*/
|
*/
|
||||||
QString ElementsLocation::fileSystemPath() const
|
QString ElementsLocation::fileSystemPath() const
|
||||||
{
|
{
|
||||||
@@ -171,19 +186,20 @@ QString ElementsLocation::fileSystemPath() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::path
|
@brief ElementsLocation::path
|
||||||
* @return The path of this location.
|
@return The path of this location.
|
||||||
* OBSOLETE, use instead collectionPath(true)
|
@deprecated use instead collectionPath(true)
|
||||||
*/
|
*/
|
||||||
QString ElementsLocation::path() const {
|
QString ElementsLocation::path() const {
|
||||||
return(m_collection_path);
|
return(m_collection_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::setPath
|
@brief ElementsLocation::setPath
|
||||||
* Set the path of this item.
|
Set the path of this item.
|
||||||
* The path can be relative to a collection (start by common:// , custom:// or embed://) or not.
|
The path can be relative to a collection
|
||||||
* @param path
|
(start by common:// , custom:// or embed://) or not.
|
||||||
|
@param path
|
||||||
*/
|
*/
|
||||||
void ElementsLocation::setPath(const QString &path)
|
void ElementsLocation::setPath(const QString &path)
|
||||||
{
|
{
|
||||||
@@ -224,7 +240,8 @@ void ElementsLocation::setPath(const QString &path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//The path is in file system, the given path is relative to common or custom collection
|
// The path is in file system,
|
||||||
|
// the given path is relative to common or custom collection
|
||||||
else if (path.startsWith("common://") || path.startsWith("custom://"))
|
else if (path.startsWith("common://") || path.startsWith("custom://"))
|
||||||
{
|
{
|
||||||
QString p;
|
QString p;
|
||||||
@@ -282,10 +299,10 @@ void ElementsLocation::setPath(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::addToPath
|
@brief ElementsLocation::addToPath
|
||||||
* Add a string to the actual path of this location
|
Add a string to the actual path of this location
|
||||||
* @param string
|
@param string
|
||||||
* @return True if the operation success
|
@return True if the operation success
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::addToPath(const QString &string)
|
bool ElementsLocation::addToPath(const QString &string)
|
||||||
{
|
{
|
||||||
@@ -308,6 +325,7 @@ bool ElementsLocation::addToPath(const QString &string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief ElementsLocation::parent
|
||||||
@return the location of the parent category, or a copy of this location
|
@return the location of the parent category, or a copy of this location
|
||||||
when it represents a root category.
|
when it represents a root category.
|
||||||
*/
|
*/
|
||||||
@@ -324,6 +342,7 @@ ElementsLocation ElementsLocation::parent() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief ElementsLocation::project
|
||||||
@return le projet de cet emplacement ou 0 si celui-ci n'est pas lie a
|
@return le projet de cet emplacement ou 0 si celui-ci n'est pas lie a
|
||||||
un projet.
|
un projet.
|
||||||
*/
|
*/
|
||||||
@@ -332,7 +351,9 @@ QETProject *ElementsLocation::project() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param project le nouveau projet pointe par cet emplacement
|
@brief ElementsLocation::setProject
|
||||||
|
@param project :
|
||||||
|
le nouveau projet pointe par cet emplacement
|
||||||
Indiquer 0 pour que cet emplacement ne soit plus lie a un projet.
|
Indiquer 0 pour que cet emplacement ne soit plus lie a un projet.
|
||||||
*/
|
*/
|
||||||
void ElementsLocation::setProject(QETProject *project) {
|
void ElementsLocation::setProject(QETProject *project) {
|
||||||
@@ -340,6 +361,7 @@ void ElementsLocation::setProject(QETProject *project) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief ElementsLocation::isNull
|
||||||
@return true si l'emplacement semble utilisable (chemin virtuel non vide).
|
@return true si l'emplacement semble utilisable (chemin virtuel non vide).
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::isNull() const {
|
bool ElementsLocation::isNull() const {
|
||||||
@@ -347,6 +369,7 @@ bool ElementsLocation::isNull() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief ElementsLocation::toString
|
||||||
@return Une chaine de caracteres representant l'emplacement
|
@return Une chaine de caracteres representant l'emplacement
|
||||||
*/
|
*/
|
||||||
QString ElementsLocation::toString() const {
|
QString ElementsLocation::toString() const {
|
||||||
@@ -362,24 +385,24 @@ QString ElementsLocation::toString() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::isElement
|
@brief ElementsLocation::isElement
|
||||||
* @return true if this location represent an element
|
@return true if this location represent an element
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::isElement() const {
|
bool ElementsLocation::isElement() const {
|
||||||
return m_collection_path.endsWith(".elmt");
|
return m_collection_path.endsWith(".elmt");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::isDirectory
|
@brief ElementsLocation::isDirectory
|
||||||
* @return true if this location represent a directory
|
@return true if this location represent a directory
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::isDirectory() const {
|
bool ElementsLocation::isDirectory() const {
|
||||||
return (!isElement() && !m_collection_path.isEmpty());
|
return (!isElement() && !m_collection_path.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::isFileSystem
|
@brief ElementsLocation::isFileSystem
|
||||||
* @return
|
@return true if
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::isFileSystem() const
|
bool ElementsLocation::isFileSystem() const
|
||||||
{
|
{
|
||||||
@@ -389,8 +412,9 @@ bool ElementsLocation::isFileSystem() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::isCommonCollection
|
@brief ElementsLocation::isCommonCollection
|
||||||
* @return True if this location represent an item from the common collection
|
@return
|
||||||
|
True if this location represent an item from the common collection
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::isCommonCollection() const
|
bool ElementsLocation::isCommonCollection() const
|
||||||
{
|
{
|
||||||
@@ -398,8 +422,9 @@ bool ElementsLocation::isCommonCollection() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::isCustomCollection
|
@brief ElementsLocation::isCustomCollection
|
||||||
* @return True if this location represent an item from the custom collection
|
@return
|
||||||
|
True if this location represent an item from the custom collection
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::isCustomCollection() const
|
bool ElementsLocation::isCustomCollection() const
|
||||||
{
|
{
|
||||||
@@ -407,8 +432,8 @@ bool ElementsLocation::isCustomCollection() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::isProject
|
@brief ElementsLocation::isProject
|
||||||
* @return True if this location represent an item from a project.
|
@return True if this location represent an item from a project.
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::isProject() const
|
bool ElementsLocation::isProject() const
|
||||||
{
|
{
|
||||||
@@ -419,8 +444,9 @@ bool ElementsLocation::isProject() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::exist
|
@brief ElementsLocation::exist
|
||||||
* @return True if this location represent an existing directory or element.
|
@return
|
||||||
|
True if this location represent an existing directory or element.
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::exist() const
|
bool ElementsLocation::exist() const
|
||||||
{
|
{
|
||||||
@@ -445,8 +471,8 @@ bool ElementsLocation::exist() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::isWritable
|
@brief ElementsLocation::isWritable
|
||||||
* @return True if this element can be writable (can use set xml)
|
@return True if this element can be writable (can use set xml)
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::isWritable() const
|
bool ElementsLocation::isWritable() const
|
||||||
{
|
{
|
||||||
@@ -463,9 +489,10 @@ bool ElementsLocation::isWritable() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::projectCollection
|
@brief ElementsLocation::projectCollection
|
||||||
* @return If this location represente a item in an embedded project collection, return this collection
|
@return
|
||||||
* else return nullptr.
|
If this location represente a item in an embedded project collection,
|
||||||
|
return this collection else return nullptr.
|
||||||
*/
|
*/
|
||||||
XmlElementCollection *ElementsLocation::projectCollection() const
|
XmlElementCollection *ElementsLocation::projectCollection() const
|
||||||
{
|
{
|
||||||
@@ -476,9 +503,9 @@ XmlElementCollection *ElementsLocation::projectCollection() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::nameList
|
@brief ElementsLocation::nameList
|
||||||
* @return the namelist of the represented element or directory.
|
@return the namelist of the represented element or directory.
|
||||||
* If namelist can't be set, return a empty namelist
|
If namelist can't be set, return a empty namelist
|
||||||
*/
|
*/
|
||||||
NamesList ElementsLocation::nameList()
|
NamesList ElementsLocation::nameList()
|
||||||
{
|
{
|
||||||
@@ -514,9 +541,9 @@ NamesList ElementsLocation::nameList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::xml
|
@brief ElementsLocation::xml
|
||||||
* @return The definition of this element or directory.
|
@return The definition of this element or directory.
|
||||||
* The definition can be null.
|
The definition can be null.
|
||||||
*/
|
*/
|
||||||
QDomElement ElementsLocation::xml() const
|
QDomElement ElementsLocation::xml() const
|
||||||
{
|
{
|
||||||
@@ -546,15 +573,19 @@ QDomElement ElementsLocation::xml() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::pugiXml
|
@brief ElementsLocation::pugiXml
|
||||||
* @return the xml document of this element or directory
|
@return the xml document of this element or directory
|
||||||
* The definition can be null
|
The definition can be null
|
||||||
*/
|
*/
|
||||||
pugi::xml_document ElementsLocation::pugiXml() const
|
pugi::xml_document ElementsLocation::pugiXml() const
|
||||||
{
|
{
|
||||||
//Except for linux OS (because linux keep in cache the file), we keep in memory the xml
|
/* Except for linux OS (because linux keep in cache the file),
|
||||||
//to avoid multiple access to file.
|
* we keep in memory the xml
|
||||||
//keep in memory the XML, consumes a little more RAM, for this reason we don't use it for linux to minimize the RAM footprint.
|
* to avoid multiple access to file.
|
||||||
|
* keep in memory the XML,
|
||||||
|
* consumes a little more RAM,
|
||||||
|
* for this reason we don't use it for linux to minimize the RAM footprint.
|
||||||
|
*/
|
||||||
#ifndef Q_OS_LINUX
|
#ifndef Q_OS_LINUX
|
||||||
if (!m_string_stream.str().empty())
|
if (!m_string_stream.str().empty())
|
||||||
{
|
{
|
||||||
@@ -604,12 +635,13 @@ pugi::xml_document ElementsLocation::pugiXml() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::setXml
|
@brief ElementsLocation::setXml
|
||||||
* Replace the current xml description by @xml_element;
|
Replace the current xml description by xml_document;
|
||||||
* The document element of @xml_document must have tagname "definition" to be written
|
The document element of xml_document must have
|
||||||
* This definition must be writable
|
tagname "definition" to be written
|
||||||
* @param xml_element
|
This definition must be writable
|
||||||
* @return true if success
|
@param xml_document
|
||||||
|
@return true if success
|
||||||
*/
|
*/
|
||||||
bool ElementsLocation::setXml(const QDomDocument &xml_document) const
|
bool ElementsLocation::setXml(const QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
@@ -666,9 +698,9 @@ bool ElementsLocation::setXml(const QDomDocument &xml_document) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::uuid
|
@brief ElementsLocation::uuid
|
||||||
* @return The uuid of the pointed element
|
@return The uuid of the pointed element
|
||||||
* Uuid can be null
|
Uuid can be null
|
||||||
*/
|
*/
|
||||||
QUuid ElementsLocation::uuid() const
|
QUuid ElementsLocation::uuid() const
|
||||||
{
|
{
|
||||||
@@ -685,16 +717,17 @@ QUuid ElementsLocation::uuid() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementLocation::icon
|
@brief ElementLocation::icon
|
||||||
* @return The icon of the represented element.
|
@return The icon of the represented element.
|
||||||
* If icon can't be set, return a null QIcon
|
If icon can't be set, return a null QIcon
|
||||||
*/
|
*/
|
||||||
QIcon ElementsLocation::icon() const
|
QIcon ElementsLocation::icon() const
|
||||||
{
|
{
|
||||||
if (!m_project)
|
if (!m_project)
|
||||||
{
|
{
|
||||||
ElementsCollectionCache *cache = QETApp::collectionCache();
|
ElementsCollectionCache *cache = QETApp::collectionCache();
|
||||||
ElementsLocation loc(*this); //Make a copy of this to keep this method const
|
// Make a copy of this to keep this method const
|
||||||
|
ElementsLocation loc(*this);
|
||||||
if (cache->fetchElement(loc))
|
if (cache->fetchElement(loc))
|
||||||
return QIcon(cache->pixmap());
|
return QIcon(cache->pixmap());
|
||||||
}
|
}
|
||||||
@@ -706,8 +739,8 @@ QIcon ElementsLocation::icon() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementLocation::name
|
@brief ElementLocation::name
|
||||||
* @return The name of the represented element in the current local
|
@return The name of the represented element in the current local
|
||||||
*/
|
*/
|
||||||
QString ElementsLocation::name() const
|
QString ElementsLocation::name() const
|
||||||
{
|
{
|
||||||
@@ -717,12 +750,14 @@ QString ElementsLocation::name() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementLocation::fileName
|
@brief ElementLocation::fileName
|
||||||
* @return Return the file name of the represented item, whatever the storage system (file system, xml collection)
|
@return Return the file name of the represented item,
|
||||||
* with is file extension.
|
whatever the storage system (file system, xml collection)
|
||||||
* For example if this location represent an element, they return myElement.elmt.
|
with is file extension.
|
||||||
* For a directory return myDirectory.
|
For example if this location represent an element,
|
||||||
* @see baseName
|
they return myElement.elmt.
|
||||||
|
For a directory return myDirectory.
|
||||||
|
@see baseName
|
||||||
*/
|
*/
|
||||||
QString ElementsLocation::fileName() const
|
QString ElementsLocation::fileName() const
|
||||||
{
|
{
|
||||||
@@ -734,9 +769,10 @@ QString ElementsLocation::fileName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsLocation::elementInformations
|
@brief ElementsLocation::elementInformations
|
||||||
* @return the element information of the element represented by this location.
|
@return
|
||||||
* If the location is a directory, the returned diagram context is empty
|
the element information of the element represented by this location.
|
||||||
|
If the location is a directory, the returned diagram context is empty
|
||||||
*/
|
*/
|
||||||
DiagramContext ElementsLocation::elementInformations() const
|
DiagramContext ElementsLocation::elementInformations() const
|
||||||
{
|
{
|
||||||
@@ -745,10 +781,18 @@ DiagramContext ElementsLocation::elementInformations() const
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.fromXml(pugiXml().document_element().child("elementInformations"), "elementInformation");
|
context.fromXml(pugiXml().document_element().child(
|
||||||
|
"elementInformations"),
|
||||||
|
"elementInformation");
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief operator <<
|
||||||
|
@param debug
|
||||||
|
@param location
|
||||||
|
@return
|
||||||
|
*/
|
||||||
QDebug operator<< (QDebug debug, const ElementsLocation &location)
|
QDebug operator<< (QDebug debug, const ElementsLocation &location)
|
||||||
{
|
{
|
||||||
QDebugStateSaver saver(debug);
|
QDebugStateSaver saver(debug);
|
||||||
@@ -762,7 +806,8 @@ QDebug operator<< (QDebug debug, const ElementsLocation &location)
|
|||||||
|
|
||||||
QString msg;
|
QString msg;
|
||||||
msg += "ElementsLocation(";
|
msg += "ElementsLocation(";
|
||||||
msg += (location.isProject()? location.projectCollectionPath() : location.collectionPath(true));
|
msg += (location.isProject()? location.projectCollectionPath()
|
||||||
|
: location.collectionPath(true));
|
||||||
msg += location.exist()? ", true" : ", false";
|
msg += location.exist()? ", true" : ", false";
|
||||||
msg +=")";
|
msg +=")";
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class QETProject;
|
|||||||
class XmlElementCollection;
|
class XmlElementCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@brief The ElementsLocation class
|
||||||
Cette classe represente la localisation, l'emplacement d'un element ou
|
Cette classe represente la localisation, l'emplacement d'un element ou
|
||||||
d'une categorie, voire d'une collection... dans une collection. Elle
|
d'une categorie, voire d'une collection... dans une collection. Elle
|
||||||
encapsule un chemin virtuel.
|
encapsule un chemin virtuel.
|
||||||
@@ -40,7 +41,8 @@ class ElementsLocation
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ElementsLocation();
|
ElementsLocation();
|
||||||
ElementsLocation(const QString &path, QETProject *project = nullptr);
|
ElementsLocation(const QString &path,
|
||||||
|
QETProject *project = nullptr);
|
||||||
ElementsLocation(const ElementsLocation &);
|
ElementsLocation(const ElementsLocation &);
|
||||||
ElementsLocation(const QMimeData *data);
|
ElementsLocation(const QMimeData *data);
|
||||||
virtual ~ElementsLocation();
|
virtual ~ElementsLocation();
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ static int header = 5;
|
|||||||
static int cross_min_heigth = 33;
|
static int cross_min_heigth = 33;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::CrossRefItem
|
@brief CrossRefItem::CrossRefItem
|
||||||
* @param elmt : element to display the cross ref
|
@param elmt : element to display the cross ref
|
||||||
*/
|
*/
|
||||||
CrossRefItem::CrossRefItem(Element *elmt) :
|
CrossRefItem::CrossRefItem(Element *elmt) :
|
||||||
QGraphicsObject(elmt),
|
QGraphicsObject(elmt),
|
||||||
@@ -40,9 +40,9 @@ CrossRefItem::CrossRefItem(Element *elmt) :
|
|||||||
{init();}
|
{init();}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::CrossRefItem
|
@brief CrossRefItem::CrossRefItem
|
||||||
* @param elmt : element to display the cross ref
|
@param elmt : element to display the cross ref
|
||||||
* @param text : If the Xref must be displayed under a text, the text.
|
@param text : If the Xref must be displayed under a text, the text.
|
||||||
*/
|
*/
|
||||||
CrossRefItem::CrossRefItem(Element *elmt, DynamicElementTextItem *text) :
|
CrossRefItem::CrossRefItem(Element *elmt, DynamicElementTextItem *text) :
|
||||||
QGraphicsObject(text),
|
QGraphicsObject(text),
|
||||||
@@ -51,9 +51,9 @@ CrossRefItem::CrossRefItem(Element *elmt, DynamicElementTextItem *text) :
|
|||||||
{init();}
|
{init();}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::CrossRefItem
|
@brief CrossRefItem::CrossRefItem
|
||||||
* @param elmt : element to display the cross ref
|
@param elmt : element to display the cross ref
|
||||||
* @param group : If the Xref must be displayed under a group, the group.
|
@param group : If the Xref must be displayed under a group, the group.
|
||||||
*/
|
*/
|
||||||
CrossRefItem::CrossRefItem(Element *elmt, ElementTextItemGroup *group) :
|
CrossRefItem::CrossRefItem(Element *elmt, ElementTextItemGroup *group) :
|
||||||
QGraphicsObject(group),
|
QGraphicsObject(group),
|
||||||
@@ -62,14 +62,14 @@ CrossRefItem::CrossRefItem(Element *elmt, ElementTextItemGroup *group) :
|
|||||||
{init();}
|
{init();}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::~CrossRefItem
|
@brief CrossRefItem::~CrossRefItem
|
||||||
* Default destructor
|
Default destructor
|
||||||
*/
|
*/
|
||||||
CrossRefItem::~CrossRefItem() {}
|
CrossRefItem::~CrossRefItem() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::init
|
@brief CrossRefItem::init
|
||||||
* init this Xref
|
init this Xref
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::init()
|
void CrossRefItem::init()
|
||||||
{
|
{
|
||||||
@@ -91,8 +91,8 @@ void CrossRefItem::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::setUpConnection
|
@brief CrossRefItem::setUpConnection
|
||||||
* Set up several connection to keep up to date the Xref
|
Set up several connection to keep up to date the Xref
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::setUpConnection()
|
void CrossRefItem::setUpConnection()
|
||||||
{
|
{
|
||||||
@@ -123,46 +123,57 @@ void CrossRefItem::setUpConnection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::boundingRect
|
@brief CrossRefItem::boundingRect
|
||||||
* @return the bounding rect of this item
|
@return the bounding rect of this item
|
||||||
*/
|
*/
|
||||||
QRectF CrossRefItem::boundingRect() const {
|
QRectF CrossRefItem::boundingRect() const {
|
||||||
return m_bounding_rect;
|
return m_bounding_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::shape
|
@brief CrossRefItem::shape
|
||||||
* @return the shape of this item
|
@return the shape of this item
|
||||||
*/
|
*/
|
||||||
QPainterPath CrossRefItem::shape() const{
|
QPainterPath CrossRefItem::shape() const{
|
||||||
return m_shape_path;
|
return m_shape_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::elementPositionText
|
@brief CrossRefItem::elementPositionText
|
||||||
* @param elmt
|
@param elmt
|
||||||
* @return the string corresponding to the position of @elmt in the diagram.
|
@param add_prefix
|
||||||
* if @add_prefix is true, prefix (for power and delay contact) is added to the poistion text.
|
@return the string corresponding to the position of elmt in the diagram.
|
||||||
|
if add_prefix is true,
|
||||||
|
prefix (for power and delay contact) is added to the poistion text.
|
||||||
*/
|
*/
|
||||||
QString CrossRefItem::elementPositionText(const Element *elmt, const bool &add_prefix) const
|
QString CrossRefItem::elementPositionText(const Element *elmt,
|
||||||
|
const bool &add_prefix) const
|
||||||
{
|
{
|
||||||
XRefProperties xrp = m_element->diagram()->project()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
|
XRefProperties xrp =
|
||||||
|
m_element->diagram()->project()->defaultXRefProperties(
|
||||||
|
m_element->kindInformations()["type"].toString());
|
||||||
QString formula = xrp.masterLabel();
|
QString formula = xrp.masterLabel();
|
||||||
autonum::sequentialNumbers seq;
|
autonum::sequentialNumbers seq;
|
||||||
QString txt = autonum::AssignVariables::formulaToLabel(formula, seq, elmt->diagram(), elmt);
|
QString txt = autonum::AssignVariables::formulaToLabel(
|
||||||
|
formula,
|
||||||
|
seq, elmt->diagram(),
|
||||||
|
elmt);
|
||||||
|
|
||||||
if (add_prefix)
|
if (add_prefix)
|
||||||
{
|
{
|
||||||
if (elmt->kindInformations()["type"].toString() == "power") txt.prepend(m_properties.prefix("power"));
|
if (elmt->kindInformations()["type"].toString() == "power")
|
||||||
else if (elmt->kindInformations()["type"].toString().contains("delay")) txt.prepend(m_properties.prefix("delay"));
|
txt.prepend(m_properties.prefix("power"));
|
||||||
else if (elmt->kindInformations()["state"].toString() == "SW") txt.prepend(m_properties.prefix("switch"));
|
else if (elmt->kindInformations()["type"].toString().contains("delay"))
|
||||||
|
txt.prepend(m_properties.prefix("delay"));
|
||||||
|
else if (elmt->kindInformations()["state"].toString() == "SW")
|
||||||
|
txt.prepend(m_properties.prefix("switch"));
|
||||||
}
|
}
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::updateProperties
|
@brief CrossRefItem::updateProperties
|
||||||
* update the curent properties
|
update the curent properties
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::updateProperties()
|
void CrossRefItem::updateProperties()
|
||||||
{
|
{
|
||||||
@@ -183,8 +194,8 @@ void CrossRefItem::updateProperties()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::updateLabel
|
@brief CrossRefItem::updateLabel
|
||||||
* Update the content of the item
|
Update the content of the item
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::updateLabel()
|
void CrossRefItem::updateLabel()
|
||||||
{
|
{
|
||||||
@@ -218,17 +229,26 @@ void CrossRefItem::updateLabel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::autoPos
|
@brief CrossRefItem::autoPos
|
||||||
* Calculate and set position automaticaly.
|
Calculate and set position automaticaly.
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::autoPos() {
|
void CrossRefItem::autoPos() {
|
||||||
//We calcul the position according to the @snapTo of the xrefproperties
|
//We calcul the position according to the @snapTo of the xrefproperties
|
||||||
if (m_properties.snapTo() == XRefProperties::Bottom)
|
if (m_properties.snapTo() == XRefProperties::Bottom)
|
||||||
centerToBottomDiagram(this, m_element, m_properties.offset() <= 40 ? 5 : m_properties.offset());
|
centerToBottomDiagram(this,
|
||||||
|
m_element,
|
||||||
|
m_properties.offset() <= 40
|
||||||
|
? 5
|
||||||
|
: m_properties.offset());
|
||||||
else
|
else
|
||||||
centerToParentBottom(this);
|
centerToParentBottom(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief CrossRefItem::sceneEvent
|
||||||
|
@param event
|
||||||
|
@return
|
||||||
|
*/
|
||||||
bool CrossRefItem::sceneEvent(QEvent *event)
|
bool CrossRefItem::sceneEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
//By default when a QGraphicsItem is a child of a QGraphicsItemGroup
|
//By default when a QGraphicsItem is a child of a QGraphicsItemGroup
|
||||||
@@ -259,21 +279,23 @@ bool CrossRefItem::sceneEvent(QEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::paint
|
@brief CrossRefItem::paint
|
||||||
* Paint this item
|
Paint this item
|
||||||
* @param painter
|
@param painter
|
||||||
* @param option
|
@param option
|
||||||
* @param widget
|
@param widget
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void CrossRefItem::paint(QPainter *painter,
|
||||||
|
const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget) {
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
m_drawing.play(painter);
|
m_drawing.play(painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::mouseDoubleClickEvent
|
@brief CrossRefItem::mouseDoubleClickEvent
|
||||||
* @param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
void CrossRefItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
@@ -288,7 +310,8 @@ void CrossRefItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
m_hovered_contact->setSelected(true);
|
m_hovered_contact->setSelected(true);
|
||||||
|
|
||||||
//Zoom to the linked slave element
|
//Zoom to the linked slave element
|
||||||
foreach(QGraphicsView *view, m_hovered_contact->diagram()->views())
|
foreach(QGraphicsView *view,
|
||||||
|
m_hovered_contact->diagram()->views())
|
||||||
{
|
{
|
||||||
QRectF fit = m_hovered_contact->sceneBoundingRect();
|
QRectF fit = m_hovered_contact->sceneBoundingRect();
|
||||||
fit.adjust(-200, -200, 200, 200);
|
fit.adjust(-200, -200, 200, 200);
|
||||||
@@ -297,12 +320,20 @@ void CrossRefItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief CrossRefItem::hoverEnterEvent
|
||||||
|
@param event
|
||||||
|
*/
|
||||||
void CrossRefItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void CrossRefItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
m_hovered_contact = nullptr;
|
m_hovered_contact = nullptr;
|
||||||
QGraphicsObject::hoverEnterEvent(event);
|
QGraphicsObject::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief CrossRefItem::hoverMoveEvent
|
||||||
|
@param event
|
||||||
|
*/
|
||||||
void CrossRefItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void CrossRefItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
@@ -357,6 +388,10 @@ void CrossRefItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief CrossRefItem::hoverLeaveEvent
|
||||||
|
@param event
|
||||||
|
*/
|
||||||
void CrossRefItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void CrossRefItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
m_hovered_contact = nullptr;
|
m_hovered_contact = nullptr;
|
||||||
@@ -364,6 +399,9 @@ void CrossRefItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
QGraphicsObject::hoverLeaveEvent(event);
|
QGraphicsObject::hoverLeaveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief CrossRefItem::linkedChanged
|
||||||
|
*/
|
||||||
void CrossRefItem::linkedChanged()
|
void CrossRefItem::linkedChanged()
|
||||||
{
|
{
|
||||||
for(const QMetaObject::Connection& c : m_slave_connection)
|
for(const QMetaObject::Connection& c : m_slave_connection)
|
||||||
@@ -376,16 +414,22 @@ void CrossRefItem::linkedChanged()
|
|||||||
|
|
||||||
for(Element *elmt : m_element->linkedElements())
|
for(Element *elmt : m_element->linkedElements())
|
||||||
{
|
{
|
||||||
m_slave_connection << connect(elmt, &Element::xChanged, this, &CrossRefItem::updateLabel);
|
m_slave_connection << connect(elmt,
|
||||||
m_slave_connection << connect(elmt, &Element::yChanged, this, &CrossRefItem::updateLabel);
|
&Element::xChanged,
|
||||||
|
this,
|
||||||
|
&CrossRefItem::updateLabel);
|
||||||
|
m_slave_connection << connect(elmt,
|
||||||
|
&Element::yChanged,
|
||||||
|
this,
|
||||||
|
&CrossRefItem::updateLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLabel();
|
updateLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::buildHeaderContact
|
@brief CrossRefItem::buildHeaderContact
|
||||||
* Draw the QPicture of m_hdr_no_ctc and m_hdr_nc_ctc
|
Draw the QPicture of m_hdr_no_ctc and m_hdr_nc_ctc
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::buildHeaderContact() {
|
void CrossRefItem::buildHeaderContact() {
|
||||||
if (!m_hdr_no_ctc.isNull() && !m_hdr_nc_ctc.isNull()) return;
|
if (!m_hdr_no_ctc.isNull() && !m_hdr_nc_ctc.isNull()) return;
|
||||||
@@ -430,10 +474,12 @@ void CrossRefItem::buildHeaderContact() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::setUpCrossBoundingRect
|
@brief CrossRefItem::setUpCrossBoundingRect
|
||||||
* Get the numbers of slaves elements linked to this parent element,
|
Get the numbers of slaves elements linked to this parent element,
|
||||||
* for calculate the size of the cross bounding rect.
|
for calculate the size of the cross bounding rect.
|
||||||
* The cross ref item is drawing according to the size of the cross bounding rect.
|
The cross ref item is drawing according to the size of
|
||||||
|
the cross bounding rect.
|
||||||
|
@param painter
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::setUpCrossBoundingRect(QPainter &painter)
|
void CrossRefItem::setUpCrossBoundingRect(QPainter &painter)
|
||||||
{
|
{
|
||||||
@@ -492,9 +538,9 @@ void CrossRefItem::setUpCrossBoundingRect(QPainter &painter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::drawAsCross
|
@brief CrossRefItem::drawAsCross
|
||||||
* Draw this crossref with a cross
|
Draw this crossref with a cross
|
||||||
* @param painter, painter to use
|
@param painter: painter to use
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::drawAsCross(QPainter &painter)
|
void CrossRefItem::drawAsCross(QPainter &painter)
|
||||||
{
|
{
|
||||||
@@ -522,9 +568,9 @@ void CrossRefItem::drawAsCross(QPainter &painter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::drawAsContacts
|
@brief CrossRefItem::drawAsContacts
|
||||||
* Draw this crossref with symbolic contacts
|
Draw this crossref with symbolic contacts
|
||||||
* @param painter painter to use
|
@param painter painter to use
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::drawAsContacts(QPainter &painter)
|
void CrossRefItem::drawAsContacts(QPainter &painter)
|
||||||
{
|
{
|
||||||
@@ -567,12 +613,12 @@ void CrossRefItem::drawAsContacts(QPainter &painter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::drawContact
|
@brief CrossRefItem::drawContact
|
||||||
* Draw one contact, the type of contact to draw is define in @flags.
|
Draw one contact, the type of contact to draw is define in flags.
|
||||||
* @param painter, painter to use
|
@param painter : painter to use
|
||||||
* @param flags, define how to draw the contact (see enul CONTACTS)
|
@param flags : define how to draw the contact (see enul CONTACTS)
|
||||||
* @param elmt, the element to display text (the position of the contact)
|
@param elmt : the element to display text (the position of the contact)
|
||||||
* @return The bounding rect of the draw (contact + text)
|
@return The bounding rect of the draw (contact + text)
|
||||||
*/
|
*/
|
||||||
QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
|
QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
|
||||||
{
|
{
|
||||||
@@ -735,8 +781,13 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Draw position text
|
//Draw position text
|
||||||
QRectF text_rect = painter.boundingRect(QRectF(30, offset+5, 5, 10), Qt::AlignLeft | Qt::AlignVCenter, str);
|
QRectF text_rect = painter.boundingRect(
|
||||||
painter.drawText(text_rect, Qt::AlignLeft | Qt::AlignVCenter, str);
|
QRectF(30, offset+5, 5, 10),
|
||||||
|
Qt::AlignLeft | Qt::AlignVCenter,
|
||||||
|
str);
|
||||||
|
painter.drawText(text_rect,
|
||||||
|
Qt::AlignLeft | Qt::AlignVCenter,
|
||||||
|
str);
|
||||||
bounding_rect = bounding_rect.united(text_rect);
|
bounding_rect = bounding_rect.united(text_rect);
|
||||||
|
|
||||||
if (m_hovered_contacts_map.contains(elmt)) {
|
if (m_hovered_contacts_map.contains(elmt)) {
|
||||||
@@ -754,9 +805,9 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::fillCrossRef
|
@brief CrossRefItem::fillCrossRef
|
||||||
* Fill the content of the cross ref
|
Fill the content of the cross ref
|
||||||
* @param painter painter to use.
|
@param painter painter to use.
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::fillCrossRef(QPainter &painter)
|
void CrossRefItem::fillCrossRef(QPainter &painter)
|
||||||
{
|
{
|
||||||
@@ -773,7 +824,11 @@ void CrossRefItem::fillCrossRef(QPainter &painter)
|
|||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
|
|
||||||
QString str = elementPositionText(elmt, true);
|
QString str = elementPositionText(elmt, true);
|
||||||
QRectF bounding = painter.boundingRect(QRectF(no_top_left, QSize(middle_cross, 1)), Qt::AlignLeft, str);
|
QRectF bounding = painter.boundingRect(
|
||||||
|
QRectF(no_top_left,
|
||||||
|
QSize(middle_cross, 1)),
|
||||||
|
Qt::AlignLeft,
|
||||||
|
str);
|
||||||
painter.drawText(bounding, Qt::AlignLeft, str);
|
painter.drawText(bounding, Qt::AlignLeft, str);
|
||||||
|
|
||||||
if (m_hovered_contacts_map.contains(elmt))
|
if (m_hovered_contacts_map.contains(elmt))
|
||||||
@@ -793,11 +848,16 @@ void CrossRefItem::fillCrossRef(QPainter &painter)
|
|||||||
foreach(Element *elmt, NCElements())
|
foreach(Element *elmt, NCElements())
|
||||||
{
|
{
|
||||||
QPen pen = painter.pen();
|
QPen pen = painter.pen();
|
||||||
m_hovered_contact == elmt ? pen.setColor(Qt::blue) :pen.setColor(Qt::black);
|
m_hovered_contact == elmt ? pen.setColor(Qt::blue)
|
||||||
|
:pen.setColor(Qt::black);
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
|
|
||||||
QString str = elementPositionText(elmt, true);
|
QString str = elementPositionText(elmt, true);
|
||||||
QRectF bounding = painter.boundingRect(QRectF(nc_top_left, QSize(middle_cross, 1)), Qt::AlignRight, str);
|
QRectF bounding = painter.boundingRect(
|
||||||
|
QRectF(nc_top_left,
|
||||||
|
QSize(middle_cross, 1)),
|
||||||
|
Qt::AlignRight,
|
||||||
|
str);
|
||||||
painter.drawText(bounding, Qt::AlignRight, str);
|
painter.drawText(bounding, Qt::AlignRight, str);
|
||||||
|
|
||||||
if (m_hovered_contacts_map.contains(elmt))
|
if (m_hovered_contacts_map.contains(elmt))
|
||||||
@@ -814,14 +874,18 @@ void CrossRefItem::fillCrossRef(QPainter &painter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::AddExtraInfo
|
@brief CrossRefItem::AddExtraInfo
|
||||||
* Add the comment info of the parent item if needed.
|
Add the comment info of the parent item if needed.
|
||||||
* @param painter painter to use for draw the text
|
@param painter painter to use for draw the text
|
||||||
* @param type type of Info do be draw e.g. comment, location.
|
@param type type of Info do be draw e.g. comment, location.
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::AddExtraInfo(QPainter &painter, const QString& type)
|
void CrossRefItem::AddExtraInfo(QPainter &painter, const QString& type)
|
||||||
{
|
{
|
||||||
QString text = autonum::AssignVariables::formulaToLabel(m_element -> elementInformations()[type].toString(), m_element->rSequenceStruct(), m_element->diagram(), m_element);
|
QString text = autonum::AssignVariables::formulaToLabel(
|
||||||
|
m_element->elementInformations()[type].toString(),
|
||||||
|
m_element->rSequenceStruct(),
|
||||||
|
m_element->diagram(),
|
||||||
|
m_element);
|
||||||
bool must_show = m_element -> elementInformations().keyMustShow(type);
|
bool must_show = m_element -> elementInformations().keyMustShow(type);
|
||||||
|
|
||||||
if (!text.isEmpty() && must_show)
|
if (!text.isEmpty() && must_show)
|
||||||
@@ -831,29 +895,42 @@ void CrossRefItem::AddExtraInfo(QPainter &painter, const QString& type)
|
|||||||
|
|
||||||
QRectF r, text_bounding;
|
QRectF r, text_bounding;
|
||||||
qreal center = boundingRect().center().x();
|
qreal center = boundingRect().center().x();
|
||||||
qreal width = boundingRect().width() > 70 ? boundingRect().width()/2 : 35;
|
qreal width = boundingRect().width() > 70
|
||||||
|
? boundingRect().width()/2
|
||||||
|
: 35;
|
||||||
|
|
||||||
r = QRectF(QPointF(center - width, boundingRect().bottom()),
|
r = QRectF(QPointF(center - width,
|
||||||
QPointF(center + width, boundingRect().bottom() + 1));
|
boundingRect().bottom()),
|
||||||
|
QPointF(center + width,
|
||||||
|
boundingRect().bottom() + 1));
|
||||||
|
|
||||||
text_bounding = painter.boundingRect(r, Qt::TextWordWrap | Qt::AlignHCenter, text);
|
text_bounding = painter.boundingRect(
|
||||||
painter.drawText(text_bounding, Qt::TextWordWrap | Qt::AlignHCenter, text);
|
r,
|
||||||
|
Qt::TextWordWrap | Qt::AlignHCenter,
|
||||||
|
text);
|
||||||
|
painter.drawText(text_bounding,
|
||||||
|
Qt::TextWordWrap | Qt::AlignHCenter,
|
||||||
|
text);
|
||||||
|
|
||||||
text_bounding.adjust(-1,0,1,0); //adjust only for better visual
|
text_bounding.adjust(-1,0,1,0); //adjust only for better visual
|
||||||
|
|
||||||
m_shape_path.addRect(text_bounding);
|
m_shape_path.addRect(text_bounding);
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
m_bounding_rect = m_bounding_rect.united(text_bounding);
|
m_bounding_rect = m_bounding_rect.united(text_bounding);
|
||||||
if (type == "comment") painter.drawRoundedRect(text_bounding, 2, 2);
|
if (type == "comment") painter.drawRoundedRect(text_bounding,
|
||||||
|
2,
|
||||||
|
2);
|
||||||
painter.restore();
|
painter.restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::NOElements
|
@brief CrossRefItem::NOElements
|
||||||
* @return The linked elements of @m_element wich are open or switch contact.
|
@return The linked elements of m_element wich are open or switch contact.
|
||||||
* If linked element is a power contact, xref propertie is set to don't show power contact
|
If linked element is a power contact,
|
||||||
* and this cross item must be drawed as cross, the element is not append in the list.
|
xref propertie is set to don't show power contact
|
||||||
|
and this cross item must be drawed as cross,
|
||||||
|
the element is not append in the list.
|
||||||
*/
|
*/
|
||||||
QList<Element *> CrossRefItem::NOElements() const
|
QList<Element *> CrossRefItem::NOElements() const
|
||||||
{
|
{
|
||||||
@@ -880,10 +957,13 @@ QList<Element *> CrossRefItem::NOElements() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::NCElements
|
@brief CrossRefItem::NCElements
|
||||||
* @return The linked elements of @m_element wich are close or switch contact
|
@return The linked elements of m_element wich are close
|
||||||
* If linked element is a power contact, xref propertie is set to don't show power contact
|
or switch contact
|
||||||
* and this cross item must be drawed as cross, the element is not append in the list.
|
If linked element is a power contact,
|
||||||
|
xref propertie is set to don't show power contact
|
||||||
|
and this cross item must be drawed as cross,
|
||||||
|
the element is not append in the list.
|
||||||
*/
|
*/
|
||||||
QList<Element *> CrossRefItem::NCElements() const
|
QList<Element *> CrossRefItem::NCElements() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,15 +29,19 @@ class DynamicElementTextItem;
|
|||||||
class ElementTextItemGroup;
|
class ElementTextItemGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The CrossRefItem class
|
@brief The CrossRefItem class
|
||||||
* This clas provide an item, for show the cross reference, like the contacts linked to a coil.
|
This clas provide an item, for show the cross reference,
|
||||||
* The item setpos automaticaly when parent move.
|
like the contacts linked to a coil.
|
||||||
* All slave displayed in cross ref will be updated when folio position change in the project.
|
The item setpos automaticaly when parent move.
|
||||||
* It's the responsability of the master element to informe displayed slave are moved,
|
All slave displayed in cross ref will be updated
|
||||||
* by calling the slot @updateLabel
|
when folio position change in the project.
|
||||||
* By default master element is the parent graphics item of this Xref,
|
It's the responsability of the master element
|
||||||
* but if the Xref must be snap to the label of master, the label become the parent of this Xref.
|
to informe displayed slave are moved,
|
||||||
* This behavior can be changed at anytime by calling setProperties.
|
by calling the slot updateLabel
|
||||||
|
By default master element is the parent graphics item of this Xref,
|
||||||
|
but if the Xref must be snap to the label of master,
|
||||||
|
the label become the parent of this Xref.
|
||||||
|
This behavior can be changed at anytime by calling setProperties.
|
||||||
*/
|
*/
|
||||||
class CrossRefItem : public QGraphicsObject
|
class CrossRefItem : public QGraphicsObject
|
||||||
{
|
{
|
||||||
@@ -46,8 +50,10 @@ class CrossRefItem : public QGraphicsObject
|
|||||||
//Methods
|
//Methods
|
||||||
public:
|
public:
|
||||||
explicit CrossRefItem(Element *elmt);
|
explicit CrossRefItem(Element *elmt);
|
||||||
explicit CrossRefItem(Element *elmt, DynamicElementTextItem *text);
|
explicit CrossRefItem(Element *elmt,
|
||||||
explicit CrossRefItem(Element *elmt, ElementTextItemGroup *group);
|
DynamicElementTextItem *text);
|
||||||
|
explicit CrossRefItem(Element *elmt,
|
||||||
|
ElementTextItemGroup *group);
|
||||||
~CrossRefItem() override;
|
~CrossRefItem() override;
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
@@ -57,6 +63,9 @@ class CrossRefItem : public QGraphicsObject
|
|||||||
enum { Type = UserType + 1009 };
|
enum { Type = UserType + 1009 };
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The CONTACTS enum
|
||||||
|
*/
|
||||||
enum CONTACTS {
|
enum CONTACTS {
|
||||||
NO = 1,
|
NO = 1,
|
||||||
NC = 2,
|
NC = 2,
|
||||||
@@ -71,7 +80,9 @@ class CrossRefItem : public QGraphicsObject
|
|||||||
|
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
QString elementPositionText (const Element *elmt, const bool &add_prefix = false) const;
|
QString elementPositionText(
|
||||||
|
const Element *elmt,
|
||||||
|
const bool &add_prefix = false) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateProperties();
|
void updateProperties();
|
||||||
@@ -80,8 +91,11 @@ class CrossRefItem : public QGraphicsObject
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool sceneEvent(QEvent *event) override;
|
bool sceneEvent(QEvent *event) override;
|
||||||
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter,
|
||||||
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent * event ) override;
|
const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget) override;
|
||||||
|
void mouseDoubleClickEvent (
|
||||||
|
QGraphicsSceneMouseEvent * event ) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
|||||||
@@ -28,6 +28,12 @@
|
|||||||
* AddElementTextCommand*
|
* AddElementTextCommand*
|
||||||
* **********************/
|
* **********************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief AddElementTextCommand::AddElementTextCommand
|
||||||
|
@param element
|
||||||
|
@param deti
|
||||||
|
@param parent
|
||||||
|
*/
|
||||||
AddElementTextCommand::AddElementTextCommand(Element *element,
|
AddElementTextCommand::AddElementTextCommand(Element *element,
|
||||||
DynamicElementTextItem *deti,
|
DynamicElementTextItem *deti,
|
||||||
QUndoCommand *parent):
|
QUndoCommand *parent):
|
||||||
@@ -38,6 +44,9 @@ AddElementTextCommand::AddElementTextCommand(Element *element,
|
|||||||
setText(QObject::tr("Ajouter un texte d'élément"));
|
setText(QObject::tr("Ajouter un texte d'élément"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief AddElementTextCommand::~AddElementTextCommand
|
||||||
|
*/
|
||||||
AddElementTextCommand::~AddElementTextCommand()
|
AddElementTextCommand::~AddElementTextCommand()
|
||||||
{
|
{
|
||||||
if(m_text->parentGroup())
|
if(m_text->parentGroup())
|
||||||
@@ -47,6 +56,9 @@ AddElementTextCommand::~AddElementTextCommand()
|
|||||||
delete m_text;
|
delete m_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief AddElementTextCommand::undo
|
||||||
|
*/
|
||||||
void AddElementTextCommand::undo()
|
void AddElementTextCommand::undo()
|
||||||
{
|
{
|
||||||
m_element->removeDynamicTextItem(m_text);
|
m_element->removeDynamicTextItem(m_text);
|
||||||
@@ -54,6 +66,9 @@ void AddElementTextCommand::undo()
|
|||||||
m_text->scene()->removeItem(m_text);
|
m_text->scene()->removeItem(m_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief AddElementTextCommand::redo
|
||||||
|
*/
|
||||||
void AddElementTextCommand::redo()
|
void AddElementTextCommand::redo()
|
||||||
{
|
{
|
||||||
m_text->setParentItem(m_element);
|
m_text->setParentItem(m_element);
|
||||||
@@ -65,10 +80,10 @@ void AddElementTextCommand::redo()
|
|||||||
* AddTextsGroupCommand*
|
* AddTextsGroupCommand*
|
||||||
* *********************/
|
* *********************/
|
||||||
/**
|
/**
|
||||||
* @brief AddTextsGroupCommand::AddTextsGroupCommand
|
@brief AddTextsGroupCommand::AddTextsGroupCommand
|
||||||
* @param element : the element to add a new group
|
@param element : the element to add a new group
|
||||||
* @param groupe_name : the name of the group
|
@param groupe_name : the name of the group
|
||||||
* @param parent : parent undo
|
@param parent : parent undo
|
||||||
*/
|
*/
|
||||||
AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
||||||
QString groupe_name,
|
QString groupe_name,
|
||||||
@@ -81,10 +96,12 @@ AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AddTextsGroupCommand::AddTextsGroupCommand
|
@brief AddTextsGroupCommand::AddTextsGroupCommand
|
||||||
* @param element : The element to add a new group
|
@param element : The element to add a new group
|
||||||
* @param dom_element : the first time the group is created, we call the function fromXml of the group, and give @dom_element has argument.
|
@param dom_element : the first time the group is created,
|
||||||
* @param parent : parent undo
|
we call the function fromXml of the group,
|
||||||
|
and give @dom_element has argument.
|
||||||
|
@param parent : parent undo
|
||||||
*/
|
*/
|
||||||
AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
||||||
const QDomElement& dom_element,
|
const QDomElement& dom_element,
|
||||||
@@ -97,10 +114,11 @@ AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AddTextsGroupCommand::AddTextsGroupCommand
|
@brief AddTextsGroupCommand::AddTextsGroupCommand
|
||||||
* @param element : The element to add a new group
|
@param element : The element to add a new group
|
||||||
* @param texts_list : a list of texts to add to the created group (texts must be child of element)
|
@param texts_list : a list of texts to add to the created group
|
||||||
* @param parent : parent undo
|
(texts must be child of element)
|
||||||
|
@param parent : parent undo
|
||||||
*/
|
*/
|
||||||
AddTextsGroupCommand::AddTextsGroupCommand(
|
AddTextsGroupCommand::AddTextsGroupCommand(
|
||||||
Element *element,
|
Element *element,
|
||||||
@@ -125,18 +143,24 @@ AddTextsGroupCommand::AddTextsGroupCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AddTextsGroupCommand::~AddTextsGroupCommand
|
@brief AddTextsGroupCommand::~AddTextsGroupCommand
|
||||||
* Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
AddTextsGroupCommand::~AddTextsGroupCommand()
|
AddTextsGroupCommand::~AddTextsGroupCommand()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief AddTextsGroupCommand::undo
|
||||||
|
*/
|
||||||
void AddTextsGroupCommand::undo()
|
void AddTextsGroupCommand::undo()
|
||||||
{
|
{
|
||||||
if(m_element && m_group)
|
if(m_element && m_group)
|
||||||
m_element.data()->removeTextGroup(m_group);
|
m_element.data()->removeTextGroup(m_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief AddTextsGroupCommand::redo
|
||||||
|
*/
|
||||||
void AddTextsGroupCommand::redo()
|
void AddTextsGroupCommand::redo()
|
||||||
{
|
{
|
||||||
if(!m_element)
|
if(!m_element)
|
||||||
@@ -179,10 +203,10 @@ void AddTextsGroupCommand::redo()
|
|||||||
* RemoveTextsGroupCommand*
|
* RemoveTextsGroupCommand*
|
||||||
* ************************/
|
* ************************/
|
||||||
/**
|
/**
|
||||||
* @brief RemoveTextsGroupCommand::RemoveTextsGroupCommand
|
@brief RemoveTextsGroupCommand::RemoveTextsGroupCommand
|
||||||
* @param element : The element where we remove a group
|
@param element : The element where we remove a group
|
||||||
* @param group : the group to remove
|
@param group : the group to remove
|
||||||
* @param parent : the parent undo command
|
@param parent : the parent undo command
|
||||||
*/
|
*/
|
||||||
RemoveTextsGroupCommand::RemoveTextsGroupCommand(Element *element,
|
RemoveTextsGroupCommand::RemoveTextsGroupCommand(Element *element,
|
||||||
ElementTextItemGroup *group,
|
ElementTextItemGroup *group,
|
||||||
@@ -197,9 +221,15 @@ RemoveTextsGroupCommand::RemoveTextsGroupCommand(Element *element,
|
|||||||
m_text_list.append(deti);
|
m_text_list.append(deti);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveTextsGroupCommand::~RemoveTextsGroupCommand
|
||||||
|
*/
|
||||||
RemoveTextsGroupCommand::~RemoveTextsGroupCommand()
|
RemoveTextsGroupCommand::~RemoveTextsGroupCommand()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveTextsGroupCommand::undo
|
||||||
|
*/
|
||||||
void RemoveTextsGroupCommand::undo()
|
void RemoveTextsGroupCommand::undo()
|
||||||
{
|
{
|
||||||
if(m_element && m_group)
|
if(m_element && m_group)
|
||||||
@@ -214,6 +244,9 @@ void RemoveTextsGroupCommand::undo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveTextsGroupCommand::redo
|
||||||
|
*/
|
||||||
void RemoveTextsGroupCommand::redo()
|
void RemoveTextsGroupCommand::redo()
|
||||||
{
|
{
|
||||||
if(m_element && m_group)
|
if(m_element && m_group)
|
||||||
@@ -233,10 +266,10 @@ void RemoveTextsGroupCommand::redo()
|
|||||||
* AddTextToGroupCommand*
|
* AddTextToGroupCommand*
|
||||||
* **********************/
|
* **********************/
|
||||||
/**
|
/**
|
||||||
* @brief AddTextToGroupCommand::AddTextToGroupCommand
|
@brief AddTextToGroupCommand::AddTextToGroupCommand
|
||||||
* @param text
|
@param text
|
||||||
* @param group
|
@param group
|
||||||
* @param parent
|
@param parent
|
||||||
*/
|
*/
|
||||||
AddTextToGroupCommand::AddTextToGroupCommand(DynamicElementTextItem *text,
|
AddTextToGroupCommand::AddTextToGroupCommand(DynamicElementTextItem *text,
|
||||||
ElementTextItemGroup *group,
|
ElementTextItemGroup *group,
|
||||||
@@ -250,8 +283,8 @@ AddTextToGroupCommand::AddTextToGroupCommand(DynamicElementTextItem *text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AddTextToGroupCommand::~AddTextToGroupCommand
|
@brief AddTextToGroupCommand::~AddTextToGroupCommand
|
||||||
* Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
AddTextToGroupCommand::~AddTextToGroupCommand()
|
AddTextToGroupCommand::~AddTextToGroupCommand()
|
||||||
{
|
{
|
||||||
@@ -263,12 +296,18 @@ AddTextToGroupCommand::~AddTextToGroupCommand()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief AddTextToGroupCommand::undo
|
||||||
|
*/
|
||||||
void AddTextToGroupCommand::undo()
|
void AddTextToGroupCommand::undo()
|
||||||
{
|
{
|
||||||
if(m_element && m_group && m_text)
|
if(m_element && m_group && m_text)
|
||||||
m_element.data()->removeTextFromGroup(m_text, m_group);
|
m_element.data()->removeTextFromGroup(m_text, m_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief AddTextToGroupCommand::redo
|
||||||
|
*/
|
||||||
void AddTextToGroupCommand::redo()
|
void AddTextToGroupCommand::redo()
|
||||||
{
|
{
|
||||||
if(m_element && m_group && m_text)
|
if(m_element && m_group && m_text)
|
||||||
@@ -286,10 +325,10 @@ void AddTextToGroupCommand::redo()
|
|||||||
* RemoveTextFromGroupCommand*
|
* RemoveTextFromGroupCommand*
|
||||||
* ***************************/
|
* ***************************/
|
||||||
/**
|
/**
|
||||||
* @brief RemoveTextFromGroupCommand::RemoveTextFromGroupCommand
|
@brief RemoveTextFromGroupCommand::RemoveTextFromGroupCommand
|
||||||
* @param text : text to add to @group
|
@param text : text to add to @group
|
||||||
* @param group
|
@param group
|
||||||
* @param parent : parent undo command
|
@param parent : parent undo command
|
||||||
*/
|
*/
|
||||||
RemoveTextFromGroupCommand::RemoveTextFromGroupCommand(
|
RemoveTextFromGroupCommand::RemoveTextFromGroupCommand(
|
||||||
DynamicElementTextItem *text,
|
DynamicElementTextItem *text,
|
||||||
@@ -304,8 +343,8 @@ RemoveTextFromGroupCommand::RemoveTextFromGroupCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand
|
@brief RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand
|
||||||
* Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand()
|
RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand()
|
||||||
{
|
{
|
||||||
@@ -317,12 +356,18 @@ RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveTextFromGroupCommand::undo
|
||||||
|
*/
|
||||||
void RemoveTextFromGroupCommand::undo()
|
void RemoveTextFromGroupCommand::undo()
|
||||||
{
|
{
|
||||||
if(m_element && m_group && m_text)
|
if(m_element && m_group && m_text)
|
||||||
m_element.data()->addTextToGroup(m_text, m_group);
|
m_element.data()->addTextToGroup(m_text, m_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief RemoveTextFromGroupCommand::redo
|
||||||
|
*/
|
||||||
void RemoveTextFromGroupCommand::redo()
|
void RemoveTextFromGroupCommand::redo()
|
||||||
{
|
{
|
||||||
if(m_element && m_group && m_text)
|
if(m_element && m_group && m_text)
|
||||||
@@ -334,10 +379,10 @@ void RemoveTextFromGroupCommand::redo()
|
|||||||
* AlignmentTextsGroupCommand*
|
* AlignmentTextsGroupCommand*
|
||||||
* ***************************/
|
* ***************************/
|
||||||
/**
|
/**
|
||||||
* @brief AlignmentTextsGroupCommand::AlignmentTextsGroupCommand
|
@brief AlignmentTextsGroupCommand::AlignmentTextsGroupCommand
|
||||||
* @param group : Group to change the alignment
|
@param group : Group to change the alignment
|
||||||
* @param new_alignment : the new alignment of the group
|
@param new_alignment : the new alignment of the group
|
||||||
* @param parent : the parent QUndoCommand of this undo
|
@param parent : the parent QUndoCommand of this undo
|
||||||
*/
|
*/
|
||||||
AlignmentTextsGroupCommand::AlignmentTextsGroupCommand(
|
AlignmentTextsGroupCommand::AlignmentTextsGroupCommand(
|
||||||
ElementTextItemGroup *group,
|
ElementTextItemGroup *group,
|
||||||
@@ -361,17 +406,17 @@ AlignmentTextsGroupCommand::AlignmentTextsGroupCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AlignmentTextsGroupCommand::~AlignmentTextsGroupCommand
|
@brief AlignmentTextsGroupCommand::~AlignmentTextsGroupCommand
|
||||||
* Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
AlignmentTextsGroupCommand::~AlignmentTextsGroupCommand()
|
AlignmentTextsGroupCommand::~AlignmentTextsGroupCommand()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AlignmentTextsGroupCommand::mergeWith
|
@brief AlignmentTextsGroupCommand::mergeWith
|
||||||
* Try to merge this command with other command
|
Try to merge this command with other command
|
||||||
* @param other
|
@param other
|
||||||
* @return true if was merged, else false
|
@return true if was merged, else false
|
||||||
*/
|
*/
|
||||||
bool AlignmentTextsGroupCommand::mergeWith(const QUndoCommand *other)
|
bool AlignmentTextsGroupCommand::mergeWith(const QUndoCommand *other)
|
||||||
{
|
{
|
||||||
@@ -388,7 +433,7 @@ bool AlignmentTextsGroupCommand::mergeWith(const QUndoCommand *other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AlignmentTextsGroupCommand::undo
|
@brief AlignmentTextsGroupCommand::undo
|
||||||
*/
|
*/
|
||||||
void AlignmentTextsGroupCommand::undo()
|
void AlignmentTextsGroupCommand::undo()
|
||||||
{
|
{
|
||||||
@@ -409,7 +454,7 @@ void AlignmentTextsGroupCommand::undo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AlignmentTextsGroupCommand::redo
|
@brief AlignmentTextsGroupCommand::redo
|
||||||
*/
|
*/
|
||||||
void AlignmentTextsGroupCommand::redo()
|
void AlignmentTextsGroupCommand::redo()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class DynamicElementTextItem;
|
|||||||
class ElementTextItemGroup;
|
class ElementTextItemGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The AddElementTextCommand class
|
@brief The AddElementTextCommand class
|
||||||
* Manage the adding of element text
|
Manage the adding of element text
|
||||||
*/
|
*/
|
||||||
class AddElementTextCommand : public QUndoCommand
|
class AddElementTextCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
@@ -47,8 +47,8 @@ class AddElementTextCommand : public QUndoCommand
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The AddTextsGroupCommand class
|
@brief The AddTextsGroupCommand class
|
||||||
* Manage the adding of a texts group
|
Manage the adding of a texts group
|
||||||
*/
|
*/
|
||||||
class AddTextsGroupCommand : public QUndoCommand
|
class AddTextsGroupCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
@@ -78,8 +78,8 @@ class AddTextsGroupCommand : public QUndoCommand
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The RemoveTextsGroupCommand class
|
@brief The RemoveTextsGroupCommand class
|
||||||
* Manage the removinf of a texts group
|
Manage the removinf of a texts group
|
||||||
*/
|
*/
|
||||||
class RemoveTextsGroupCommand : public QUndoCommand
|
class RemoveTextsGroupCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
@@ -98,6 +98,9 @@ class RemoveTextsGroupCommand : public QUndoCommand
|
|||||||
QList<QPointer<DynamicElementTextItem>> m_text_list;
|
QList<QPointer<DynamicElementTextItem>> m_text_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The AddTextToGroupCommand class
|
||||||
|
*/
|
||||||
class AddTextToGroupCommand : public QUndoCommand
|
class AddTextToGroupCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -115,6 +118,9 @@ class AddTextToGroupCommand : public QUndoCommand
|
|||||||
QPointer<Element> m_element;
|
QPointer<Element> m_element;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The RemoveTextFromGroupCommand class
|
||||||
|
*/
|
||||||
class RemoveTextFromGroupCommand : public QUndoCommand
|
class RemoveTextFromGroupCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -132,6 +138,9 @@ class RemoveTextFromGroupCommand : public QUndoCommand
|
|||||||
QPointer<Element> m_element;
|
QPointer<Element> m_element;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The AlignmentTextsGroupCommand class
|
||||||
|
*/
|
||||||
class AlignmentTextsGroupCommand : public QUndoCommand
|
class AlignmentTextsGroupCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user