umbrello: umbrello/umlappprivate.h Source File

umbrello 2.38.0 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 "cmds.h"
11#include "finddialog.h"
12#include "findresults.h"
13#include "uml.h"
14#include "umldoc.h"
15#include "diagramswindow.h"
16#include "objectswindow.h"
17#include "stereotypeswindow.h"
18
19// kde includes
20#include <KActionCollection>
21#include <KToggleAction>
22#include <ktexteditor/configinterface.h>
23#include <ktexteditor/document.h>
24#include <ktexteditor/editor.h>
25#include <ktexteditor/view.h>
26
27// qt includes
28#include <QDesktopServices>
29#include <QFile>
30#include <QFileInfo>
31#include <QFont>
32#include <QListWidget>
33#include <QObject>
34#ifdef WEBKIT_WELCOMEPAGE
35#include <QWebView>
36#else
37#include <QTextBrowser>
38#endif
39
40class QWidget;
41
42
49 class UMLAppPrivate : public QObject
50{
51 Q_OBJECT
52public:
53 UMLApp *parent;
54 FindDialog findDialog;
55 FindResults findResults;
56 QListWidget *logWindow;
57 KToggleAction *viewDiagramsWindow;
58 KToggleAction *viewObjectsWindow;
59 KToggleAction *viewStereotypesWindow;
60 KToggleAction *viewWelcomeWindow;
61 DiagramsWindow *diagramsWindow;
62 ObjectsWindow *objectsWindow;
63 StereotypesWindow *stereotypesWindow;
64 QDockWidget *welcomeWindow;
65 QDockWidget *editorWindow;
66
67 KTextEditor::Editor *editor;
68 KTextEditor::View *view;
69 KTextEditor::Document *document;
70
71 explicit UMLAppPrivate(UMLApp *_parent)
72 : parent(_parent),
73 findDialog(_parent),
74 viewDiagramsWindow(0),
75 viewObjectsWindow(0),
76 viewStereotypesWindow(0),
77 viewWelcomeWindow(0),
78 diagramsWindow(0),
79 objectsWindow(0),
80 stereotypesWindow(0),
81 welcomeWindow(0),
82 editorWindow(0),
83 view(0),
84 document(0)
85 {
86 /* TODO: On the call to KTextEditor::Editor::instance() Valgrind reports
87 "Conditional jump or move depends on uninitialised value(s)".
88 */
89 editor = KTextEditor::Editor::instance();
90 logWindow = new QListWidget;
91 QFont mono;
92 mono.setFamily(QStringLiteral("Monospace"));
93 logWindow->setFont(mono);
94 connect(logWindow, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotLogWindowItemDoubleClicked(QListWidgetItem *)));
95 }
96
97 ~UMLAppPrivate()
98 {
99 delete diagramsWindow;
100 delete editorWindow;
101 delete logWindow;
102 delete objectsWindow;
103 delete stereotypesWindow;
104 delete welcomeWindow;
105 }
106
107 bool openFileInEditor(const QUrl &file, int startCursor=0, int endCursor=0);
108
109public slots:
110 void slotLogWindowItemDoubleClicked(QListWidgetItem *item)
111 {
112 QStringList columns = item->text().split(QChar::fromLatin1(':'));
113
114 openFileInEditor(QUrl::fromLocalFile(columns[0]), columns[1].toInt()-1, columns[2].toInt());
115 }
116
117 void createDiagramsWindow()
118 {
119 // create the tree viewer
120 diagramsWindow = new DiagramsWindow(i18n("&Diagrams"), parent);
121 parent->addDockWidget(Qt::LeftDockWidgetArea, diagramsWindow);
122
123 viewDiagramsWindow = parent->actionCollection()->add<KToggleAction>(QStringLiteral("view_show_diagrams"));
124 connect(viewDiagramsWindow, SIGNAL(triggered(bool)), diagramsWindow, SLOT(setVisible(bool)));
125 }
126
127 void createObjectsWindow()
128 {
129 // create the object window
130 objectsWindow = new ObjectsWindow(i18n("&UML Objects"), parent);
131 parent->addDockWidget(Qt::LeftDockWidgetArea, objectsWindow);
132
133 viewObjectsWindow = parent->actionCollection()->add<KToggleAction>(QStringLiteral("view_show_objects"));
134 connect(viewObjectsWindow, SIGNAL(triggered(bool)), objectsWindow, SLOT(setVisible(bool)));
135 }
136
137 void createStereotypesWindow()
138 {
139 // create the tree viewer
140 stereotypesWindow = new StereotypesWindow(i18n("&Stereotypes"), parent);
141 parent->addDockWidget(Qt::LeftDockWidgetArea, stereotypesWindow);
142
143 viewStereotypesWindow = parent->actionCollection()->add<KToggleAction>(QStringLiteral("view_show_stereotypes"));
144 connect(viewStereotypesWindow, SIGNAL(triggered(bool)), stereotypesWindow, SLOT(setVisible(bool)));
145 }
146
147 void createWelcomeWindow()
148 {
149 QString file = findWelcomeFile();
150 if (file.isEmpty())
151 return;
152 QString html = readWelcomeFile(file);
153 if (html.isEmpty())
154 return;
155 // qDebug() << html;
156 welcomeWindow = new QDockWidget(i18n("Welcome"), parent);
157 welcomeWindow->setObjectName(QStringLiteral("WelcomeDock"));
158#ifdef WEBKIT_WELCOMEPAGE
159 QWebView *view = new QWebView;
160 view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
161 view->setContextMenuPolicy(Qt::NoContextMenu);
162 connect(view, SIGNAL(linkClicked(const QUrl)), this, SLOT(slotWelcomeWindowLinkClicked(const QUrl)));
163 view->setHtml(html);
164 view->show();
165 welcomeWindow->setWidget(view);
166#else
167 QTextBrowser *tb = new QTextBrowser(dynamic_cast<QWidget*>(this));
168 tb->setOpenExternalLinks(true);
169 tb->setOpenLinks(false);
170 tb->setHtml(html);
171 connect(tb, SIGNAL(anchorClicked(const QUrl)), this, SLOT(slotWelcomeWindowLinkClicked(const QUrl)));
172 welcomeWindow->setWidget(tb);
173#endif
174 parent->addDockWidget(Qt::RightDockWidgetArea, welcomeWindow);
175
176 viewWelcomeWindow = parent->actionCollection()->add<KToggleAction>(QStringLiteral("view_show_welcome"));
177 connect(viewWelcomeWindow, SIGNAL(triggered(bool)), welcomeWindow, SLOT(setVisible(bool)));
178 }
179
180 void slotWelcomeWindowLinkClicked(const QUrl &url)
181 {
182 //qDebug() << url;
183 if (url.scheme() == QStringLiteral("mailto") || url.scheme().startsWith(QStringLiteral("http"))) {
184 QDesktopServices::openUrl(url);
185 return;
186 }
187 QStringList list = url.toString().split(QLatin1Char('-'));
188 list.removeLast();
189 QString key;
190 foreach(const QString s, list) {
191 QString a = s;
192 a[0] = a[0].toUpper();
193 key.append(a);
194 }
195 Uml::DiagramType::Enum type = Uml::DiagramType::fromString(key);
196 if (type == Uml::DiagramType::Undefined)
197 return;
198 QString diagramName = UMLApp::app()->document()->createDiagramName(type);
199 if (!diagramName.isEmpty())
200 UMLApp::app()->executeCommand(new Uml::CmdCreateDiagram(UMLApp::app()->document(), type, diagramName));
201 }
202
203private:
204 QString findWelcomeFile();
205 QString readWelcomeFile(const QString &file);
206};
207
208#endif
DiagramsWindow
Definition diagramswindow.h:15
FindDialog
Definition finddialog.h:20
FindResults
Definition findresults.h:25
ObjectsWindow
Definition objectswindow.h:16
StereotypesWindow
Definition stereotypeswindow.h:15
UMLAppPrivate
Definition umlappprivate.h:50
UMLAppPrivate::editor
KTextEditor::Editor * editor
Definition umlappprivate.h:67
UMLAppPrivate::openFileInEditor
bool openFileInEditor(const QUrl &file, int startCursor=0, int endCursor=0)
Definition umlappprivate.cpp:127
UMLAppPrivate::createStereotypesWindow
void createStereotypesWindow()
Definition umlappprivate.h:137
UMLAppPrivate::view
KTextEditor::View * view
Definition umlappprivate.h:68
UMLAppPrivate::diagramsWindow
DiagramsWindow * diagramsWindow
Definition umlappprivate.h:61
UMLAppPrivate::createWelcomeWindow
void createWelcomeWindow()
Definition umlappprivate.h:147
UMLAppPrivate::findWelcomeFile
QString findWelcomeFile()
Definition umlappprivate.cpp:20
UMLAppPrivate::viewObjectsWindow
KToggleAction * viewObjectsWindow
Definition umlappprivate.h:58
UMLAppPrivate::~UMLAppPrivate
~UMLAppPrivate()
Definition umlappprivate.h:97
UMLAppPrivate::parent
UMLApp * parent
Definition umlappprivate.h:53
UMLAppPrivate::findDialog
FindDialog findDialog
Definition umlappprivate.h:54
UMLAppPrivate::document
KTextEditor::Document * document
Definition umlappprivate.h:69
UMLAppPrivate::readWelcomeFile
QString readWelcomeFile(const QString &file)
Definition umlappprivate.cpp:68
UMLAppPrivate::viewStereotypesWindow
KToggleAction * viewStereotypesWindow
Definition umlappprivate.h:59
UMLAppPrivate::viewDiagramsWindow
KToggleAction * viewDiagramsWindow
Definition umlappprivate.h:57
UMLAppPrivate::findResults
FindResults findResults
Definition umlappprivate.h:55
UMLAppPrivate::stereotypesWindow
StereotypesWindow * stereotypesWindow
Definition umlappprivate.h:63
UMLAppPrivate::welcomeWindow
QDockWidget * welcomeWindow
Definition umlappprivate.h:64
UMLAppPrivate::createObjectsWindow
void createObjectsWindow()
Definition umlappprivate.h:127
UMLAppPrivate::slotWelcomeWindowLinkClicked
void slotWelcomeWindowLinkClicked(const QUrl &url)
Definition umlappprivate.h:180
UMLAppPrivate::slotLogWindowItemDoubleClicked
void slotLogWindowItemDoubleClicked(QListWidgetItem *item)
Definition umlappprivate.h:110
UMLAppPrivate::UMLAppPrivate
UMLAppPrivate(UMLApp *_parent)
Definition umlappprivate.h:71
UMLAppPrivate::logWindow
QListWidget * logWindow
Logging window.
Definition umlappprivate.h:56
UMLAppPrivate::editorWindow
QDockWidget * editorWindow
Definition umlappprivate.h:65
UMLAppPrivate::createDiagramsWindow
void createDiagramsWindow()
Definition umlappprivate.h:117
UMLAppPrivate::objectsWindow
ObjectsWindow * objectsWindow
Definition umlappprivate.h:62
UMLAppPrivate::viewWelcomeWindow
KToggleAction * viewWelcomeWindow
Definition umlappprivate.h:60
UMLApp
Definition uml.h:85
UMLApp::document
UMLDoc * document() const
Definition uml.cpp:1051
UMLApp::executeCommand
void executeCommand(QUndoCommand *cmd)
Definition uml.cpp:3379
UMLApp::app
static UMLApp * app()
Definition uml.cpp:306
UMLDoc::createDiagramName
QString createDiagramName(Uml::DiagramType::Enum type, bool askForName=true)
Definition umldoc.cpp:1492
Uml::CmdCreateDiagram
Definition cmdcreatediagram.h:20
cmds.h
diagramswindow.h
finddialog.h
findresults.h
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
uml.h
umldoc.h