• 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.14
  • kdesdk
  • umbrello
  • umbrello
  • cmds
  • widget
cmd_baseWidgetCommand.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) 2007-2014 *
8  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9  ***************************************************************************/
10 
11 #include "cmd_baseWidgetCommand.h"
12 
13 // app includes
14 #include "messagewidget.h"
15 #include "uml.h"
16 #include "umldoc.h"
17 #include "umlscene.h"
18 #include "umlview.h"
19 #include "umlwidget.h"
20 
21 // kde includes
22 #include <klocale.h>
23 
24 namespace Uml
25 {
26  CmdBaseWidgetCommand::CmdBaseWidgetCommand(UMLWidget* widget)
27  {
28  setWidget(widget);
29  }
30 
31  CmdBaseWidgetCommand::~CmdBaseWidgetCommand()
32  {
33  }
34 
35  void CmdBaseWidgetCommand::setWidget(UMLWidget* widget)
36  {
37  Q_ASSERT(widget);
38 
39  m_widgetId = widget->localID();
40  m_sceneId = widget->umlScene()->ID();
41  }
42 
43  UMLScene* CmdBaseWidgetCommand::scene()
44  {
45  UMLView* umlView = UMLApp::app()->document()->findView(m_sceneId);
46 
47  Q_ASSERT(umlView);
48 
49  return umlView->umlScene();
50  }
51 
52  UMLWidget* CmdBaseWidgetCommand::widget()
53  {
54  UMLWidget* umlWidget = scene()->findWidget(m_widgetId);
55 
56  Q_ASSERT(umlWidget);
57 
58  return umlWidget;
59  }
60 
66  void CmdBaseWidgetCommand::addWidgetToScene(UMLWidget* umlWidget)
67  {
68  if (umlWidget->baseType() == WidgetBase::wt_Message) {
69  scene()->messageList().append(
70  dynamic_cast<MessageWidget*>(umlWidget)
71  );
72  } else {
73  scene()->widgetList().append(umlWidget);
74  }
75 
76  umlWidget->activate();
77  }
78 }
messagewidget.h
umlview.h
UMLScene::widgetList
UMLWidgetList & widgetList()
Returns a reference to the widget list.
Definition: umlscene.cpp:452
Uml::CmdBaseWidgetCommand::addWidgetToScene
void addWidgetToScene(UMLWidget *widget)
Add widget to scene.
Definition: cmd_baseWidgetCommand.cpp:66
umlscene.h
UMLView
UMLView instances represent views onto diagrams (scenes).
Definition: umlview.h:34
WidgetBase::umlScene
UMLScene * umlScene() const
Deliver a pointer to the connected UMLView (needed esp.
Definition: widgetbase.cpp:107
UMLApp::app
static UMLApp * app()
Get the last created instance of this class.
Definition: uml.cpp:214
Uml::CmdBaseWidgetCommand::CmdBaseWidgetCommand
CmdBaseWidgetCommand(UMLWidget *widget)
Definition: cmd_baseWidgetCommand.cpp:26
UMLApp::document
UMLDoc * document() const
Returns a pointer to the current document connected to the KMainWindow instance.
Definition: uml.cpp:910
Uml::CmdBaseWidgetCommand::m_widgetId
Uml::ID::Type m_widgetId
Definition: cmd_baseWidgetCommand.h:31
Uml::CmdBaseWidgetCommand::m_sceneId
Uml::ID::Type m_sceneId
Definition: cmd_baseWidgetCommand.h:30
UMLDoc::findView
UMLView * findView(Uml::ID::Type id)
Finds a view (diagram) by the ID given to method.
Definition: umldoc.cpp:749
QList::append
void append(const T &value)
UMLWidget::localID
Uml::ID::Type localID() const
Returns the local ID for this object.
Definition: umlwidget.cpp:202
Uml::CmdBaseWidgetCommand::setWidget
void setWidget(UMLWidget *widget)
Definition: cmd_baseWidgetCommand.cpp:35
Uml::CmdBaseWidgetCommand::widget
UMLWidget * widget()
Definition: cmd_baseWidgetCommand.cpp:52
umlwidget.h
UMLWidget::activate
virtual bool activate(IDChangeLog *ChangeLog=0)
Activate the object after serializing it from a QDataStream.
Definition: umlwidget.cpp:979
Uml::CmdBaseWidgetCommand::scene
UMLScene * scene()
Definition: cmd_baseWidgetCommand.cpp:43
UMLScene::findWidget
UMLWidget * findWidget(Uml::ID::Type id)
Finds a widget with the given ID.
Definition: umlscene.cpp:1114
umldoc.h
UMLView::umlScene
UMLScene * umlScene() const
Getter for the scene.
Definition: umlview.cpp:58
WidgetBase::baseType
WidgetType baseType() const
Read property of m_baseType.
Definition: widgetbase.cpp:80
WidgetBase::wt_Message
Definition: widgetbase.h:55
UMLScene::messageList
MessageWidgetList & messageList()
Returns a reference to the message list.
Definition: umlscene.cpp:460
UMLScene
UMLScene instances represent diagrams.
Definition: umlscene.h:68
uml.h
cmd_baseWidgetCommand.h
Uml::CmdBaseWidgetCommand::~CmdBaseWidgetCommand
virtual ~CmdBaseWidgetCommand()
Definition: cmd_baseWidgetCommand.cpp:31
UMLScene::ID
Uml::ID::Type ID() const
Returns the ID of the diagram.
Definition: umlscene.cpp:300
UMLWidget
This is the base class for nearly all graphical widgets.
Definition: umlwidget.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:40:25 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
  • 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