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