mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 00:30:53 +01:00
Ajout d'une liste des parties dans l'editeur d'elements
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@206 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -2,10 +2,6 @@
|
|||||||
#include "customelement.h"
|
#include "customelement.h"
|
||||||
#include "qetelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
|
|
||||||
QPicture *CustomElementPart::getCustomElementQPicture(CustomElement &ce) const {
|
|
||||||
return(&(ce.dessin));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return le QETElementEditor auquel cet editeur appartient
|
/// @return le QETElementEditor auquel cet editeur appartient
|
||||||
QETElementEditor *CustomElementPart::elementEditor() const {
|
QETElementEditor *CustomElementPart::elementEditor() const {
|
||||||
return(element_editor);
|
return(element_editor);
|
||||||
|
|||||||
@@ -32,16 +32,11 @@ class CustomElementPart {
|
|||||||
virtual void fromXml(const QDomElement &) = 0;
|
virtual void fromXml(const QDomElement &) = 0;
|
||||||
virtual const QDomElement toXml(QDomDocument &) const = 0;
|
virtual const QDomElement toXml(QDomDocument &) const = 0;
|
||||||
virtual QWidget *elementInformations() = 0;
|
virtual QWidget *elementInformations() = 0;
|
||||||
//virtual void renderToCustomElement(CustomElement &) const = 0;
|
|
||||||
//virtual void toEditorPart(const EditorPart &);
|
|
||||||
//virtual void fromEditorPart(const EditorPart &) = 0;
|
|
||||||
virtual void setProperty(const QString &, const QVariant &) = 0;
|
virtual void setProperty(const QString &, const QVariant &) = 0;
|
||||||
virtual QVariant property(const QString &) = 0;
|
virtual QVariant property(const QString &) = 0;
|
||||||
virtual QETElementEditor *elementEditor() const;
|
virtual QETElementEditor *elementEditor() const;
|
||||||
virtual ElementScene *elementScene() const;
|
virtual ElementScene *elementScene() const;
|
||||||
virtual QUndoStack &undoStack() const;
|
virtual QUndoStack &undoStack() const;
|
||||||
|
virtual QString name() const = 0;
|
||||||
protected:
|
|
||||||
QPicture *getCustomElementQPicture(CustomElement &ce) const;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -168,33 +168,40 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
switch(behavior) {
|
switch(behavior) {
|
||||||
case Line:
|
case Line:
|
||||||
undo_stack.push(new AddPartCommand(tr("ligne"), this, current_line));
|
undo_stack.push(new AddPartCommand(tr("ligne"), this, current_line));
|
||||||
|
emit(partsAdded());
|
||||||
break;
|
break;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
current_ellipse -> setRect(current_ellipse -> rect().normalized());
|
current_ellipse -> setRect(current_ellipse -> rect().normalized());
|
||||||
undo_stack.push(new AddPartCommand(tr("ellipse"), this, current_ellipse));
|
undo_stack.push(new AddPartCommand(tr("ellipse"), this, current_ellipse));
|
||||||
|
emit(partsAdded());
|
||||||
break;
|
break;
|
||||||
case Arc:
|
case Arc:
|
||||||
current_arc-> setRect(current_arc -> rect().normalized());
|
current_arc-> setRect(current_arc -> rect().normalized());
|
||||||
undo_stack.push(new AddPartCommand(tr("arc"), this, current_arc));
|
undo_stack.push(new AddPartCommand(tr("arc"), this, current_arc));
|
||||||
|
emit(partsAdded());
|
||||||
break;
|
break;
|
||||||
case Circle:
|
case Circle:
|
||||||
current_circle -> setRect(current_circle -> rect().normalized());
|
current_circle -> setRect(current_circle -> rect().normalized());
|
||||||
undo_stack.push(new AddPartCommand(tr("cercle"), this, current_circle));
|
undo_stack.push(new AddPartCommand(tr("cercle"), this, current_circle));
|
||||||
|
emit(partsAdded());
|
||||||
break;
|
break;
|
||||||
case Terminal:
|
case Terminal:
|
||||||
terminal = new PartTerminal(element_editor, 0, this);
|
terminal = new PartTerminal(element_editor, 0, this);
|
||||||
terminal -> setPos(e -> scenePos());
|
terminal -> setPos(e -> scenePos());
|
||||||
undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
|
undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
|
||||||
|
emit(partsAdded());
|
||||||
break;
|
break;
|
||||||
case Text:
|
case Text:
|
||||||
text = new PartText(element_editor, 0, this);
|
text = new PartText(element_editor, 0, this);
|
||||||
text -> setPos(e -> scenePos());
|
text -> setPos(e -> scenePos());
|
||||||
undo_stack.push(new AddPartCommand(tr("texte"), this, text));
|
undo_stack.push(new AddPartCommand(tr("texte"), this, text));
|
||||||
|
emit(partsAdded());
|
||||||
break;
|
break;
|
||||||
case TextField:
|
case TextField:
|
||||||
textfield = new PartTextField(element_editor, 0, this);
|
textfield = new PartTextField(element_editor, 0, this);
|
||||||
textfield -> setPos(e -> scenePos());
|
textfield -> setPos(e -> scenePos());
|
||||||
undo_stack.push(new AddPartCommand(tr("champ de texte"), this, textfield));
|
undo_stack.push(new AddPartCommand(tr("champ de texte"), this, textfield));
|
||||||
|
emit(partsAdded());
|
||||||
break;
|
break;
|
||||||
case Normal:
|
case Normal:
|
||||||
default:
|
default:
|
||||||
@@ -212,6 +219,7 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
behavior = Normal;
|
behavior = Normal;
|
||||||
undo_stack.push(new AddPartCommand(tr("polygone"), this, current_polygon));
|
undo_stack.push(new AddPartCommand(tr("polygone"), this, current_polygon));
|
||||||
current_polygon = NULL;
|
current_polygon = NULL;
|
||||||
|
emit(partsAdded());
|
||||||
emit(needNormalMode());
|
emit(needNormalMode());
|
||||||
} else QGraphicsScene::mouseReleaseEvent(e);
|
} else QGraphicsScene::mouseReleaseEvent(e);
|
||||||
} else QGraphicsScene::mouseReleaseEvent(e);
|
} else QGraphicsScene::mouseReleaseEvent(e);
|
||||||
@@ -424,6 +432,7 @@ void ElementScene::slot_delete() {
|
|||||||
|
|
||||||
// efface tout ce qui est selectionne
|
// efface tout ce qui est selectionne
|
||||||
undo_stack.push(new DeletePartsCommand(this, selected_items));
|
undo_stack.push(new DeletePartsCommand(this, selected_items));
|
||||||
|
emit(partsRemoved());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementScene::slot_editSizeHotSpot() {
|
void ElementScene::slot_editSizeHotSpot() {
|
||||||
@@ -536,6 +545,7 @@ void ElementScene::slot_editNames() {
|
|||||||
*/
|
*/
|
||||||
void ElementScene::slot_bringForward() {
|
void ElementScene::slot_bringForward() {
|
||||||
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::BringForward));
|
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::BringForward));
|
||||||
|
emit(partsZValueChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,6 +553,7 @@ void ElementScene::slot_bringForward() {
|
|||||||
*/
|
*/
|
||||||
void ElementScene::slot_raise() {
|
void ElementScene::slot_raise() {
|
||||||
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::Raise));
|
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::Raise));
|
||||||
|
emit(partsZValueChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -550,6 +561,7 @@ void ElementScene::slot_raise() {
|
|||||||
*/
|
*/
|
||||||
void ElementScene::slot_lower() {
|
void ElementScene::slot_lower() {
|
||||||
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::Lower));
|
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::Lower));
|
||||||
|
emit(partsZValueChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -557,6 +569,7 @@ void ElementScene::slot_lower() {
|
|||||||
*/
|
*/
|
||||||
void ElementScene::slot_sendBackward() {
|
void ElementScene::slot_sendBackward() {
|
||||||
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::SendBackward));
|
undoStack().push(new ChangeZValueCommand(this, ChangeZValueCommand::SendBackward));
|
||||||
|
emit(partsZValueChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -115,6 +115,9 @@ class ElementScene : public QGraphicsScene {
|
|||||||
signals:
|
signals:
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
void needNormalMode();
|
void needNormalMode();
|
||||||
|
void partsAdded();
|
||||||
|
void partsRemoved();
|
||||||
|
void partsZValueChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void ElementScene::setWidth(const uint &wid) {
|
inline void ElementScene::setWidth(const uint &wid) {
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene
|
|||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new ArcEditor(elementEditor(), this);
|
informations = new ArcEditor(elementEditor(), this);
|
||||||
informations -> setElementTypeName(QObject::tr("arc"));
|
informations -> setElementTypeName(name());
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
style_editor -> setElementTypeName(QObject::tr("arc"));
|
style_editor -> setElementTypeName(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
|||||||
enum { Type = UserType + 1101 };
|
enum { Type = UserType + 1101 };
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
||||||
|
virtual QString name() const { return(QObject::tr("arc")); }
|
||||||
virtual const QDomElement toXml(QDomDocument &) const;
|
virtual const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ PartCircle::PartCircle(QETElementEditor *editor, QGraphicsItem *parent, QGraphic
|
|||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new CircleEditor(elementEditor(), this);
|
informations = new CircleEditor(elementEditor(), this);
|
||||||
informations -> setElementTypeName(QObject::tr("cercle"));
|
informations -> setElementTypeName(name());
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
style_editor -> setElementTypeName(QObject::tr("cercle"));
|
style_editor -> setElementTypeName(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
void PartCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class PartCircle : public QGraphicsEllipseItem, public CustomElementGraphicPart
|
|||||||
enum { Type = UserType + 1102 };
|
enum { Type = UserType + 1102 };
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
||||||
|
virtual QString name() const { return(QObject::tr("cercle")); }
|
||||||
virtual const QDomElement toXml(QDomDocument &) const;
|
virtual const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ PartEllipse::PartEllipse(QETElementEditor *editor, QGraphicsItem *parent, QGraph
|
|||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new EllipseEditor(elementEditor(), this);
|
informations = new EllipseEditor(elementEditor(), this);
|
||||||
informations -> setElementTypeName(QObject::tr("ellipse"));
|
informations -> setElementTypeName(name());
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
style_editor -> setElementTypeName(QObject::tr("ellipse"));
|
style_editor -> setElementTypeName(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart
|
|||||||
enum { Type = UserType + 1103 };
|
enum { Type = UserType + 1103 };
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
||||||
|
virtual QString name() const { return(QObject::tr("ellipse")); }
|
||||||
virtual const QDomElement toXml(QDomDocument &) const;
|
virtual const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsSce
|
|||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new LineEditor(elementEditor(), this);
|
informations = new LineEditor(elementEditor(), this);
|
||||||
informations -> setElementTypeName(QObject::tr("ligne"));
|
informations -> setElementTypeName(name());
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
style_editor -> setElementTypeName(QObject::tr("ligne"));
|
style_editor -> setElementTypeName(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem */*q*/, QWidget */*w*/) {
|
void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem */*q*/, QWidget */*w*/) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
|
|||||||
enum { Type = UserType + 1104 };
|
enum { Type = UserType + 1104 };
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
||||||
|
virtual QString name() const { return(QObject::tr("ligne")); }
|
||||||
virtual const QDomElement toXml(QDomDocument &) const;
|
virtual const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneP1() const;
|
virtual QPointF sceneP1() const;
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent, QGraph
|
|||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new PolygonEditor(elementEditor(), this);
|
informations = new PolygonEditor(elementEditor(), this);
|
||||||
informations -> setElementTypeName(QObject::tr("polygone"));
|
informations -> setElementTypeName(name());
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
style_editor -> setElementTypeName(QObject::tr("polygone"));
|
style_editor -> setElementTypeName(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartPolygon::fromXml(const QDomElement &qde) {
|
void PartPolygon::fromXml(const QDomElement &qde) {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
|
|||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1105 };
|
enum { Type = UserType + 1105 };
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
|
virtual QString name() const { return(QObject::tr("polygone")); }
|
||||||
void fromXml(const QDomElement &);
|
void fromXml(const QDomElement &);
|
||||||
const QDomElement toXml(QDomDocument &) const;
|
const QDomElement toXml(QDomDocument &) const;
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent, QGra
|
|||||||
_orientation(QET::North)
|
_orientation(QET::North)
|
||||||
{
|
{
|
||||||
informations = new TerminalEditor(elementEditor(), this);
|
informations = new TerminalEditor(elementEditor(), this);
|
||||||
informations -> setElementTypeName(QObject::tr("borne"));
|
informations -> setElementTypeName(name());
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setZValue(100000);
|
setZValue(100000);
|
||||||
@@ -59,12 +59,12 @@ void PartTerminal::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget
|
|||||||
t.setWidthF(1.0);
|
t.setWidthF(1.0);
|
||||||
|
|
||||||
// dessin de la borne en rouge
|
// dessin de la borne en rouge
|
||||||
t.setColor(Qt::red);
|
t.setColor(isSelected() ? Terminal::couleur_neutre : Qt::red);
|
||||||
p -> setPen(t);
|
p -> setPen(t);
|
||||||
p -> drawLine(QPointF(0.0, 0.0), second_point);
|
p -> drawLine(QPointF(0.0, 0.0), second_point);
|
||||||
|
|
||||||
// dessin du point d'amarrage au conducteur en bleu
|
// dessin du point d'amarrage au conducteur en bleu
|
||||||
t.setColor(Terminal::couleur_neutre);
|
t.setColor(isSelected() ? Qt::red : Terminal::couleur_neutre);
|
||||||
p -> setPen(t);
|
p -> setPen(t);
|
||||||
p -> setBrush(Terminal::couleur_neutre);
|
p -> setBrush(Terminal::couleur_neutre);
|
||||||
p -> drawPoint(QPointF(0.0, 0.0));
|
p -> drawPoint(QPointF(0.0, 0.0));
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
|||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1106 };
|
enum { Type = UserType + 1106 };
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
|
virtual QString name() const { return(QObject::tr("borne")); }
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual const QDomElement toXml(QDomDocument &) const;
|
virtual const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual QWidget *elementInformations();
|
virtual QWidget *elementInformations();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent, ElementScene
|
|||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setPlainText(QObject::tr("T"));
|
setPlainText(QObject::tr("T"));
|
||||||
infos = new TextEditor(elementEditor(), this);
|
infos = new TextEditor(elementEditor(), this);
|
||||||
infos -> setElementTypeName(QObject::tr("texte"));
|
infos -> setElementTypeName(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
PartText::~PartText() {
|
PartText::~PartText() {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1107 };
|
enum { Type = UserType + 1107 };
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
|
virtual QString name() const { return(QObject::tr("texte")); }
|
||||||
void fromXml(const QDomElement &);
|
void fromXml(const QDomElement &);
|
||||||
const QDomElement toXml(QDomDocument &) const;
|
const QDomElement toXml(QDomDocument &) const;
|
||||||
QWidget *elementInformations();
|
QWidget *elementInformations();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ PartTextField::PartTextField(QETElementEditor *editor, QGraphicsItem *parent, QG
|
|||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setPlainText(QObject::tr("_"));
|
setPlainText(QObject::tr("_"));
|
||||||
infos = new TextFieldEditor(elementEditor(), this);
|
infos = new TextFieldEditor(elementEditor(), this);
|
||||||
infos -> setElementTypeName(QObject::tr("champ de texte"));
|
infos -> setElementTypeName(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
PartTextField::~PartTextField() {
|
PartTextField::~PartTextField() {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1108 };
|
enum { Type = UserType + 1108 };
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
|
virtual QString name() const { return(QObject::tr("champ de texte")); }
|
||||||
void fromXml(const QDomElement &);
|
void fromXml(const QDomElement &);
|
||||||
const QDomElement toXml(QDomDocument &) const;
|
const QDomElement toXml(QDomDocument &) const;
|
||||||
QWidget *elementInformations();
|
QWidget *elementInformations();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "elementview.h"
|
#include "elementview.h"
|
||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
#include "newelementwizard.h"
|
#include "newelementwizard.h"
|
||||||
|
#include "elementitemeditor.h"
|
||||||
|
|
||||||
QETElementEditor::QETElementEditor(QWidget *parent) :
|
QETElementEditor::QETElementEditor(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
@@ -259,7 +260,24 @@ void QETElementEditor::setupInterface() {
|
|||||||
addDockWidget(Qt::RightDockWidgetArea, undo_dock);
|
addDockWidget(Qt::RightDockWidgetArea, undo_dock);
|
||||||
undo_dock -> setWidget(new QUndoView(&(ce_scene -> undoStack()), this));
|
undo_dock -> setWidget(new QUndoView(&(ce_scene -> undoStack()), this));
|
||||||
|
|
||||||
|
// panel sur le côté pour la liste des parties
|
||||||
|
parts_list = new QListWidget(this);
|
||||||
|
parts_list -> setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
connect(ce_scene, SIGNAL(partsAdded()), this, SLOT(slot_createPartsList()));
|
||||||
|
connect(ce_scene, SIGNAL(partsRemoved()), this, SLOT(slot_createPartsList()));
|
||||||
|
connect(ce_scene, SIGNAL(partsZValueChanged()), this, SLOT(slot_createPartsList()));
|
||||||
|
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updatePartsList()));
|
||||||
|
connect(parts_list, SIGNAL(itemSelectionChanged()), this, SLOT(slot_updateSelectionFromPartsList()));
|
||||||
|
parts_dock = new QDockWidget(tr("Parties"), this);
|
||||||
|
parts_dock -> setObjectName("parts_list");
|
||||||
|
parts_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
|
parts_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||||
|
parts_dock -> setMinimumWidth(290);
|
||||||
|
addDockWidget(Qt::RightDockWidgetArea, parts_dock);
|
||||||
|
parts_dock -> setWidget(parts_list);
|
||||||
|
|
||||||
slot_updateInformations();
|
slot_updateInformations();
|
||||||
|
slot_createPartsList();
|
||||||
|
|
||||||
// barre d'etat
|
// barre d'etat
|
||||||
statusBar() -> showMessage(tr("\311diteur d'\351l\351ments"));
|
statusBar() -> showMessage(tr("\311diteur d'\351l\351ments"));
|
||||||
@@ -357,6 +375,7 @@ void QETElementEditor::fromFile(const QString &filepath) {
|
|||||||
|
|
||||||
// chargement de l'element
|
// chargement de l'element
|
||||||
ce_scene -> fromXml(document_xml);
|
ce_scene -> fromXml(document_xml);
|
||||||
|
slot_createPartsList();
|
||||||
|
|
||||||
// gestion de la lecture seule
|
// gestion de la lecture seule
|
||||||
if (!infos_file.isWritable()) {
|
if (!infos_file.isWritable()) {
|
||||||
@@ -496,3 +515,59 @@ void QETElementEditor::closeEvent(QCloseEvent *qce) {
|
|||||||
qce -> accept();
|
qce -> accept();
|
||||||
} else qce -> ignore();
|
} else qce -> ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Remplit la liste des parties
|
||||||
|
*/
|
||||||
|
void QETElementEditor::slot_createPartsList() {
|
||||||
|
parts_list -> blockSignals(true);
|
||||||
|
parts_list -> clear();
|
||||||
|
QList<QGraphicsItem *> qgis = ce_scene -> zItems(true);
|
||||||
|
for (int j = qgis.count() - 1 ; j >= 0 ; -- j) {
|
||||||
|
QGraphicsItem *qgi = qgis[j];
|
||||||
|
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
|
||||||
|
QString part_desc = cep -> name();
|
||||||
|
QListWidgetItem *qlwi = new QListWidgetItem(part_desc);
|
||||||
|
QVariant v;
|
||||||
|
v.setValue<QGraphicsItem *>(qgi);
|
||||||
|
qlwi -> setData(42, v);
|
||||||
|
parts_list -> addItem(qlwi);
|
||||||
|
qlwi -> setSelected(qgi -> isSelected());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parts_list -> blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Met a jour la selection dans la liste des parties
|
||||||
|
*/
|
||||||
|
void QETElementEditor::slot_updatePartsList() {
|
||||||
|
parts_list -> blockSignals(true);
|
||||||
|
int i = 0;
|
||||||
|
QList<QGraphicsItem *> items = ce_scene -> zItems(true);
|
||||||
|
for (int j = items.count() - 1 ; j >= 0 ; -- j) {
|
||||||
|
QGraphicsItem *qgi = items[j];
|
||||||
|
QListWidgetItem *qlwi = parts_list -> item(i);
|
||||||
|
if (qlwi) qlwi -> setSelected(qgi -> isSelected());
|
||||||
|
++ i;
|
||||||
|
}
|
||||||
|
parts_list -> blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Met a jour la selection des parties de l'element a partir de la liste des
|
||||||
|
parties
|
||||||
|
*/
|
||||||
|
void QETElementEditor::slot_updateSelectionFromPartsList() {
|
||||||
|
ce_scene -> blockSignals(true);
|
||||||
|
parts_list -> blockSignals(true);
|
||||||
|
for (int i = 0 ; i < parts_list -> count() ; ++ i) {
|
||||||
|
QListWidgetItem *qlwi = parts_list -> item(i);
|
||||||
|
QGraphicsItem *qgi = qlwi -> data(42).value<QGraphicsItem *>();
|
||||||
|
if (qgi) {
|
||||||
|
qgi -> setSelected(qlwi -> isSelected());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parts_list -> blockSignals(false);
|
||||||
|
ce_scene -> blockSignals(false);
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ class QETElementEditor : public QMainWindow {
|
|||||||
QDockWidget *tools_dock;
|
QDockWidget *tools_dock;
|
||||||
/// container pour la liste des annulations
|
/// container pour la liste des annulations
|
||||||
QDockWidget *undo_dock;
|
QDockWidget *undo_dock;
|
||||||
|
/// Container pour la liste des parties
|
||||||
|
QDockWidget *parts_dock;
|
||||||
|
/// Liste des parties
|
||||||
|
QListWidget *parts_list;
|
||||||
/// actions du menu fichier
|
/// actions du menu fichier
|
||||||
QAction *new_element, *open, *save, *save_as, *quit;
|
QAction *new_element, *open, *save, *save_as, *quit;
|
||||||
/// actions du menu edition
|
/// actions du menu edition
|
||||||
@@ -90,6 +94,9 @@ class QETElementEditor : public QMainWindow {
|
|||||||
void slot_updateInformations();
|
void slot_updateInformations();
|
||||||
void slot_updateMenus();
|
void slot_updateMenus();
|
||||||
void slot_updateTitle();
|
void slot_updateTitle();
|
||||||
|
void slot_createPartsList();
|
||||||
|
void slot_updatePartsList();
|
||||||
|
void slot_updateSelectionFromPartsList();
|
||||||
void xmlPreview();
|
void xmlPreview();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user