QElectroTech  0.70
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
PartText Class Reference

#include <parttext.h>

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)
 

Public Member Functions

 PartText (QETElementEditor *, QGraphicsItem *=nullptr)
 
 ~PartText () override
 Destructeur. More...
 
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)
 
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)
 
- Public Member Functions inherited from CustomElementPart
 CustomElementPart (QETElementEditor *editor)
 
virtual ~CustomElementPart ()
 Destructor. More...
 
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
 
void focusOutEvent (QFocusEvent *) override
 
void keyPressEvent (QKeyEvent *) override
 
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
 

Private Member Functions

 PartText (const PartText &)
 
QPointF margin () const
 

Private Attributes

QString previous_text
 
qreal real_font_size_
 
QPointF saved_point_
 
qreal saved_font_size_
 
QGraphicsItem * decorator_
 
QPointF m_origine_pos
 

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.

Definition at line 29 of file parttext.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 53 of file parttext.h.

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

Definition at line 30 of file parttext.cpp.

References adjustItemPosition(), QETApp::diagramTextsFont(), font, real_font_size_, setDefaultTextColor(), setFont(), setPlainText(), and QET::Icons::tr.

◆ ~PartText()

PartText::~PartText ( )
override

Destructeur.

Definition at line 51 of file parttext.cpp.

◆ PartText() [2/2]

PartText::PartText ( const PartText )
private

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

Definition at line 304 of file parttext.cpp.

References margin().

Referenced by PartText().

◆ boundingRect()

QRectF PartText::boundingRect ( ) const
overrideprotected
Returns
le rectangle delimitant cette partie.

Definition at line 188 of file parttext.cpp.

◆ colorChanged

void PartText::colorChanged ( const QColor &  color)
signal

◆ endEdition

void PartText::endEdition ( )
slot

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

Definition at line 341 of file parttext.cpp.

References previous_text, setEditable(), QET::Icons::tr, and CustomElementPart::undoStack().

Referenced by focusOutEvent(), and keyPressEvent().

◆ focusInEvent()

void PartText::focusInEvent ( QFocusEvent *  e)
overrideprotected

QGraphicsItem::focusInEvent(QFocusEvent *)

Parameters
eThe QFocusEvent object describing the focus gain. Start text edition when the item gains focus.

Definition at line 128 of file parttext.cpp.

References startEdition().

◆ focusOutEvent()

void PartText::focusOutEvent ( QFocusEvent *  e)
overrideprotected

QGraphicsItem::focusOutEvent(QFocusEvent *)

Parameters
eThe QFocusEvent object describing the focus loss. End text edition when the item loses focus.

Definition at line 139 of file parttext.cpp.

References endEdition().

◆ fontChanged

void PartText::fontChanged ( const QFont &  font)
signal

Referenced by setFont(), and TextEditor::setPart().

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

Definition at line 58 of file parttext.cpp.

References font, setDefaultTextColor(), setFont(), setPlainText(), and setRotation().

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

Definition at line 226 of file parttext.cpp.

References CustomElementPart::mapPoints(), saved_font_size_, saved_point_, and setProperty().

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

Definition at line 199 of file parttext.cpp.

◆ 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

Definition at line 174 of file parttext.cpp.

References CustomElementPart::updateCurrentPartEditor().

◆ keyPressEvent()

void PartText::keyPressEvent ( QKeyEvent *  event)
overrideprotected

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

Definition at line 149 of file parttext.cpp.

References endEdition().

◆ margin()

QPointF PartText::margin ( ) const
private
Returns
Les coordonnees du point situe en bas a gauche du texte.

Definition at line 108 of file parttext.cpp.

References font.

Referenced by adjustItemPosition().

◆ 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

Definition at line 162 of file parttext.cpp.

References setEditable().

◆ mouseMoveEvent()

void PartText::mouseMoveEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

Definition at line 265 of file parttext.cpp.

References CustomElementPart::elementScene(), and m_origine_pos.

◆ mousePressEvent()

void PartText::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

Definition at line 276 of file parttext.cpp.

References m_origine_pos.

