umbrello: umbrello/umllistview.h Source File

umbrello 2.32.1 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

umllistview.h
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) 2002-2020 *
8 * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9 ***************************************************************************/
10
11 #ifndef UMLLISTVIEW_H
12 #define UMLLISTVIEW_H
13
14 #include "basictypes.h"
15 #include "umllistviewitem.h"
16 #include "umllistviewitemlist.h"
17 #include "icon_utils.h"
18 #include "umlobject.h"
19
20 #include <QDomDocument>
21 #include <QDomElement>
22 #include <QTreeWidget>
23 #include <QTreeWidgetItem>
24 #include <QXmlStreamWriter>
25
26 class QEvent;
27 class QMouseEvent;
28 class QFocusEvent;
29 class QKeyEvent;
30 class QDropEvent;
31 class UMLClassifier;
32 class UMLDoc;
33 class UMLView;
34 class UMLClassifierListItem;
35 class UMLDragData;
36
47 class UMLListView : public QTreeWidget
48 {
49 Q_OBJECT
50 public:
51 explicit UMLListView(QWidget *parent = 0);
52 ~UMLListView();
53
54 void setDocument(UMLDoc * doc);
55 UMLDoc * document() const;
56
57 void init();
58 void clean();
59
60 void setView(UMLView* view);
61
62 void setTitle(int column, const QString &text);
63
64 UMLListViewItemList selectedItems();
65 UMLListViewItemList selectedItemsRoot();
66 int selectedItemsCount();
67
68 UMLListViewItem* createDiagramItem(UMLView *view);
69
70 bool createItem(UMLListViewItem *item);
71
72 UMLListViewItem* findFolderForDiagram(Uml::DiagramType::Enum dt);
73
74 UMLListViewItem* determineParentItem(UMLObject* object) const;
75 UMLListViewItem* determineParentItem(UMLListViewItem::ListViewType lvt) const;
76
77 static bool mayHaveChildItems(UMLObject::ObjectType type);
78
79 void addNewItem(UMLListViewItem * parent, UMLListViewItem::ListViewType type);
80
81 UMLListViewItem * findUMLObject(const UMLObject *p) const;
82 UMLListViewItem * findView(UMLView *v);
83 UMLListViewItem * findItem(Uml::ID::Type id);
84
85 UMLListViewItem *rootView(UMLListViewItem::ListViewType type);
86
87 void changeIconOf(UMLObject *o, Icon_Utils::IconType to);
88
89 bool isUnique(UMLListViewItem * item, const QString &name);
90
91 void setStartedCut(bool startedCut);
92 void setStartedCopy(bool startedCopy);
93 bool startedCopy() const;
94
95 UMLListViewItem * moveObject(Uml::ID::Type srcId, UMLListViewItem::ListViewType srcType,
96 UMLListViewItem *newParent);
97
98 void closeDatatypesFolder();
99
100 UMLListViewItem *theRootView() { return m_rv; }
101 UMLListViewItem *theLogicalView() { return m_lv[Uml::ModelType::Logical]; }
102 UMLListViewItem *theUseCaseView() { return m_lv[Uml::ModelType::UseCase]; }
103 UMLListViewItem *theComponentView() { return m_lv[Uml::ModelType::Component]; }
104 UMLListViewItem *theDeploymentView() { return m_lv[Uml::ModelType::Deployment]; }
105 UMLListViewItem *theDatatypeFolder() { return m_datatypeFolder; }
106
107 UMLListViewItem::ListViewType rootViewType(UMLListViewItem *item);
108
109 void saveToXMI1(QXmlStreamWriter& writer);
110 bool loadFromXMI1(QDomElement & element);
111 bool loadChildrenFromXMI(UMLListViewItem * parent, QDomElement & element);
112
113 friend QDebug operator<<(QDebug out, const UMLListView& view);
114
115 protected:
116 bool event(QEvent *e);
117 void mouseReleaseEvent(QMouseEvent *me);
118 void mousePressEvent(QMouseEvent *me);
119 void mouseMoveEvent(QMouseEvent *me);
120 void mouseDoubleClickEvent(QMouseEvent *me);
121 void focusOutEvent (QFocusEvent *fe);
122 void contextMenuEvent(QContextMenuEvent *event);
123 UMLDragData* getDragData();
124
125 bool acceptDrag(QDropEvent* event) const;
126 void keyPressEvent(QKeyEvent* ke);
127 void dragEnterEvent(QDragEnterEvent* event);
128 void dragMoveEvent(QDragMoveEvent* event);
129 void dropEvent(QDropEvent* event);
130 void commitData(QWidget *editor);
131
132 UMLListViewItem * findUMLObjectInFolder(UMLListViewItem *folder, UMLObject *obj);
133
134 static bool isExpandable(UMLListViewItem::ListViewType lvt);
135
136 void deleteChildrenOf(UMLListViewItem *parent);
137
138 bool deleteItem(UMLListViewItem *temp);
139
140 void childObjectAdded(UMLClassifierListItem* child, UMLClassifier* parent);
141
142 void addAtContainer(UMLListViewItem *item, UMLListViewItem *parent);
143
144 public slots:
145 void slotDiagramCreated(Uml::ID::Type id);
146 void slotDiagramRenamed(Uml::ID::Type id);
147 void slotDiagramRemoved(Uml::ID::Type id);
148 void slotObjectCreated(UMLObject* object);
149 void slotObjectRemoved(UMLObject* object);
150
151 void connectNewObjectsSlots(UMLObject* object);
152
153 void childObjectAdded(UMLClassifierListItem* obj);
154 void childObjectRemoved(UMLClassifierListItem* obj);
155
156 void slotObjectChanged();
157
158 void slotMenuSelection(QAction* action, const QPoint &position = QPoint());
159
160 void slotDropped(QDropEvent* de, UMLListViewItem* target);
161
162 void expandAll(UMLListViewItem *item);
163 void collapseAll(UMLListViewItem *item);
164
165 void slotCutSuccessful();
166 void slotDeleteSelectedItems();
167
168 protected slots:
169 void slotItemSelectionChanged();
170 void slotExpanded(QTreeWidgetItem* item);
171 void slotCollapsed(QTreeWidgetItem* item);
172
173 private:
174 UMLListViewItem* recursiveSearchForView(UMLListViewItem* folder,
175 UMLListViewItem::ListViewType type, Uml::ID::Type id);
176
177 void setBackgroundColor(const QColor & color);
178
179 UMLListViewItem* m_rv;
180 UMLListViewItem* m_lv[Uml::ModelType::N_MODELTYPES];
181 UMLListViewItem* m_datatypeFolder;
182 UMLListViewItem* m_settingsFolder;
183 UMLDoc* m_doc;
184 bool m_bStartedCut;
185 bool m_bStartedCopy;
186 bool m_bCreatingChildObject;
187 QPoint m_dragStartPosition;
188 QMimeData* m_dragCopyData;
189 QList<QTreeWidgetItem*> m_findItems;
190 };
191
192 #endif
basictypes.h
UMLClassifierListItem
A base class for classifier list items (e.g. attributes)
Definition: classifierlistitem.h:30
UMLClassifier
Information for a non-graphical Concept/Class.
Definition: classifier.h:40
UMLDoc
Definition: umldoc.h:75
UMLDragData
Definition: umldragdata.h:38
UMLListViewItem
Items used by UMLListView.
Definition: umllistviewitem.h:41
UMLListViewItem::ListViewType
ListViewType
Definition: umllistviewitem.h:44
UMLListView
Displays the list view for the program.
Definition: umllistview.h:48
UMLListView::setDocument
void setDocument(UMLDoc *doc)
Definition: umllistview.cpp:1217
UMLListView::slotDropped
void slotDropped(QDropEvent *de, UMLListViewItem *target)
Definition: umllistview.cpp:1936
UMLListView::theUseCaseView
UMLListViewItem * theUseCaseView()
Definition: umllistview.h:102
UMLListView::slotExpanded
void slotExpanded(QTreeWidgetItem *item)
Definition: umllistview.cpp:2180
UMLListView::setBackgroundColor
void setBackgroundColor(const QColor &color)
Definition: umllistview.cpp:2934
UMLListView::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event)
Definition: umllistview.cpp:2864
UMLListView::findView
UMLListViewItem * findView(UMLView *v)
Definition: umllistview.cpp:1354
UMLListView::loadFromXMI1
bool loadFromXMI1(QDomElement &element)
Definition: umllistview.cpp:2451
UMLListView::document
UMLDoc * document() const
Definition: umllistview.cpp:2094
UMLListView::slotCutSuccessful
void slotCutSuccessful()
Definition: umllistview.cpp:2207
UMLListView::init
void init()
Definition: umllistview.cpp:1435
UMLListView::moveObject
UMLListViewItem * moveObject(Uml::ID::Type srcId, UMLListViewItem::ListViewType srcType, UMLListViewItem *newParent)
Definition: umllistview.cpp:1646
UMLListView::slotItemSelectionChanged
void slotItemSelectionChanged()
Definition: umllistview.cpp:168
UMLListView::theLogicalView
UMLListViewItem * theLogicalView()
Definition: umllistview.h:101
UMLListView::m_settingsFolder
UMLListViewItem * m_settingsFolder
settings root
Definition: umllistview.h:182
UMLListView::slotObjectRemoved
void slotObjectRemoved(UMLObject *object)
Definition: umllistview.cpp:1235
UMLListView::slotDiagramRemoved
void slotDiagramRemoved(Uml::ID::Type id)
Definition: umllistview.cpp:1250
UMLListView::addNewItem
void addNewItem(UMLListViewItem *parent, UMLListViewItem::ListViewType type)
Definition: umllistview.cpp:2233
UMLListView::dropEvent
void dropEvent(QDropEvent *event)
Definition: umllistview.cpp:2886
UMLListView::findFolderForDiagram
UMLListViewItem * findFolderForDiagram(Uml::DiagramType::Enum dt)
Definition: umllistview.cpp:826
UMLListView::slotDiagramRenamed
void slotDiagramRenamed(Uml::ID::Type id)
Definition: umllistview.cpp:1200
UMLListView::theComponentView
UMLListViewItem * theComponentView()
Definition: umllistview.h:103
UMLListView::mayHaveChildItems
static bool mayHaveChildItems(UMLObject::ObjectType type)
Definition: umllistview.cpp:943
UMLListView::loadChildrenFromXMI
bool loadChildrenFromXMI(UMLListViewItem *parent, QDomElement &element)
Definition: umllistview.cpp:2478
UMLListView::m_bStartedCopy
bool m_bStartedCopy
Definition: umllistview.h:185
UMLListView::mousePressEvent
void mousePressEvent(QMouseEvent *me)
Definition: umllistview.cpp:210
UMLListView::deleteItem
bool deleteItem(UMLListViewItem *temp)
Definition: umllistview.cpp:2802
UMLListView::selectedItemsRoot
UMLListViewItemList selectedItemsRoot()
Definition: umllistview.cpp:1990
UMLListView::event
bool event(QEvent *e)
Definition: umllistview.cpp:190
UMLListView::isExpandable
static bool isExpandable(UMLListViewItem::ListViewType lvt)
Definition: umllistview.cpp:2161
UMLListView::keyPressEvent
void keyPressEvent(QKeyEvent *ke)
Definition: umllistview.cpp:311
UMLListView::createDiagramItem
UMLListViewItem * createDiagramItem(UMLView *view)
Definition: umllistview.cpp:2016
UMLListView::acceptDrag
bool acceptDrag(QDropEvent *event) const
Definition: umllistview.cpp:1548
UMLListView::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *event)
Definition: umllistview.cpp:2115
UMLListView::focusOutEvent
void focusOutEvent(QFocusEvent *fe)
Definition: umllistview.cpp:2103
UMLListView::slotDeleteSelectedItems
void slotDeleteSelectedItems()
Definition: umllistview.cpp:2220
UMLListView::slotCollapsed
void slotCollapsed(QTreeWidgetItem *item)
Definition: umllistview.cpp:2193
UMLListView::startedCopy
bool startedCopy() const
Definition: umllistview.cpp:2732
UMLListView::recursiveSearchForView
UMLListViewItem * recursiveSearchForView(UMLListViewItem *folder, UMLListViewItem::ListViewType type, Uml::ID::Type id)
Definition: umllistview.cpp:1394
UMLListView::deleteChildrenOf
void deleteChildrenOf(UMLListViewItem *parent)
Definition: umllistview.cpp:2776
UMLListView::findItem
UMLListViewItem * findItem(Uml::ID::Type id)
Definition: umllistview.cpp:1420
UMLListView::m_datatypeFolder
UMLListViewItem * m_datatypeFolder
Definition: umllistview.h:181
UMLListView::setView
void setView(UMLView *view)
Definition: umllistview.cpp:1500
UMLListView::theDeploymentView
UMLListViewItem * theDeploymentView()
Definition: umllistview.h:104
UMLListView::m_bCreatingChildObject
bool m_bCreatingChildObject
when creating an attribute or an operation to stop it adding a second listViewItem
Definition: umllistview.h:186
UMLListView::~UMLListView
~UMLListView()
Definition: umllistview.cpp:147
UMLListView::childObjectAdded
void childObjectAdded(UMLClassifierListItem *child, UMLClassifier *parent)
Definition: umllistview.cpp:1152
UMLListView::connectNewObjectsSlots
void connectNewObjectsSlots(UMLObject *object)
Definition: umllistview.cpp:1037
UMLListView::findUMLObjectInFolder
UMLListViewItem * findUMLObjectInFolder(UMLListViewItem *folder, UMLObject *obj)
Definition: umllistview.cpp:1285
UMLListView::commitData
void commitData(QWidget *editor)
Definition: umllistview.cpp:2902
UMLListView::expandAll
void expandAll(UMLListViewItem *item)
Definition: umllistview.cpp:2688
UMLListView::childObjectRemoved
void childObjectRemoved(UMLClassifierListItem *obj)
Definition: umllistview.cpp:1185
UMLListView::selectedItems
UMLListViewItemList selectedItems()
Definition: umllistview.cpp:1970
UMLListView::clean
void clean()
Definition: umllistview.cpp:1487
UMLListView::rootViewType
UMLListViewItem::ListViewType rootViewType(UMLListViewItem *item)
Definition: umllistview.cpp:2138
UMLListView::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *me)
Definition: umllistview.cpp:1512
UMLListView::createItem
bool createItem(UMLListViewItem *item)
UMLListView::dragMoveEvent
void dragMoveEvent(QDragMoveEvent *event)
Definition: umllistview.cpp:2872
UMLListView::determineParentItem
UMLListViewItem * determineParentItem(UMLObject *object) const
Definition: umllistview.cpp:885
UMLListView::m_doc
UMLDoc * m_doc
Definition: umllistview.h:183
UMLListView::slotObjectCreated
void slotObjectCreated(UMLObject *object)
Definition: umllistview.cpp:966
UMLListView::operator<<
friend QDebug operator<<(QDebug out, const UMLListView &view)
Definition: umllistview.cpp:2944
UMLListView::getDragData
UMLDragData * getDragData()
Definition: umllistview.cpp:1260
UMLListView::isUnique
bool isUnique(UMLListViewItem *item, const QString &name)
Definition: umllistview.cpp:2331
UMLListView::m_dragStartPosition
QPoint m_dragStartPosition
Definition: umllistview.h:187
UMLListView::setStartedCopy
void setStartedCopy(bool startedCopy)
Definition: umllistview.cpp:2724
UMLListView::setStartedCut
void setStartedCut(bool startedCut)
Definition: umllistview.cpp:2714
UMLListView::m_rv
UMLListViewItem * m_rv
root view (home)
Definition: umllistview.h:179
UMLListView::UMLListView
UMLListView(QWidget *parent=0)
Definition: umllistview.cpp:102
UMLListView::m_dragCopyData
QMimeData * m_dragCopyData
Definition: umllistview.h:188
UMLListView::saveToXMI1
void saveToXMI1(QXmlStreamWriter &writer)
Definition: umllistview.cpp:2441
UMLListView::addAtContainer
void addAtContainer(UMLListViewItem *item, UMLListViewItem *parent)
Definition: umllistview.cpp:1617
UMLListView::theRootView
UMLListViewItem * theRootView()
Definition: umllistview.h:100
UMLListView::m_lv
UMLListViewItem * m_lv[Uml::ModelType::N_MODELTYPES]
predefined list view roots
Definition: umllistview.h:180
UMLListView::closeDatatypesFolder
void closeDatatypesFolder()
Definition: umllistview.cpp:2792
UMLListView::m_findItems
QList< QTreeWidgetItem * > m_findItems
Definition: umllistview.h:189
UMLListView::slotObjectChanged
void slotObjectChanged()
Definition: umllistview.cpp:1124
UMLListView::theDatatypeFolder
UMLListViewItem * theDatatypeFolder()
Definition: umllistview.h:105
UMLListView::setTitle
void setTitle(int column, const QString &text)
Definition: umllistview.cpp:160
UMLListView::rootView
UMLListViewItem * rootView(UMLListViewItem::ListViewType type)
Definition: umllistview.cpp:2741
UMLListView::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *me)
Definition: umllistview.cpp:287
UMLListView::slotDiagramCreated
void slotDiagramCreated(Uml::ID::Type id)
Definition: umllistview.cpp:857
UMLListView::slotMenuSelection
void slotMenuSelection(QAction *action, const QPoint &position=QPoint())
Definition: umllistview.cpp:331
UMLListView::collapseAll
void collapseAll(UMLListViewItem *item)
Definition: umllistview.cpp:2700
UMLListView::selectedItemsCount
int selectedItemsCount()
Definition: umllistview.cpp:2085
UMLListView::changeIconOf
void changeIconOf(UMLObject *o, Icon_Utils::IconType to)
Definition: umllistview.cpp:1342
UMLListView::m_bStartedCut
bool m_bStartedCut
Definition: umllistview.h:184
UMLListView::findUMLObject
UMLListViewItem * findUMLObject(const UMLObject *p) const
Definition: umllistview.cpp:1330
UMLListView::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *me)
Definition: umllistview.cpp:253
UMLObject
The base class for UML objects.
Definition: umlobject.h:75
UMLObject::ObjectType
ObjectType
Definition: umlobject.h:81
UMLView
Definition: umlview.h:35
v
std::vector< std::string > v
Definition: cxx11-initializer-lists.h:19
icon_utils.h
Icon_Utils::IconType
IconType
Definition: icon_utils.h:47
Uml::DiagramType::Enum
Enum
Definition: basictypes.h:77
Uml::ID::Type
std::string Type
Definition: basictypes.h:385
Uml::ModelType::N_MODELTYPES
@ N_MODELTYPES
Definition: basictypes.h:47
Uml::ModelType::Logical
@ Logical
Definition: basictypes.h:42
Uml::ModelType::UseCase
@ UseCase
Definition: basictypes.h:43
Uml::ModelType::Deployment
@ Deployment
Definition: basictypes.h:45
Uml::ModelType::Component
@ Component
Definition: basictypes.h:44
umllistviewitem.h
umllistviewitemlist.h
UMLListViewItemList
QList< UMLListViewItem * > UMLListViewItemList
Definition: umllistviewitemlist.h:24
umlobject.h