QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
Public Types | Signals | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | Private Member Functions | Private Attributes | List of all members
DiagramTextItem Class Referenceabstract

#include <diagramtextitem.h>

Inheritance diagram for DiagramTextItem:
Inheritance graph
Collaboration diagram for DiagramTextItem:
Collaboration graph

Public Types

enum  { Type = UserType + 1004 }
 

Signals

void colorChanged (QColor color)
 
void alignmentChanged (Qt::Alignment alignment)
 
void textEdited (const QString &old_str, const QString &new_str)
 
void fontChanged (QFont font)
 

Public Member Functions

 DiagramTextItem (QGraphicsItem *=nullptr)
 DiagramTextItem::DiagramTextItem.
 
 DiagramTextItem (const QString &, QGraphicsItem *=nullptr)
 DiagramTextItem::DiagramTextItem.
 
int type () const override
 
Diagramdiagram () const
 DiagramTextItem::diagram.
 
virtual void fromXml (const QDomElement &)=0
 
virtual QDomElement toXml (QDomDocument &) const
 DiagramTextItem::toXml This method do nothing and return an empty DomElement This is used to be inherited by child class.
 
void edit ()
 Edit the text with HtmlEditor.
 
QPointF mapMovementToScene (const QPointF &) const
 
QPointF mapMovementFromScene (const QPointF &) const
 
QPointF mapMovementToParent (const QPointF &) const
 
QPointF mapMovementFromParent (const QPointF &) const
 
void setFont (const QFont &font)
 
void setColor (const QColor &color)
 
QColor color () const
 
void setNoEditable (bool e=true)
 
void setAlignment (const Qt::Alignment &alignment)
 
Qt::Alignment alignment () const
 
QRectF frameRect () const
 DiagramTextItem::frameRect.
 
void setHtml (const QString &text)
 
void setPlainText (const QString &text)
 
bool isHtml () const
 

Public Attributes

bool m_block_alignment = false
 

Protected Member Functions

void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override
 DiagramTextItem::paint Draw this text field. This method draws the text by calling QGraphicsTextItem::paint. If text is hovered, this method draws the bounding rect in grey.
 
void focusInEvent (QFocusEvent *) override
 DiagramTextItem::focusInEvent.
 
void focusOutEvent (QFocusEvent *) override
 DiagramTextItem::focusOutEvent.
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
 
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 DiagramTextItem::mousePressEvent.
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 DiagramTextItem::mouseMoveEvent.
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 DiagramTextItem::mouseReleaseEvent.
 
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override
 
void hoverMoveEvent (QGraphicsSceneHoverEvent *) override
 
virtual void applyRotation (const qreal &)
 
void prepareAlignment ()
 DiagramTextItem::prepareAlignment Call this function before changing the bounding rect of this text.
 
void finishAlignment ()
 DiagramTextItem::finishAlignment Call this function after changing the bounding rect of this text to set the position of this text according to the alignment property.
 

Protected Attributes

bool m_mouse_hover = false
 
bool m_first_move = true
 
bool m_no_editable
 
bool m_is_html = false
 
QString m_previous_html_text
 
QString m_previous_text
 
QPointF m_mouse_to_origin_movement
 

Properties

QColor color
 
Qt::Alignment alignment
 
QString plainText
 
QFont font
 

Private Member Functions

void build ()
 DiagramTextItem::build Build this item with default value.
 

Private Attributes

QRectF m_alignment_rect
 
Qt::Alignment m_alignment = (Qt::AlignTop | Qt::AlignLeft)
 

Detailed Description

This class represents a selectable, movable and editable text field on a diagram.

See also
QGraphicsItem::GraphicsItemFlags

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Constructor & Destructor Documentation

◆ DiagramTextItem() [1/2]

DiagramTextItem::DiagramTextItem ( QGraphicsItem *  parent = nullptr)

DiagramTextItem::DiagramTextItem.

Parameters
parent: parent item
Here is the call graph for this function:

◆ DiagramTextItem() [2/2]

DiagramTextItem::DiagramTextItem ( const QString &  text,
QGraphicsItem *  parent = nullptr 
)

DiagramTextItem::DiagramTextItem.

