QElectroTech  0.70
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>

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. More...
 
 DiagramTextItem (const QString &, QGraphicsItem *=nullptr)
 DiagramTextItem::DiagramTextItem. More...
 
int type () const override
 
Diagramdiagram () const
 DiagramTextItem::diagram. More...
 
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. More...
 
void edit ()
 Edit the text with HtmlEditor. More...
 
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. More...
 
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 draw the text by calling QGraphicsTextItem::paint. If text is hovered, this method draw the bounding rect in grey. More...
 
void focusInEvent (QFocusEvent *) override
 DiagramTextItem::focusInEvent. More...
 
void focusOutEvent (QFocusEvent *) override
 DiagramTextItem::focusOutEvent. More...
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
 
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 DiagramTextItem::mousePressEvent. More...
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 DiagramTextItem::mouseMoveEvent. More...
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 DiagramTextItem::mouseReleaseEvent. More...
 
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. More...
 
void finishAlignment ()
 DiagramTextItem::finishAlignment Call this function after changing the bouding rect of this text to set the position of this text according to the alignment property. More...
 

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. More...
 

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

Definition at line 33 of file diagramtextitem.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 57 of file diagramtextitem.h.

Constructor & Destructor Documentation

◆ DiagramTextItem() [1/2]

DiagramTextItem::DiagramTextItem ( QGraphicsItem *  parent = nullptr)

DiagramTextItem::DiagramTextItem.

Parameters
parent: parent item

Definition at line 28 of file diagramtextitem.cpp.

References build().

◆ DiagramTextItem() [2/2]

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

DiagramTextItem::DiagramTextItem.

Parameters
text: text to display
parent: parent item

Definition at line 37 of file diagramtextitem.cpp.

References build().

Member Function Documentation

◆ alignment()

Qt::Alignment DiagramTextItem::alignment ( ) const

◆ alignmentChanged

void DiagramTextItem::alignmentChanged ( Qt::Alignment  alignment)
signal

Referenced by setAlignment().

◆ 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

Definition at line 392 of file diagramtextitem.cpp.

References QET::correctAngle().

◆ build()

void DiagramTextItem::build ( )
private

DiagramTextItem::build Build this item with default value.

Definition at line 47 of file diagramtextitem.cpp.

References QETApp::diagramTextsItemFont(), setFont(), setNoEditable(), and QET::Icons::tr.

Referenced by DiagramTextItem().

◆ color()

QColor DiagramTextItem::color ( ) const

◆ colorChanged

void DiagramTextItem::colorChanged ( QColor  color)
signal

◆ diagram()

Diagram * DiagramTextItem::diagram ( ) const

◆ edit()

void DiagramTextItem::edit ( )

◆ finishAlignment()

void DiagramTextItem::finishAlignment ( )
protected

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

Definition at line 410 of file diagramtextitem.cpp.

References m_alignment, m_alignment_rect, and m_block_alignment.

Referenced by setFont(), and DynamicElementTextItem::setPlainText().

◆ focusInEvent()

void DiagramTextItem::focusInEvent ( QFocusEvent *  event)
overrideprotected

DiagramTextItem::focusInEvent.

Parameters
e

Definition at line 267 of file diagramtextitem.cpp.

References m_previous_html_text, and m_previous_text.

◆ focusOutEvent()

void DiagramTextItem::focusOutEvent ( QFocusEvent *  event)
overrideprotected

DiagramTextItem::focusOutEvent.

Parameters
event

Definition at line 281 of file diagramtextitem.cpp.

References m_previous_text, and textEdited().

Referenced by IndependentTextItem::focusOutEvent().

◆ fontChanged

void DiagramTextItem::fontChanged ( QFont  font)
signal

◆ frameRect()

QRectF DiagramTextItem::frameRect ( ) const

DiagramTextItem::frameRect.

Returns
the rect used to draw a frame around this text

Definition at line 192 of file diagramtextitem.cpp.

Referenced by DynamicElementTextItem::paint().

◆ 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

Definition at line 472 of file diagramtextitem.cpp.

References m_mouse_hover.

Referenced by DynamicElementTextItem::hoverEnterEvent().

◆ 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

Definition at line 486 of file diagramtextitem.cpp.

References m_mouse_hover.

Referenced by DynamicElementTextItem::hoverLeaveEvent().

◆ hoverMoveEvent()

void DiagramTextItem::hoverMoveEvent ( QGraphicsSceneHoverEvent *  e)
overrideprotected

Do nothing default function .

Parameters
eQGraphicsSceneHoverEvent

Definition at line 496 of file diagramtextitem.cpp.

◆ isHtml()

bool DiagramTextItem::isHtml ( ) const

Definition at line 224 of file diagramtextitem.cpp.

References m_is_html.

◆ 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

Definition at line 140 of file diagramtextitem.cpp.

◆ 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

Definition at line 102 of file diagramtextitem.cpp.

◆ 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

Definition at line 121 of file diagramtextitem.cpp.

◆ 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

Definition at line 83 of file diagramtextitem.cpp.

◆ mouseDoubleClickEvent()

void DiagramTextItem::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

Gere les double-clics sur ce champ de texte.

Parameters
eventun QGraphicsSceneMouseEvent decrivant le double-clic

Definition at line 303 of file diagramtextitem.cpp.

References m_no_editable.

Referenced by DynamicElementTextItem::mouseDoubleClickEvent().

◆ mouseMoveEvent()

void DiagramTextItem::mouseMoveEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

◆ mousePressEvent()

void DiagramTextItem::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

◆ mouseReleaseEvent()

void DiagramTextItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

◆ paint()

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

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

Parameters
painter: painter to use
option: style option
widget: widget where must to draw

Definition at line 236 of file diagramtextitem.cpp.

References m_mouse_hover.

Referenced by DynamicElementTextItem::paint().

◆ prepareAlignment()

void DiagramTextItem::prepareAlignment ( )
protected

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

Definition at line 400 of file diagramtextitem.cpp.

References m_alignment_rect.

Referenced by setFont(), and DynamicElementTextItem::setPlainText().

◆ setAlignment()

void DiagramTextItem::setAlignment ( const Qt::Alignment &  alignment)

Definition at line 177 of file diagramtextitem.cpp.

References alignment(), alignmentChanged(), and m_alignment.

Referenced by DynamicElementTextItem::fromXml().

◆ setColor()

void DiagramTextItem::setColor ( const QColor &  color)

Definition at line 167 of file diagramtextitem.cpp.

References color(), and colorChanged().

Referenced by DynamicElementTextItem::fromXml().

◆ setFont()

void DiagramTextItem::setFont ( const QFont &  font)

◆ setHtml()

void DiagramTextItem::setHtml ( const QString &  text)

Definition at line 212 of file diagramtextitem.cpp.

References m_is_html.

Referenced by edit(), IndependentTextItem::fromXml(), and ChangeDiagramTextCommand::redo().

◆ setNoEditable()

void DiagramTextItem::setNoEditable ( bool  e = true)
inline

Definition at line 75 of file diagramtextitem.h.

References m_no_editable.

Referenced by build(), and DynamicElementTextItem::setTextFrom().

◆ setPlainText()

void DiagramTextItem::setPlainText ( const QString &  text)

◆ textEdited

void DiagramTextItem::textEdited ( const QString &  old_str,
const QString &  new_str 
)
signal

◆ 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 DynamicElementTextItem, and IndependentTextItem.

Definition at line 73 of file diagramtextitem.cpp.

◆ type()

int DiagramTextItem::type ( ) const
inlineoverride

Definition at line 58 of file diagramtextitem.h.

References Type.

Member Data Documentation

◆ m_alignment

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

Definition at line 119 of file diagramtextitem.h.

Referenced by finishAlignment(), and setAlignment().

◆ m_alignment_rect

QRectF DiagramTextItem::m_alignment_rect
private

Definition at line 118 of file diagramtextitem.h.

Referenced by finishAlignment(), and prepareAlignment().

◆ m_block_alignment

bool DiagramTextItem::m_block_alignment = false

Definition at line 79 of file diagramtextitem.h.

Referenced by finishAlignment().

◆ m_first_move

bool DiagramTextItem::m_first_move = true
protected

◆ m_is_html

bool DiagramTextItem::m_is_html = false
protected

Definition at line 110 of file diagramtextitem.h.

Referenced by isHtml(), setHtml(), and setPlainText().

◆ 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

Definition at line 108 of file diagramtextitem.h.

Referenced by mouseDoubleClickEvent(), and setNoEditable().

◆ m_previous_html_text

QString DiagramTextItem::m_previous_html_text
protected

Definition at line 112 of file diagramtextitem.h.

Referenced by focusInEvent(), and IndependentTextItem::focusOutEvent().

◆ m_previous_text

QString DiagramTextItem::m_previous_text
protected

Definition at line 112 of file diagramtextitem.h.

Referenced by focusInEvent(), and focusOutEvent().

Property Documentation

◆ alignment

Qt::Alignment DiagramTextItem::alignment
readwrite

◆ color

QColor DiagramTextItem::color
readwrite

◆ font

QFont DiagramTextItem::font
readwrite

◆ plainText

QString DiagramTextItem::plainText
readwrite

Definition at line 39 of file diagramtextitem.h.


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