umbrello: umbrello/umlappprivate.h Source File

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

umlappprivate.h
Go to the documentation of this file.
1/*
2 SPDX-License-Identifier: GPL-2.0-or-later
3 SPDX-FileCopyrightText: 2002-2020 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 "debug_utils.h"
12#include "finddialog.h"
13#include "findresults.h"
14#include "uml.h"
15#include "umldoc.h"
16#include "diagramswindow.h"
17#include "objectswindow.h"
18#include "stereotypeswindow.h"
19
20// kde includes
21#include <KActionCollection>
22#if QT_VERSION < 0x050000
23#include <KStandardDirs>
24#endif
25#include <KToggleAction>
26#include <ktexteditor/configinterface.h>
27#include <ktexteditor/document.h>
28#include <ktexteditor/editor.h>
29#if QT_VERSION < 0x050000
30#include <ktexteditor/editorchooser.h>
31#endif
32#include <ktexteditor/view.h>
33
34// qt includes
35#include <QDesktopServices>
36#include <QFile>
37#include <QFileInfo>
38#include <QListWidget>
39#include <QObject>
40#include <QWebView>
41
42class QWidget;
43
44
51 class UMLAppPrivate : public QObject
52{
53 Q_OBJECT
54public:
55 UMLApp *parent;
56 FindDialog findDialog;
57 FindResults findResults;
58 QListWidget *logWindow;
59 KToggleAction *viewDiagramsWindow;
60 KToggleAction *viewObjectsWindow;
61 KToggleAction *viewStereotypesWindow;
62 KToggleAction *viewWelcomeWindow;
63 DiagramsWindow *diagramsWindow;
64 ObjectsWindow *objectsWindow;
65 StereotypesWindow *stereotypesWindow;
66 QDockWidget *welcomeWindow;
67 QDockWidget *editorWindow;
68
69 KTextEditor::Editor *editor;
70 KTextEditor::View *view;
71 KTextEditor::Document *document;
72
73 explicit UMLAppPrivate(UMLApp *_parent)
74 : parent(_parent),
75 findDialog(_parent),
76 viewDiagramsWindow(0),
77 viewObjectsWindow(0),
78 viewStereotypesWindow(0),
79 viewWelcomeWindow(0),
80 diagramsWindow(0),
81 objectsWindow(0),
82 stereotypesWindow(0),
83 welcomeWindow(0),
84 editorWindow(0),
85 view(0),
86 document(0)
87 {
88#if QT_VERSION >= 0x050000
89 editor = KTextEditor::Editor::instance();
90#else
91 editor = KTextEditor::EditorChooser::editor();
92#endif
93 logWindow = new QListWidget;
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>(QLatin1String("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>(QLatin1String("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>(QLatin1String("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(QLatin1String("WelcomeDock"));
158 QWebView *view = new QWebView;
159 view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
160 view->setContextMenuPolicy(Qt::NoContextMenu);
161 connect(view, SIGNAL(linkClicked(const QUrl)), this, SLOT(slotWelcomeWindowLinkClicked(const QUrl)));
162 view->setHtml(html);
163 view->show();
164 welcomeWindow->setWidget(view);
165 parent->addDockWidget(Qt::RightDockWidgetArea, welcomeWindow);
166
167 viewWelcomeWindow = parent->actionCollection()->add<KToggleAction>(QLatin1String("view_show_welcome"));
168 connect(viewWelcomeWindow, SIGNAL(triggered(bool)), welcomeWindow, SLOT(setVisible(bool)));
169 }
170
171 void slotWelcomeWindowLinkClicked(const QUrl &url)
172 {
173 //qDebug() << url;
174 if (url.scheme() == QLatin1String("mailto") || url.scheme().startsWith(QLatin1String("http"))) {
175 QDesktopServices::openUrl(url);
176 return;
177 }
178 QStringList list = url.toString().split(QLatin1Char('-'));
179 list.removeLast();
180 QString key;
181 foreach(const QString s, list) {
182 QString a = s;
183 a[0] = a[0].toUpper();
184 key.append(a);
185 }
186 Uml::DiagramType::Enum type = Uml::DiagramType::fromString(key);
187 if (type == Uml::DiagramType::Undefined)
188 return;
189 QString diagramName = UMLApp::app()->document()->createDiagramName(type);
190 if (!diagramName.isEmpty())
191 UMLApp::app()->executeCommand(new Uml::CmdCreateDiagram(UMLApp::app()->document(), type, diagramName));
192 }
193
194private:
195 QString findWelcomeFile();
196 QString readWelcomeFile(const QString &file);
197};
198
199#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:52
UMLAppPrivate::editor
KTextEditor::Editor * editor
Definition: umlappprivate.h:69
UMLAppPrivate::openFileInEditor
bool openFileInEditor(const QUrl &file, int startCursor=0, int endCursor=0)
Definition: umlappprivate.cpp:131
UMLAppPrivate::createStereotypesWindow
void createStereotypesWindow()
Definition: umlappprivate.h:137
UMLAppPrivate::view
KTextEditor::View * view
Definition: umlappprivate.h:70
UMLAppPrivate::diagramsWindow
DiagramsWindow * diagramsWindow
Definition: umlappprivate.h:63
UMLAppPrivate::createWelcomeWindow
void createWelcomeWindow()
Definition: umlappprivate.h:147
UMLAppPrivate::findWelcomeFile
QString findWelcomeFile()
Definition: umlappprivate.cpp:17
UMLAppPrivate::viewObjectsWindow
KToggleAction * viewObjectsWindow
Definition: umlappprivate.h:60
UMLAppPrivate::~UMLAppPrivate
~UMLAppPrivate()
Definition: umlappprivate.h:97
UMLAppPrivate::parent
UMLApp * parent
Definition: umlappprivate.h:55
UMLAppPrivate::findDialog
FindDialog findDialog
Definition: umlappprivate.h:56
UMLAppPrivate::document
KTextEditor::Document * document
Definition: umlappprivate.h:71
UMLAppPrivate::readWelcomeFile
QString readWelcomeFile(const QString &file)
Definition: umlappprivate.cpp:76
UMLAppPrivate::viewStereotypesWindow
KToggleAction * viewStereotypesWindow
Definition: umlappprivate.h:61
UMLAppPrivate::viewDiagramsWindow
KToggleAction * viewDiagramsWindow
Definition: umlappprivate.h:59
UMLAppPrivate::findResults
FindResults findResults
Definition: umlappprivate.h:57
UMLAppPrivate::stereotypesWindow
StereotypesWindow * stereotypesWindow
Definition: umlappprivate.h:65
UMLAppPrivate::welcomeWindow
QDockWidget * welcomeWindow
Definition: umlappprivate.h:66
UMLAppPrivate::createObjectsWindow
void createObjectsWindow()
Definition: umlappprivate.h:127
UMLAppPrivate::slotWelcomeWindowLinkClicked
void slotWelcomeWindowLinkClicked(const QUrl &url)
Definition: umlappprivate.h:171
UMLAppPrivate::slotLogWindowItemDoubleClicked
void slotLogWindowItemDoubleClicked(QListWidgetItem *item)
Definition: umlappprivate.h:110
UMLAppPrivate::UMLAppPrivate
UMLAppPrivate(UMLApp *_parent)
Definition: umlappprivate.h:73
UMLAppPrivate::logWindow
QListWidget * logWindow
Logging window.
Definition: umlappprivate.h:58
UMLAppPrivate::editorWindow
QDockWidget * editorWindow
Definition: umlappprivate.h:67
UMLAppPrivate::createDiagramsWindow
void createDiagramsWindow()
Definition: umlappprivate.h:117
UMLAppPrivate::objectsWindow
ObjectsWindow * objectsWindow
Definition: umlappprivate.h:64
UMLAppPrivate::viewWelcomeWindow
KToggleAction * viewWelcomeWindow
Definition: umlappprivate.h:62
UMLApp
Definition: uml.h:95
UMLApp::document
UMLDoc * document() const
Definition: uml.cpp:1063
UMLApp::executeCommand
void executeCommand(QUndoCommand *cmd)
Definition: uml.cpp:3447
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:275
UMLDoc::createDiagramName
QString createDiagramName(Uml::DiagramType::Enum type, bool askForName=true)
Definition: umldoc.cpp:1615
Uml::CmdCreateDiagram
Definition: cmdcreatediagram.h:20
cmds.h
debug_utils.h
diagramswindow.h
finddialog.h
findresults.h
i18n
#define i18n
Definition: main.cpp:34
MyProject\connect
connect()
Definition: namespaces-multiple.php:5
Uml::DiagramType::fromString
Enum fromString(const QString &item)
Definition: basictypes.cpp:222
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