Parameters
text: text to display
parent: parent item
Here is the call graph for this function:

Member Function Documentation

◆ alignment()

Qt::Alignment DiagramTextItem::alignment ( ) const

◆ alignmentChanged

void DiagramTextItem::alignmentChanged ( Qt::Alignment  alignment)
signal
Here is the caller graph for this function:

◆ applyRotation()

void DiagramTextItem::applyRotation ( const qreal &  angle)
protectedvirtual

Effectue la rotation du texte en elle-meme Pour les DiagramTextItem, la rotation s'effectue autour du point (0, 0). Cette methode peut toutefois etre redefinie dans des classes filles

Parameters
angleAngle de la rotation a effectuer
Here is the call graph for this function:

◆ build()

void DiagramTextItem::build ( )
private

DiagramTextItem::build Build this item with default value.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ color()

QColor DiagramTextItem::color ( ) const

◆ colorChanged

void DiagramTextItem::colorChanged ( QColor  color)
signal
Here is the caller graph for this function:

◆ diagram()

Diagram * DiagramTextItem::diagram ( ) const

DiagramTextItem::diagram.

Returns
The diagram of this item or 0 if this text isn't in a diagram
Here is the caller graph for this function:

◆ edit()

void DiagramTextItem::edit ( )

Edit the text with HtmlEditor.

Here is the call graph for this function:

◆ finishAlignment()

void DiagramTextItem::finishAlignment ( )
protected

DiagramTextItem::finishAlignment Call this function after changing the bounding rect of this text to set the position of this text according to the alignment property.

Here is the caller graph for this function:

◆ focusInEvent()

void DiagramTextItem::focusInEvent ( QFocusEvent *  event)
overrideprotected

DiagramTextItem::focusInEvent.

Parameters
event

◆ focusOutEvent()

void DiagramTextItem::focusOutEvent ( QFocusEvent *  event)
overrideprotected

DiagramTextItem::focusOutEvent.

Parameters
event
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fontChanged

void DiagramTextItem::fontChanged ( QFont  font)
signal
Here is the caller graph for this function:

◆ frameRect()

QRectF DiagramTextItem::frameRect ( ) const

DiagramTextItem::frameRect.

Returns
the rect used to draw a frame around this text
Here is the caller graph for this function:

◆ fromXml()

virtual void DiagramTextItem::fromXml ( const QDomElement &  )
pure virtual

◆ hoverEnterEvent()

void DiagramTextItem::hoverEnterEvent ( QGraphicsSceneHoverEvent *  e)
overrideprotected

When mouse over element change m_mouse_hover to true (used in paint() function )

Parameters
eQGraphicsSceneHoverEvent
Here is the caller graph for this function:

◆ hoverLeaveEvent()

void DiagramTextItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  e)
overrideprotected

When mouse over element leave the position change m_mouse_hover to false (used in paint() function )

Parameters
eQGraphicsSceneHoverEvent
Here is the caller graph for this function:

◆ hoverMoveEvent()

void DiagramTextItem::hoverMoveEvent ( QGraphicsSceneHoverEvent *  e)
overrideprotected

Do nothing default function .

Parameters
eQGraphicsSceneHoverEvent

◆ isHtml()

bool DiagramTextItem::isHtml ( ) const

◆ mapMovementFromParent()

QPointF DiagramTextItem::mapMovementFromParent ( const QPointF &  movement) const

Traduit en coordonnees locales un mouvement / vecteur initialement exprime en coordonnees du parent.

Parameters
movementVecteur exprime en coordonnees du parent
Returns
le meme vecteur, exprime en coordonnees locales

◆ mapMovementFromScene()

QPointF DiagramTextItem::mapMovementFromScene ( const QPointF &  movement) const

Traduit en coordonnees locales un mouvement / vecteur initialement exprime en coordonnees de la scene.

Parameters
movementVecteur exprime en coordonnees de la scene
Returns
le meme vecteur, exprime en coordonnees locales

◆ mapMovementToParent()

QPointF DiagramTextItem::mapMovementToParent ( const QPointF &  movement) const

Traduit en coordonnees de l'item parent un mouvement / vecteur initialement exprime en coordonnees locales.

