QElectroTech  0.70
dveventinterface.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "dveventinterface.h"
19 #include "diagramview.h"
20 #include <QMouseEvent>
21 
23  QObject(dv),
24  m_dv(dv),
25  m_diagram(dv->diagram()),
26  m_running(false),
27  m_abort(false)
28 {
29 }
30 
32 }
33 
34 bool DVEventInterface::mouseDoubleClickEvent(QMouseEvent *event) {
35  Q_UNUSED (event);
36  return false;
37 }
38 
39 bool DVEventInterface::mousePressEvent(QMouseEvent *event) {
40  Q_UNUSED (event);
41  return false;
42 }
43 
44 bool DVEventInterface::mouseMoveEvent(QMouseEvent *event) {
45  Q_UNUSED (event);
46  return false;
47 }
48 
49 bool DVEventInterface::mouseReleaseEvent(QMouseEvent *event) {
50  Q_UNUSED (event);
51  return false;
52 }
53 
54 bool DVEventInterface::wheelEvent(QWheelEvent *event) {
55  Q_UNUSED (event);
56  return false;
57 }
58 
66 bool DVEventInterface::keyPressEvent(QKeyEvent *event)
67 {
68  if (event->key() == Qt::Key_Escape)
69  {
70  m_running = false;
71  m_abort = true;
72  emit finish();
73  return true;
74  }
75  return false;
76 }
77 
78 bool DVEventInterface::KeyReleaseEvent(QKeyEvent *event) {
79  Q_UNUSED (event);
80  return false;
81 }
82 
84  return m_running;
85 }
86 
88  return !m_running;
89 }
~DVEventInterface() override=0
virtual bool keyPressEvent(QKeyEvent *event)
DVEventInterface::keyPressEvent By default, press escape key abort the curent action. isFinish return true, and emit finish.
virtual bool isRunning() const
virtual bool mouseDoubleClickEvent(QMouseEvent *event)
virtual bool KeyReleaseEvent(QKeyEvent *event)
virtual bool mouseReleaseEvent(QMouseEvent *event)
void finish()
finish emited when the interface finish is work
virtual bool mouseMoveEvent(QMouseEvent *event)
virtual bool wheelEvent(QWheelEvent *event)
virtual bool mousePressEvent(QMouseEvent *event)
virtual bool isFinish() const
DVEventInterface(DiagramView *dv)