mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-06 13:40:52 +01:00
Diagram view: All add action (text/shape/image) is now managed outside of diagram view by subclass of DVEventInterface
DVEventInterface :this abstract class is used by diagram view to manage is event action (mouse event). For add new action to diagram view, we must to create subclass of DVEventInterface and give it to diagram view, when diagram view get the new dvevent, they manage it, and delete it when action is finish. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3329 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
155
sources/dvevent/dveventaddimage.cpp
Normal file
155
sources/dvevent/dveventaddimage.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "diagramimageitem.h"
|
||||
#include "diagramcommands.h"
|
||||
#include "dveventaddimage.h"
|
||||
#include "diagramview.h"
|
||||
#include "diagram.h"
|
||||
#include <QObject>
|
||||
|
||||
/**
|
||||
* @brief DVEventAddImage::DVEventAddImage
|
||||
* Defaultconstructor
|
||||
* @param dv : diagram view where operate this event
|
||||
*/
|
||||
DVEventAddImage::DVEventAddImage(DiagramView *dv) :
|
||||
DVEventInterface (dv),
|
||||
m_image (nullptr),
|
||||
m_is_added (false)
|
||||
{
|
||||
openDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddImage::~DVEventAddImage
|
||||
*/
|
||||
DVEventAddImage::~DVEventAddImage() {
|
||||
if (m_running) {
|
||||
if (m_is_added) m_diagram -> removeItem(m_image);
|
||||
delete m_image;
|
||||
}
|
||||
m_dv -> setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddImage::mousePressEvent
|
||||
* Action when mouse is pressed
|
||||
* @param event : event of mouse pressed
|
||||
* @return : true if this event is managed, otherwise false
|
||||
*/
|
||||
bool DVEventAddImage::mousePressEvent(QMouseEvent *event) {
|
||||
if (m_image && event -> button() == Qt::LeftButton) {
|
||||
m_diagram -> undoStack().push(new AddImageCommand(m_diagram, m_image, m_dv->mapToScene(event->pos())));
|
||||
m_dv -> setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||
m_running = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_image && event -> button() == Qt::RightButton) {
|
||||
m_image -> rotateBy(90);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddImage::mouseMoveEvent
|
||||
* Action when mouse move
|
||||
* @param event : event of mouse move
|
||||
* @return : true if this event is managed, otherwise false
|
||||
*/
|
||||
bool DVEventAddImage::mouseMoveEvent(QMouseEvent *event) {
|
||||
//@m_image isn't loaded, we return true and @m_running return
|
||||
//so the diagram view owner of this DVEevent will delete it.
|
||||
//if (!m_image) return true;
|
||||
|
||||
if (!m_image || event -> buttons() != Qt::NoButton) return false;
|
||||
|
||||
QPointF pos = m_dv -> mapToScene(event -> pos());
|
||||
|
||||
if (!m_is_added) {
|
||||
m_dv -> setContextMenuPolicy(Qt::NoContextMenu);
|
||||
m_diagram -> addItem(m_image);
|
||||
m_is_added = true;
|
||||
}
|
||||
m_image -> setPos(pos - m_image -> boundingRect().center());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddImage::mouseDoubleClickEvent
|
||||
* This methode is only use to overwrite double click.
|
||||
* When double clic, image propertie dialog isn't open.
|
||||
* @param event : event of mouse double click
|
||||
* @return : true if this event is managed, otherwise false
|
||||
*/
|
||||
bool DVEventAddImage::mouseDoubleClickEvent(QMouseEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddImage::wheelEvent
|
||||
* Action when mouse wheel is rotate
|
||||
* @param event : event of mouse wheel
|
||||
* @return : true if this event is managed, otherwise false
|
||||
*/
|
||||
bool DVEventAddImage::wheelEvent(QWheelEvent *event) {
|
||||
|
||||
if (!m_is_added || !m_image || event -> modifiers() != Qt::CTRL) return false;
|
||||
|
||||
qreal scaling = m_image->scale();
|
||||
event->delta() > 1? scaling += 0.01 : scaling -= 0.01;
|
||||
if (scaling>0.01 && scaling <= 2)
|
||||
m_image->setScale(scaling);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddImage::isNull
|
||||
* @return true if image can't be loaded, otherwise return false.
|
||||
*/
|
||||
bool DVEventAddImage::isNull() const {
|
||||
if (!m_image) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddImage::openDialog
|
||||
* Open dialog for select the image to add.
|
||||
*/
|
||||
void DVEventAddImage::openDialog() {
|
||||
if (m_diagram -> isReadOnly()) return;
|
||||
|
||||
//Open dialog for select image
|
||||
QString pathPictures = QDesktopServices::storageLocation ( QDesktopServices::PicturesLocation );
|
||||
QString fileName = QFileDialog::getOpenFileName(m_dv, QObject::tr("Selectionner une image..."), pathPictures, QObject::tr("Image Files (*.png *.jpg *.bmp *.svg)"));
|
||||
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
QImage image(fileName);
|
||||
if(image.isNull()) {
|
||||
QMessageBox::critical(m_dv, QObject::tr("Erreur"), QObject::tr("Impossible de charger l'image."));
|
||||
return;
|
||||
}
|
||||
|
||||
m_image = new DiagramImageItem (QPixmap::fromImage(image));
|
||||
m_running = true;
|
||||
}
|
||||
50
sources/dvevent/dveventaddimage.h
Normal file
50
sources/dvevent/dveventaddimage.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef DVEVENTADDIMAGE_H
|
||||
#define DVEVENTADDIMAGE_H
|
||||
|
||||
#include "dveventinterface.h"
|
||||
|
||||
class DiagramImageItem;
|
||||
|
||||
/**
|
||||
* @brief The DVEventAddImage class
|
||||
* This dv event, open an image and add it to diagram view.
|
||||
*/
|
||||
class DVEventAddImage : public DVEventInterface
|
||||
{
|
||||
public:
|
||||
DVEventAddImage(DiagramView *dv);
|
||||
virtual ~DVEventAddImage();
|
||||
|
||||
virtual bool mousePressEvent (QMouseEvent *event);
|
||||
virtual bool mouseMoveEvent (QMouseEvent *event);
|
||||
virtual bool mouseDoubleClickEvent (QMouseEvent *event);
|
||||
virtual bool wheelEvent (QWheelEvent *event);
|
||||
|
||||
bool isNull () const;
|
||||
|
||||
private:
|
||||
void openDialog();
|
||||
|
||||
DiagramImageItem *m_image;
|
||||
bool m_is_added;
|
||||
|
||||
};
|
||||
|
||||
#endif // DVEVENTADDIMAGE_H
|
||||
130
sources/dvevent/dveventaddshape.cpp
Normal file
130
sources/dvevent/dveventaddshape.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "dveventaddshape.h"
|
||||
#include "diagramview.h"
|
||||
#include "qetshapeitem.h"
|
||||
#include "diagram.h"
|
||||
#include "diagramcommands.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
/**
|
||||
* @brief DVEventAddShape::DVEventAddShape
|
||||
* Default constructor
|
||||
* @param dv, the diagram view where operate this event
|
||||
* @param shape_type, the shape type to draw
|
||||
*/
|
||||
DVEventAddShape::DVEventAddShape(DiagramView *dv, QetShapeItem::ShapeType shape_type) :
|
||||
DVEventInterface(dv),
|
||||
m_shape_type (shape_type),
|
||||
m_shape_item (nullptr)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddShape::~DVEventAddShape
|
||||
*/
|
||||
DVEventAddShape::~DVEventAddShape() {
|
||||
if (m_running) {
|
||||
m_diagram -> removeItem(m_shape_item);
|
||||
delete m_shape_item;
|
||||
}
|
||||
m_dv -> setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddShape::mousePressEvent
|
||||
* Action when mouse is pressed
|
||||
* @param event : event of mouse press
|
||||
* @return : true if this event is managed, otherwise false
|
||||
*/
|
||||
bool DVEventAddShape::mousePressEvent(QMouseEvent *event) {
|
||||
|
||||
if (!m_dv->isInteractive() && m_diagram->isReadOnly()) return false;
|
||||
|
||||
QPointF pos = m_dv->mapToScene(event->pos());
|
||||
|
||||
//@m_running false => shape isn't created yet, we create a new shape
|
||||
if (m_running == false && event -> button() == Qt::LeftButton) {
|
||||
m_shape_item = new QetShapeItem(pos, pos, m_shape_type);
|
||||
m_dv -> setContextMenuPolicy (Qt::NoContextMenu);
|
||||
m_diagram -> addItem (m_shape_item);
|
||||
m_running = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//At this point m_shape_item must be created
|
||||
if (!m_shape_item) return false;
|
||||
|
||||
// Next left click finish all shape item except the polyline
|
||||
if (m_shape_type != QetShapeItem::Polyline && event->button() == Qt::LeftButton) {
|
||||
m_shape_item -> setP2 (pos);
|
||||
m_diagram -> undoStack().push (new AddShapeCommand(m_diagram, m_shape_item, pos));
|
||||
m_dv -> setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||
m_running = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Next left click create new segment for polyline
|
||||
if (m_shape_type == QetShapeItem::Polyline && event -> button() == Qt::LeftButton) {
|
||||
m_shape_item -> setNextPoint (Diagram::snapToGrid(pos)); //< this point is ok for pos
|
||||
m_shape_item -> setNextPoint (Diagram::snapToGrid(pos)); //< Add new point for next segment. the pos of this point
|
||||
//< can be changed by calling QetShapItem::setP2()
|
||||
return true;
|
||||
}
|
||||
|
||||
// If shape item is polyline and click is right button, the shape item is finish
|
||||
// m_running is set to false at the release of right button.
|
||||
if (m_shape_type == QetShapeItem::Polyline && event -> button() == Qt::RightButton) {
|
||||
m_shape_item -> setP2 (pos);
|
||||
m_diagram -> undoStack().push(new AddShapeCommand(m_diagram, m_shape_item, pos));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddShape::mouseMoveEvent
|
||||
* Action when mouse move
|
||||
* @param event : event of mouse move
|
||||
* @return : true if this event is managed, otherwise false
|
||||
*/
|
||||
bool DVEventAddShape::mouseMoveEvent(QMouseEvent *event) {
|
||||
if (!m_running) return false;
|
||||
if (m_shape_item && event -> buttons() == Qt::NoButton) {
|
||||
m_shape_item -> setP2 (m_dv -> mapToScene (event -> pos()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DVEventAddShape::mouseReleaseEvent
|
||||
* Action when mouse button is released
|
||||
* @param event : event of mouse release
|
||||
* @return : true if this event is managed, otherwise false
|
||||
*/
|
||||
bool DVEventAddShape::mouseReleaseEvent(QMouseEvent *event) {
|
||||
//When the shape is polyline, we set default context menu to diagram view
|
||||
//only when the right button is released
|
||||
if (m_shape_type == QetShapeItem::Polyline && event -> button() == Qt::RightButton ) {
|
||||
m_dv -> setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||
m_running = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
40
sources/dvevent/dveventaddshape.h
Normal file
40
sources/dvevent/dveventaddshape.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef DVEVENTADDSHAPE_H
|
||||
#define DVEVENTADDSHAPE_H
|
||||
|
||||
#include "dveventinterface.h"
|
||||
#include "qetshapeitem.h"
|
||||
|
||||
class QMouseEvent;
|
||||
|
||||
class DVEventAddShape : public DVEventInterface
|
||||
{
|
||||
public:
|
||||
DVEventAddShape(DiagramView *dv, QetShapeItem::ShapeType shape_type);
|
||||
virtual ~DVEventAddShape ();
|
||||
virtual bool mousePressEvent (QMouseEvent *event);
|
||||
virtual bool mouseMoveEvent (QMouseEvent *event);
|
||||
virtual bool mouseReleaseEvent (QMouseEvent *event);
|
||||
|
||||
protected:
|
||||
QetShapeItem::ShapeType m_shape_type;
|
||||
QetShapeItem *m_shape_item;
|
||||
};
|
||||
|
||||
#endif // DVEVENTADDSHAPE_H
|
||||
39
sources/dvevent/dveventaddtext.cpp
Normal file
39
sources/dvevent/dveventaddtext.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "dveventaddtext.h"
|
||||
#include "independenttextitem.h"
|
||||
#include "diagram.h"
|
||||
#include "diagramcommands.h"
|
||||
#include "diagramview.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
DVEventAddText::DVEventAddText(DiagramView *dv) :
|
||||
DVEventInterface (dv)
|
||||
{}
|
||||
|
||||
DVEventAddText::~DVEventAddText() {}
|
||||
|
||||
bool DVEventAddText::mousePressEvent(QMouseEvent *event) {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
m_diagram -> undoStack().push(new AddTextCommand(m_diagram,
|
||||
new IndependentTextItem("_"),
|
||||
m_dv -> mapToScene(event -> pos())));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
31
sources/dvevent/dveventaddtext.h
Normal file
31
sources/dvevent/dveventaddtext.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef DVEVENTADDTEXT_H
|
||||
#define DVEVENTADDTEXT_H
|
||||
|
||||
#include "dveventinterface.h"
|
||||
|
||||
class DVEventAddText : public DVEventInterface
|
||||
{
|
||||
public:
|
||||
DVEventAddText(DiagramView *dv);
|
||||
virtual ~DVEventAddText ();
|
||||
virtual bool mousePressEvent (QMouseEvent *event);
|
||||
};
|
||||
|
||||
#endif // DVEVENTADDTEXT_H
|
||||
62
sources/dvevent/dveventinterface.cpp
Normal file
62
sources/dvevent/dveventinterface.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "dveventinterface.h"
|
||||
#include "diagramview.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
DVEventInterface::DVEventInterface(DiagramView *dv) :
|
||||
m_dv(dv),
|
||||
m_diagram(dv->diagram()),
|
||||
m_running(false)
|
||||
{
|
||||
}
|
||||
|
||||
DVEventInterface::~DVEventInterface() {};
|
||||
|
||||
bool DVEventInterface::mouseDoubleClickEvent(QMouseEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DVEventInterface::mousePressEvent(QMouseEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DVEventInterface::mouseMoveEvent(QMouseEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DVEventInterface::mouseReleaseEvent(QMouseEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DVEventInterface::wheelEvent(QWheelEvent *event) {
|
||||
Q_UNUSED (event);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DVEventInterface::isRunning() const {
|
||||
return m_running;
|
||||
}
|
||||
|
||||
bool DVEventInterface::isFinish() const {
|
||||
return !m_running;
|
||||
}
|
||||
54
sources/dvevent/dveventinterface.h
Normal file
54
sources/dvevent/dveventinterface.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef DVEVENTINTERFACE_H
|
||||
#define DVEVENTINTERFACE_H
|
||||
|
||||
class QMouseEvent;
|
||||
class QWheelEvent;
|
||||
class DiagramView;
|
||||
class Diagram;
|
||||
|
||||
/**
|
||||
* @brief The DVEventInterface class
|
||||
* This class is the main interface for manage event of a Diagram View.
|
||||
* This do nothing, for create new event behavior, we must to create new class from this.
|
||||
* Each method return a bool: True if the methode do something else return false.
|
||||
* Each method of DVEventInterface return false;
|
||||
* isRunning() return true if action is started but not finish. By default return false.
|
||||
* isFinish() return true when the action is finish, or not started. By default return true.
|
||||
*/
|
||||
class DVEventInterface
|
||||
{
|
||||
public:
|
||||
DVEventInterface(DiagramView *dv);
|
||||
virtual ~DVEventInterface () = 0;
|
||||
virtual bool mouseDoubleClickEvent (QMouseEvent *event);
|
||||
virtual bool mousePressEvent (QMouseEvent *event);
|
||||
virtual bool mouseMoveEvent (QMouseEvent *event);
|
||||
virtual bool mouseReleaseEvent (QMouseEvent *event);
|
||||
virtual bool wheelEvent (QWheelEvent *event);
|
||||
virtual bool isRunning () const;
|
||||
virtual bool isFinish () const;
|
||||
|
||||
protected:
|
||||
DiagramView *m_dv;
|
||||
Diagram *m_diagram;
|
||||
bool m_running;
|
||||
};
|
||||
|
||||
#endif // DVEVENTINTERFACE_H
|
||||
Reference in New Issue
Block a user