• 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
toolbarstatefactory.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 #include "toolbarstatefactory.h"
11 
12 #include "toolbarstate.h"
13 #include "toolbarstatepool.h"
14 #include "toolbarstateother.h"
15 #include "toolbarstatearrow.h"
16 #include "toolbarstatemessages.h"
17 #include "toolbarstateassociation.h"
18 #include "toolbarstateonewidget.h"
19 
20 #include "umlview.h"
21 
22 ToolBarStateFactory::ToolBarStateFactory()
23 {
24  for (int i = 0; i < NR_OF_TOOLBAR_STATES; ++i)
25  {
26  m_states[i] = 0;
27  }
28 }
29 
30 ToolBarStateFactory::~ToolBarStateFactory()
31 {
32  for (int i = 0; i < NR_OF_TOOLBAR_STATES; ++i)
33  {
34  if (m_states[i])
35  delete m_states[i];
36  }
37 }
38 
39 
40 ToolBarState* ToolBarStateFactory::getState(const WorkToolBar::ToolBar_Buttons &toolbarButton, UMLScene *umlScene)
41 {
42  int key = getKey(toolbarButton);
43 
44  if (m_states[key] == 0)
45  {
46  switch (key)
47  {
48  // When you add a new state, make sure you also increase the
49  // NR_OF_TOOLBAR_STATES
50  case 0: m_states[0] = new ToolBarStateOther(umlScene); break;
51  case 1: m_states[1] = new ToolBarStateAssociation(umlScene); break;
52  case 2: m_states[2] = new ToolBarStateMessages(umlScene); break;
53 
54  // This case has no pool.
55  case 3: m_states[3] = new ToolBarStateArrow(umlScene); break;
56  case 4: m_states[4] = new ToolBarStateOneWidget(umlScene); break;
57  }
58  }
59 
60  // Make explicit the selected button. This is only necessary for states with a pool.
61  if (key != 3) ((ToolBarStatePool *) m_states[key])->setButton(toolbarButton);
62 
63  return m_states[key];
64 }
65 
66 
67 int ToolBarStateFactory::getKey(const WorkToolBar::ToolBar_Buttons &toolbarButton) const
68 {
69  switch (toolbarButton)
70  {
71  // Associations
72  case WorkToolBar::tbb_Dependency: return 1;
73  case WorkToolBar::tbb_Aggregation: return 1;
74  case WorkToolBar::tbb_Relationship: return 1;
75  case WorkToolBar::tbb_Generalization: return 1;
76  case WorkToolBar::tbb_Association: return 1;
77  case WorkToolBar::tbb_UniAssociation: return 1;
78  case WorkToolBar::tbb_Composition: return 1;
79  case WorkToolBar::tbb_Containment: return 1;
80  case WorkToolBar::tbb_Anchor: return 1;
81  case WorkToolBar::tbb_Coll_Message: return 1;
82  case WorkToolBar::tbb_State_Transition: return 1;
83  case WorkToolBar::tbb_Activity_Transition: return 1;
84  case WorkToolBar::tbb_Exception: return 1;
85  case WorkToolBar::tbb_Category2Parent: return 1;
86  case WorkToolBar::tbb_Child2Category: return 1;
87 
88  // Messages
89  case WorkToolBar::tbb_Seq_Message_Synchronous: return 2;
90  case WorkToolBar::tbb_Seq_Message_Asynchronous: return 2;
91  case WorkToolBar::tbb_Seq_Message_Found: return 2;
92  case WorkToolBar::tbb_Seq_Message_Lost: return 2;
93 
94  case WorkToolBar::tbb_Seq_Precondition: return 4;
95  case WorkToolBar::tbb_Pin: return 4;
96 
97  // Arrow pointer
98  case WorkToolBar::tbb_Arrow: return 3;
99 
100  // Other.
101  default: return 0;
102  }
103 
104 }
WorkToolBar::tbb_Anchor
Definition: worktoolbar.h:78
WorkToolBar::tbb_Association
Definition: worktoolbar.h:61
WorkToolBar::tbb_Coll_Message
Definition: worktoolbar.h:63
ToolBarStatePool
Base class for tools that can use the same state but with different button.
Definition: toolbarstatepool.h:22
ToolBarStateAssociation
Association tool to create associations between widgets.
Definition: toolbarstateassociation.h:38
umlview.h
toolbarstateassociation.h
WorkToolBar::tbb_Dependency
Definition: worktoolbar.h:60
WorkToolBar::tbb_Composition
Definition: worktoolbar.h:70
WorkToolBar::tbb_Seq_Message_Found
Definition: worktoolbar.h:66
WorkToolBar::tbb_UniAssociation
Definition: worktoolbar.h:72
WorkToolBar::tbb_Aggregation
Definition: worktoolbar.h:59
ToolBarStateFactory::m_states
ToolBarState * m_states[NR_OF_TOOLBAR_STATES]
Definition: toolbarstatefactory.h:48
ToolBarStateFactory::~ToolBarStateFactory
virtual ~ToolBarStateFactory()
Definition: toolbarstatefactory.cpp:30
toolbarstatemessages.h
toolbarstatefactory.h
WorkToolBar::tbb_Seq_Message_Asynchronous
Definition: worktoolbar.h:65
WorkToolBar::tbb_Arrow
Definition: worktoolbar.h:57
ToolBarStateFactory::ToolBarStateFactory
ToolBarStateFactory()
Definition: toolbarstatefactory.cpp:22
WorkToolBar::ToolBar_Buttons
ToolBar_Buttons
Enumeration of all available toolbar buttons.
Definition: worktoolbar.h:55
WorkToolBar::tbb_Category2Parent
Definition: worktoolbar.h:116
WorkToolBar::tbb_State_Transition
Definition: worktoolbar.h:73
WorkToolBar::tbb_Relationship
Definition: worktoolbar.h:71
NR_OF_TOOLBAR_STATES
#define NR_OF_TOOLBAR_STATES
Definition: toolbarstatefactory.h:19
WorkToolBar::tbb_Containment
Definition: worktoolbar.h:62
ToolBarStateFactory::getKey
int getKey(const WorkToolBar::ToolBar_Buttons &toolbarButton) const
Definition: toolbarstatefactory.cpp:67
WorkToolBar::tbb_Generalization
Definition: worktoolbar.h:58
WorkToolBar::tbb_Activity_Transition
Definition: worktoolbar.h:74
toolbarstateonewidget.h
ToolBarStateFactory::getState
ToolBarState * getState(const WorkToolBar::ToolBar_Buttons &toolbarButton, UMLScene *umlScene)
Definition: toolbarstatefactory.cpp:40
toolbarstate.h
WorkToolBar::tbb_Seq_Precondition
Definition: worktoolbar.h:69
ToolBarStateOneWidget
Sequence tool to create components linked with one object in sequence diagram like precondition...
Definition: toolbarstateonewidget.h:23
WorkToolBar::tbb_Seq_Message_Synchronous
Definition: worktoolbar.h:64
toolbarstatearrow.h
toolbarstatepool.h
ToolBarStateOther
Other tool creates almost all the objects (except associations and messages).
Definition: toolbarstateother.h:25
toolbarstateother.h
WorkToolBar::tbb_Pin
Definition: worktoolbar.h:102
ToolBarStateArrow
Arrow tool for select, move and resize widgets and associations.
Definition: toolbarstatearrow.h:30
ToolBarStateMessages
Messages tool to create messages between objects in sequence diagrams.
Definition: toolbarstatemessages.h:50
WorkToolBar::tbb_Child2Category
Definition: worktoolbar.h:117
ToolBarState
Base class for toolbar states.
Definition: toolbarstate.h:69
WorkToolBar::tbb_Exception
Definition: worktoolbar.h:112
UMLScene
UMLScene instances represent diagrams.
Definition: umlscene.h:70
WorkToolBar::tbb_Seq_Message_Lost
Definition: worktoolbar.h:67
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