• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

rocs/VisualEditor

  • sources
  • kde-4.14
  • kdeedu
  • rocs
  • VisualEditor
  • Actions
AbstractAction.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Rocs.
3  Copyright 2008 Tomaz Canabrava <tomaz.canabrava@gmail.com>
4  Copyright 2008 Ugo Sangiori <ugorox@gmail.com>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "AbstractAction.h"
21 #include "Scene/GraphScene.h"
22 #include "DataStructure.h"
23 #include "Document.h"
24 #include <QPointF>
25 #include <QGraphicsSceneEvent>
26 #include <QGraphicsSceneMouseEvent>
27 #include <QKeyEvent>
28 #include <KDebug>
29 
30 AbstractAction::AbstractAction(GraphScene *scene, QObject *parent)
31  : KToggleAction(parent)
32 {
33  _graphScene = scene;
34 }
35 
36 void AbstractAction::sendExecuteBit()
37 {
38  _graphScene -> setAction(this);
39 }
40 
41 const QString& AbstractAction::name() const
42 {
43  return _name;
44 }
45 
46 bool AbstractAction::eventFilter(QObject * watched, QEvent * event)
47 {
48  Q_UNUSED(watched);
49  switch (event->type()) {
50  case QEvent::GraphicsSceneMousePress : {
51  QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
52  if (e->button() == Qt::LeftButton) {
53  return executePress(e->scenePos());
54  }
55  // a right click shall not trigger any QAction parent class function
56  // since this is reserved for the context menu
57  // TODO add specific entries to graph scene context menu here
58  if (e->button() == Qt::RightButton) {
59  e->accept();
60  return true;
61  }
62  }
63  case QEvent::GraphicsSceneMouseMove : {
64  QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
65  return executeMove(e->scenePos());
66  }
67  case QEvent::GraphicsSceneMouseRelease : {
68  QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
69  return executeRelease(e->scenePos());
70  }
71  case QEvent::GraphicsSceneMouseDoubleClick : {
72  QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
73  return executeDoubleClick(e->scenePos());
74  }
75  case QEvent::KeyPress: {
76  QKeyEvent *e = static_cast<QKeyEvent*>(event);
77  return executeKeyPress(e);
78  }
79  case QEvent::KeyRelease: {
80  QKeyEvent *e = static_cast<QKeyEvent*>(event);
81  return executeKeyRelease(e);
82  }
83  case QEvent::GraphicsSceneWheel: {
84  QGraphicsSceneWheelEvent *e = static_cast<QGraphicsSceneWheelEvent*>(event);
85  return executeWheelEvent(e);
86  }
87  default: return false;
88  }
89  return false;
90 }
91 
92 bool AbstractAction::executePress(QPointF pos)
93 {
94  Q_UNUSED(pos);
95  return false;
96 }
97 bool AbstractAction::executeMove(QPointF pos)
98 {
99  Q_UNUSED(pos);
100  return false;
101 }
102 bool AbstractAction::executeRelease(QPointF pos)
103 {
104  Q_UNUSED(pos);
105  return false;
106 }
107 bool AbstractAction::executeDoubleClick(QPointF pos)
108 {
109  Q_UNUSED(pos);
110  return false;
111 }
112 bool AbstractAction::executeKeyPress(QKeyEvent *keyEvent)
113 {
114  Q_UNUSED(keyEvent);
115  return false;
116 }
117 bool AbstractAction::executeKeyRelease(QKeyEvent *keyEvent)
118 {
119  Q_UNUSED(keyEvent);
120  return false;
121 }
122 bool AbstractAction::executeWheelEvent(QGraphicsSceneWheelEvent* wEvent)
123 {
124  Q_UNUSED(wEvent);
125  return false;
126 }
AbstractAction::name
const QString & name() const
Definition: AbstractAction.cpp:41
QEvent
QEvent::type
Type type() const
QGraphicsSceneWheelEvent
AbstractAction::executeKeyRelease
virtual bool executeKeyRelease(QKeyEvent *keyEvent)
Definition: AbstractAction.cpp:117
AbstractAction.h
QGraphicsSceneMouseEvent::scenePos
QPointF scenePos() const
GraphScene.h
QPointF
AbstractAction::executeDoubleClick
virtual bool executeDoubleClick(QPointF pos)
Definition: AbstractAction.cpp:107
GraphScene
Definition: GraphScene.h:38
QObject
AbstractAction::_name
QString _name
Definition: AbstractAction.h:90
QGraphicsSceneMouseEvent
AbstractAction::executeRelease
virtual bool executeRelease(QPointF pos)
Definition: AbstractAction.cpp:102
AbstractAction::executePress
virtual bool executePress(QPointF pos)
Definition: AbstractAction.cpp:92
QGraphicsSceneMouseEvent::button
Qt::MouseButton button() const
QString
QEvent::accept
void accept()
AbstractAction::executeMove
virtual bool executeMove(QPointF pos)
Definition: AbstractAction.cpp:97
QKeyEvent
AbstractAction::_graphScene
GraphScene * _graphScene
Definition: AbstractAction.h:88
AbstractAction::AbstractAction
AbstractAction(GraphScene *scene, QObject *parent)
Definition: AbstractAction.cpp:30
AbstractAction::executeWheelEvent
virtual bool executeWheelEvent(QGraphicsSceneWheelEvent *wEvent)
Definition: AbstractAction.cpp:122
KToggleAction
AbstractAction::executeKeyPress
virtual bool executeKeyPress(QKeyEvent *keyEvent)
Definition: AbstractAction.cpp:112
AbstractAction::eventFilter
bool eventFilter(QObject *watched, QEvent *event)
Definition: AbstractAction.cpp:46
AbstractAction::sendExecuteBit
void sendExecuteBit()
Definition: AbstractAction.cpp:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:16:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

rocs/VisualEditor

Skip menu "rocs/VisualEditor"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal