umbrello 26.03.70-1a62d36 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 , debugDock(nullptr)
101 , view(nullptr)
102 , document(nullptr)
103 , dockCategory(new KActionCategory(i18n("Show/hide window"), parent->actionCollection()))
104 {
105 }
106
107 ~UMLAppPrivate()
108 {
109 delete diagramsWindow;
110 delete editorWindow;
111 delete logWindow;
112 delete objectsWindow;
113 delete stereotypesWindow;
114 delete welcomeWindow;
115 delete birdView;
116 delete listView;
117 }
118
119 bool openFileInEditor(const QUrl &file, int startCursor=0, int endCursor=0);
120
121 void onSettingsChanged(const Settings::OptionState &optionState)
122 {
123 const bool showDebugWindows = optionState.generalState.showDebugWindows;
124
125 if (showDebugWindows) {
126 createDebugWindow();
127 if (debugDock && logDock)
128 parent->tabifyDockWidget(logDock, debugDock);
129#ifdef ENABLE_UML_OBJECTS_WINDOW
130 createObjectsWindow();
131 if (objectsWindow && diagramsWindow)
132 parent->tabifyDockWidget(diagramsWindow, objectsWindow);
133#endif
134 }
135
136 if (debugDock) {
137 debugDock->setVisible(showDebugWindows);
138 debugDock->toggleViewAction()->setChecked(showDebugWindows);
139 }
140 if (objectsWindow) {
141 objectsWindow->setVisible(showDebugWindows);
142 objectsWindow->toggleViewAction()->setChecked(showDebugWindows);
143 }
144 Tracer::onSettingsChanged(optionState);
145 }
146
147 public Q_SLOTS:
148 void slotLogWindowItemDoubleClicked(QListWidgetItem *item)
149 {
150 QStringList columns = item->text().split(QChar::fromLatin1(':'));
151
152 openFileInEditor(QUrl::fromLocalFile(columns[0]), columns[1].toInt()-1, columns[2].toInt());
153 }
154
155 void initActions()
156 {
157 createBirdWindow();
158 createCommandHistoryWindow();
159 createDiagramsWindow();
160 createDocumentationWindow();
161 createLogWindow();
162 createPropertyWindow();
163 createStereotypesWindow();
164 createTreeWindow();
165 createWelcomeWindow();
166
167 parent->tabifyDockWidget(documentationDock, cmdHistoryDock);
168 parent->tabifyDockWidget(cmdHistoryDock, logDock);
169 //tabifyDockWidget(m_cmdHistoryDock, m_propertyDock); //:TODO:
170 parent->tabifyDockWidget(listDock, stereotypesWindow);
171 parent->tabifyDockWidget(stereotypesWindow, diagramsWindow);
172 if (welcomeWindow) {
173 parent->tabifyDockWidget(welcomeWindow, birdViewDock);
174 welcomeWindow->raise();
175 }
176 listDock->raise();
177 }
178
179 void initWidgets()
180 {
181 /* TODO: On the call to KTextEditor::Editor::instance() Valgrind reports
182 "Conditional jump or move depends on uninitialised value(s)".
183 */
184 editor = KTextEditor::Editor::instance();
185 }
186
187 void createBirdWindow()
188 {
189 birdViewDock = new BirdViewDockWidget(i18n("&Bird's eye view"), parent);
190 birdViewDock->setObjectName(QStringLiteral("BirdViewDock"));
191 parent->addDockWidget(Qt::RightDockWidgetArea, birdViewDock);
192 dockCategory->addAction(QStringLiteral("view_show_bird"), birdViewDock->toggleViewAction());
193 }
194
195 void createCommandHistoryWindow()
196 {
197 cmdHistoryDock = new QDockWidget(i18n("Co&mmand history"), parent);
198 cmdHistoryDock->setObjectName(QStringLiteral("CmdHistoryDock"));
199 parent->addDockWidget(Qt::LeftDockWidgetArea, cmdHistoryDock);
200 pQUndoView = new QUndoView(cmdHistoryDock);
201 pQUndoView->setCleanIcon(Icon_Utils::SmallIcon(Icon_Utils::it_UndoView));
202 pQUndoView->setStack(parent->m_pUndoStack);
203 cmdHistoryDock->setWidget(pQUndoView);
204 dockCategory->addAction(QStringLiteral("view_show_undo"), cmdHistoryDock->toggleViewAction());
205 }
206
207 void createDebugWindow()
208 {
209 if (debugDock)
210 return;
211
212 debugDock = new QDockWidget(i18n("&Debug"), parent);
213 debugDock->setObjectName(QStringLiteral("DebugDock"));
214 parent->addDockWidget(Qt::LeftDockWidgetArea, debugDock);
215 debugDock->setWidget(Tracer::instance());
216 dockCategory->addAction(QStringLiteral("view_show_debug"), debugDock->toggleViewAction());
217 }
218
219 void createDiagramsWindow()
220 {
221 diagramsWindow = new DiagramsWindow(i18n("&Diagrams"), parent);
222 parent->addDockWidget(Qt::LeftDockWidgetArea, diagramsWindow);
223 dockCategory->addAction(QStringLiteral("view_show_diagrams"), diagramsWindow->toggleViewAction());
224 }
225
226 void createDocumentationWindow()
227 {
228 documentationDock = new QDockWidget(i18n("Doc&umentation"), parent);
229 documentationDock->setObjectName(QStringLiteral("DocumentationDock"));
230 parent->addDockWidget(Qt::LeftDockWidgetArea, documentationDock);
231 docWindow = new DocWindow(parent->document(), documentationDock);
232 docWindow->setObjectName(QStringLiteral("DOCWINDOW"));
233 documentationDock->setWidget(docWindow);
234 dockCategory->addAction(QStringLiteral("view_show_doc"), documentationDock->toggleViewAction());
235 }
236
237 void createLogWindow()
238 {
239 logWindow = new QListWidget;
240 QFont mono;
241 mono.setFamily(QStringLiteral("Monospace"));
242 logWindow->setFont(mono);
243 connect(logWindow, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotLogWindowItemDoubleClicked(QListWidgetItem *)));
244
245 logDock = new QDockWidget(i18n("&Log"), parent);
246 logDock->setObjectName(QStringLiteral("LogDock"));
247 parent->addDockWidget(Qt::LeftDockWidgetArea, logDock);
248 logDock->setWidget(logWindow);
249 dockCategory->addAction(QStringLiteral("view_show_log"), logDock->toggleViewAction());
250 }
251
252 void createObjectsWindow()
253 {
254 if (objectsWindow)
255 return;
256
257 objectsWindow = new ObjectsWindow(i18n("&UML Objects"), parent);
258 parent->addDockWidget(Qt::LeftDockWidgetArea, objectsWindow);
259 dockCategory->addAction(QStringLiteral("view_show_objects"), objectsWindow->toggleViewAction());
260 }
261
262 void createPropertyWindow()
263 {
264 //m_propertyDock = new QDockWidget(i18n("&Properties"), this);
265 //m_propertyDock->setObjectName(QStringLiteral("PropertyDock"));
266 //addDockWidget(Qt::LeftDockWidgetArea, m_propertyDock); //:TODO:
267 }
268
269 void createStereotypesWindow()
270 {
271 stereotypesWindow = new StereotypesWindow(i18n("&Stereotypes"), parent);
272 parent->addDockWidget(Qt::LeftDockWidgetArea, stereotypesWindow);
273 dockCategory->addAction(QStringLiteral("view_show_stereotypes"), stereotypesWindow->toggleViewAction());
274 }
275
276 void createTreeWindow()
277 {
278 listDock = new QDockWidget(i18n("&Tree View"), parent);
279 listDock->setObjectName(QStringLiteral("TreeViewDock"));
280 parent->addDockWidget(Qt::LeftDockWidgetArea, listDock);
281 listView = new UMLListView(listDock);
282 //m_listView->setSorting(-1);
283 listView->setDocument(parent->document());
284 listView->init();
285 listDock->setWidget(listView);
286 dockCategory->addAction(QStringLiteral("view_show_tree"), listDock->toggleViewAction());
287 }
288
289 void createWelcomeWindow()
290 {
291 QString file = findWelcomeFile();
292 if (file.isEmpty())
293 return;
294 QString html = readWelcomeFile(file);
295 if (html.isEmpty())
296 return;
297 // qDebug() << html;
298 welcomeWindow = new QDockWidget(i18n("Welcome"), parent);
299 welcomeWindow->setObjectName(QStringLiteral("WelcomeDock"));
300#ifdef WEBKIT_WELCOMEPAGE
301 QWebView *view = new QWebView;
302 view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
303 view->setContextMenuPolicy(Qt::NoContextMenu);
304 connect(view, SIGNAL(linkClicked(const QUrl)), this, SLOT(slotWelcomeWindowLinkClicked(const QUrl)));
305 view->setHtml(html);
306 view->show();
307 welcomeWindow->setWidget(view);
308#else
309 QTextBrowser *tb = new QTextBrowser(dynamic_cast<QWidget*>(this));
310 tb->setOpenExternalLinks(true);
311 tb->setOpenLinks(false);
312 tb->setHtml(html);
313 connect(tb, SIGNAL(anchorClicked(const QUrl)), this, SLOT(slotWelcomeWindowLinkClicked(const QUrl)));
314 welcomeWindow->setWidget(tb);
315#endif
316 parent->addDockWidget(Qt::RightDockWidgetArea, welcomeWindow);
317 dockCategory->addAction(QStringLiteral("view_show_welcome"), welcomeWindow->toggleViewAction());
318 }
319
320 void slotWelcomeWindowLinkClicked(const QUrl &url)
321 {
322 //qDebug() << url;
323 if (url.scheme() == QStringLiteral("mailto") || url.scheme().startsWith(QStringLiteral("http"))) {
324 QDesktopServices::openUrl(url);
325 return;
326 }
327 QStringList list = url.toString().split(QLatin1Char('-'));
328 list.removeLast();
329 QString key;
330 for(const QString &s: list) {
331 QString a = s;
332 a[0] = a[0].toUpper();
333 key.append(a);
334 }
335 Uml::DiagramType::Enum type = Uml::DiagramType::fromString(key);
336 if (type == Uml::DiagramType::Undefined)
337 return;
338 QString diagramName = UMLApp::app()->document()->createDiagramName(type);
339 if (!diagramName.isEmpty())
340 UMLApp::app()->executeCommand(new Uml::CmdCreateDiagram(UMLApp::app()->document(), type, diagramName));
341 }
342
346 void createBirdView(UMLView *view)
347 {
348 if (birdView) {
349 delete birdView;
350 }
351 birdView = new BirdView(birdViewDock, view);
352 connect(birdView, SIGNAL(viewPositionChanged(QPointF)), this, SLOT(slotBirdViewChanged(QPointF)));
353 connect(birdViewDock, SIGNAL(sizeChanged(QSize)), birdView, SLOT(slotDockSizeChanged(QSize)));
354 }
355
356 void deleteBirdView()
357 {
358 disconnect(birdView, SIGNAL(viewPositionChanged(QPointF)), this, SLOT(slotBirdViewChanged(QPointF)));
359 disconnect(birdViewDock, SIGNAL(sizeChanged(QSize)), birdView, SLOT(slotDockSizeChanged(QSize)));
360
361 if (birdView) {
362 delete birdView;
363 }
364 birdView = nullptr;
365 }
366
371 void slotBirdViewChanged(const QPointF& delta)
372 {
373 birdView->setSlotsEnabled(false);
374 UMLView* view = parent->currentView();
375 QPointF oldCenter = view->mapToScene(view->viewport()->rect().center());
376 QPointF newCenter = oldCenter + delta;
377 view->centerOn(newCenter);
378 // DEBUG() << "view moved with: " << delta;
379 birdView->setSlotsEnabled(true);
380 }
381
382 private:
383 QString findWelcomeFile();
384 QString readWelcomeFile(const QString &file);
385};
386
387#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
Settings::GeneralState::showDebugWindows
bool showDebugWindows
Definition: optionstate.h:66
Settings::OptionState
Definition: optionstate.h:314
Settings::OptionState::generalState
GeneralState generalState
Definition: optionstate.h:326
StereotypesWindow
Definition: stereotypeswindow.h:15
Tracer::instance
static Tracer * instance()
Definition: debug_utils.cpp:113
Tracer::onSettingsChanged
static void onSettingsChanged(const Settings::OptionState &state)
Definition: debug_utils.cpp:159
UMLApp
Definition: umlapp.h:85
UMLApp::document
UMLDoc * document() const
Definition: umlapp.cpp:948
UMLApp::executeCommand
void executeCommand(QUndoCommand *cmd)
Definition: umlapp.cpp:3265
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:3019
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:269
UMLAppPrivate::view
KTextEditor::View * view
Definition: umlappprivate.h:85
UMLAppPrivate::deleteBirdView
void deleteBirdView()
Definition: umlappprivate.h:356
UMLAppPrivate::createCommandHistoryWindow
void createCommandHistoryWindow()
Definition: umlappprivate.h:195
UMLAppPrivate::diagramsWindow
DiagramsWindow * diagramsWindow
Definition: umlappprivate.h:67
UMLAppPrivate::createWelcomeWindow
void createWelcomeWindow()
Definition: umlappprivate.h:289
UMLAppPrivate::createTreeWindow
void createTreeWindow()
Definition: umlappprivate.h:276
UMLAppPrivate::findWelcomeFile
QString findWelcomeFile()
Definition: umlappprivate.cpp:19
UMLAppPrivate::onSettingsChanged
void onSettingsChanged(const Settings::OptionState &optionState)
Definition: umlappprivate.h:121
UMLAppPrivate::~UMLAppPrivate
~UMLAppPrivate()
Definition: umlappprivate.h:107
UMLAppPrivate::createDocumentationWindow
void createDocumentationWindow()
Definition: umlappprivate.h:226
UMLAppPrivate::slotBirdViewChanged
void slotBirdViewChanged(const QPointF &delta)
Definition: umlappprivate.h:371
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:237
UMLAppPrivate::findResults
FindResults findResults
Definition: umlappprivate.h:65
UMLAppPrivate::createBirdView
void createBirdView(UMLView *view)
Definition: umlappprivate.h:346
UMLAppPrivate::dockCategory
KActionCategory * dockCategory
Definition: umlappprivate.h:87
UMLAppPrivate::stereotypesWindow
StereotypesWindow * stereotypesWindow
Definition: umlappprivate.h:69
UMLAppPrivate::createPropertyWindow
void createPropertyWindow()
Definition: umlappprivate.h:262
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:187
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:207
UMLAppPrivate::listView
UMLListView * listView
Listview shows the current open file.
Definition: umlappprivate.h:72
UMLAppPrivate::createObjectsWindow
void createObjectsWindow()
Definition: umlappprivate.h:252
UMLAppPrivate::slotWelcomeWindowLinkClicked
void slotWelcomeWindowLinkClicked(const QUrl &url)
Definition: umlappprivate.h:320
UMLAppPrivate::initWidgets
void initWidgets()
Definition: umlappprivate.h:179
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:148
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:219
UMLAppPrivate::initActions
void initActions()
Definition: umlappprivate.h:155
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:219
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