Parameters
movementVecteur exprime en coordonnees locales
Returns
le meme vecteur, exprime en coordonnees du parent

◆ mapMovementToScene()

QPointF DiagramTextItem::mapMovementToScene ( const QPointF &  movement) const

Traduit en coordonnees de la scene un mouvement / vecteur initialement exprime en coordonnees locales.

Parameters
movementVecteur exprime en coordonnees locales
Returns
le meme vecteur, exprime en coordonnees de la scene

◆ mouseDoubleClickEvent()

void DiagramTextItem::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

Gere les double-clics sur ce champ de texte.

Parameters
eventun QGraphicsSceneMouseEvent decrivant le double-clic
Here is the caller graph for this function:

◆ mouseMoveEvent()

void DiagramTextItem::mouseMoveEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

DiagramTextItem::mouseMoveEvent.

Parameters
event
Here is the call graph for this function:

◆ mousePressEvent()

void DiagramTextItem::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

DiagramTextItem::mousePressEvent.

Parameters
event
Here is the caller graph for this function:

◆ mouseReleaseEvent()

void DiagramTextItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

DiagramTextItem::mouseReleaseEvent.

Parameters
event
Here is the call graph for this function:

◆ paint()

void DiagramTextItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)
overrideprotected

DiagramTextItem::paint Draw this text field. This method draws the text by calling QGraphicsTextItem::paint. If text is hovered, this method draws the bounding rect in grey.

Parameters
painter: painter to use
option: style option
widget: widget that is drawn to
Here is the caller graph for this function:

◆ prepareAlignment()

void DiagramTextItem::prepareAlignment ( )
protected

DiagramTextItem::prepareAlignment Call this function before changing the bounding rect of this text.

Here is the caller graph for this function:

◆ setAlignment()

void DiagramTextItem::setAlignment ( const Qt::Alignment &  alignment)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setColor()

void DiagramTextItem::setColor ( const QColor &  color)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFont()

void DiagramTextItem::setFont ( const QFont &  font)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHtml()

void DiagramTextItem::setHtml ( const QString &  text)
Here is the caller graph for this function:

◆ setNoEditable()

void DiagramTextItem::setNoEditable ( bool  e = true)
inline
Here is the caller graph for this function:

◆ setPlainText()

void DiagramTextItem::setPlainText ( const QString &  text)
Here is the caller graph for this function:

◆ textEdited

void DiagramTextItem::textEdited ( const QString &  old_str,
const QString &  new_str 
)
signal
Here is the caller graph for this function:

◆ toXml()

QDomElement DiagramTextItem::toXml ( QDomDocument &  ) const
virtual

DiagramTextItem::toXml This method do nothing and return an empty DomElement This is used to be inherited by child class.

Returns

Reimplemented in IndependentTextItem, and DynamicElementTextItem.

◆ type()

int DiagramTextItem::type ( ) const
inlineoverride

Member Data Documentation

◆ m_alignment

Qt::Alignment DiagramTextItem::m_alignment = (Qt::AlignTop | Qt::AlignLeft)
private

◆ m_alignment_rect

QRectF DiagramTextItem::m_alignment_rect
private

◆ m_block_alignment

bool DiagramTextItem::m_block_alignment = false

◆ m_first_move

bool DiagramTextItem::m_first_move = true
protected

◆ m_is_html

bool DiagramTextItem::m_is_html = false
protected

◆ m_mouse_hover

bool DiagramTextItem::m_mouse_hover = false
protected

◆ m_mouse_to_origin_movement

QPointF DiagramTextItem::m_mouse_to_origin_movement
protected

◆ m_no_editable

bool DiagramTextItem::m_no_editable
protected

◆ m_previous_html_text

QString DiagramTextItem::m_previous_html_text
protected

◆ m_previous_text

QString DiagramTextItem::m_previous_text
protected

Property Documentation

◆ alignment

Qt::Alignment DiagramTextItem::alignment
readwrite

◆ color

QColor DiagramTextItem::color
readwrite

◆ font

QFont DiagramTextItem::font
readwrite

◆ plainText

QString DiagramTextItem::plainText
readwrite

The documentation for this class was generated from the following files: