QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
PartText Class Reference

#include <parttext.h>

Inheritance diagram for PartText:
Inheritance graph
Collaboration diagram for PartText:
Collaboration graph

Public Types

enum  { Type = UserType + 1107 }

Public Slots

void adjustItemPosition (int=0)
void setEditable (bool)
void startEdition ()
void endEdition ()

Signals

void fontChanged (const QFont &font)
void colorChanged (const QColor &color)
void plainTextChanged (const QString &text)
void alignmentChanged (Qt::Alignment alignment)

Public Member Functions

 PartText (QETElementEditor *, QGraphicsItem *=nullptr)
 ~PartText () override
 Destructeur.
int type () const override
QString name () const override
QString xmlName () const override
void fromXml (const QDomElement &) override
const QDomElement toXml (QDomDocument &) const override
void setRotation (qreal angle)
void mirror (qreal axis_x=0)
void flip (qreal axis_y=0)
bool isUseless () const override
QRectF sceneGeometricRect () const override
void startUserTransformation (const QRectF &) override
void handleUserTransformation (const QRectF &, const QRectF &) override
void setProperty (const char *name, const QVariant &value) override
QVariant property (const char *name) const override
qreal realSize () const
void setRealSize (qreal rs)
void setDefaultTextColor (const QColor &color)
void setPlainText (const QString &text)
void setFont (const QFont &font)
void setAlignment (const Qt::Alignment &alignment)
 PartText::setAlignment Set how this text is anchored to its position: when the content later changes, the given corner/center of the bounding rect keeps its place (the historical behaviour, and the default, is top-left). The horizontal part also aligns the lines of a multi-line text relative to each other. Changing the alignment never moves the text itself.
Qt::Alignment alignment () const
Public Member Functions inherited from CustomElementPart
 CustomElementPart (QETElementEditor *editor)
 CustomElementPart Constructor.
virtual ~CustomElementPart ()
 ~CustomElementPart Destructor
virtual QETElementEditorelementEditor () const
virtual void updateCurrentPartEditor () const
virtual ElementSceneelementScene () const
virtual QUndoStack & undoStack () const
virtual QGraphicsItem * toItem ()
virtual QET::ScalingMethod preferredScalingMethod () const

Protected Member Functions

void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
void focusInEvent (QFocusEvent *) override
 PartText::focusInEvent.
void focusOutEvent (QFocusEvent *) override
 PartText::focusOutEvent.
void keyPressEvent (QKeyEvent *) override
 PartText::keyPressEvent Used to handle the escape key when the event is delivered to the field, not to the decorator.
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *) override
QVariant itemChange (GraphicsItemChange, const QVariant &) override
QRectF boundingRect () const override
Protected Member Functions inherited from CustomElementPart
QList< QPointF > mapPoints (const QRectF &, const QRectF &, const QList< QPointF > &)

Properties

qreal real_size
QColor color
QString text
QFont font
Qt::Alignment alignment

Private Member Functions

 PartText (const PartText &)
QPointF margin () const
void applyLineAlignment ()
 PartText::applyLineAlignment Align the lines of a multi-line text relative to each other according to the horizontal part of the alignment property. QGraphicsTextItem only honors the document text option when a text width is set, hence the idealWidth() dance; -1 restores the free (historical) layout.
void prepareAlignment ()
 PartText::prepareAlignment Call before a change of the bounding rect (see finishAlignment).
void finishAlignment ()
 PartText::finishAlignment Call after a change of the bounding rect: moves the text so that the point selected by the alignment property stays where it was (same logic as DiagramTextItem::finishAlignment).

Private Attributes

QString previous_text
qreal real_font_size_
QPointF saved_point_
qreal saved_font_size_
QGraphicsItem * decorator_
QPointF m_origin_pos
Qt::Alignment m_alignment = (Qt::AlignTop | Qt::AlignLeft)
QRectF m_alignment_rect

Detailed Description

This class represents an static text primitive which may be used to compose the drawing of an electrical element within the element editor.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Constructor & Destructor Documentation

◆ PartText() [1/2]

PartText::PartText ( QETElementEditor * editor,
QGraphicsItem * parent = nullptr )

Constructeur

Parameters
editorL'editeur d'element concerne
parentLe QGraphicsItem parent de ce texte statique
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~PartText()

PartText::~PartText ( )
override

Destructeur.

◆ PartText() [2/2]

PartText::PartText ( const PartText & )
private
Here is the call graph for this function:

Member Function Documentation

◆ adjustItemPosition

void PartText::adjustItemPosition ( int new_block_count = 0)
slot

Cette methode s'assure que la position du champ de texte est coherente en repositionnant son origine (c-a-d le milieu du bord gauche du champ de texte) a la position originale. Cela est notamment utile lorsque le champ de texte est agrandi ou retreci verticalement (ajout ou retrait de lignes).

Parameters
new_block_countNombre de blocs dans le PartText
Here is the call graph for this function:
Here is the caller graph for this function:

◆ alignment()

Qt::Alignment PartText::alignment ( ) const
inline

◆ alignmentChanged

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

◆ applyLineAlignment()

void PartText::applyLineAlignment ( )
private

PartText::applyLineAlignment Align the lines of a multi-line text relative to each other according to the horizontal part of the alignment property. QGraphicsTextItem only honors the document text option when a text width is set, hence the idealWidth() dance; -1 restores the free (historical) layout.

Here is the caller graph for this function:

◆ boundingRect()

QRectF PartText::boundingRect ( ) const
overrideprotected
Returns
le rectangle delimitant cette partie.
Here is the caller graph for this function:

◆ colorChanged

void PartText::colorChanged ( const QColor & color)
signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endEdition

void PartText::endEdition ( )
slot

End text edition, potentially generating a ChangePartCommand if the text has changed.

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

◆ finishAlignment()

void PartText::finishAlignment ( )
private

PartText::finishAlignment Call after a change of the bounding rect: moves the text so that the point selected by the alignment property stays where it was (same logic as DiagramTextItem::finishAlignment).

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

◆ flip()

void PartText::flip ( qreal axis_y = 0)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ focusInEvent()

void PartText::focusInEvent ( QFocusEvent * e)
overrideprotected

PartText::focusInEvent.

Parameters
e: The QFocusEvent object describing the focus gain. Start text edition when the item gains focus.
See also
QGraphicsItem::focusInEvent(QFocusEvent *)
Here is the call graph for this function:

◆ focusOutEvent()

void PartText::focusOutEvent ( QFocusEvent * e)
overrideprotected

PartText::focusOutEvent.

Parameters
e: The QFocusEvent object describing the focus loss. End text edition when the item loses focus.
See also
QGraphicsItem::focusOutEvent(QFocusEvent *)
Here is the call graph for this function:

◆ fontChanged

void PartText::fontChanged ( const QFont & font)
signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromXml()

void PartText::fromXml ( const QDomElement & xml_element)
overridevirtual

Importe les proprietes d'un texte statique depuis un element XML

Parameters
xml_elementElement XML a lire

Implements CustomElementPart.

Here is the call graph for this function:

◆ handleUserTransformation()

void PartText::handleUserTransformation ( const QRectF & initial_selection_rect,
const QRectF & new_selection_rect )
overridevirtual

Handle the user-induced transformation from initial_selection_rect to new_selection_rect

Implements CustomElementPart.

Here is the call graph for this function:

◆ isUseless()

bool PartText::isUseless ( ) const
overridevirtual
Returns
true si cette partie n'est pas pertinente et ne merite pas d'etre conservee / enregistree. Un texte statique n'est pas pertinent lorsque son texte est vide.

Implements CustomElementPart.

◆ itemChange()

QVariant PartText::itemChange ( GraphicsItemChange change,
const QVariant & value )
overrideprotected

Gere les changements intervenant sur cette partie

Parameters
changeType de changement
valueValeur numerique relative au changement
Here is the call graph for this function:

◆ keyPressEvent()

void PartText::keyPressEvent ( QKeyEvent * event)
overrideprotected

PartText::keyPressEvent Used to handle the escape key when the event is delivered to the field, not to the decorator.

Parameters
event
See also
QGraphicsTextItem::keyPressEvent()
Here is the call graph for this function:

◆ margin()

QPointF PartText::margin ( ) const
private
Returns
Les coordonnees du point situe en bas a gauche du texte. The coordinates of the point at the bottom left of the text.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mirror()

