48 foreach (QGraphicsView *view,
m_diagram->views())
49 view->setContextMenuPolicy((Qt::DefaultContextMenu));
59 if (
m_image && event -> button() == Qt::LeftButton)
61 QPointF pos =
event->scenePos();
66 for (QGraphicsView *view :
m_diagram->views()) {
67 view->setContextMenuPolicy((Qt::DefaultContextMenu));
72 event->setAccepted(
true);
74 else if (
m_image && event -> button() == Qt::RightButton)
77 event->setAccepted(
true);
88 if (!
m_image || event->buttons() != Qt::NoButton) {
92 QPointF pos =
event->scenePos();
96 for (QGraphicsView *view :
m_diagram->views()) {
97 view->setContextMenuPolicy((Qt::NoContextMenu));
105 event->setAccepted(
true);
115 event->setAccepted(
true);
129 qreal scaling =
m_image->scale();
130 event->delta() > 1? scaling += 0.01 : scaling -= 0.01;
131 if (scaling>0.01 && scaling <= 2) {
135 event->setAccepted(
true);
157 QString pathPictures = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
158 QString fileName = QFileDialog::getOpenFileName(
m_diagram->views().
isEmpty()? nullptr :
m_diagram->views().first(),
QObject::tr(
"Selectionner une image..."), pathPictures,
QObject::tr(
"Image Files (*.png *.jpg *.jpeg *.bmp *.svg)"));
160 if (fileName.isEmpty())
return;
162 QImage image(fileName);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddImage::mouseMoveEvent Action when mouse move.
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddImage::mousePressEvent Action when mouse is pressed.
~DiagramEventAddImage() override
DiagramEventAddImage::~DiagramEventAddImage.
void openDialog()
DiagramEventAddImage::openDialog Open dialog for select the image to add.
DiagramEventAddImage(Diagram *diagram)
DiagramEventAddImage::DiagramEventAddImage Default constructor.
QRectF boundingRect() const override
DiagramImageItem::boundingRect the outer bounds of the item as a rectangle, if no pixmap are set...
The AddItemCommand class This command add an item in a diagram The item to add is template...
bool isNull() const
DiagramEventAddImage::isNull.
virtual void removeItem(QGraphicsItem *item)
Diagram::removeItem Réimplemented from QGraphicsScene::removeItem(QGraphicsItem *item) Do some specif...
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddImage::mouseDoubleClickEvent This method is only use to overwrite double click...
DiagramImageItem * m_image
The DiagramEventInterface class isRunning() return true if action is running (do something). By default return false.
void wheelEvent(QGraphicsSceneWheelEvent *event) override
DiagramEventAddImage::wheelEvent Action when mouse wheel is rotate.
virtual void addItem(QGraphicsItem *item)
Diagram::addItem Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item) Do some specific ope...
virtual void setPos(const QPointF &p)
QetGraphicsItem::setPos set the position of the item to p.
QMessageBox::StandardButton critical(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)