48 m_element -> setFlag(QGraphicsItem::ItemIsSelectable,
false);
63 foreach(QGraphicsView *view,
m_diagram->views())
64 view -> setContextMenuPolicy(Qt::DefaultContextMenu);
78 event->setAccepted(
true);
88 event->setAccepted(
true);
102 if (event->button() == Qt::RightButton)
109 else if (event->button() == Qt::LeftButton)
115 event->setAccepted(
true);
126 if (
m_element && (event -> button() == Qt::LeftButton))
134 event->setAccepted(
true);
145 if (
m_element && event->key() == Qt::Key_Space)
148 event->setAccepted(
true);
161 foreach(QGraphicsView *view,
m_diagram->views())
162 view->setContextMenuPolicy(Qt::NoContextMenu);
172 if (import_loc.
exist()) {
176 qDebug() <<
"DiagramView::addDroppedElement : Impossible d'ajouter l'element.";
216 element -> setRotation(
m_element -> rotation());
224 QUndoCommand *undo_object =
new QUndoCommand(
tr(
"Ajouter %1").arg(element->
name()));
227 while (!element -> AlignedFreeTerminals().isEmpty() &&
m_diagram -> project() -> autoConductor())
229 QPair <Terminal *, Terminal *> pair = element -> AlignedFreeTerminals().takeFirst();
238 conductor->setFreezeLabel(
true);
242 m_diagram -> undoStack().push(undo_object);
243 element->setUpFormula();
244 element->freezeNewAddedElement();
virtual void keyPressEvent(QKeyEvent *event)
DiagramEventInterface::keyPressEvent By default, press escape key abort the curent action...
ElementsLocation importElement(ElementsLocation &location)
QETProject::importElement Import the element represented by to the embbeded collection of this proje...
QString projectCollectionPath() const
ElementsLocation::projectCollectionPath.
bool isFreezeNewConductors()
QETProject::isFreezeNewConductors.
DiagramEventAddElement(ElementsLocation &location, Diagram *diagram, QPointF pos=QPointF(0, 0))
DiagramEventAddElement::DiagramEventAddElement Defaut constructor.
bool buildElement()
DiagramEventAddElement::buildElement Build the element, if the element is build successfully, we return true, otherwise false.
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddElement::mouseDoubleClickEvent If mouse left double clic, finish this event (isRunning...
ElementsLocation m_location
QString name() const override
Element::name.
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddElement::mouseReleaseEvent Right button finish this event (isRunning = false) and emit...
The AddItemCommand class This command add an item in a diagram The item to add is template...
void keyPressEvent(QKeyEvent *event) override
DiagramEventAddElement::keyPressEvent Press space key rotate the element to 90° (return true) else ca...
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddElement::mouseMoveEvent Move the element to new pos of mouse the event is always accep...
bool freezeNewConductors()
Diagram::freezeNewConductors.
~DiagramEventAddElement() override
DiagramEventAddElement::~DiagramEventAddElement Destructor Enable context menu for each view of diagr...
void init() override
DiagramEventAddElement::init Init this event.
bool exist() const
ElementsLocation::exist.
static QPointF snapToGrid(const QPointF &p)
Diagram::snapToGrid Return a nearest snap point of p.
QList< DynamicElementTextItem * > m_dynamic_text_list
The DiagramEventInterface class isRunning() return true if action is running (do something). By default return false.
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddElement::mousePressEvent Do nothing, but return true for not transit the event to othe...
bool isElement() const
ElementsLocation::isElement.
virtual void setPos(const QPointF &p)
QetGraphicsItem::setPos set the position of the item to p.
QETProject * project() const
QHash< DynamicElementTextItem *, QPointF > m_converted_text_from_xml_description
static ElementFactory * Instance()
void addElement()
DiagramEventAddElement::addElement Add an element at the current pos en current rotation, if project autoconductor option is enable, and the element can be wired, we do it.