void PartText::mirror ( qreal axis_x = 0)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void PartText::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * e)
overrideprotected

Permet a l'element texte de devenir editable lorsqu'on double-clique dessus

Parameters
eLe QGraphicsSceneMouseEvent qui decrit le double-clic
Here is the call graph for this function:

◆ mouseMoveEvent()

void PartText::mouseMoveEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected
Here is the call graph for this function:

◆ mousePressEvent()

void PartText::mousePressEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected

◆ mouseReleaseEvent()

void PartText::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected
Here is the call graph for this function:

◆ name()

QString PartText::name ( ) const
inlineoverridevirtual
Returns
the name of the primitive

Implements CustomElementPart.

Here is the caller graph for this function:

◆ plainTextChanged

void PartText::plainTextChanged ( const QString & text)
signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepareAlignment()

void PartText::prepareAlignment ( )
private

PartText::prepareAlignment Call before a change of the bounding rect (see finishAlignment).

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

◆ property()

QVariant PartText::property ( const char * name) const
inlineoverridevirtual

Get the current value of a specific primitive property

Implements CustomElementPart.

Here is the call graph for this function:

◆ realSize()

qreal PartText::realSize ( ) const
inline
Here is the caller graph for this function:

◆ sceneGeometricRect()

QRectF PartText::sceneGeometricRect ( ) const
overridevirtual
Returns
the minimum, margin-less rectangle this part can fit into, in scene coordinates. It is different from boundingRect() because it is not supposed to imply any margin, and it is different from shape because it is a regular rectangle, not a complex shape.

Implements CustomElementPart.

◆ setAlignment()

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

PartText::setAlignment Set how this text is anchored to its position: when the content later changes, the given corner/center of the bounding rect keeps its place (the historical behaviour, and the default, is top-left). The horizontal part also aligns the lines of a multi-line text relative to each other. Changing the alignment never moves the text itself.

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

◆ setDefaultTextColor()

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

◆ setEditable

void PartText::setEditable ( bool editable)
slot
Parameters
editableWhether this text item should be interactively editable.
Here is the caller graph for this function:

◆ setFont()

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

◆ setPlainText()

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

◆ setProperty()

void PartText::setProperty ( const char * name,
const QVariant & value )
inlineoverridevirtual

Set a specific property of the primitive

Implements CustomElementPart.

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

◆ setRealSize()

void PartText::setRealSize ( qreal rs)
inline

◆ setRotation()

void PartText::setRotation ( qreal angle)

Redefines setRotation

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

◆ startEdition

void PartText::startEdition ( )
slot

Start text edition by storing the former value of the text.

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

◆ startUserTransformation()

void PartText::startUserTransformation ( const QRectF & rect)
overridevirtual

Start the user-induced transformation, provided this primitive is contained within the rect bounding rectangle.

Implements CustomElementPart.

◆ toXml()

const QDomElement PartText::toXml ( QDomDocument & xml_document) const
overridevirtual

Exporte le texte statique en XML

Parameters
xml_documentDocument XML a utiliser pour creer l'element XML
Returns
un element XML decrivant le texte statique

Implements CustomElementPart.

Here is the call graph for this function:

◆ type()

int PartText::type ( ) const
inlineoverride

Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartText.

Returns
the QGraphicsItem type

◆ xmlName()

QString PartText::xmlName ( ) const
inlineoverridevirtual
Returns
the name that will be used as XML tag when exporting the primitive

Implements CustomElementPart.

Here is the caller graph for this function:

Member Data Documentation

◆ decorator_

QGraphicsItem* PartText::decorator_
private

◆ m_alignment

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

◆ m_alignment_rect

QRectF PartText::m_alignment_rect
private

◆ m_origin_pos

QPointF PartText::m_origin_pos
private

◆ previous_text

QString PartText::previous_text
private

◆ real_font_size_

qreal PartText::real_font_size_
private

◆ saved_font_size_

qreal PartText::saved_font_size_
private

◆ saved_point_

QPointF PartText::saved_point_
private

Property Documentation

◆ alignment

Qt::Alignment PartText::alignment
readwrite

◆ color

QColor PartText::color
readwrite

◆ font

QFont PartText::font
readwrite

◆ real_size

qreal PartText::real_size
readwrite

◆ text

QString PartText::text
readwrite

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