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

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

umlappprivate.h
Go to the documentation of this file.
1/*
2 SPDX-License-Identifier: GPL-2.0-or-later
3 SPDX-FileCopyrightText: 2002-2022 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
4*/
5
6#ifndef UMLAPPPRIVATE_H
7#define UMLAPPPRIVATE_H
8
9// app includes
10#include "birdview.h"
11#include "birdviewdockwidget.h"
12#include "cmdcreatediagram.h"
13#include "debug_utils.h"
14#include "diagramswindow.h"
15#include "docwindow.h"
16#include "finddialog.h"
17#include "findresults.h"
18#include "objectswindow.h"
19#include "stereotypeswindow.h"
20#include "umlapp.h"
21#include "umldoc.h"
22#include "umllistview.h"
23#include "umlview.h"
24
25// kde includes
26#include <KActionCategory>
27#include <KActionCollection>
28#include <KToggleAction>
29#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
30#include <ktexteditor/configinterface.h>
31#endif
32#include <ktexteditor/document.h>
33#include <ktexteditor/editor.h>
34#include <ktexteditor/view.h>
35
36// qt includes
37#include <QDesktopServices>
38#include <QFile>
39#include <QFileInfo>
40#include <QFont>
41#include <QListWidget>
42#include <QObject>
43#include <QUndoView>
44#ifdef WEBKIT_WELCOMEPAGE
45#include <QWebView>
46#else
47#include <QTextBrowser>
48#endif
49
50 class QWidget;
51
52
59 class UMLAppPrivate : public QObject
60{
61 Q_OBJECT
62 public:
63 UMLApp *parent;
64 FindDialog findDialog;
65 FindResults findResults;
66 QListWidget *logWindow;
67 DiagramsWindow *diagramsWindow;
68 ObjectsWindow *objectsWindow;
69 StereotypesWindow *stereotypesWindow;
70 DocWindow* docWindow;
71 BirdView* birdView;
72 UMLListView* listView;
73 QUndoView* pQUndoView;
74
75 BirdViewDockWidget* birdViewDock;
76 QDockWidget *editorWindow;
77 QDockWidget *logDock;
78 QDockWidget *welcomeWindow;
79 QDockWidget* cmdHistoryDock;
80 QDockWidget* debugDock;
81 QDockWidget* documentationDock;
82 QDockWidget* listDock;
83
84 KTextEditor::Editor *editor;
85 KTextEditor::View *view;
86 KTextEditor::Document *document;
87 KActionCategory *dockCategory;
88
89 explicit UMLAppPrivate(UMLApp *_parent)
90 : parent(_parent),
91 findDialog(_parent),
92 diagramsWindow(nullptr),
93 objectsWindow(nullptr),
94 stereotypesWindow(nullptr),
95 birdView(nullptr),
96 listView(nullptr),
97 pQUndoView(nullptr),
98 editorWindow(nullptr),
99 welcomeWindow(nullptr),
100 view(nullptr),
101 document(nullptr),
102 dockCategory(new KActionCategory(i18n("Show/hide window"), parent->actionCollection()))
103 {
104 }
105
106 ~UMLAppPrivate()
107 {
108 delete diagramsWindow;
109 delete editorWindow;
110 delete logWindow;
111 delete objectsWindow;
112 delete stereotypesWindow;
113 delete welcomeWindow;
114 delete birdView;
115 delete listView;
116 }
117
118 bool openFileInEditor(const QUrl &file, int startCursor=0, int endCursor=0);
119
120 public Q_SLOTS:
121 void slotLogWindowItemDoubleClicked(QListWidgetItem *item)
122 {
123 QStringList columns = item->text().split(QChar::fromLatin1(':'));
124
125 openFileInEditor(QUrl::fromLocalFile(columns[0]), columns[1].toInt()-1, columns[2].toInt());
126 }
127
128 void initActions()
129 {
130 createBirdWindow();
131 createCommandHistoryWindow();
132 createDebugWindow();
133 createDiagramsWindow();
134 createDocumentationWindow();
135 createLogWindow();
136#ifdef ENABLE_UML_OBJECTS_WINDOW
137 createObjectsWindow();
138#endif
139 createPropertyWindow();
140 createStereotypesWindow();
141 createTreeWindow();
142 createWelcomeWindow();
143
144 parent->tabifyDockWidget(documentationDock, cmdHistoryDock);
145 parent->tabifyDockWidget(cmdHistoryDock, logDock);
146 //tabifyDockWidget(m_cmdHistoryDock, m_propertyDock); //:TODO:
147 parent->tabifyDockWidget(logDock, debugDock);
148 parent->tabifyDockWidget(listDock, stereotypesWindow);
149 parent->tabifyDockWidget(stereotypesWindow, diagramsWindow);
150 #ifdef ENABLE_UML_OBJECTS_WINDOW
151 parent->tabifyDockWidget(diagramsWindow, objectsWindow);
152 #endif
153 if (welcomeWindow) {
154 parent->tabifyDockWidget(welcomeWindow, birdViewDock);
155 welcomeWindow->raise();
156 }
157 listDock->raise();
158 }
159
160 void initWidgets()
161 {
162 /* TODO: On the call to KTextEditor::Editor::instance() Valgrind reports
163 "Conditional jump or move depends on uninitialised value(s)".
164 */
165 editor = KTextEditor::Editor::instance();
166 }
167
168 void createBirdWindow()
169 {
170 birdViewDock = new BirdViewDockWidget(i18n("&Bird's eye view"), parent);
171 birdViewDock->setObjectName(QStringLiteral("BirdViewDock"));
172 parent->addDockWidget(Qt::RightDockWidgetArea, birdViewDock);
173 dockCategory->addAction(QStringLiteral("view_show_bird"), birdViewDock->toggleViewAction());
174 }
175
176 void createCommandHistoryWindow()
177 {
178 cmdHistoryDock = new QDockWidget(i18n("Co&mmand history"), parent);
179 cmdHistoryDock->setObjectName(QStringLiteral("CmdHistoryDock"));
180 parent->addDockWidget(Qt::LeftDockWidgetArea, cmdHistoryDock);
181 pQUndoView = new QUndoView(cmdHistoryDock);
182 pQUndoView->setCleanIcon(Icon_Utils::SmallIcon(Icon_Utils::it_UndoView));
183 pQUndoView->setStack(parent->m_pUndoStack);
184 cmdHistoryDock->setWidget(pQUndoView);
185 dockCategory->addAction(QStringLiteral("view_show_undo"), cmdHistoryDock->toggleViewAction());
186 }
187
188 void createDebugWindow()
189 {
190 debugDock = new QDockWidget(i18n("&Debug"), parent);
191 debugDock->setObjectName(QStringLiteral("DebugDock"));
192 parent->addDockWidget(Qt::LeftDockWidgetArea, debugDock);
193 debugDock->setWidget(Tracer::instance());
194 dockCategory->addAction(QStringLiteral("view_show_debug"), debugDock->toggleViewAction());
195 }
196
197 void createDiagramsWindow()
198 {
199 diagramsWindow = new DiagramsWindow(i18n("&Diagrams"), parent);
200 parent->addDockWidget(Qt::LeftDockWidgetArea, diagramsWindow);
201 dockCategory->addAction(QStringLiteral("view_show_diagrams"), diagramsWindow->toggleViewAction());
202 }
203
204 void createDocumentationWindow()
205 {
206 documentationDock = new QDockWidget(i18n("Doc&umentation"), parent);
207 documentationDock->setObjectName(QStringLiteral("DocumentationDock"));
208 parent->addDockWidget(Qt::LeftDockWidgetArea, documentationDock);
209 docWindow = new DocWindow(parent->document(), documentationDock);
210 docWindow->setObjectName(QStringLiteral("DOCWINDOW"));
211 documentationDock->setWidget(docWindow);
212 dockCategory->addAction(QStringLiteral("view_show_doc"), documentationDock->toggleViewAction());
213 }
214
215 void createLogWindow()
216 {
217 logWindow = new QListWidget;
218 QFont mono;
219 mono.setFamily(QStringLiteral("Monospace"));
220 logWindow->setFont(mono);
221 connect(logWindow, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotLogWindowItemDoubleClicked(QListWidgetItem *)));
222
223 logDock = new QDockWidget(i18n("&Log"), parent);
224 logDock->setObjectName(QStringLiteral("LogDock"));
225 parent->addDockWidget(Qt::LeftDockWidgetArea, logDock);
226 logDock->setWidget(logWindow);
227 dockCategory->addAction(QStringLiteral("view_show_log"), logDock->toggleViewAction());
228 }
229
230 void createObjectsWindow()
231 {
232 objectsWindow = new ObjectsWindow(i18n("&UML Objects"), parent);
233 parent->addDockWidget(Qt::LeftDockWidgetArea, objectsWindow);
234 dockCategory->addAction(QStringLiteral("view_show_objects"), objectsWindow->toggleViewAction());
235 }
236
237 void createPropertyWindow()
238 {
239 //m_propertyDock = new QDockWidget(i18n("&Properties"), this);
240 //m_propertyDock->setObjectName(QStringLiteral("PropertyDock"));
241 //addDockWidget(Qt::LeftDockWidgetArea, m_propertyDock); //:TODO:
242 }
243
244 void createStereotypesWindow()
245 {
246 stereotypesWindow = new StereotypesWindow(i18n("&Stereotypes"), parent);
247 parent->addDockWidget(Qt::LeftDockWidgetArea, stereotypesWindow);
248 dockCategory->addAction(QStringLiteral("view_show_stereotypes"), stereotypesWindow->toggleViewAction());
249 }
250
251 void createTreeWindow()
252 {
253 listDock = new QDockWidget(i18n("&Tree View"), parent);
254 listDock->setObjectName(QStringLiteral("TreeViewDock"));
255 parent->addDockWidget(Qt::LeftDockWidgetArea, listDock);
256 listView = new UMLListView(listDock);
257 //m_listView->setSorting(-1);
258 listView->setDocument(parent->document());
259 listView->init();
260 listDock->setWidget(listView);
261 dockCategory->addAction(QStringLiteral("view_show_tree"), listDock->toggleViewAction());
262 }
263
264 void createWelcomeWindow()
265 {
266 QString file = findWelcomeFile();
267 if (file.isEmpty())
268 return;
269 QString html = readWelcomeFile(file);
270 if (html.isEmpty())
271 return;
272 // qDebug() << html;
273 welcomeWindow = new QDockWidget(i18n("Welcome"), parent);
274 welcomeWindow->setObjectName(QStringLiteral("WelcomeDock"));
275#ifdef WEBKIT_WELCOMEPAGE
276 QWebView *view = new QWebView;
277 view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
278 view->setContextMenuPolicy(Qt::NoContextMenu);
279 connect(view, SIGNAL(linkClicked(const QUrl)), this, SLOT(slotWelcomeWindowLinkClicked(const QUrl)));
280 view->setHtml(html);
281 view->show();
282 welcomeWindow->setWidget(view);
283#else
284 QTextBrowser *tb = new QTextBrowser(dynamic_cast<QWidget*>(this));
285 tb->setOpenExternalLinks(true);
286 tb->setOpenLinks(false);
287 tb->setHtml(html);
288 connect(tb, SIGNAL(anchorClicked(const QUrl)), this, SLOT(slotWelcomeWindowLinkClicked(const QUrl)));
289 welcomeWindow->setWidget(tb);
290#endif
291 parent->addDockWidget(Qt::RightDockWidgetArea, welcomeWindow);
292 dockCategory->addAction(QStringLiteral("view_show_welcome"), welcomeWindow->toggleViewAction());
293 }
294
295 void slotWelcomeWindowLinkClicked(const QUrl &url)
296 {
297 //qDebug() << url;
298 if (url.scheme() == QStringLiteral("mailto") || url.scheme().startsWith(QStringLiteral("http"))) {
299 QDesktopServices::openUrl(url);
300 return;
301 }
302 QStringList list = url.toString().split(QLatin1Char('-'));
303 list.removeLast();
304 QString key;
305 for(const QString &s: list) {
306 QString a = s;
307 a[0] = a[0].toUpper();
308 key.append(a);
309 }
310 Uml::DiagramType::Enum type = Uml::DiagramType::fromString(key);
311 if (type == Uml::DiagramType::Undefined)
312 return;
313 QString diagramName = UMLApp::app()->document()->createDiagramName(type);
314 if (!diagramName.isEmpty())
315 UMLApp::app()->executeCommand(new Uml::CmdCreateDiagram(UMLApp::app()->document(), type, diagramName));
316 }
317
321 void createBirdView(UMLView *view)
322 {
323 if (birdView) {
324 delete birdView;
325 }
326 birdView = new BirdView(birdViewDock, view);
327 connect(birdView, SIGNAL(viewPositionChanged(QPointF)), this, SLOT(slotBirdViewChanged(QPointF)));
328 connect(birdViewDock, SIGNAL(sizeChanged(QSize)), birdView, SLOT(slotDockSizeChanged(QSize)));
329 }
330
331 void deleteBirdView()
332 {
333 disconnect(birdView, SIGNAL(viewPositionChanged(QPointF)), this, SLOT(slotBirdViewChanged(QPointF)));
334 disconnect(birdViewDock, SIGNAL(sizeChanged(QSize)), birdView, SLOT(slotDockSizeChanged(QSize)));
335
336 if (birdView) {
337 delete birdView;
338 }
339 birdView = nullptr;
340 }
341
346 void slotBirdViewChanged(const QPointF& delta)
347 {
348 birdView->setSlotsEnabled(false);
349 UMLView* view = parent->currentView();
350 QPointF oldCenter = view->mapToScene(view->viewport()->rect().center());
351 QPointF newCenter = oldCenter + delta;
352 view->centerOn(newCenter);
353 // DEBUG() << "view moved with: " << delta;
354 birdView->setSlotsEnabled(true);
355 }
356
357 private:
358 QString findWelcomeFile();
359 QString readWelcomeFile(const QString &file);
360};
361
362#endif
birdview.h
birdviewdockwidget.h
BirdViewDockWidget
The class BirdViewDockWidget contains the bird view.
Definition: birdviewdockwidget.h:19
BirdView
The class BirdView controls the view of the whole scene.
Definition: birdview.h:30
BirdView::setSlotsEnabled
void setSlotsEnabled(bool enabled)
Definition: birdview.cpp:222
DiagramsWindow
Definition: diagramswindow.h:15
DocWindow
Definition: docwindow.h:25
FindDialog
Definition: finddialog.h:20
FindResults
Definition: findresults.h:25
ObjectsWindow
Definition: objectswindow.h:16
StereotypesWindow
Definition: stereotypeswindow.h:15
Tracer::instance
static Tracer * instance()
Definition: debug_utils.cpp:109
UMLApp
Definition: umlapp.h:85
UMLApp::document
UMLDoc * document() const
Definition: umlapp.cpp:945
UMLApp::executeCommand
void executeCommand(QUndoCommand *cmd)
Definition: umlapp.cpp:3261
UMLApp::app
static UMLApp * app()
Definition: umlapp.cpp:284
UMLApp::m_pUndoStack
QUndoStack * m_pUndoStack
UndoStack used to store actions, to provide Undo/Redo feature.
Definition: umlapp.h:450
UMLApp::currentView
UMLView * currentView() const
Definition: umlapp.cpp:3015
UMLAppPrivate
Definition: umlappprivate.h:60
UMLAppPrivate::editor
KTextEditor::Editor * editor
Definition: umlappprivate.h:84
UMLAppPrivate::openFileInEditor
bool openFileInEditor(const QUrl &file, int startCursor=0, int endCursor=0)
Definition: umlappprivate.cpp:128
UMLAppPrivate::createStereotypesWindow
void createStereotypesWindow()
Definition: umlappprivate.h:244
UMLAppPrivate::view
KTextEditor::View * view
Definition: umlappprivate.h:85
UMLAppPrivate::deleteBirdView
void deleteBirdView()
Definition: umlappprivate.h:331
UMLAppPrivate::createCommandHistoryWindow
void createCommandHistoryWindow()
Definition: umlappprivate.h:176
UMLAppPrivate::diagramsWindow
DiagramsWindow * diagramsWindow
Definition: umlappprivate.h:67
UMLAppPrivate::createWelcomeWindow
void createWelcomeWindow()
Definition: umlappprivate.h:264
UMLAppPrivate::createTreeWindow
void createTreeWindow()
Definition: umlappprivate.h:251
UMLAppPrivate::findWelcomeFile
QString findWelcomeFile()
Definition: umlappprivate.cpp:19
UMLAppPrivate::~UMLAppPrivate
~UMLAppPrivate()
Definition: umlappprivate.h:106
UMLAppPrivate::createDocumentationWindow
void createDocumentationWindow()
Definition: umlappprivate.h:204
UMLAppPrivate::slotBirdViewChanged
void slotBirdViewChanged(const QPointF &delta)
Definition: umlappprivate.h:346
UMLAppPrivate::parent
UMLApp * parent
Definition: umlappprivate.h:63
UMLAppPrivate::findDialog
FindDialog findDialog
Definition: umlappprivate.h:64
UMLAppPrivate::document
KTextEditor::Document * document
Definition: umlappprivate.h:86
UMLAppPrivate::readWelcomeFile
QString readWelcomeFile(const QString &file)
Definition: umlappprivate.cpp:67
UMLAppPrivate::createLogWindow
void createLogWindow()
Definition: umlappprivate.h:215
UMLAppPrivate::findResults
FindResults findResults
Definition: umlappprivate.h:65
UMLAppPrivate::createBirdView
void createBirdView(UMLView *view)
Definition: umlappprivate.h:321
UMLAppPrivate::dockCategory
KActionCategory * dockCategory
Definition: umlappprivate.h:87
UMLAppPrivate::stereotypesWindow
StereotypesWindow * stereotypesWindow
Definition: umlappprivate.h:69
UMLAppPrivate::createPropertyWindow
void createPropertyWindow()
Definition: umlappprivate.h:237
UMLAppPrivate::debugDock
QDockWidget * debugDock
Contains the debug DocWindow widget.
Definition: umlappprivate.h:80
UMLAppPrivate::docWindow
DocWindow * docWindow
Documentation window.
Definition: umlappprivate.h:70
UMLAppPrivate::listDock
QDockWidget * listDock
Contains the UMLListView tree view.
Definition: umlappprivate.h:82
UMLAppPrivate::createBirdWindow
void createBirdWindow()
Definition: umlappprivate.h:168
UMLAppPrivate::welcomeWindow
QDockWidget * welcomeWindow
Definition: umlappprivate.h:78
UMLAppPrivate::logDock
QDockWidget * logDock
Contains the log window widget.
Definition: umlappprivate.h:77
UMLAppPrivate::birdViewDock
BirdViewDockWidget * birdViewDock
Contains the bird's eye view.
Definition: umlappprivate.h:75
UMLAppPrivate::createDebugWindow
void createDebugWindow()
Definition: umlappprivate.h:188
UMLAppPrivate::listView
UMLListView * listView
Listview shows the current open file.
Definition: umlappprivate.h:72
UMLAppPrivate::createObjectsWindow
void createObjectsWindow()
Definition: umlappprivate.h:230
UMLAppPrivate::slotWelcomeWindowLinkClicked
void slotWelcomeWindowLinkClicked(const QUrl &url)
Definition: umlappprivate.h:295
UMLAppPrivate::initWidgets
void initWidgets()
Definition: umlappprivate.h:160
UMLAppPrivate::pQUndoView
QUndoView * pQUndoView
Undo / Redo Viewer.
Definition: umlappprivate.h:73
UMLAppPrivate::cmdHistoryDock
QDockWidget * cmdHistoryDock
Contains the undo/redo viewer widget.
Definition: umlappprivate.h:79
UMLAppPrivate::slotLogWindowItemDoubleClicked
void slotLogWindowItemDoubleClicked(QListWidgetItem *item)
Definition: umlappprivate.h:121
UMLAppPrivate::UMLAppPrivate
UMLAppPrivate(UMLApp *_parent)
Definition: umlappprivate.h:89
UMLAppPrivate::documentationDock
QDockWidget * documentationDock
Contains the documentation DocWindow widget.
Definition: umlappprivate.h:81
UMLAppPrivate::logWindow
QListWidget * logWindow
Logging window.
Definition: umlappprivate.h:66
UMLAppPrivate::editorWindow
QDockWidget * editorWindow
Definition: umlappprivate.h:76
UMLAppPrivate::birdView
BirdView * birdView
Bird View window.
Definition: umlappprivate.h:71
UMLAppPrivate::createDiagramsWindow
void createDiagramsWindow()
Definition: umlappprivate.h:197
UMLAppPrivate::initActions
void initActions()
Definition: umlappprivate.h:128
UMLAppPrivate::objectsWindow
ObjectsWindow * objectsWindow
Definition: umlappprivate.h:68
UMLDoc::createDiagramName
QString createDiagramName(Uml::DiagramType::Enum type, bool askForName=true)
Definition: umldoc.cpp:1617
UMLListView
Displays the list view for the program.
Definition: umllistview.h:43
UMLListView::setDocument
void setDocument(UMLDoc *doc)
Definition: umllistview.cpp:1199
UMLListView::init
void init()
Definition: umllistview.cpp:1419
UMLView
Definition: umlview.h:30
Uml::CmdCreateDiagram
Definition: cmdcreatediagram.h:20
cmdcreatediagram.h
debug_utils.h
diagramswindow.h
docwindow.h
finddialog.h
findresults.h
Icon_Utils::it_UndoView
@ it_UndoView
Definition: icon_utils.h:122
Icon_Utils::SmallIcon
QPixmap SmallIcon(IconType type)
Definition: icon_utils.cpp:32
Uml::DiagramType::fromString
Enum fromString(const QString &item)
Definition: basictypes.cpp:218
Uml::DiagramType::Enum
Enum
Definition: basictypes.h:63
Uml::DiagramType::Undefined
@ Undefined
Definition: basictypes.h:66
objectswindow.h
a
QString a
Definition: petalnode.cpp:13
stereotypeswindow.h
umlapp.h
umldoc.h
umllistview.h
umlview.h