mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-09 17:09:59 +01:00
Wrap code for better readability
This commit is contained in:
@@ -87,7 +87,8 @@ QRectF AbstractPartEllipse::boundingRect() const
|
||||
and it is different from shape because it is a regular
|
||||
rectangle, not a complex shape.
|
||||
*/
|
||||
QRectF AbstractPartEllipse::sceneGeometricRect() const {
|
||||
QRectF AbstractPartEllipse::sceneGeometricRect() const
|
||||
{
|
||||
return(mapToScene(rect()).boundingRect());
|
||||
}
|
||||
|
||||
@@ -95,7 +96,8 @@ QRectF AbstractPartEllipse::sceneGeometricRect() const {
|
||||
@brief AbstractPartEllipse::sceneTopLeft
|
||||
@return return the top left of rectangle, in scene coordinate
|
||||
*/
|
||||
QPointF AbstractPartEllipse::sceneTopLeft() const {
|
||||
QPointF AbstractPartEllipse::sceneTopLeft() const
|
||||
{
|
||||
return(mapToScene(rect().topLeft()));
|
||||
}
|
||||
|
||||
@@ -103,7 +105,8 @@ QPointF AbstractPartEllipse::sceneTopLeft() const {
|
||||
@brief AbstractPartEllipse::rect
|
||||
Returns the item's ellipse geometry as a QRectF.
|
||||
*/
|
||||
QRectF AbstractPartEllipse::rect() const {
|
||||
QRectF AbstractPartEllipse::rect() const
|
||||
{
|
||||
return m_rect;
|
||||
}
|
||||
|
||||
@@ -131,7 +134,8 @@ void AbstractPartEllipse::setRect(const QRectF &rect)
|
||||
and does not deserve to be Retained / registered.
|
||||
An ellipse is relevant when is rect is not null.
|
||||
*/
|
||||
bool AbstractPartEllipse::isUseless() const {
|
||||
bool AbstractPartEllipse::isUseless() const
|
||||
{
|
||||
return(rect().isNull());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
#include "qetelementeditor.h"
|
||||
|
||||
/// @return le QETElementEditor auquel cet editeur appartient
|
||||
QETElementEditor *CustomElementPart::elementEditor() const {
|
||||
QETElementEditor *CustomElementPart::elementEditor() const
|
||||
{
|
||||
return(element_editor);
|
||||
}
|
||||
|
||||
@@ -27,24 +28,28 @@ QETElementEditor *CustomElementPart::elementEditor() const {
|
||||
Appelle le slot updateCurrentPartEditor de l'editeur
|
||||
@see QETElementEditor::updateCurrentPartEditor()
|
||||
*/
|
||||
void CustomElementPart::updateCurrentPartEditor() const {
|
||||
void CustomElementPart::updateCurrentPartEditor() const
|
||||
{
|
||||
if (element_editor) {
|
||||
element_editor -> updateCurrentPartEditor();
|
||||
}
|
||||
}
|
||||
|
||||
/// @return l'ElementScene contenant les parties editees par cet editeur
|
||||
ElementScene *CustomElementPart::elementScene() const {
|
||||
ElementScene *CustomElementPart::elementScene() const
|
||||
{
|
||||
return(element_editor -> elementScene());
|
||||
}
|
||||
|
||||
/// @return la QUndoStack a utiliser pour les annulations
|
||||
QUndoStack &CustomElementPart::undoStack() const {
|
||||
QUndoStack &CustomElementPart::undoStack() const
|
||||
{
|
||||
return(elementScene() -> undoStack());
|
||||
}
|
||||
|
||||
/// @return this primitive as a QGraphicsItem
|
||||
QGraphicsItem *CustomElementPart::toItem() {
|
||||
QGraphicsItem *CustomElementPart::toItem()
|
||||
{
|
||||
return(dynamic_cast<QGraphicsItem *>(this));
|
||||
}
|
||||
|
||||
@@ -55,7 +60,8 @@ QGraphicsItem *CustomElementPart::toItem() {
|
||||
The default implementation systematically returns
|
||||
QET::SnapScalingPointToGrid
|
||||
*/
|
||||
QET::ScalingMethod CustomElementPart::preferredScalingMethod() const {
|
||||
QET::ScalingMethod CustomElementPart::preferredScalingMethod() const
|
||||
{
|
||||
return(QET::SnapScalingPointToGrid);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,8 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return : an xml element that describe this arc
|
||||
*/
|
||||
const QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
||||
const QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("arc");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
|
||||
@@ -49,11 +49,13 @@ PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsIt
|
||||
document() -> setDefaultTextOption(option);
|
||||
}
|
||||
|
||||
QString PartDynamicTextField::name() const {
|
||||
QString PartDynamicTextField::name() const
|
||||
{
|
||||
return tr("Champ de texte dynamique", "element part name");
|
||||
}
|
||||
|
||||
QString PartDynamicTextField::xmlName() const {
|
||||
QString PartDynamicTextField::xmlName() const
|
||||
{
|
||||
return QString("dynamic_text");
|
||||
}
|
||||
|
||||
@@ -90,7 +92,8 @@ void PartDynamicTextField::handleUserTransformation(
|
||||
@param dom_doc
|
||||
@return
|
||||
*/
|
||||
const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const {
|
||||
const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||
{
|
||||
QDomElement root_element = dom_doc.createElement(xmlName());
|
||||
|
||||
root_element.setAttribute("x", QString::number(pos().x()));
|
||||
@@ -260,7 +263,8 @@ void PartDynamicTextField::fromTextFieldXml(const QDomElement &dom_element)
|
||||
@brief PartDynamicTextField::textFrom
|
||||
@return what the final text is created from.
|
||||
*/
|
||||
DynamicElementTextItem::TextFrom PartDynamicTextField::textFrom() const {
|
||||
DynamicElementTextItem::TextFrom PartDynamicTextField::textFrom() const
|
||||
{
|
||||
return m_text_from;
|
||||
}
|
||||
|
||||
@@ -291,7 +295,8 @@ void PartDynamicTextField::setTextFrom(DynamicElementTextItem::TextFrom text_fro
|
||||
@brief PartDynamicTextField::text
|
||||
@return the text of this text
|
||||
*/
|
||||
QString PartDynamicTextField::text() const {
|
||||
QString PartDynamicTextField::text() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
@@ -337,7 +342,8 @@ void PartDynamicTextField::setCompositeText(const QString &text) {
|
||||
@brief PartDynamicTextField::compositeText
|
||||
@return the composite text of this text
|
||||
*/
|
||||
QString PartDynamicTextField::compositeText() const {
|
||||
QString PartDynamicTextField::compositeText() const
|
||||
{
|
||||
return m_composite_text;
|
||||
}
|
||||
|
||||
@@ -354,7 +360,8 @@ void PartDynamicTextField::setColor(const QColor& color) {
|
||||
@brief PartDynamicTextField::color
|
||||
@return The color of this text
|
||||
*/
|
||||
QColor PartDynamicTextField::color() const {
|
||||
QColor PartDynamicTextField::color() const
|
||||
{
|
||||
return defaultTextColor();
|
||||
}
|
||||
|
||||
@@ -364,7 +371,8 @@ void PartDynamicTextField::setFrame(bool frame) {
|
||||
emit frameChanged(m_frame);
|
||||
}
|
||||
|
||||
bool PartDynamicTextField::frame() const {
|
||||
bool PartDynamicTextField::frame() const
|
||||
{
|
||||
return m_frame;
|
||||
}
|
||||
|
||||
@@ -403,7 +411,8 @@ void PartDynamicTextField::setAlignment(Qt::Alignment alignment) {
|
||||
emit alignmentChanged(m_alignment);
|
||||
}
|
||||
|
||||
Qt::Alignment PartDynamicTextField::alignment() const {
|
||||
Qt::Alignment PartDynamicTextField::alignment() const
|
||||
{
|
||||
return m_alignment;
|
||||
}
|
||||
|
||||
@@ -532,7 +541,8 @@ void PartDynamicTextField::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
||||
Used to up to date this text field,
|
||||
when the element information (see elementScene) changed
|
||||
*/
|
||||
void PartDynamicTextField::elementInfoChanged() {
|
||||
void PartDynamicTextField::elementInfoChanged()
|
||||
{
|
||||
if(!elementScene())
|
||||
return;
|
||||
|
||||
@@ -543,11 +553,13 @@ void PartDynamicTextField::elementInfoChanged() {
|
||||
m_composite_text, elementScene() -> elementInformation()));
|
||||
}
|
||||
|
||||
void PartDynamicTextField::prepareAlignment() {
|
||||
void PartDynamicTextField::prepareAlignment()
|
||||
{
|
||||
m_alignment_rect = boundingRect();
|
||||
}
|
||||
|
||||
void PartDynamicTextField::finishAlignment() {
|
||||
void PartDynamicTextField::finishAlignment()
|
||||
{
|
||||
if(m_block_alignment)
|
||||
return;
|
||||
|
||||
|
||||
@@ -346,7 +346,8 @@ void PartLine::removeHandler()
|
||||
@brief PartLine::sceneP1
|
||||
@return the point p1 in scene coordinate
|
||||
*/
|
||||
QPointF PartLine::sceneP1() const {
|
||||
QPointF PartLine::sceneP1() const
|
||||
{
|
||||
return(mapToScene(m_line.p1()));
|
||||
}
|
||||
|
||||
@@ -354,7 +355,8 @@ QPointF PartLine::sceneP1() const {
|
||||
@brief PartLine::sceneP2
|
||||
@return the point p2 in scen coordinate
|
||||
*/
|
||||
QPointF PartLine::sceneP2() const {
|
||||
QPointF PartLine::sceneP2() const
|
||||
{
|
||||
return(mapToScene(m_line.p2()));
|
||||
}
|
||||
|
||||
@@ -473,7 +475,8 @@ QRectF PartLine::firstEndCircleRect() const
|
||||
@brief PartLine::secondEndCircleRect
|
||||
@return the rectangle bordering the entirety of the second extremity
|
||||
*/
|
||||
QRectF PartLine::secondEndCircleRect() const {
|
||||
QRectF PartLine::secondEndCircleRect() const
|
||||
{
|
||||
QList<QPointF> interesting_points = fourEndPoints(m_line.p2(),
|
||||
m_line.p1(),
|
||||
second_length);
|
||||
@@ -543,7 +546,8 @@ QRectF PartLine::boundingRect() const
|
||||
@return true if this part is irrelevant and does not deserve to be Retained / registered.
|
||||
A line is relevant when is two point is different
|
||||
*/
|
||||
bool PartLine::isUseless() const {
|
||||
bool PartLine::isUseless() const
|
||||
{
|
||||
return(m_line.p1() == m_line.p2());
|
||||
}
|
||||
|
||||
@@ -554,7 +558,8 @@ bool PartLine::isUseless() const {
|
||||
to imply any margin, and it is different from shape because it is a regular
|
||||
rectangle, not a complex shape.
|
||||
*/
|
||||
QRectF PartLine::sceneGeometricRect() const {
|
||||
QRectF PartLine::sceneGeometricRect() const
|
||||
{
|
||||
return(QRectF(sceneP1(), sceneP2()));
|
||||
}
|
||||
|
||||
@@ -617,7 +622,8 @@ QList<QPointF> PartLine::fourEndPoints(const QPointF &end_point, const QPointF &
|
||||
return(QList<QPointF>() << o << a << b << c);
|
||||
}
|
||||
|
||||
QLineF PartLine::line() const {
|
||||
QLineF PartLine::line() const
|
||||
{
|
||||
return m_line;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,8 @@ bool PartPolygon::isUseless() const
|
||||
to imply any margin, and it is different from shape because it is a regular
|
||||
rectangle, not a complex shape.
|
||||
*/
|
||||
QRectF PartPolygon::sceneGeometricRect() const {
|
||||
QRectF PartPolygon::sceneGeometricRect() const
|
||||
{
|
||||
return(mapToScene(m_polygon.boundingRect()).boundingRect());
|
||||
}
|
||||
|
||||
@@ -185,7 +186,8 @@ void PartPolygon::handleUserTransformation(const QRectF &initial_selection_rect,
|
||||
single primitive is being scaled.
|
||||
@return : This reimplementation systematically returns QET::RoundScaleRatios.
|
||||
*/
|
||||
QET::ScalingMethod PartPolygon::preferredScalingMethod() const {
|
||||
QET::ScalingMethod PartPolygon::preferredScalingMethod() const
|
||||
{
|
||||
return(QET::RoundScaleRatios);
|
||||
}
|
||||
|
||||
@@ -193,7 +195,8 @@ QET::ScalingMethod PartPolygon::preferredScalingMethod() const {
|
||||
@brief PartPolygon::polygon
|
||||
@return the item's polygon, or an empty polygon if no polygon has been set.
|
||||
*/
|
||||
QPolygonF PartPolygon::polygon() const {
|
||||
QPolygonF PartPolygon::polygon() const
|
||||
{
|
||||
return m_polygon;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
/**
|
||||
@brief PartRectangle::~PartRectangle
|
||||
*/
|
||||
PartRectangle::~PartRectangle() {
|
||||
PartRectangle::~PartRectangle()
|
||||
{
|
||||
removeHandler();
|
||||
}
|
||||
|
||||
@@ -126,7 +127,8 @@ void PartRectangle::fromXml(const QDomElement &qde)
|
||||
@brief PartRectangle::rect
|
||||
@return : Returns the item's rectangle.
|
||||
*/
|
||||
QRectF PartRectangle::rect() const {
|
||||
QRectF PartRectangle::rect() const
|
||||
{
|
||||
return m_rect;
|
||||
}
|
||||
|
||||
@@ -167,7 +169,8 @@ void PartRectangle::setYRadius(qreal Y)
|
||||
to imply any margin, and it is different from shape because it is a regular
|
||||
rectangle, not a complex shape.
|
||||
*/
|
||||
QRectF PartRectangle::sceneGeometricRect() const {
|
||||
QRectF PartRectangle::sceneGeometricRect() const
|
||||
{
|
||||
return(mapToScene(rect()).boundingRect());
|
||||
}
|
||||
|
||||
@@ -175,7 +178,8 @@ QRectF PartRectangle::sceneGeometricRect() const {
|
||||
@brief PartRectangle::sceneTopLeft
|
||||
@return the top left of rectangle, in scene coordinate
|
||||
*/
|
||||
QPointF PartRectangle::sceneTopLeft() const {
|
||||
QPointF PartRectangle::sceneTopLeft() const
|
||||
{
|
||||
return(mapToScene(rect().topLeft()));
|
||||
}
|
||||
|
||||
@@ -228,7 +232,8 @@ QRectF PartRectangle::boundingRect() const
|
||||
@return true if this part is irrelevant and does not deserve to be Retained / registered.
|
||||
An rectangle is relevant when he's not null.
|
||||
*/
|
||||
bool PartRectangle::isUseless() const {
|
||||
bool PartRectangle::isUseless() const
|
||||
{
|
||||
return(rect().isNull());
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
PartTerminal::~PartTerminal() {
|
||||
PartTerminal::~PartTerminal()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +55,8 @@ void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||
@return un element XML decrivant la borne
|
||||
*/
|
||||
const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
||||
const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
return d -> toXml(xml_document);
|
||||
}
|
||||
|
||||
@@ -97,7 +99,8 @@ void PartTerminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, Q
|
||||
@brief PartTerminal::shape
|
||||
@return the shape of this item
|
||||
*/
|
||||
QPainterPath PartTerminal::shape() const {
|
||||
QPainterPath PartTerminal::shape() const
|
||||
{
|
||||
QPainterPath shape;
|
||||
shape.lineTo(d -> second_point);
|
||||
|
||||
@@ -111,7 +114,8 @@ QPainterPath PartTerminal::shape() const {
|
||||
@brief PartTerminal::boundingRect
|
||||
@return the bounding rect of this item
|
||||
*/
|
||||
QRectF PartTerminal::boundingRect() const {
|
||||
QRectF PartTerminal::boundingRect() const
|
||||
{
|
||||
QRectF br(QPointF(0, 0), d -> second_point);
|
||||
br = br.normalized();
|
||||
|
||||
@@ -141,7 +145,8 @@ void PartTerminal::setName(QString& name) {
|
||||
emit nameChanged();
|
||||
}
|
||||
|
||||
void PartTerminal::setNewUuid() {
|
||||
void PartTerminal::setNewUuid()
|
||||
{
|
||||
d -> m_uuid = QUuid::createUuid();
|
||||
}
|
||||
|
||||
@@ -149,7 +154,8 @@ void PartTerminal::setNewUuid() {
|
||||
Met a jour la position du second point en fonction de la position et de
|
||||
l'orientation de la borne.
|
||||
*/
|
||||
void PartTerminal::updateSecondPoint() {
|
||||
void PartTerminal::updateSecondPoint()
|
||||
{
|
||||
qreal ts = 4.0; // terminal size
|
||||
switch(d -> m_orientation) {
|
||||
case Qet::North: d -> second_point = QPointF(0.0, ts); break;
|
||||
@@ -165,7 +171,8 @@ void PartTerminal::updateSecondPoint() {
|
||||
Une borne est toujours pertinente ; cette fonction renvoie donc
|
||||
toujours false
|
||||
*/
|
||||
bool PartTerminal::isUseless() const {
|
||||
bool PartTerminal::isUseless() const
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -175,7 +182,8 @@ bool PartTerminal::isUseless() const {
|
||||
to imply any margin, and it is different from shape because it is a regular
|
||||
rectangle, not a complex shape.
|
||||
*/
|
||||
QRectF PartTerminal::sceneGeometricRect() const {
|
||||
QRectF PartTerminal::sceneGeometricRect() const
|
||||
{
|
||||
return(sceneBoundingRect());
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
PartText::~PartText() {
|
||||
PartText::~PartText()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +96,8 @@ void PartText::fromXml(const QDomElement &xml_element) {
|
||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||
@return un element XML decrivant le texte statique
|
||||
*/
|
||||
const QDomElement PartText::toXml(QDomDocument &xml_document) const {
|
||||
const QDomElement PartText::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement(xmlName());
|
||||
|
||||
xml_element.setAttribute("x", QString::number(pos().x()));
|
||||
@@ -111,7 +113,8 @@ const QDomElement PartText::toXml(QDomDocument &xml_document) const {
|
||||
/**
|
||||
@return Les coordonnees du point situe en bas a gauche du texte.
|
||||
*/
|
||||
QPointF PartText::margin() const {
|
||||
QPointF PartText::margin() const
|
||||
{
|
||||
QFont used_font = font();
|
||||
QFontMetrics qfm(used_font);
|
||||
qreal document_margin = document() -> documentMargin();
|
||||
@@ -191,7 +194,8 @@ QVariant PartText::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
/**
|
||||
@return le rectangle delimitant cette partie.
|
||||
*/
|
||||
QRectF PartText::boundingRect() const {
|
||||
QRectF PartText::boundingRect() const
|
||||
{
|
||||
QRectF r = QGraphicsTextItem::boundingRect();
|
||||
r.adjust(0.0, -1.1, 0.0, 0.0);
|
||||
return(r);
|
||||
@@ -202,7 +206,8 @@ QRectF PartText::boundingRect() const {
|
||||
conservee / enregistree.
|
||||
Un texte statique n'est pas pertinent lorsque son texte est vide.
|
||||
*/
|
||||
bool PartText::isUseless() const {
|
||||
bool PartText::isUseless() const
|
||||
{
|
||||
return(toPlainText().isEmpty());
|
||||
}
|
||||
|
||||
@@ -212,7 +217,8 @@ bool PartText::isUseless() const {
|
||||
to imply any margin, and it is different from shape because it is a regular
|
||||
rectangle, not a complex shape.
|
||||
*/
|
||||
QRectF PartText::sceneGeometricRect() const {
|
||||
QRectF PartText::sceneGeometricRect() const
|
||||
{
|
||||
return(sceneBoundingRect());
|
||||
}
|
||||
|
||||
@@ -327,7 +333,8 @@ void PartText::setEditable(bool editable) {
|
||||
/**
|
||||
Start text edition by storing the former value of the text.
|
||||
*/
|
||||
void PartText::startEdition() {
|
||||
void PartText::startEdition()
|
||||
{
|
||||
// !previous_text.isNull() means the text is being edited
|
||||
previous_text = toPlainText();
|
||||
}
|
||||
@@ -336,7 +343,8 @@ void PartText::startEdition() {
|
||||
End text edition, potentially generating a ChangePartCommand if the text
|
||||
has changed.
|
||||
*/
|
||||
void PartText::endEdition() {
|
||||
void PartText::endEdition()
|
||||
{
|
||||
if (!previous_text.isNull()) {
|
||||
// the text was being edited
|
||||
QString new_text = toPlainText();
|
||||
|
||||
Reference in New Issue
Block a user