◆ mouseReleaseEvent()

void PartText::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

◆ name()

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

Implements CustomElementPart.

Definition at line 60 of file parttext.h.

References QET::Icons::tr.

Referenced by property(), setProperty(), and toXml().

◆ plainTextChanged

void PartText::plainTextChanged ( const QString &  text)
signal

◆ property()

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

Get the current value of a specific primitive property

Implements CustomElementPart.

Definition at line 71 of file parttext.h.

References name().

◆ realSize()

qreal PartText::realSize ( ) const
inline

Definition at line 73 of file parttext.h.

References real_font_size_.

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

Definition at line 209 of file parttext.cpp.

◆ setDefaultTextColor()

void PartText::setDefaultTextColor ( const QColor &  color)

Definition at line 237 of file parttext.cpp.

References color, and colorChanged().

Referenced by fromXml(), and PartText().

◆ setEditable

void PartText::setEditable ( bool  editable)
slot
Parameters
editableWhether this text item should be interactively editable.

Definition at line 317 of file parttext.cpp.

Referenced by endEdition(), and mouseDoubleClickEvent().

◆ setFont()

void PartText::setFont ( const QFont &  font)

Definition at line 255 of file parttext.cpp.

References font, and fontChanged().

Referenced by fromXml(), and PartText().

◆ setPlainText()

void PartText::setPlainText ( const QString &  text)

Definition at line 246 of file parttext.cpp.

References plainTextChanged(), and text.

Referenced by fromXml(), and PartText().

◆ setProperty()

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

Set a specific property of the primitive

Implements CustomElementPart.

Definition at line 70 of file parttext.h.

References name().

Referenced by handleUserTransformation().

◆ setRealSize()

void PartText::setRealSize ( qreal  rs)
inline

Definition at line 74 of file parttext.h.

References real_font_size_.

◆ setRotation()

void PartText::setRotation ( qreal  angle)
inline

Definition at line 64 of file parttext.h.

References QET::correctAngle().

Referenced by fromXml().

◆ startEdition

void PartText::startEdition ( )
slot

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

Definition at line 332 of file parttext.cpp.

References previous_text.

Referenced by focusInEvent().

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

Definition at line 217 of file parttext.cpp.

References real_font_size_, saved_font_size_, and saved_point_.

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

Definition at line 91 of file parttext.cpp.

References font, name(), and xmlName().

◆ type()

int PartText::type ( ) const
inlineoverride

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

Returns
the QGraphicsItem type

Definition at line 59 of file parttext.h.

References Type.

◆ xmlName()

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

Implements CustomElementPart.

Definition at line 61 of file parttext.h.

Referenced by toXml().

Member Data Documentation

◆ decorator_

QGraphicsItem* PartText::decorator_
private

Definition at line 102 of file parttext.h.

◆ m_origine_pos

QPointF PartText::m_origine_pos
private

Definition at line 103 of file parttext.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ previous_text

QString PartText::previous_text
private

Definition at line 98 of file parttext.h.

Referenced by endEdition(), and startEdition().

◆ real_font_size_

qreal PartText::real_font_size_
private

Definition at line 99 of file parttext.h.

Referenced by PartText(), realSize(), setRealSize(), and startUserTransformation().

◆ saved_font_size_

qreal PartText::saved_font_size_
private

Definition at line 101 of file parttext.h.

Referenced by handleUserTransformation(), and startUserTransformation().

◆ saved_point_

QPointF PartText::saved_point_
private

Definition at line 100 of file parttext.h.

Referenced by handleUserTransformation(), and startUserTransformation().

Property Documentation

◆ color

QColor PartText::color
readwrite

Definition at line 34 of file parttext.h.

Referenced by setDefaultTextColor().

◆ font

QFont PartText::font
readwrite

Definition at line 36 of file parttext.h.

Referenced by fromXml(), margin(), PartText(), setFont(), and toXml().

◆ real_size

qreal PartText::real_size
readwrite

Definition at line 33 of file parttext.h.

◆ text

QString PartText::text
readwrite

Definition at line 35 of file parttext.h.

Referenced by setPlainText().


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