• 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
PropertiesDialogAction.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Rocs.
3  Copyright 2012 Andreas Cord-Landwehr <cola@uni-paderborn.de>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library 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 GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 
21 #include "PropertiesDialogAction.h"
22 
23 #include <QPointer>
24 #include "Interface/DataStructurePropertiesDialog.h"
25 #include "Interface/DocumentPropertiesDialog.h"
26 #include "Interface/DataPropertiesWidget.h"
27 #include "Interface/DataTypePage.h"
28 #include "Interface/PointerPropertiesWidget.h"
29 #include "Interface/PointerTypePage.h"
30 #include <DocumentManager.h>
31 #include <Document.h>
32 
33 #include <QDebug>
34 #include <KTabWidget>
35 
36 
37 PropertiesDialogAction::PropertiesDialogAction(QString text, Document* document, QObject* parent)
38  : KAction(text, parent)
39 {
40  _document = document;
41  _dialogType = DOCUMENT;
42  this->setIcon(KIcon("document-properties"));
43  connect(this, SIGNAL(triggered()), this, SLOT(showDialog()));
44 }
45 
46 
47 PropertiesDialogAction::PropertiesDialogAction(QString text, DataStructurePtr dataStructure, QObject* parent)
48  : KAction(text, parent)
49 {
50  _dataStructure = dataStructure;
51  _dialogType = DATASTRUCTURE;
52  this->setIcon(KIcon("document-properties"));
53  connect(this, SIGNAL(triggered()), this, SLOT(showDialog()));
54 }
55 
56 
57 PropertiesDialogAction::PropertiesDialogAction(QString text, DataPtr data, QObject* parent)
58  : KAction(text, parent)
59 {
60  _data = data;
61  _dialogType = DATA;
62  this->setIcon(KIcon("document-properties"));
63  connect(this, SIGNAL(triggered()), this, SLOT(showDialog()));
64 }
65 
66 
67 PropertiesDialogAction::PropertiesDialogAction(QString text, PointerPtr pointer, QObject* parent)
68  : KAction(text, parent)
69 {
70  _pointer = pointer;
71  _dialogType = POINTER;
72  this->setIcon(KIcon("document-properties"));
73  connect(this, SIGNAL(triggered()), this, SLOT(showDialog()));
74 }
75 
76 
77 PropertiesDialogAction::PropertiesDialogAction(QString text, DataTypePtr dataType, QObject* parent)
78  : KAction(text, parent)
79 {
80  _dataType = dataType;
81  _dialogType = DATATYPE;
82  this->setIcon(KIcon("document-properties"));
83  connect(this, SIGNAL(triggered()), this, SLOT(showDialog()));
84 }
85 
86 
87 PropertiesDialogAction::PropertiesDialogAction(QString text, PointerTypePtr pointerType, QObject* parent)
88  : KAction(text, parent)
89 {
90  _pointerType = pointerType;
91  _dialogType = POINTERTYPE;
92  this->setIcon(KIcon("document-properties"));
93  connect(this, SIGNAL(triggered()), this, SLOT(showDialog()));
94 }
95 
96 void PropertiesDialogAction::showDialog()
97 {
98  switch (_dialogType) {
99  case DOCUMENT: {
100  if (!_document) {
101  return;
102  }
103  QPointer<DocumentPropertiesDialog> dialog = new DocumentPropertiesDialog;
104  dialog->setDocument(_document);
105  if (_screenPosition.isNull()) {
106  // value -3 means: center on screen that currently contains the mouse pointer.
107  KDialog::centerOnScreen(dialog, -3);
108  }
109  else {
110  dialog->setPosition(_screenPosition);
111  }
112  dialog->exec();
113  break;
114  }
115  case DATASTRUCTURE: {
116  if (!_dataStructure) {
117  return;
118  }
119  QPointer<DataStructurePropertiesDialog> dialog = new DataStructurePropertiesDialog;
120  dialog->setDataStructure(_dataStructure);
121  if (_screenPosition.isNull()) {
122  // value -3 means: center on screen that currently contains the mouse pointer.
123  KDialog::centerOnScreen(dialog, -3);
124  }
125  else {
126  dialog->setPosition(_screenPosition);
127  }
128  dialog->exec();
129  break;
130  }
131  case DATA: {
132  if (!_data) {
133  return;
134  }
135  QPointer<DataPropertiesWidget> dialog = new DataPropertiesWidget(_data);
136  if (_screenPosition.isNull()) {
137  // value -3 means: center on screen that currently contains the mouse pointer.
138  KDialog::centerOnScreen(dialog, -3);
139  }
140  else {
141  dialog->setPosition(_screenPosition);
142  }
143  dialog->exec();
144  break;
145  }
146  case POINTER: {
147  if (!_pointer) {
148  return;
149  }
150  QPointer<PointerPropertiesWidget> dialog = new PointerPropertiesWidget(_pointer);
151  if (_screenPosition.isNull()) {
152  // value -3 means: center on screen that currently contains the mouse pointer.
153  KDialog::centerOnScreen(dialog, -3);
154  }
155  else {
156  dialog->setPosition(_screenPosition);
157  }
158  dialog->exec();
159  break;
160  }
161  case DATATYPE: {
162  if (!_dataType) {
163  return;
164  }
165  QPointer<KDialog> dialog = new KDialog;
166  DataTypePage* typePage = new DataTypePage(dialog);
167  typePage->setDataType(_dataType);
168  dialog->setMainWidget(typePage);
169  dialog->setCaption(i18nc("@title:window", "Data Type Properties"));
170  dialog->setButtons(KDialog::Close);
171  dialog->setAttribute(Qt::WA_DeleteOnClose);
172  if (_screenPosition.isNull()) {
173  // value -3 means: center on screen that currently contains the mouse pointer.
174  KDialog::centerOnScreen(dialog, -3);
175  }
176  else {
177  dialog->move(_screenPosition.x() + 10, _screenPosition.y() + 10);
178  }
179  dialog->exec();
180  break;
181  }
182  case POINTERTYPE: {
183  if (!_pointerType) {
184  return;
185  }
186  QPointer<KDialog> dialog = new KDialog;
187  PointerTypePage* typePage = new PointerTypePage(dialog);
188  typePage->setPointerType(_pointerType);
189  dialog->setMainWidget(typePage);
190  dialog->setCaption(i18nc("@title:window", "Pointer Type Properties"));
191  dialog->setButtons(KDialog::Close);
192  dialog->setAttribute(Qt::WA_DeleteOnClose);
193  if (_screenPosition.isNull()) {
194  // value -3 means: center on screen that currently contains the mouse pointer.
195  KDialog::centerOnScreen(dialog, -3);
196  }
197  else {
198  dialog->move(_screenPosition.x() + 10, _screenPosition.y() + 10);
199  }
200  dialog->exec();
201  break;
202  }
203  default:
204  break;
205  }
206 }
207 
208 
209 void PropertiesDialogAction::setPosition(QPointF screenPosition)
210 {
211  _screenPosition = screenPosition;
212 }
PointerTypePage.h
QPointer
DataTypePage::setDataType
void setDataType(DataTypePtr dataType)
Definition: DataTypePage.cpp:217
DataTypePage.h
KDialog
PropertiesDialogAction::setPosition
void setPosition(QPointF screenPosition)
Definition: PropertiesDialogAction.cpp:209
PointerTypePage
Properties page for PointerType.
Definition: PointerTypePage.h:35
PointerPropertiesWidget.h
DataStructurePropertiesDialog.h
QPointF
PropertiesDialogAction.h
QPointF::x
qreal x() const
QPointF::y
qreal y() const
QObject
DataTypePage
Properties page for DataType.
Definition: DataTypePage.h:34
DocumentPropertiesDialog
Properties widget for Documents.
Definition: DocumentPropertiesDialog.h:33
PointerPropertiesWidget
Definition: PointerPropertiesWidget.h:35
QString
PropertiesDialogAction::PropertiesDialogAction
PropertiesDialogAction(QString text, Document *document, QObject *parent)
Definition: PropertiesDialogAction.cpp:37
DataStructurePropertiesDialog
Properties widget for DataStructure.
Definition: DataStructurePropertiesDialog.h:33
DocumentPropertiesDialog.h
KAction
DataPropertiesWidget
Properties Area.
Definition: DataPropertiesWidget.h:34
PropertiesDialogAction::showDialog
void showDialog()
Definition: PropertiesDialogAction.cpp:96
DataPropertiesWidget.h
PointerTypePage::setPointerType
void setPointerType(PointerTypePtr pointerType)
Definition: PointerTypePage.cpp:230
QPointF::isNull
bool isNull() const
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