mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Line editor : use QPropertyUndoCommand instead of ChangePartCommand
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4068 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -59,8 +59,7 @@ bool ESEventAddLine::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
|||||||
if (!m_line) {
|
if (!m_line) {
|
||||||
m_line = new PartLine(m_editor);
|
m_line = new PartLine(m_editor);
|
||||||
m_scene -> addItem(m_line);
|
m_scene -> addItem(m_line);
|
||||||
m_line -> setP1(pos);
|
m_line->setLine(QLineF(pos, pos));
|
||||||
m_line -> setP2(pos);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,11 +80,14 @@ bool ESEventAddLine::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
|||||||
* @param event
|
* @param event
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool ESEventAddLine::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
bool ESEventAddLine::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
updateHelpCross (event -> scenePos());
|
updateHelpCross (event -> scenePos());
|
||||||
if (!m_line) return false;
|
if (!m_line) return false;
|
||||||
|
|
||||||
m_line -> setP2(m_scene -> snapToGrid(event -> scenePos()));
|
QLineF line = m_line->line();
|
||||||
|
line.setP2(m_scene -> snapToGrid(event -> scenePos()));
|
||||||
|
m_line -> setLine(line);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,46 +139,6 @@ void PartLine::fromXml(const QDomElement &qde) {
|
|||||||
second_length = qde.attribute("length2", "1.5").toDouble();
|
second_length = qde.attribute("length2", "1.5").toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PartLine::p1
|
|
||||||
* @return the point p1 of line.
|
|
||||||
*/
|
|
||||||
QPointF PartLine::p1() const {
|
|
||||||
return m_line.p1();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PartLine::setP1
|
|
||||||
* set first point to P1
|
|
||||||
* @param p1
|
|
||||||
*/
|
|
||||||
void PartLine::setP1(const QPointF &p1)
|
|
||||||
{
|
|
||||||
if (p1 == m_line.p1()) return;
|
|
||||||
prepareGeometryChange();
|
|
||||||
m_line.setP1(p1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PartLine::p2
|
|
||||||
* @return the point p2 of line
|
|
||||||
*/
|
|
||||||
QPointF PartLine::p2() const {
|
|
||||||
return m_line.p2();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PartLine::setP2
|
|
||||||
* set second point to P2
|
|
||||||
* @param p2
|
|
||||||
*/
|
|
||||||
void PartLine::setP2(const QPointF &p2)
|
|
||||||
{
|
|
||||||
if (p2 == m_line.p2()) return;
|
|
||||||
prepareGeometryChange();
|
|
||||||
m_line.setP2(p2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PartLine::mousePressEvent
|
* @brief PartLine::mousePressEvent
|
||||||
* Handle mouse press event
|
* Handle mouse press event
|
||||||
@@ -243,7 +203,7 @@ void PartLine::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
* @return the point p1 in scene coordinate
|
* @return the point p1 in scene coordinate
|
||||||
*/
|
*/
|
||||||
QPointF PartLine::sceneP1() const {
|
QPointF PartLine::sceneP1() const {
|
||||||
return(mapToScene(p1()));
|
return(mapToScene(m_line.p1()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -251,7 +211,7 @@ QPointF PartLine::sceneP1() const {
|
|||||||
* @return the point p2 in scen coordinate
|
* @return the point p2 in scen coordinate
|
||||||
*/
|
*/
|
||||||
QPointF PartLine::sceneP2() const {
|
QPointF PartLine::sceneP2() const {
|
||||||
return(mapToScene(p2()));
|
return(mapToScene(m_line.p2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -406,10 +366,10 @@ void PartLine::debugPaint(QPainter *painter)
|
|||||||
|
|
||||||
painter -> setPen(Qt::red);
|
painter -> setPen(Qt::red);
|
||||||
|
|
||||||
foreach(QPointF pointy, fourEndPoints(p1(), p2(), first_length))
|
foreach(QPointF pointy, fourEndPoints(m_line.p1(), m_line.p2(), first_length))
|
||||||
painter -> drawEllipse(pointy, 0.1, 0.1);
|
painter -> drawEllipse(pointy, 0.1, 0.1);
|
||||||
|
|
||||||
foreach(QPointF pointy, fourEndPoints(p2(), p1(), second_length))
|
foreach(QPointF pointy, fourEndPoints(m_line.p2(), m_line.p1(), second_length))
|
||||||
painter -> drawEllipse(pointy, 0.1, 0.1);
|
painter -> drawEllipse(pointy, 0.1, 0.1);
|
||||||
|
|
||||||
painter -> restore();
|
painter -> restore();
|
||||||
@@ -526,11 +486,44 @@ QLineF PartLine::line() const {
|
|||||||
|
|
||||||
void PartLine::setLine(const QLineF &line)
|
void PartLine::setLine(const QLineF &line)
|
||||||
{
|
{
|
||||||
if (m_line != line)
|
if (m_line == line) return;
|
||||||
{
|
prepareGeometryChange();
|
||||||
prepareGeometryChange();
|
m_line = line;
|
||||||
m_line = line;
|
emit lineChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartLine::setFirstEndType(const Qet::EndType &et)
|
||||||
|
{
|
||||||
|
if (first_end == et) return;
|
||||||
|
prepareGeometryChange();
|
||||||
|
first_end = et;
|
||||||
|
emit firstEndTypeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PartLine::setSecondEndType(const Qet::EndType &et)
|
||||||
|
{
|
||||||
|
if (second_end == et) return;
|
||||||
|
prepareGeometryChange();
|
||||||
|
second_end = et;
|
||||||
|
emit secondEndTypeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PartLine::setFirstEndLength(const qreal &l)
|
||||||
|
{
|
||||||
|
qreal length = qMin(qAbs(l), m_line.length());
|
||||||
|
if (first_length == length) return;
|
||||||
|
prepareGeometryChange();
|
||||||
|
first_length = length;
|
||||||
|
emit firstEndLengthChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PartLine::setSecondEndLength(const qreal &l)
|
||||||
|
{
|
||||||
|
qreal length = qMin(qAbs(l), m_line.length());
|
||||||
|
if (second_length == length) return;
|
||||||
|
prepareGeometryChange();
|
||||||
|
second_length = length;
|
||||||
|
emit secondEndLengthChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,24 +37,25 @@ class PartLine : public CustomElementGraphicPart
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QPointF p1 READ p1 WRITE setP1)
|
|
||||||
Q_PROPERTY(QPointF p2 READ p2 WRITE setP2)
|
|
||||||
Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType)
|
Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType)
|
||||||
Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
|
Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
|
||||||
Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
|
Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
|
||||||
Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
|
Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
|
||||||
Q_PROPERTY(QLineF line READ line WRITE setLine)
|
Q_PROPERTY(QLineF line READ line WRITE setLine)
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartLine(QETElementEditor *, QGraphicsItem * = 0);
|
PartLine(QETElementEditor *, QGraphicsItem * = 0);
|
||||||
virtual ~PartLine();
|
virtual ~PartLine();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PartLine(const PartLine &);
|
PartLine(const PartLine &);
|
||||||
|
|
||||||
// attributes
|
signals:
|
||||||
private:
|
void lineChanged();
|
||||||
|
void firstEndTypeChanged();
|
||||||
|
void secondEndTypeChanged();
|
||||||
|
void firstEndLengthChanged();
|
||||||
|
void secondEndLengthChanged();
|
||||||
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
@@ -85,18 +86,14 @@ class PartLine : public CustomElementGraphicPart
|
|||||||
|
|
||||||
QLineF line() const;
|
QLineF line() const;
|
||||||
void setLine(const QLineF &line);
|
void setLine(const QLineF &line);
|
||||||
QPointF p1() const;
|
|
||||||
void setP1 (const QPointF &p1);
|
|
||||||
QPointF p2 () const;
|
|
||||||
void setP2 (const QPointF &p2);
|
|
||||||
Qet::EndType firstEndType() const {return first_end;}
|
Qet::EndType firstEndType() const {return first_end;}
|
||||||
void setFirstEndType(const Qet::EndType &et) {first_end = et;}
|
void setFirstEndType(const Qet::EndType &et);
|
||||||
Qet::EndType secondEndType() const {return second_end;}
|
Qet::EndType secondEndType() const {return second_end;}
|
||||||
void setSecondEndType(const Qet::EndType &et) {second_end = et;}
|
void setSecondEndType(const Qet::EndType &et);
|
||||||
qreal firstEndLength() const {return first_length;}
|
qreal firstEndLength() const {return first_length;}
|
||||||
void setFirstEndLength(const qreal &l) {first_length = qMin(qAbs(l), m_line.length());}
|
void setFirstEndLength(const qreal &l);
|
||||||
qreal secondEndLength() const {return second_length;}
|
qreal secondEndLength() const {return second_length;}
|
||||||
void setSecondEndLength(const qreal &l) {second_length = qMin(qAbs(l), m_line.length());}
|
void setSecondEndLength(const qreal &l);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "partline.h"
|
#include "partline.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include "qeticons.h"
|
#include "qeticons.h"
|
||||||
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
|
#include "elementscene.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -29,7 +31,8 @@
|
|||||||
*/
|
*/
|
||||||
LineEditor::LineEditor(QETElementEditor *editor, PartLine *line, QWidget *parent) :
|
LineEditor::LineEditor(QETElementEditor *editor, PartLine *line, QWidget *parent) :
|
||||||
ElementItemEditor(editor, parent),
|
ElementItemEditor(editor, parent),
|
||||||
part(line)
|
part(line),
|
||||||
|
m_locked (false)
|
||||||
{
|
{
|
||||||
style_ = new StyleEditor(editor);
|
style_ = new StyleEditor(editor);
|
||||||
|
|
||||||
@@ -89,27 +92,50 @@ LineEditor::~LineEditor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de specifier a cet editeur quelle primitive il doit editer. A noter
|
* @brief LineEditor::setPart
|
||||||
qu'un editeur peut accepter ou refuser d'editer une primitive.
|
* Specifie to this editor the part to edit.
|
||||||
L'editeur de ligne acceptera d'editer la primitive new_part s'il s'agit d'un
|
* Note that an editor can accept or refuse to edit a part. This editor accept only PartLine.
|
||||||
objet de la classe PartLine.
|
* @param new_part
|
||||||
@param new_part Nouvelle primitive a editer
|
* @return
|
||||||
@return true si l'editeur a accepter d'editer la primitive, false sinon
|
*/
|
||||||
*/
|
bool LineEditor::setPart(CustomElementPart *new_part)
|
||||||
bool LineEditor::setPart(CustomElementPart *new_part) {
|
{
|
||||||
if (!new_part) {
|
if (!new_part)
|
||||||
|
{
|
||||||
|
if (part)
|
||||||
|
{
|
||||||
|
disconnect(part, &PartLine::lineChanged, this, &LineEditor::updateForm);
|
||||||
|
disconnect(part, &PartLine::firstEndTypeChanged, this, &LineEditor::updateForm);
|
||||||
|
disconnect(part, &PartLine::secondEndTypeChanged, this, &LineEditor::updateForm);
|
||||||
|
disconnect(part, &PartLine::firstEndLengthChanged, this, &LineEditor::updateForm);
|
||||||
|
disconnect(part, &PartLine::secondEndLengthChanged, this, &LineEditor::updateForm);
|
||||||
|
}
|
||||||
part = 0;
|
part = 0;
|
||||||
style_ -> setPart(0);
|
style_ -> setPart(0);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
if (PartLine *part_line = dynamic_cast<PartLine *>(new_part)) {
|
if (PartLine *part_line = dynamic_cast<PartLine *>(new_part))
|
||||||
|
{
|
||||||
|
if (part == part_line) return true;
|
||||||
|
if (part)
|
||||||
|
{
|
||||||
|
disconnect(part, &PartLine::lineChanged, this, &LineEditor::updateForm);
|
||||||
|
disconnect(part, &PartLine::firstEndTypeChanged, this, &LineEditor::updateForm);
|
||||||
|
disconnect(part, &PartLine::secondEndTypeChanged, this, &LineEditor::updateForm);
|
||||||
|
disconnect(part, &PartLine::firstEndLengthChanged, this, &LineEditor::updateForm);
|
||||||
|
disconnect(part, &PartLine::secondEndLengthChanged, this, &LineEditor::updateForm);
|
||||||
|
}
|
||||||
part = part_line;
|
part = part_line;
|
||||||
style_ -> setPart(part);
|
style_ -> setPart(part);
|
||||||
updateForm();
|
updateForm();
|
||||||
|
connect(part, &PartLine::lineChanged, this, &LineEditor::updateForm);
|
||||||
|
connect(part, &PartLine::firstEndTypeChanged, this, &LineEditor::updateForm);
|
||||||
|
connect(part, &PartLine::secondEndTypeChanged, this, &LineEditor::updateForm);
|
||||||
|
connect(part, &PartLine::firstEndLengthChanged, this, &LineEditor::updateForm);
|
||||||
|
connect(part, &PartLine::secondEndLengthChanged, this, &LineEditor::updateForm);
|
||||||
return(true);
|
return(true);
|
||||||
} else {
|
|
||||||
return(false);
|
|
||||||
}
|
}
|
||||||
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,40 +161,94 @@ QPointF LineEditor::editedP2() const {
|
|||||||
return part -> mapFromScene(x2->value(), y2->value());
|
return part -> mapFromScene(x2->value(), y2->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// Met a jour le type de la premiere extremite
|
||||||
Met a jour la ligne a partir des donnees du formulaire
|
void LineEditor::updateLineEndType1()
|
||||||
*/
|
{
|
||||||
void LineEditor::updateLine() {
|
if (m_locked) return;
|
||||||
if (!part) return;
|
m_locked = true;
|
||||||
part -> setProperty("end1", end1_type -> itemData(end1_type->currentIndex()));
|
QVariant end = end1_type -> itemData(end1_type->currentIndex());
|
||||||
part -> setProperty("length1", end1_length -> value());
|
|
||||||
part -> setProperty("end2", end2_type -> itemData(end2_type->currentIndex()));
|
if (end != part->property("end1"))
|
||||||
part -> setProperty("length2", end2_length -> value());
|
{
|
||||||
part -> setProperty("p1", editedP1());
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "end1", part->property("end1"), end);
|
||||||
part -> setProperty("p2", editedP2());
|
undo->setText(tr("Modifier une ligne"));
|
||||||
|
elementScene()->undoStack().push(undo);
|
||||||
|
}
|
||||||
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Met a jour l'abscisse du premier point de la ligne et cree un objet d'annulation
|
|
||||||
void LineEditor::updateLineX1() { addChangePartCommand(tr("abscisse point 1"), part, "p1", editedP1()); }
|
|
||||||
/// Met a jour l'ordonnee du premier point de la ligne et cree un objet d'annulation
|
|
||||||
void LineEditor::updateLineY1() { addChangePartCommand(tr("ordonnée point 1"), part, "p1", editedP1()); }
|
|
||||||
/// Met a jour l'abscisse du second point de la ligne et cree un objet d'annulation
|
|
||||||
void LineEditor::updateLineX2() { addChangePartCommand(tr("abscisse point 2"), part, "p2", editedP2()); }
|
|
||||||
/// Met a jour l'ordonnee du second point de la ligne et cree un objet d'annulation
|
|
||||||
void LineEditor::updateLineY2() { addChangePartCommand(tr("ordonnée point 2"), part, "p2", editedP2()); }
|
|
||||||
/// Met a jour le type de la premiere extremite
|
|
||||||
void LineEditor::updateLineEndType1() { addChangePartCommand(tr("type fin 1"), part, "end1", end1_type -> itemData(end1_type->currentIndex())); }
|
|
||||||
/// Met a jour la longueur de la premiere extremite
|
/// Met a jour la longueur de la premiere extremite
|
||||||
void LineEditor::updateLineEndLength1() { addChangePartCommand(tr("longueur fin 1"), part, "length1", end1_length -> value()); }
|
void LineEditor::updateLineEndLength1()
|
||||||
|
{
|
||||||
|
if (m_locked) return;
|
||||||
|
m_locked = true;
|
||||||
|
double length = end1_length->value();
|
||||||
|
|
||||||
|
if (length != part->property("length1"))
|
||||||
|
{
|
||||||
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "length1", part->property("length1"), length);
|
||||||
|
undo->setText(tr("Modifier une ligne"));
|
||||||
|
undo->enableAnimation();
|
||||||
|
elementScene()->undoStack().push(undo);
|
||||||
|
}
|
||||||
|
m_locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
/// Met a jour le type de la seconde extremite
|
/// Met a jour le type de la seconde extremite
|
||||||
void LineEditor::updateLineEndType2() { addChangePartCommand(tr("type fin 2"), part, "end2", end2_type -> itemData(end2_type->currentIndex())); }
|
void LineEditor::updateLineEndType2()
|
||||||
|
{
|
||||||
|
if (m_locked) return;
|
||||||
|
m_locked = true;
|
||||||
|
QVariant end = end2_type -> itemData(end2_type->currentIndex());
|
||||||
|
|
||||||
|
if (end != part->property("end2"))
|
||||||
|
{
|
||||||
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "end2", part->property("end2"), end);
|
||||||
|
undo->setText(tr("Modifier une ligne"));
|
||||||
|
elementScene()->undoStack().push(undo);
|
||||||
|
}
|
||||||
|
m_locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
/// Met a jour la longueur de la seconde extremite
|
/// Met a jour la longueur de la seconde extremite
|
||||||
void LineEditor::updateLineEndLength2() { addChangePartCommand(tr("longueur fin 2"), part, "length2", end2_length -> value()); }
|
void LineEditor::updateLineEndLength2()
|
||||||
|
{
|
||||||
|
if (m_locked) return;
|
||||||
|
m_locked = true;
|
||||||
|
double length = end2_length->value();
|
||||||
|
|
||||||
|
if (length != part->property("length2"))
|
||||||
|
{
|
||||||
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "length2", part->property("length2"), length);
|
||||||
|
undo->setText(tr("Modifier une ligne"));
|
||||||
|
undo->enableAnimation();
|
||||||
|
elementScene()->undoStack().push(undo);
|
||||||
|
}
|
||||||
|
m_locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineEditor::lineEditingFinished()
|
||||||
|
{
|
||||||
|
if (m_locked) return;
|
||||||
|
m_locked = true;
|
||||||
|
QLineF line (editedP1(), editedP2());
|
||||||
|
|
||||||
|
if (line != part->property("line"))
|
||||||
|
{
|
||||||
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "line", part->property("line"), line);
|
||||||
|
undo->setText(tr("Modifier une ligne"));
|
||||||
|
undo->enableAnimation();
|
||||||
|
elementScene()->undoStack().push(undo);
|
||||||
|
}
|
||||||
|
m_locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met a jour le formulaire d'edition
|
* @brief LineEditor::updateForm
|
||||||
*/
|
* Update the value of the widgets
|
||||||
void LineEditor::updateForm() {
|
*/
|
||||||
|
void LineEditor::updateForm()
|
||||||
|
{
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
QPointF p1(part -> sceneP1());
|
QPointF p1(part -> sceneP1());
|
||||||
@@ -185,24 +265,30 @@ void LineEditor::updateForm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Active ou desactive les connexionx signaux/slots entre les widgets internes.
|
* @brief LineEditor::activeConnections
|
||||||
@param active true pour activer les connexions, false pour les desactiver
|
* Enable/disable connection between editor widget and slot editingFinished
|
||||||
*/
|
* True == enable | false == disable
|
||||||
void LineEditor::activeConnections(bool active) {
|
* @param active
|
||||||
if (active) {
|
*/
|
||||||
connect(x1, SIGNAL(editingFinished()), this, SLOT(updateLineX1()));
|
void LineEditor::activeConnections(bool active)
|
||||||
connect(y1, SIGNAL(editingFinished()), this, SLOT(updateLineY1()));
|
{
|
||||||
connect(x2, SIGNAL(editingFinished()), this, SLOT(updateLineX2()));
|
if (active)
|
||||||
connect(y2, SIGNAL(editingFinished()), this, SLOT(updateLineY2()));
|
{
|
||||||
|
connect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()));
|
||||||
|
connect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()));
|
||||||
|
connect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()));
|
||||||
|
connect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()));
|
||||||
connect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
|
connect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
|
||||||
connect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
|
connect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
|
||||||
connect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));
|
connect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));
|
||||||
connect(end2_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength2()));
|
connect(end2_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength2()));
|
||||||
} else {
|
}
|
||||||
disconnect(x1, SIGNAL(editingFinished()), this, SLOT(updateLineX1()));
|
else
|
||||||
disconnect(y1, SIGNAL(editingFinished()), this, SLOT(updateLineY1()));
|
{
|
||||||
disconnect(x2, SIGNAL(editingFinished()), this, SLOT(updateLineX2()));
|
disconnect(x1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()));
|
||||||
disconnect(y2, SIGNAL(editingFinished()), this, SLOT(updateLineY2()));
|
disconnect(y1, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()));
|
||||||
|
disconnect(x2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()));
|
||||||
|
disconnect(y2, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()));
|
||||||
disconnect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
|
disconnect(end1_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType1()));
|
||||||
disconnect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
|
disconnect(end1_length, SIGNAL(editingFinished()), this, SLOT(updateLineEndLength1()));
|
||||||
disconnect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));
|
disconnect(end2_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLineEndType2()));
|
||||||
|
|||||||
@@ -17,32 +17,37 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef LINE_EDITOR_H
|
#ifndef LINE_EDITOR_H
|
||||||
#define LINE_EDITOR_H
|
#define LINE_EDITOR_H
|
||||||
#include <QtWidgets>
|
|
||||||
#include "elementitemeditor.h"
|
#include "elementitemeditor.h"
|
||||||
|
|
||||||
class PartLine;
|
class PartLine;
|
||||||
class StyleEditor;
|
class StyleEditor;
|
||||||
|
class QComboBox;
|
||||||
|
class QDoubleSpinBox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class provides a widget to edit lines within the element editor.
|
This class provides a widget to edit lines within the element editor.
|
||||||
*/
|
*/
|
||||||
class LineEditor : public ElementItemEditor
|
class LineEditor : public ElementItemEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
LineEditor(QETElementEditor *, PartLine * = 0, QWidget * = 0);
|
LineEditor(QETElementEditor *, PartLine * = 0, QWidget * = 0);
|
||||||
virtual ~LineEditor();
|
virtual ~LineEditor();
|
||||||
private:
|
private:
|
||||||
LineEditor(const LineEditor &);
|
LineEditor(const LineEditor &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
PartLine *part;
|
PartLine *part;
|
||||||
StyleEditor *style_;
|
StyleEditor *style_;
|
||||||
QDoubleSpinBox *x1, *y1, *x2, *y2;
|
QDoubleSpinBox *x1, *y1, *x2, *y2;
|
||||||
QComboBox *end1_type, *end2_type;
|
QComboBox *end1_type, *end2_type;
|
||||||
QDoubleSpinBox*end1_length, *end2_length;
|
QDoubleSpinBox*end1_length, *end2_length;
|
||||||
|
bool m_locked;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
virtual bool setPart(CustomElementPart *);
|
virtual bool setPart(CustomElementPart *);
|
||||||
virtual CustomElementPart *currentPart() const;
|
virtual CustomElementPart *currentPart() const;
|
||||||
@@ -50,15 +55,11 @@ class LineEditor : public ElementItemEditor
|
|||||||
QPointF editedP2() const;
|
QPointF editedP2() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLine();
|
|
||||||
void updateLineX1();
|
|
||||||
void updateLineY1();
|
|
||||||
void updateLineX2();
|
|
||||||
void updateLineY2();
|
|
||||||
void updateLineEndType1();
|
void updateLineEndType1();
|
||||||
void updateLineEndLength1();
|
void updateLineEndLength1();
|
||||||
void updateLineEndType2();
|
void updateLineEndType2();
|
||||||
void updateLineEndLength2();
|
void updateLineEndLength2();
|
||||||
|
void lineEditingFinished();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user