umbrello: umbrello/umlappprivate.h Source File

umbrello 2.31.1 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 * This program is free software; you can redistribute it and/or modify *
3 * it under the terms of the GNU General Public License as published by *
4 * the Free Software Foundation; either version 2 of the License, or *
5 * (at your option) any later version. *
6 * *
7 * copyright (C) 2002-2020 *
8 * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9 ***************************************************************************/
10
11 #ifndef UMLAPPPRIVATE_H
12 #define UMLAPPPRIVATE_H
13
14 // app includes
15 #include "cmds.h"
16 #include "debug_utils.h"
17 #include "finddialog.h"
18 #include "findresults.h"
19 #include "uml.h"
20 #include "umldoc.h"
21 #include "diagramswindow.h"
22 #include "objectswindow.h"
23 #include "stereotypeswindow.h"
24
25 // kde includes
26 #include <KActionCollection>
27 #if QT_VERSION < 0x050000
28 #include <KStandardDirs>
29 #endif
30 #include <KToggleAction>
31 #include <ktexteditor/configinterface.h>
32 #include <ktexteditor/document.h>
33 #include <ktexteditor/editor.h>
34 #if QT_VERSION < 0x050000
35 #include <ktexteditor/editorchooser.h>
36 #endif
37 #include <ktexteditor/view.h>
38
39 // qt includes
40 #include <QDesktopServices>
41 #include <QFile>
42 #include <QFileInfo>
43 #include <QListWidget>
44 #include <QObject>
45 #include <QWebView>
46
47 class QWidget;
48
49
56 class UMLAppPrivate : public QObject
57 {
58 Q_OBJECT
59 public:
60 UMLApp *parent;
61 FindDialog findDialog;
62 FindResults findResults;
63 QListWidget *logWindow;
64 KToggleAction *viewDiagramsWindow;
65 KToggleAction *viewObjectsWindow;
66 KToggleAction *viewStereotypesWindow;
67 KToggleAction *viewWelcomeWindow;
68 DiagramsWindow *diagramsWindow;
69 ObjectsWindow *objectsWindow;
70 StereotypesWindow *stereotypesWindow;
71 QDockWidget *welcomeWindow;
72 QDockWidget *editorWindow;
73
74 KTextEditor::Editor *editor;
75 KTextEditor::View *view;
76 KTextEditor::Document *document;
77
78 explicit UMLAppPrivate(UMLApp *_parent)
79 : parent(_parent),
80 findDialog(_parent),
81 viewDiagramsWindow(0),
82 viewObjectsWindow(0),
83 viewStereotypesWindow(0),
84 viewWelcomeWindow(0),
85 diagramsWindow(0),
86 objectsWindow(0),
87 stereotypesWindow(0),
88 welcomeWindow(0),
89 editorWindow(0),
90 view(0),
91 document(0)
92 {
93 #if QT_VERSION >= 0x050000
94 editor = KTextEditor::Editor::instance();
95 #else
96 editor = KTextEditor::EditorChooser::editor();
97 #endif
98 logWindow = new QListWidget;
99 connect(logWindow, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotLogWindowItemDoubleClicked(QListWidgetItem *)));
100 }
101
102 ~UMLAppPrivate()
103 {
104 delete diagramsWindow;
105 delete editorWindow;
106 delete logWindow;
107 delete objectsWindow;
108 delete stereotypesWindow;
109 delete welcomeWindow;
110 }
111
112 bool openFileInEditor(const QUrl &file, int startCursor=0, int endCursor=0);
113
114 public slots:
115 void slotLogWindowItemDoubleClicked(QListWidgetItem *item)
116 {
117 QStringList columns = item->text().split(QChar::fromLatin1(':'));
118
119 openFileInEditor(QUrl::fromLocalFile(columns[0]), columns[1].toInt()-1, columns[2].toInt());
120 }
121
122 void createDiagramsWindow()
123 {
124 // create the tree viewer
125 diagramsWindow = new DiagramsWindow(i18n("&Diagrams"), parent);
126 parent->addDockWidget(Qt::LeftDockWidgetArea, diagramsWindow);
127
128 viewDiagramsWindow = parent->actionCollection()->add<KToggleAction>(QLatin1String("view_show_diagrams"));
129 connect(viewDiagramsWindow, SIGNAL(triggered(bool)), diagramsWindow, SLOT(setVisible(bool)));
130 }
131
132 void createObjectsWindow()
133 {
134 // create the object window
135 objectsWindow = new ObjectsWindow(i18n("&UML Objects"), parent);
136 parent->addDockWidget(Qt::LeftDockWidgetArea, objectsWindow);
137
138 viewObjectsWindow = parent->actionCollection()->add<KToggleAction>(QLatin1String("view_show_objects"));
139 connect(viewObjectsWindow, SIGNAL(triggered(bool)), objectsWindow, SLOT(setVisible(bool)));
140 }
141
142 void createStereotypesWindow()
143 {
144 // create the tree viewer
145 stereotypesWindow = new StereotypesWindow(i18n("&Stereotypes"), parent);
146 parent->addDockWidget(Qt::LeftDockWidgetArea, stereotypesWindow);
147
148 viewStereotypesWindow = parent->actionCollection()->add<KToggleAction>(QLatin1String("view_show_stereotypes"));
149 connect(viewStereotypesWindow, SIGNAL(triggered(bool)), stereotypesWindow, SLOT(setVisible(bool)));
150 }
151
152 void createWelcomeWindow()
153 {
154 QString file = findWelcomeFile();
155 if (file.isEmpty())
156 return;
157 QString html = readWelcomeFile(file);
158 if (html.isEmpty())
159 return;
160 // qDebug() << html;
161 welcomeWindow = new QDockWidget(i18n("Welcome"), parent);
162 welcomeWindow->setObjectName(QLatin1String("WelcomeDock"));
163 QWebView *view = new QWebView;
164 view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
165 view->setContextMenuPolicy(Qt::NoContextMenu);
166 connect(view, SIGNAL(linkClicked(const QUrl)), this, SLOT(slotWelcomeWindowLinkClicked(const QUrl)));
167 view->setHtml(html);
168 view->show();
169 welcomeWindow->setWidget(view);
170 parent->addDockWidget(Qt::RightDockWidgetArea, welcomeWindow);
171
172 viewWelcomeWindow = parent->actionCollection()->add<KToggleAction>(QLatin1String("view_show_welcome"));
173 connect(viewWelcomeWindow, SIGNAL(triggered(bool)), welcomeWindow, SLOT(setVisible(bool)));
174 }
175
176 void slotWelcomeWindowLinkClicked(const QUrl &url)
177 {
178 //qDebug() << url;
179 if (url.scheme() == QLatin1String("mailto") || url.scheme().startsWith(QLatin1String("http"))) {
180 QDesktopServices::openUrl(url);
181 return;
182 }
183 QStringList list = url.toString().split(QLatin1Char('-'));
184 list.removeLast();
185 QString key;
186 foreach(const QString s, list) {
187 QString a = s;
188 a[0] = a[0].toUpper();
189 key.append(a);
190 }
191 Uml::DiagramType::Enum type = Uml::DiagramType::fromString(key);
192 if (type == Uml::DiagramType::Undefined)
193 return;
194 QString diagramName = UMLApp::app()->document()->createDiagramName(type);
195 if (!diagramName.isEmpty())
196 UMLApp::app()->executeCommand(new Uml::CmdCreateDiagram(UMLApp::app()->document(), type, diagramName));
197 }
198
199 private:
200 QString findWelcomeFile();
201 QString readWelcomeFile(const QString &file);
202 };
203
204 #endif
UMLAppPrivate::slotLogWindowItemDoubleClicked
void slotLogWindowItemDoubleClicked(QListWidgetItem *item)
Definition: umlappprivate.h:115
UMLAppPrivate::view
KTextEditor::View * view
Definition: umlappprivate.h:75
UMLAppPrivate::findResults
FindResults findResults
Definition: umlappprivate.h:62
Uml::CmdCreateDiagram
Definition: cmdcreatediagram.h:25
UMLAppPrivate::editor
KTextEditor::Editor * editor
Definition: umlappprivate.h:74
findresults.h
UMLAppPrivate::viewObjectsWindow
KToggleAction * viewObjectsWindow
Definition: umlappprivate.h:65
UMLAppPrivate::viewWelcomeWindow
KToggleAction * viewWelcomeWindow
Definition: umlappprivate.h:67
finddialog.h
UMLAppPrivate::objectsWindow
ObjectsWindow * objectsWindow
Definition: umlappprivate.h:69
UMLAppPrivate::slotWelcomeWindowLinkClicked
void slotWelcomeWindowLinkClicked(const QUrl &url)
Definition: umlappprivate.h:176
FindDialog
Definition: finddialog.h:25
Uml::DiagramType::Enum
Enum
Definition: basictypes.h:94
cmds.h
Icon_Utils::Cursor
QCursor Cursor(IconType type)
Definition: icon_utils.cpp:112
DiagramsWindow
Definition: diagramswindow.h:20
UMLAppPrivate::createStereotypesWindow
void createStereotypesWindow()
Definition: umlappprivate.h:142
UMLAppPrivate::createObjectsWindow
void createObjectsWindow()
Definition: umlappprivate.h:132
umlappprivate.h
FindResults
Definition: findresults.h:30
UMLDoc::createDiagramName
QString createDiagramName(Uml::DiagramType::Enum type, bool askForName=true)
Definition: umldoc.cpp:1617
UMLAppPrivate
Definition: umlappprivate.h:57
UMLAppPrivate::parent
UMLApp * parent
Definition: umlappprivate.h:60
UMLAppPrivate::findDialog
FindDialog findDialog
Definition: umlappprivate.h:61
UMLAppPrivate::logWindow
QListWidget * logWindow
Logging window.
Definition: umlappprivate.h:63
UMLAppPrivate::createDiagramsWindow
void createDiagramsWindow()
Definition: umlappprivate.h:122
UMLApp
Definition: uml.h:100
a
QString a
Definition: petalnode.cpp:18
ObjectsWindow
Definition: objectswindow.h:21
i18n
#define i18n
Definition: main.cpp:39
UMLAppPrivate::viewStereotypesWindow
KToggleAction * viewStereotypesWindow
Definition: umlappprivate.h:66
uDebug
#define uDebug()
Definition: debug_utils.h:122
objectswindow.h
MyProject\connect
connect()
Definition: namespaces-multiple.php:5
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:269
Uml::DiagramType::fromString
Enum fromString(const QString &item)
Definition: basictypes.cpp:253
UMLAppPrivate::UMLAppPrivate
UMLAppPrivate(UMLApp *_parent)
Definition: umlappprivate.h:78
UMLAppPrivate::openFileInEditor
bool openFileInEditor(const QUrl &file, int startCursor=0, int endCursor=0)
Definition: umlappprivate.cpp:136
UMLAppPrivate::findWelcomeFile
QString findWelcomeFile()
Definition: umlappprivate.cpp:22
diagramswindow.h
UMLAppPrivate::stereotypesWindow
StereotypesWindow * stereotypesWindow
Definition: umlappprivate.h:70
uError
#define uError()
Definition: debug_utils.h:123
stereotypeswindow.h
uml.h
UMLAppPrivate::editorWindow
QDockWidget * editorWindow
Definition: umlappprivate.h:72
debug_utils.h
StereotypesWindow
Definition: stereotypeswindow.h:20
Uml::DiagramType::Undefined
@ Undefined
Definition: basictypes.h:97
UMLAppPrivate::welcomeWindow
QDockWidget * welcomeWindow
Definition: umlappprivate.h:71
UMLAppPrivate::viewDiagramsWindow
KToggleAction * viewDiagramsWindow
Definition: umlappprivate.h:64
UMLAppPrivate::~UMLAppPrivate
~UMLAppPrivate()
Definition: umlappprivate.h:102
UMLApp::executeCommand
void executeCommand(QUndoCommand *cmd)
Definition: uml.cpp:3416
UMLAppPrivate::diagramsWindow
DiagramsWindow * diagramsWindow
Definition: umlappprivate.h:68
UMLAppPrivate::readWelcomeFile
QString readWelcomeFile(const QString &file)
Definition: umlappprivate.cpp:81
UMLApp::document
UMLDoc * document() const
Definition: uml.cpp:1055
UMLAppPrivate::createWelcomeWindow
void createWelcomeWindow()
Definition: umlappprivate.h:152
umldoc.h
UMLAppPrivate::document
KTextEditor::Document * document
Definition: umlappprivate.h:76