• 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
DeleteAction.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  Copyright 2011 Andreas Cord-Landwehr <cola@uni-paderborn.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include "DeleteAction.h"
22 
23 #include <KLocale>
24 #include <QGraphicsItem>
25 #include <QGraphicsScene>
26 #include <QKeyEvent>
27 #include "Scene/GraphScene.h"
28 #include "Scene/DataItem.h"
29 #include "DataStructure.h"
30 #include "Data.h"
31 
32 
33 DeleteAction::DeleteAction(const QString& name, GraphScene *scene, QWidget *parent)
34  : KAction(KIcon(), name, parent)
35 {
36  _graphScene = scene;
37  connect(this, SIGNAL(triggered()), this, SLOT(executeDelete()));
38 }
39 
40 DeleteAction::DeleteAction(const QString& name, GraphScene *scene, DataPtr data, QWidget *parent)
41  : KAction(KIcon(), name, parent)
42 {
43  _graphScene = scene;
44  _data = data;
45  connect(this, SIGNAL(triggered()), this, SLOT(executeDelete()));
46 }
47 
48 DeleteAction::DeleteAction(const QString& name, GraphScene *scene, DataStructurePtr dataStructure, QWidget *parent)
49  : KAction(KIcon(), name, parent)
50 {
51  _graphScene = scene;
52  _dataStructure = dataStructure;
53  connect(this, SIGNAL(triggered()), this, SLOT(executeDelete()));
54 }
55 
56 
57 void DeleteAction::executeDelete()
58 {
59  if (_data) {
60  _data->remove();
61  return;
62  }
63  if (_dataStructure) {
64  _dataStructure->remove();
65  return;
66  }
67  foreach(QGraphicsItem * selectedItem, _graphScene->selectedItems()) {
68  if (DataItem *dItem = qgraphicsitem_cast<DataItem*>(selectedItem)) {
69  dItem->data()->remove();
70  }
71  }
72 }
QWidget
QGraphicsScene::selectedItems
QList< QGraphicsItem * > selectedItems() const
QGraphicsItem
GraphScene.h
DeleteAction.h
GraphScene
Definition: GraphScene.h:38
QString
DeleteAction::executeDelete
void executeDelete()
Definition: DeleteAction.cpp:57
DeleteAction::DeleteAction
DeleteAction(const QString &name, GraphScene *scene, QWidget *parent)
Constructor for delete action that deletes all selected data items.
Definition: DeleteAction.cpp:33
DataItem
Definition: DataItem.h:38
KAction
DataItem.h
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