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

umbrello/umbrello

  • sources
  • kde-4.12
  • kdesdk
  • umbrello
  • umbrello
toolbarstateother.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * This program is free software; you can redistribute it and/or modify *
3  * it under the terms of the GNU General Public License as published by *
4  * the Free Software Foundation; either version 2 of the License, or *
5  * (at your option) any later version. *
6  * *
7  * copyright (C) 2004-2013 *
8  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9  ***************************************************************************/
10 
11 // own header
12 #include "toolbarstateother.h"
13 
14 // app includes
15 #include "activitywidget.h"
16 #include "boxwidget.h"
17 #include "debug_utils.h"
18 #include "dialog_utils.h"
19 #include "regionwidget.h"
20 #include "floatingtextwidget.h"
21 #include "forkjoinwidget.h"
22 #include "notewidget.h"
23 #include "object_factory.h"
24 #include "preconditionwidget.h"
25 #include "combinedfragmentwidget.h"
26 #include "statewidget.h"
27 #include "signalwidget.h"
28 #include "uml.h"
29 #include "umlview.h"
30 #include "umldoc.h"
31 #include "objectwidget.h"
32 #include "objectnodewidget.h"
33 #include "pinwidget.h"
34 #include "umlscene.h"
35 
36 // kde includes
37 #include <klocale.h>
38 #include <kinputdialog.h>
39 
40 using namespace Uml;
41 
46 ToolBarStateOther::ToolBarStateOther(UMLScene *umlScene)
47  : ToolBarStatePool(umlScene)
48 {
49 }
50 
54 ToolBarStateOther::~ToolBarStateOther()
55 {
56 }
57 
63 void ToolBarStateOther::setCurrentElement()
64 {
65 }
66 
77 void ToolBarStateOther::mouseReleaseEmpty()
78 {
79  if (m_pMouseEvent->button() == Qt::LeftButton) {
80  if (!newWidget()) {
81  // Is UMLObject?
82 
83  m_pUMLScene->setCreateObject(true);
84  Object_Factory::createUMLObject(getObjectType());
85  }
86 
87  m_pUMLScene->resizeSceneToItems();
88  }
89 }
90 
95 UMLObject::ObjectType ToolBarStateOther::getObjectType()
96 {
97  UMLObject::ObjectType ot;
98 
99  switch(getButton()) {
100  case WorkToolBar::tbb_Actor: ot = UMLObject::ot_Actor; break;
101  case WorkToolBar::tbb_UseCase: ot = UMLObject::ot_UseCase; break;
102  case WorkToolBar::tbb_Class: ot = UMLObject::ot_Class; break;
103  case WorkToolBar::tbb_Object: ot = UMLObject::ot_Class; break; // Object is a class.
104  case WorkToolBar::tbb_Package: ot = UMLObject::ot_Package; break;
105  case WorkToolBar::tbb_Component: ot = UMLObject::ot_Component; break;
106  case WorkToolBar::tbb_Node: ot = UMLObject::ot_Node; break;
107  case WorkToolBar::tbb_Artifact: ot = UMLObject::ot_Artifact; break;
108  case WorkToolBar::tbb_Interface: ot = UMLObject::ot_Interface; break;
109  case WorkToolBar::tbb_Enum: ot = UMLObject::ot_Enum; break;
110  case WorkToolBar::tbb_Entity: ot = UMLObject::ot_Entity; break;
111  case WorkToolBar::tbb_Datatype: ot = UMLObject::ot_Datatype; break;
112  case WorkToolBar::tbb_Category: ot = UMLObject::ot_Category; break;
113 
114  default: ot = UMLObject::ot_UMLObject; break;
115  }
116 
117  return ot;
118 }
119 
130 bool ToolBarStateOther::newWidget()
131 {
132  UMLWidget* umlWidget = 0;
133 
134  switch (getButton()) {
135  case WorkToolBar::tbb_Note:
136  umlWidget = new NoteWidget(m_pUMLScene, NoteWidget::Normal);
137  break;
138 
139  case WorkToolBar::tbb_Box:
140  umlWidget = new BoxWidget(m_pUMLScene);
141  break;
142 
143  case WorkToolBar::tbb_Text:
144  umlWidget = new FloatingTextWidget(m_pUMLScene, Uml::TextRole::Floating, "");
145  break;
146 
147  // Activity buttons
148  case WorkToolBar::tbb_Initial_Activity:
149  umlWidget = new ActivityWidget(m_pUMLScene, ActivityWidget::Initial);
150  break;
151 
152  case WorkToolBar::tbb_Activity:
153  umlWidget = new ActivityWidget(m_pUMLScene, ActivityWidget::Normal);
154  break;
155 
156  case WorkToolBar::tbb_End_Activity:
157  umlWidget = new ActivityWidget(m_pUMLScene, ActivityWidget::End);
158  break;
159 
160  case WorkToolBar::tbb_Final_Activity:
161  umlWidget = new ActivityWidget(m_pUMLScene, ActivityWidget::Final);
162  break;
163 
164  case WorkToolBar::tbb_Branch:
165  umlWidget = new ActivityWidget(m_pUMLScene, ActivityWidget::Branch);
166  break;
167 
168  case WorkToolBar::tbb_Fork:
169  umlWidget = new ForkJoinWidget(m_pUMLScene);
170  break;
171 
172  case WorkToolBar::tbb_Initial_State:
173  umlWidget = new StateWidget(m_pUMLScene, StateWidget::Initial);
174  break;
175 
176  case WorkToolBar::tbb_State:
177  umlWidget = new StateWidget(m_pUMLScene, StateWidget::Normal);
178  break;
179 
180  case WorkToolBar::tbb_End_State:
181  umlWidget = new StateWidget(m_pUMLScene, StateWidget::End);
182  break;
183 
184  case WorkToolBar::tbb_StateFork:
185  umlWidget = new StateWidget(m_pUMLScene, StateWidget::Fork);
186  break;
187 
188  case WorkToolBar::tbb_StateJoin:
189  umlWidget = new StateWidget(m_pUMLScene, StateWidget::Join);
190  break;
191 
192  case WorkToolBar::tbb_Junction:
193  umlWidget = new StateWidget(m_pUMLScene, StateWidget::Junction);
194  break;
195 
196  case WorkToolBar::tbb_DeepHistory:
197  umlWidget = new StateWidget(m_pUMLScene, StateWidget::DeepHistory);
198  break;
199 
200  case WorkToolBar::tbb_ShallowHistory:
201  umlWidget = new StateWidget(m_pUMLScene, StateWidget::ShallowHistory);
202  break;
203 
204  case WorkToolBar::tbb_Choice:
205  umlWidget = new StateWidget(m_pUMLScene, StateWidget::Choice);
206  break;
207 
208  case WorkToolBar::tbb_Send_Signal:
209  umlWidget = new SignalWidget(m_pUMLScene, SignalWidget::Send);
210  break;
211 
212  case WorkToolBar::tbb_Accept_Signal:
213  umlWidget = new SignalWidget(m_pUMLScene, SignalWidget::Accept);
214  break;
215 
216  case WorkToolBar::tbb_Accept_Time_Event:
217  umlWidget = new SignalWidget(m_pUMLScene, SignalWidget::Time);
218  break;
219 
220  case WorkToolBar::tbb_Region:
221  umlWidget = new RegionWidget(m_pUMLScene);
222  break;
223 
224  case WorkToolBar::tbb_Seq_Combined_Fragment:
225  umlWidget = new CombinedFragmentWidget(m_pUMLScene);
226  break;
227 
228  case WorkToolBar::tbb_Object_Node:
229  umlWidget = new ObjectNodeWidget(m_pUMLScene, ObjectNodeWidget::Data);
230  break;
231 
232  case WorkToolBar::tbb_PrePostCondition:
233  umlWidget = new NoteWidget(m_pUMLScene, NoteWidget::Normal);
234  break;
235 
236  default:
237  break;
238  }
239 
240  // Return false if we didn't find a suitable widget.
241  if (umlWidget == 0) {
242  return false;
243  }
244 
245  // Special treatment for some buttons
246  switch (getButton()) {
247  case WorkToolBar::tbb_Activity:
248  {
249  Dialog_Utils::askNameForWidget(
250  umlWidget, i18n("Enter Activity Name"),
251  i18n("Enter the name of the new activity:"), i18n("new activity"));
252  }
253  break;
254  case WorkToolBar::tbb_Accept_Signal:
255  case WorkToolBar::tbb_Send_Signal:
256  {
257  Dialog_Utils::askNameForWidget(
258  umlWidget, i18n("Enter Signal Name"),
259  i18n("Enter Signal"), i18n("new Signal"));
260  }
261  break;
262  case WorkToolBar::tbb_Accept_Time_Event:
263  {
264  Dialog_Utils::askNameForWidget(
265  umlWidget, i18n("Enter Time Event Name"),
266  i18n("Enter Time Event"), i18n("new time event"));
267  }
268  break;
269  case WorkToolBar::tbb_Seq_Combined_Fragment:
270  {
271  dynamic_cast<CombinedFragmentWidget*>(umlWidget)->askNameForWidgetType(
272  umlWidget, i18n("Enter Combined Fragment Name"),
273  i18n("Enter the Combined Fragment"), i18n("new Combined Fragment"));
274  }
275  break;
276  case WorkToolBar::tbb_State:
277  {
278  Dialog_Utils::askNameForWidget(
279  umlWidget, i18n("Enter State Name"),
280  i18n("Enter the name of the new state:"), i18n("new state"));
281  }
282  break;
283  case WorkToolBar::tbb_Text:
284  {
285  // It is pretty invisible otherwise.
286  FloatingTextWidget* ft = (FloatingTextWidget*) umlWidget;
287  ft->showChangeTextDialog();
288  }
289  break;
290  case WorkToolBar::tbb_Object_Node:
291  {
292  dynamic_cast<ObjectNodeWidget*>(umlWidget)->askForObjectNodeType(umlWidget);
293  }
294  break;
295  case WorkToolBar::tbb_PrePostCondition:
296  {
297  dynamic_cast<NoteWidget*>(umlWidget)->askForNoteType(umlWidget);
298  }
299  break;
300  default:
301  uWarning() << "Unknown ToolBar_Buttons: " << QLatin1String(ENUM_NAME(WorkToolBar, WorkToolBar::ToolBar_Buttons, getButton()));
302  break;
303  }
304 
305  // Create the widget. Some setup functions can remove the widget.
306  if (umlWidget != 0) {
307  m_pUMLScene->setupNewWidget(umlWidget);
308  }
309 
310  return true;
311 }
312 
313 #include "toolbarstateother.moc"
object_factory.h
StateWidget::DeepHistory
Definition: statewidget.h:52
ActivityWidget::Branch
Definition: activitywidget.h:44
pinwidget.h
ObjectNodeWidget
This class is the graphical version of a UML Object Node.
Definition: objectnodewidget.h:28
UMLObject::ot_Component
Definition: umlobject.h:62
ToolBarStatePool
Base class for tools that can use the same state but with different button.
Definition: toolbarstatepool.h:22
statewidget.h
dialog_utils.h
ToolBarState::m_pUMLScene
UMLScene * m_pUMLScene
The UMLScene.
Definition: toolbarstate.h:120
RegionWidget
Represents a rectangular region on Activity diagram.
Definition: regionwidget.h:19
ActivityWidget::Initial
Definition: activitywidget.h:40
UMLScene::resizeSceneToItems
void resizeSceneToItems()
Sets the size of the scene to just fit on all the items.
Definition: umlscene.cpp:3700
SignalWidget::Send
Definition: signalwidget.h:35
NoteWidget
Displays a note box to allow multiple lines of text to be displayed.
Definition: notewidget.h:30
boxwidget.h
WorkToolBar::tbb_Accept_Time_Event
Definition: worktoolbar.h:77
ForkJoinWidget
Displays a fork/join plate in a state diagram.
Definition: forkjoinwidget.h:25
umlview.h
WorkToolBar::tbb_Entity
Definition: worktoolbar.h:88
UMLObject::ot_Enum
Definition: umlobject.h:55
WorkToolBar::tbb_Node
Definition: worktoolbar.h:91
WorkToolBar::tbb_Box
Definition: worktoolbar.h:80
ObjectNodeWidget::Data
Definition: objectnodewidget.h:36
Dialog_Utils::askNameForWidget
void askNameForWidget(UMLWidget *&targetWidget, const QString &dialogTitle, const QString &dialogPrompt, const QString &defaultName)
Helper function for requesting a name for an UMLWidget using a dialog.
Definition: dialog_utils.cpp:64
WorkToolBar::tbb_End_State
Definition: worktoolbar.h:97
UMLObject::ot_UseCase
Definition: umlobject.h:51
WorkToolBar::tbb_PrePostCondition
Definition: worktoolbar.h:114
umlscene.h
WorkToolBar::tbb_Category
Definition: worktoolbar.h:115
SignalWidget
Represents a Send signal, Accept signal or Time event on an Activity diagram.
Definition: signalwidget.h:27
forkjoinwidget.h
WorkToolBar::tbb_DeepHistory
Definition: worktoolbar.h:105
StateWidget::End
Definition: statewidget.h:48
uWarning
#define uWarning()
Definition: debug_utils.h:97
WorkToolBar::tbb_Component
Definition: worktoolbar.h:90
WorkToolBar::tbb_Initial_State
Definition: worktoolbar.h:94
debug_utils.h
WorkToolBar::ToolBar_Buttons
ToolBar_Buttons
Enumeration of all available toolbar buttons.
Definition: worktoolbar.h:55
WorkToolBar::tbb_StateJoin
Definition: worktoolbar.h:108
objectwidget.h
ENUM_NAME
#define ENUM_NAME(o, e, v)
In a Q_OBJECT class define any enum as Q_ENUMS.
Definition: debug_utils.h:114
Uml::TextRole::Floating
Definition: basictypes.h:151
notewidget.h
ActivityWidget::Normal
Definition: activitywidget.h:41
StateWidget::Fork
Definition: statewidget.h:49
StateWidget::Junction
Definition: statewidget.h:51
Object_Factory::createUMLObject
UMLObject * createUMLObject(UMLObject::ObjectType type, const QString &n, UMLPackage *parentPkg, bool solicitNewName)
Creates a UMLObject of the given type.
Definition: object_factory.cpp:162
ActivityWidget::End
Definition: activitywidget.h:42
WorkToolBar::tbb_Object
Definition: worktoolbar.h:93
WorkToolBar::tbb_Enum
Definition: worktoolbar.h:87
StateWidget::Join
Definition: statewidget.h:50
WorkToolBar::tbb_State
Definition: worktoolbar.h:95
WorkToolBar::tbb_Choice
Definition: worktoolbar.h:110
StateWidget
This class is the graphical version of a UML State.
Definition: statewidget.h:38
ToolBarStatePool::getButton
WorkToolBar::ToolBar_Buttons getButton() const
Returns the current button.
Definition: toolbarstatepool.cpp:42
WorkToolBar::tbb_Package
Definition: worktoolbar.h:89
WorkToolBar::tbb_Accept_Signal
Definition: worktoolbar.h:76
WorkToolBar::tbb_Fork
Definition: worktoolbar.h:104
SignalWidget::Accept
Definition: signalwidget.h:36
SignalWidget::Time
Definition: signalwidget.h:37
StateWidget::Initial
Definition: statewidget.h:46
UMLObject::ot_Category
Definition: umlobject.h:74
UMLObject::ot_Entity
Definition: umlobject.h:67
ActivityWidget
This class is the graphical version of a UML Activity.
Definition: activitywidget.h:33
WorkToolBar::tbb_Artifact
Definition: worktoolbar.h:92
WorkToolBar::tbb_Datatype
Definition: worktoolbar.h:86
WorkToolBar::tbb_Send_Signal
Definition: worktoolbar.h:75
WorkToolBar::tbb_Actor
Definition: worktoolbar.h:82
StateWidget::Choice
Definition: statewidget.h:54
UMLObject::ot_Interface
Definition: umlobject.h:53
UMLObject::ot_Actor
Definition: umlobject.h:50
WorkToolBar::tbb_Activity
Definition: worktoolbar.h:99
WorkToolBar::tbb_Interface
Definition: worktoolbar.h:85
UMLObject::ot_Artifact
Definition: umlobject.h:63
NoteWidget::Normal
Definition: notewidget.h:38
umldoc.h
ToolBarStateOther::ToolBarStateOther
ToolBarStateOther(UMLScene *umlScene)
Creates a new ToolBarStateOther.
Definition: toolbarstateother.cpp:46
UMLObject::ObjectType
ObjectType
Definition: umlobject.h:47
WorkToolBar::tbb_Region
Definition: worktoolbar.h:96
WorkToolBar::tbb_ShallowHistory
Definition: worktoolbar.h:106
UMLObject::ot_Class
Definition: umlobject.h:56
FloatingTextWidget
Displays a line of text or an operation.
Definition: floatingtextwidget.h:36
signalwidget.h
WorkToolBar::tbb_End_Activity
Definition: worktoolbar.h:100
WorkToolBar::tbb_Note
Definition: worktoolbar.h:79
WorkToolBar
This is the toolbar that is displayed on the right-hand side of the program window.
Definition: worktoolbar.h:40
toolbarstateother.h
UMLScene::setCreateObject
void setCreateObject(bool bCreate)
Set whether we are currently creating an object.
Definition: umlscene.cpp:540
UMLObject::ot_UMLObject
Definition: umlobject.h:49
ToolBarState::m_pMouseEvent
QGraphicsSceneMouseEvent * m_pMouseEvent
The mouse event currently in use.
Definition: toolbarstate.h:121
floatingtextwidget.h
BoxWidget
Displays a rectangular box.
Definition: boxwidget.h:27
WorkToolBar::tbb_Initial_Activity
Definition: worktoolbar.h:98
StateWidget::Normal
Definition: statewidget.h:47
CombinedFragmentWidget
This class is the graphical version of a UML combined fragment.
Definition: combinedfragmentwidget.h:36
preconditionwidget.h
WorkToolBar::tbb_Object_Node
Definition: worktoolbar.h:113
StateWidget::ShallowHistory
Definition: statewidget.h:53
WorkToolBar::tbb_Final_Activity
Definition: worktoolbar.h:101
WorkToolBar::tbb_Branch
Definition: worktoolbar.h:103
UMLObject::ot_Package
Definition: umlobject.h:52
ActivityWidget::Final
Definition: activitywidget.h:43
WorkToolBar::tbb_Junction
Definition: worktoolbar.h:109
WorkToolBar::tbb_UseCase
Definition: worktoolbar.h:83
WorkToolBar::tbb_Text
Definition: worktoolbar.h:81
combinedfragmentwidget.h
WorkToolBar::tbb_Seq_Combined_Fragment
Definition: worktoolbar.h:68
FloatingTextWidget::showChangeTextDialog
void showChangeTextDialog()
Displays a dialog box to change the text.
Definition: floatingtextwidget.cpp:187
regionwidget.h
UMLObject::ot_Datatype
Definition: umlobject.h:54
UMLScene
UMLScene instances represent diagrams.
Definition: umlscene.h:70
WorkToolBar::tbb_StateFork
Definition: worktoolbar.h:107
WorkToolBar::tbb_Class
Definition: worktoolbar.h:84
objectnodewidget.h
uml.h
UMLObject::ot_Node
Definition: umlobject.h:64
ToolBarStateOther::~ToolBarStateOther
virtual ~ToolBarStateOther()
Destroys this ToolBarStateOther.
Definition: toolbarstateother.cpp:54
activitywidget.h
UMLScene::setupNewWidget
void setupNewWidget(UMLWidget *w)
Initialize and announce a newly created widget.
Definition: umlscene.cpp:512
UMLWidget
This is the base class for nearly all graphical widgets.
Definition: umlwidget.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:06:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

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