Changeset View
Changeset View
Standalone View
Standalone View
src/part/kgraphviewer_part.cpp
Show All 10 Lines | 1 | /* This file is part of KGraphViewer. | |||
---|---|---|---|---|---|
11 | General Public License for more details. | 11 | General Public License for more details. | ||
12 | 12 | | |||
13 | You should have received a copy of the GNU General Public License | 13 | You should have received a copy of the GNU General Public License | ||
14 | along with this program; if not, write to the Free Software | 14 | along with this program; if not, write to the Free Software | ||
15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
16 | 02110-1301, USA | 16 | 02110-1301, USA | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | | ||||
20 | #include "kgraphviewer_part.h" | 19 | #include "kgraphviewer_part.h" | ||
21 | #include "kgraphviewerlib_debug.h" | | |||
22 | #include "dotgraphview.h" | | |||
23 | #include "dotgraph.h" | | |||
24 | #include "config-kgraphviewer.h" | 20 | #include "config-kgraphviewer.h" | ||
21 | #include "dotgraph.h" | ||||
22 | #include "dotgraphview.h" | ||||
23 | #include "kgraphviewerlib_debug.h" | ||||
25 | 24 | | |||
25 | #include <KAboutData> | ||||
26 | #include <KDirWatch> | 26 | #include <KDirWatch> | ||
27 | #include <QAction> | 27 | #include <KPluginFactory> | ||
28 | #include <ktoggleaction.h> | | |||
29 | #include <kselectaction.h> | | |||
30 | #include <kactioncollection.h> | | |||
31 | #include <kstandardaction.h> | | |||
32 | #include <KSharedConfig> | 28 | #include <KSharedConfig> | ||
29 | #include <QAction> | ||||
33 | #include <QDebug> | 30 | #include <QDebug> | ||
34 | #include <KPluginFactory> | | |||
35 | #include <QIcon> | 31 | #include <QIcon> | ||
36 | #include <QStandardPaths> | 32 | #include <QStandardPaths> | ||
37 | #include <KAboutData> | | |||
38 | #include <klocalizedstring.h> | | |||
39 | #include <iostream> | 33 | #include <iostream> | ||
34 | #include <kactioncollection.h> | ||||
35 | #include <klocalizedstring.h> | ||||
36 | #include <kselectaction.h> | ||||
37 | #include <kstandardaction.h> | ||||
38 | #include <ktoggleaction.h> | ||||
40 | 39 | | |||
41 | #include <graphviz/gvc.h> | 40 | #include <graphviz/gvc.h> | ||
42 | 41 | | |||
43 | | ||||
44 | // #include "kgraphviewersettings.h" | 42 | // #include "kgraphviewersettings.h" | ||
45 | #include "kgraphviewer_partsettings.h" | 43 | #include "kgraphviewer_partsettings.h" | ||
46 | 44 | | |||
47 | namespace KGraphViewer | 45 | namespace KGraphViewer | ||
48 | { | 46 | { | ||
49 | | ||||
50 | K_PLUGIN_FACTORY(KGraphViewerPartFactory, registerPlugin<KGraphViewerPart>();) | 47 | K_PLUGIN_FACTORY(KGraphViewerPartFactory, registerPlugin<KGraphViewerPart>();) | ||
51 | 48 | | |||
52 | class KGraphViewerPartPrivate | 49 | class KGraphViewerPartPrivate | ||
53 | { | 50 | { | ||
54 | public: | 51 | public: | ||
55 | KGraphViewerPartPrivate() : m_watch(new KDirWatch()), m_layoutMethod(KGraphViewerInterface::InternalLibrary) | 52 | KGraphViewerPartPrivate() | ||
53 | : m_watch(new KDirWatch()) | ||||
54 | , m_layoutMethod(KGraphViewerInterface::InternalLibrary) | ||||
56 | { | 55 | { | ||
57 | | ||||
58 | } | 56 | } | ||
59 | 57 | | |||
60 | ~KGraphViewerPartPrivate() | 58 | ~KGraphViewerPartPrivate() | ||
61 | { | 59 | { | ||
62 | delete m_watch; | 60 | delete m_watch; | ||
63 | } | 61 | } | ||
64 | 62 | | |||
65 | DotGraphView *m_widget; | 63 | DotGraphView *m_widget; | ||
66 | KDirWatch* m_watch; | 64 | KDirWatch *m_watch; | ||
67 | KGraphViewerPart::LayoutMethod m_layoutMethod; | 65 | KGraphViewerPart::LayoutMethod m_layoutMethod; | ||
68 | | ||||
69 | }; | 66 | }; | ||
70 | 67 | | |||
71 | KGraphViewerPart::KGraphViewerPart( QWidget *parentWidget, QObject *parent, const QVariantList & ) | 68 | KGraphViewerPart::KGraphViewerPart(QWidget *parentWidget, QObject *parent, const QVariantList &) | ||
72 | : KParts::ReadOnlyPart(parent), d(new KGraphViewerPartPrivate()) | 69 | : KParts::ReadOnlyPart(parent) | ||
70 | , d(new KGraphViewerPartPrivate()) | ||||
73 | { | 71 | { | ||
74 | /* set the component name (1st argument) so that the XMLGUI .rc | 72 | /* set the component name (1st argument) so that the XMLGUI .rc | ||
75 | file is found also when this part is called from applications | 73 | file is found also when this part is called from applications | ||
76 | different then kgraphviewer (like kgrapheditor and konqueror). | 74 | different then kgraphviewer (like kgrapheditor and konqueror). | ||
77 | */ | 75 | */ | ||
78 | KAboutData aboutData( | 76 | KAboutData aboutData(QStringLiteral("kgraphviewer"), i18n("KGraphViewerPart"), KGRAPHVIEWER_VERSION_STRING, i18n("Graphviz DOT files viewer"), KAboutLicense::GPL, i18n("(c) 2005-2006, Gaël de Chalendar <kleag@free.fr>")); | ||
79 | QStringLiteral("kgraphviewer"), | | |||
80 | i18n("KGraphViewerPart"), | | |||
81 | KGRAPHVIEWER_VERSION_STRING, | | |||
82 | i18n("Graphviz DOT files viewer"), | | |||
83 | KAboutLicense::GPL, | | |||
84 | i18n("(c) 2005-2006, Gaël de Chalendar <kleag@free.fr>") | | |||
85 | ); | | |||
86 | setComponentData(aboutData, false); | 77 | setComponentData(aboutData, false); | ||
87 | 78 | | |||
88 | // set our XML-UI resource file | 79 | // set our XML-UI resource file | ||
89 | setXMLFile(QStringLiteral("kgraphviewer_part.rc"), true); | 80 | setXMLFile(QStringLiteral("kgraphviewer_part.rc"), true); | ||
90 | 81 | | |||
91 | // this should be your custom internal widget | 82 | // this should be your custom internal widget | ||
92 | d->m_widget = new DotGraphView( actionCollection(), parentWidget); | 83 | d->m_widget = new DotGraphView(actionCollection(), parentWidget); | ||
93 | d->m_widget->initEmpty(); | 84 | d->m_widget->initEmpty(); | ||
94 | d->m_widget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 85 | d->m_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | ||
95 | connect(d->m_widget, &DotGraphView::graphLoaded, | 86 | connect(d->m_widget, &DotGraphView::graphLoaded, this, &KGraphViewerPart::graphLoaded); | ||
96 | this, &KGraphViewerPart::graphLoaded); | 87 | connect(d->m_widget, &DotGraphView::newEdgeAdded, this, &KGraphViewerPart::newEdgeAdded); | ||
97 | connect(d->m_widget, &DotGraphView::newEdgeAdded, | 88 | connect(d->m_widget, &DotGraphView::newNodeAdded, this, &KGraphViewerPart::newNodeAdded); | ||
98 | this, &KGraphViewerPart::newEdgeAdded); | 89 | connect(d->m_widget, &DotGraphView::removeEdge, this, &KGraphViewerPart::removeEdge); | ||
99 | connect(d->m_widget, &DotGraphView::newNodeAdded, | 90 | connect(d->m_widget, &DotGraphView::removeElement, this, &KGraphViewerPart::removeElement); | ||
100 | this, &KGraphViewerPart::newNodeAdded); | 91 | connect(d->m_widget, &DotGraphView::selectionIs, this, &KGraphViewerPart::selectionIs); | ||
101 | connect(d->m_widget, &DotGraphView::removeEdge, | 92 | connect(d->m_widget, static_cast<void (DotGraphView::*)(const QString &, const QPoint &)>(&DotGraphView::contextMenuEvent), this, &KGraphViewerPart::contextMenuEvent); | ||
102 | this, &KGraphViewerPart::removeEdge); | 93 | connect(d->m_widget, &DotGraphView::newEdgeFinished, this, &KGraphViewerPart::newEdgeFinished); | ||
103 | connect(d->m_widget, &DotGraphView::removeElement, | 94 | connect(d->m_widget, &DotGraphView::hoverEnter, this, &KGraphViewerPart::hoverEnter); | ||
104 | this, &KGraphViewerPart::removeElement); | 95 | connect(d->m_widget, &DotGraphView::hoverLeave, this, &KGraphViewerPart::hoverLeave); | ||
105 | connect(d->m_widget, &DotGraphView::selectionIs, | | |||
106 | this, &KGraphViewerPart::selectionIs); | | |||
107 | connect(d->m_widget, static_cast<void(DotGraphView::*)(const QString&, const QPoint&)>(&DotGraphView::contextMenuEvent), | | |||
108 | this, &KGraphViewerPart::contextMenuEvent); | | |||
109 | connect(d->m_widget, &DotGraphView::newEdgeFinished, | | |||
110 | this, &KGraphViewerPart::newEdgeFinished); | | |||
111 | connect(d->m_widget, &DotGraphView::hoverEnter, | | |||
112 | this, &KGraphViewerPart::hoverEnter); | | |||
113 | connect(d->m_widget, &DotGraphView::hoverLeave, | | |||
114 | this, &KGraphViewerPart::hoverLeave); | | |||
115 | | ||||
116 | | ||||
117 | | ||||
118 | 96 | | |||
119 | // notify the part that this is our internal widget | 97 | // notify the part that this is our internal widget | ||
120 | setWidget(d->m_widget); | 98 | setWidget(d->m_widget); | ||
121 | 99 | | |||
122 | QAction* printAct = actionCollection()->addAction(KStandardAction::Print, "file_print", d->m_widget, SLOT(print())); | 100 | QAction *printAct = actionCollection()->addAction(KStandardAction::Print, "file_print", d->m_widget, SLOT(print())); | ||
123 | actionCollection()->setDefaultShortcut(printAct, Qt::ControlModifier + Qt::Key_P); | 101 | actionCollection()->setDefaultShortcut(printAct, Qt::ControlModifier + Qt::Key_P); | ||
124 | printAct->setWhatsThis(i18n("Print the graph using current page setup settings")); | 102 | printAct->setWhatsThis(i18n("Print the graph using current page setup settings")); | ||
125 | 103 | | |||
126 | QAction* printPreviewAct = actionCollection()->addAction(KStandardAction::PrintPreview, "file_print_preview", d->m_widget, SLOT(printPreview())); | 104 | QAction *printPreviewAct = actionCollection()->addAction(KStandardAction::PrintPreview, "file_print_preview", d->m_widget, SLOT(printPreview())); | ||
127 | actionCollection()->setDefaultShortcut(printPreviewAct, Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_P); | 105 | actionCollection()->setDefaultShortcut(printPreviewAct, Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_P); | ||
128 | printPreviewAct->setWhatsThis(i18n("Open the print preview window")); | 106 | printPreviewAct->setWhatsThis(i18n("Open the print preview window")); | ||
129 | 107 | | |||
130 | // KAction* pagesetupAct = new KAction(i18n("&Page setup"), this); //actionCollection(), "file_page_setup"); | 108 | // KAction* pagesetupAct = new KAction(i18n("&Page setup"), this); //actionCollection(), "file_page_setup"); | ||
131 | QAction* pagesetupAct = actionCollection()->addAction("file_page_setup", d->m_widget, SLOT(pageSetup())); | 109 | QAction *pagesetupAct = actionCollection()->addAction("file_page_setup", d->m_widget, SLOT(pageSetup())); | ||
132 | pagesetupAct->setText(i18n("Page setup")); | 110 | pagesetupAct->setText(i18n("Page setup")); | ||
133 | pagesetupAct->setWhatsThis(i18n("Opens the Page Setup dialog to allow graph printing to be setup")); | 111 | pagesetupAct->setWhatsThis(i18n("Opens the Page Setup dialog to allow graph printing to be setup")); | ||
134 | 112 | | |||
135 | QAction* redisplayAct = actionCollection()->addAction(KStandardAction::Redisplay, "view_redisplay", d->m_widget, SLOT(reload())); | 113 | QAction *redisplayAct = actionCollection()->addAction(KStandardAction::Redisplay, "view_redisplay", d->m_widget, SLOT(reload())); | ||
136 | redisplayAct->setWhatsThis(i18n("Reload the current graph from file")); | 114 | redisplayAct->setWhatsThis(i18n("Reload the current graph from file")); | ||
137 | redisplayAct->setShortcut(Qt::Key_F5); | 115 | redisplayAct->setShortcut(Qt::Key_F5); | ||
138 | 116 | | |||
139 | QAction* zoomInAct = actionCollection()->addAction(KStandardAction::ZoomIn, "view_zoom_in", d->m_widget, SLOT(zoomIn())); | 117 | QAction *zoomInAct = actionCollection()->addAction(KStandardAction::ZoomIn, "view_zoom_in", d->m_widget, SLOT(zoomIn())); | ||
140 | // xgettext: no-c-format | 118 | // xgettext: no-c-format | ||
141 | zoomInAct->setWhatsThis(i18n("Zoom in by 10% on the currently viewed graph")); | 119 | zoomInAct->setWhatsThis(i18n("Zoom in by 10% on the currently viewed graph")); | ||
142 | zoomInAct->setShortcut(Qt::Key_F7); | 120 | zoomInAct->setShortcut(Qt::Key_F7); | ||
143 | 121 | | |||
144 | QAction* zoomOutAct = actionCollection()->addAction(KStandardAction::ZoomOut, "view_zoom_out", d->m_widget, SLOT(zoomOut())); | 122 | QAction *zoomOutAct = actionCollection()->addAction(KStandardAction::ZoomOut, "view_zoom_out", d->m_widget, SLOT(zoomOut())); | ||
145 | // xgettext: no-c-format | 123 | // xgettext: no-c-format | ||
146 | zoomOutAct->setWhatsThis(i18n("Zoom out by 10% from the currently viewed graph")); | 124 | zoomOutAct->setWhatsThis(i18n("Zoom out by 10% from the currently viewed graph")); | ||
147 | zoomOutAct->setShortcut(Qt::Key_F8); | 125 | zoomOutAct->setShortcut(Qt::Key_F8); | ||
148 | } | 126 | } | ||
149 | 127 | | |||
150 | /*DotGraph* KGraphViewerPart::graph() | 128 | /*DotGraph* KGraphViewerPart::graph() | ||
151 | { | 129 | { | ||
152 | return d->m_widget->graph(); | 130 | return d->m_widget->graph(); | ||
153 | } | 131 | } | ||
154 | 132 | | |||
155 | const DotGraph* KGraphViewerPart::graph() const | 133 | const DotGraph* KGraphViewerPart::graph() const | ||
156 | { | 134 | { | ||
157 | return d->m_widget->graph(); | 135 | return d->m_widget->graph(); | ||
158 | } | 136 | } | ||
159 | */ | 137 | */ | ||
160 | 138 | | |||
161 | void KGraphViewerPart::setBackgroundColor(const QColor& color) | 139 | void KGraphViewerPart::setBackgroundColor(const QColor &color) | ||
162 | { | 140 | { | ||
163 | d->m_widget->setBackgroundColor(color); | 141 | d->m_widget->setBackgroundColor(color); | ||
164 | } | 142 | } | ||
165 | 143 | | |||
166 | bool KGraphViewerPart::closeUrl() | 144 | bool KGraphViewerPart::closeUrl() | ||
167 | { | 145 | { | ||
168 | return d->m_widget->initEmpty(); | 146 | return d->m_widget->initEmpty(); | ||
169 | } | 147 | } | ||
170 | 148 | | |||
171 | bool KGraphViewerPart::slotLoadLibrary(graph_t* graph) | 149 | bool KGraphViewerPart::slotLoadLibrary(graph_t *graph) | ||
172 | { | 150 | { | ||
173 | bool res = d->m_widget->slotLoadLibrary(graph); | 151 | bool res = d->m_widget->slotLoadLibrary(graph); | ||
174 | if (res) | 152 | if (res) | ||
175 | d->m_widget->show(); | 153 | d->m_widget->show(); | ||
176 | return res; | 154 | return res; | ||
177 | } | 155 | } | ||
178 | 156 | | |||
179 | KGraphViewerPart::~KGraphViewerPart() | 157 | KGraphViewerPart::~KGraphViewerPart() | ||
180 | { | 158 | { | ||
181 | delete d; | 159 | delete d; | ||
182 | } | 160 | } | ||
183 | 161 | | |||
184 | bool KGraphViewerPart::openFile() | 162 | bool KGraphViewerPart::openFile() | ||
185 | { | 163 | { | ||
186 | qCDebug(KGRAPHVIEWERLIB_LOG) << " " << localFilePath(); | 164 | qCDebug(KGRAPHVIEWERLIB_LOG) << " " << localFilePath(); | ||
187 | // d->m_widget->loadedDot( localFilePath() ); | 165 | // d->m_widget->loadedDot( localFilePath() ); | ||
188 | switch (d->m_layoutMethod) | 166 | switch (d->m_layoutMethod) { | ||
189 | { | | |||
190 | case ExternalProgram: | 167 | case ExternalProgram: | ||
191 | if (!d->m_widget->loadDot(localFilePath())) | 168 | if (!d->m_widget->loadDot(localFilePath())) | ||
192 | return false; | 169 | return false; | ||
193 | break; | 170 | break; | ||
194 | case InternalLibrary: | 171 | case InternalLibrary: | ||
195 | // kpart expects loading to be done sync in this method | 172 | // kpart expects loading to be done sync in this method | ||
196 | if (!d->m_widget->loadLibrarySync(localFilePath())) | 173 | if (!d->m_widget->loadLibrarySync(localFilePath())) | ||
197 | return false; | 174 | return false; | ||
198 | break; | 175 | break; | ||
199 | default: | 176 | default: | ||
200 | qCWarning(KGRAPHVIEWERLIB_LOG) << "Unsupported layout method " << d->m_layoutMethod; | 177 | qCWarning(KGRAPHVIEWERLIB_LOG) << "Unsupported layout method " << d->m_layoutMethod; | ||
201 | } | 178 | } | ||
202 | 179 | | |||
203 | // deletes the existing file watcher because we have no way know here the name of the | 180 | // deletes the existing file watcher because we have no way know here the name of the | ||
204 | // previously watched file and thus we cannot use removeFile... :-( | 181 | // previously watched file and thus we cannot use removeFile... :-( | ||
205 | delete d->m_watch; | 182 | delete d->m_watch; | ||
206 | d->m_watch = new KDirWatch(); | 183 | d->m_watch = new KDirWatch(); | ||
207 | 184 | | |||
208 | // qCDebug(KGRAPHVIEWERLIB_LOG) << "Watching file " << localFilePath(); | 185 | // qCDebug(KGRAPHVIEWERLIB_LOG) << "Watching file " << localFilePath(); | ||
209 | d->m_watch->addFile(localFilePath()); | 186 | d->m_watch->addFile(localFilePath()); | ||
210 | connect(d->m_watch, &KDirWatch::dirty, d->m_widget, &DotGraphView::dirty); | 187 | connect(d->m_watch, &KDirWatch::dirty, d->m_widget, &DotGraphView::dirty); | ||
211 | QString label = localFilePath().section('/',-1,-1); | 188 | QString label = localFilePath().section('/', -1, -1); | ||
212 | 189 | | |||
213 | d->m_widget->show(); | 190 | d->m_widget->show(); | ||
214 | return true; | 191 | return true; | ||
215 | } | 192 | } | ||
216 | 193 | | |||
217 | void KGraphViewerPart::slotHide(KParts::Part* part) | 194 | void KGraphViewerPart::slotHide(KParts::Part *part) | ||
218 | { | 195 | { | ||
219 | if (part == this) | 196 | if (part == this) { | ||
220 | { | | |||
221 | d->m_widget->hideToolsWindows(); | 197 | d->m_widget->hideToolsWindows(); | ||
222 | } | 198 | } | ||
223 | } | 199 | } | ||
224 | 200 | | |||
225 | void KGraphViewerPart::slotUpdate() | 201 | void KGraphViewerPart::slotUpdate() | ||
226 | { | 202 | { | ||
227 | d->m_widget->slotUpdate(); | 203 | d->m_widget->slotUpdate(); | ||
228 | } | 204 | } | ||
229 | 205 | | |||
230 | void KGraphViewerPart::prepareAddNewElement(const QMap<QString,QString>& attribs) | 206 | void KGraphViewerPart::prepareAddNewElement(const QMap<QString, QString> &attribs) | ||
231 | { | 207 | { | ||
232 | d->m_widget->prepareAddNewElement(attribs); | 208 | d->m_widget->prepareAddNewElement(attribs); | ||
233 | } | 209 | } | ||
234 | 210 | | |||
235 | void KGraphViewerPart::slotSetGraphAttributes(const QMap<QString,QString>& attribs) | 211 | void KGraphViewerPart::slotSetGraphAttributes(const QMap<QString, QString> &attribs) | ||
236 | { | 212 | { | ||
237 | d->m_widget->graph()->setGraphAttributes(attribs); | 213 | d->m_widget->graph()->setGraphAttributes(attribs); | ||
238 | } | 214 | } | ||
239 | 215 | | |||
240 | void KGraphViewerPart::slotAddNewNode(const QMap<QString,QString>& attribs) | 216 | void KGraphViewerPart::slotAddNewNode(const QMap<QString, QString> &attribs) | ||
241 | { | 217 | { | ||
242 | d->m_widget->graph()->addNewNode(attribs); | 218 | d->m_widget->graph()->addNewNode(attribs); | ||
243 | } | 219 | } | ||
244 | 220 | | |||
245 | void KGraphViewerPart::slotAddNewSubgraph(const QMap<QString,QString>& attribs) | 221 | void KGraphViewerPart::slotAddNewSubgraph(const QMap<QString, QString> &attribs) | ||
246 | { | 222 | { | ||
247 | d->m_widget->graph()->addNewSubgraph(attribs); | 223 | d->m_widget->graph()->addNewSubgraph(attribs); | ||
248 | } | 224 | } | ||
249 | 225 | | |||
250 | void KGraphViewerPart::slotAddNewNodeToSubgraph(const QMap<QString,QString>& attribs, | 226 | void KGraphViewerPart::slotAddNewNodeToSubgraph(const QMap<QString, QString> &attribs, const QString &subgraph) | ||
251 | const QString& subgraph) | | |||
252 | { | 227 | { | ||
253 | d->m_widget->graph()->addNewNodeToSubgraph(attribs, subgraph); | 228 | d->m_widget->graph()->addNewNodeToSubgraph(attribs, subgraph); | ||
254 | } | 229 | } | ||
255 | 230 | | |||
256 | void KGraphViewerPart::slotAddExistingNodeToSubgraph(const QMap<QString,QString>& attribs,const QString& subgraph) | 231 | void KGraphViewerPart::slotAddExistingNodeToSubgraph(const QMap<QString, QString> &attribs, const QString &subgraph) | ||
257 | { | 232 | { | ||
258 | d->m_widget->graph()->addExistingNodeToSubgraph(attribs, subgraph); | 233 | d->m_widget->graph()->addExistingNodeToSubgraph(attribs, subgraph); | ||
259 | } | 234 | } | ||
260 | 235 | | |||
261 | void KGraphViewerPart::slotMoveExistingNodeToMainGraph(const QMap<QString,QString>& attribs) | 236 | void KGraphViewerPart::slotMoveExistingNodeToMainGraph(const QMap<QString, QString> &attribs) | ||
262 | { | 237 | { | ||
263 | d->m_widget->graph()->moveExistingNodeToMainGraph(attribs); | 238 | d->m_widget->graph()->moveExistingNodeToMainGraph(attribs); | ||
264 | } | 239 | } | ||
265 | 240 | | |||
266 | void KGraphViewerPart::slotAddNewEdge(const QString& src, const QString& tgt, const QMap<QString,QString>& attribs) | 241 | void KGraphViewerPart::slotAddNewEdge(const QString &src, const QString &tgt, const QMap<QString, QString> &attribs) | ||
267 | { | 242 | { | ||
268 | d->m_widget->graph()->addNewEdge(src,tgt,attribs); | 243 | d->m_widget->graph()->addNewEdge(src, tgt, attribs); | ||
269 | } | 244 | } | ||
270 | 245 | | |||
271 | void KGraphViewerPart::prepareAddNewEdge(const QMap<QString,QString>& attribs) | 246 | void KGraphViewerPart::prepareAddNewEdge(const QMap<QString, QString> &attribs) | ||
272 | { | 247 | { | ||
273 | d->m_widget->prepareAddNewEdge(attribs); | 248 | d->m_widget->prepareAddNewEdge(attribs); | ||
274 | } | 249 | } | ||
275 | 250 | | |||
276 | void KGraphViewerPart::setReadOnly() | 251 | void KGraphViewerPart::setReadOnly() | ||
277 | { | 252 | { | ||
278 | d->m_widget->setReadOnly(); | 253 | d->m_widget->setReadOnly(); | ||
279 | } | 254 | } | ||
280 | 255 | | |||
281 | void KGraphViewerPart::setReadWrite() | 256 | void KGraphViewerPart::setReadWrite() | ||
282 | { | 257 | { | ||
283 | d->m_widget->setReadWrite(); | 258 | d->m_widget->setReadWrite(); | ||
284 | } | 259 | } | ||
285 | 260 | | |||
286 | void KGraphViewerPart::saveTo(const QString& fileName) | 261 | void KGraphViewerPart::saveTo(const QString &fileName) | ||
287 | { | 262 | { | ||
288 | d->m_widget->graph()->saveTo(fileName); | 263 | d->m_widget->graph()->saveTo(fileName); | ||
289 | } | 264 | } | ||
290 | 265 | | |||
291 | void KGraphViewerPart::slotRemoveNode(const QString& nodeName) | 266 | void KGraphViewerPart::slotRemoveNode(const QString &nodeName) | ||
292 | { | 267 | { | ||
293 | d->m_widget->graph()->removeNodeNamed(nodeName); | 268 | d->m_widget->graph()->removeNodeNamed(nodeName); | ||
294 | } | 269 | } | ||
295 | 270 | | |||
296 | void KGraphViewerPart::slotRemoveNodeFromSubgraph(const QString& nodeName, const QString& subgraphName) | 271 | void KGraphViewerPart::slotRemoveNodeFromSubgraph(const QString &nodeName, const QString &subgraphName) | ||
297 | { | 272 | { | ||
298 | d->m_widget->graph()->removeNodeFromSubgraph(nodeName, subgraphName); | 273 | d->m_widget->graph()->removeNodeFromSubgraph(nodeName, subgraphName); | ||
299 | } | 274 | } | ||
300 | 275 | | |||
301 | void KGraphViewerPart::slotRemoveSubgraph(const QString& subgraphName) | 276 | void KGraphViewerPart::slotRemoveSubgraph(const QString &subgraphName) | ||
302 | { | 277 | { | ||
303 | d->m_widget->graph()->removeSubgraphNamed(subgraphName); | 278 | d->m_widget->graph()->removeSubgraphNamed(subgraphName); | ||
304 | } | 279 | } | ||
305 | 280 | | |||
306 | void KGraphViewerPart::slotSelectNode(const QString& nodeName) | 281 | void KGraphViewerPart::slotSelectNode(const QString &nodeName) | ||
307 | { | 282 | { | ||
308 | d->m_widget->slotSelectNode(nodeName); | 283 | d->m_widget->slotSelectNode(nodeName); | ||
309 | } | 284 | } | ||
310 | 285 | | |||
311 | void KGraphViewerPart::slotAddAttribute(const QString&) | 286 | void KGraphViewerPart::slotAddAttribute(const QString &) | ||
312 | { | 287 | { | ||
313 | qCDebug(KGRAPHVIEWERLIB_LOG) << "NOT IMPLEMENTED"; | 288 | qCDebug(KGRAPHVIEWERLIB_LOG) << "NOT IMPLEMENTED"; | ||
314 | } | 289 | } | ||
315 | 290 | | |||
316 | void KGraphViewerPart::slotSetAttribute(const QString& elementId, const QString& attributeName, const QString& attributeValue) | 291 | void KGraphViewerPart::slotSetAttribute(const QString &elementId, const QString &attributeName, const QString &attributeValue) | ||
317 | { | 292 | { | ||
318 | d->m_widget->graph()->setAttribute(elementId,attributeName,attributeValue); | 293 | d->m_widget->graph()->setAttribute(elementId, attributeName, attributeValue); | ||
319 | } | 294 | } | ||
320 | 295 | | |||
321 | void KGraphViewerPart::slotRemoveAttribute(const QString& nodeName, const QString& attribName) | 296 | void KGraphViewerPart::slotRemoveAttribute(const QString &nodeName, const QString &attribName) | ||
322 | { | 297 | { | ||
323 | d->m_widget->graph()->removeAttribute(nodeName, attribName); | 298 | d->m_widget->graph()->removeAttribute(nodeName, attribName); | ||
324 | } | 299 | } | ||
325 | 300 | | |||
326 | void KGraphViewerPart::slotRemoveEdge(const QString& id) | 301 | void KGraphViewerPart::slotRemoveEdge(const QString &id) | ||
327 | { | 302 | { | ||
328 | d->m_widget->graph()->removeEdge(id); | 303 | d->m_widget->graph()->removeEdge(id); | ||
329 | } | 304 | } | ||
330 | 305 | | |||
331 | void KGraphViewerPart::slotRemoveElement(const QString& id) | 306 | void KGraphViewerPart::slotRemoveElement(const QString &id) | ||
332 | { | 307 | { | ||
333 | d->m_widget->graph()->removeElement(id); | 308 | d->m_widget->graph()->removeElement(id); | ||
334 | } | 309 | } | ||
335 | 310 | | |||
336 | void KGraphViewerPart::slotSetHighlighting(bool highlightingValue) | 311 | void KGraphViewerPart::slotSetHighlighting(bool highlightingValue) | ||
337 | { | 312 | { | ||
338 | d->m_widget->setHighlighting(highlightingValue); | 313 | d->m_widget->setHighlighting(highlightingValue); | ||
339 | } | 314 | } | ||
340 | 315 | | |||
341 | | ||||
342 | void KGraphViewerPart::slotPrepareToSelect() | 316 | void KGraphViewerPart::slotPrepareToSelect() | ||
343 | { | 317 | { | ||
344 | d->m_widget->prepareSelectElements(); | 318 | d->m_widget->prepareSelectElements(); | ||
345 | } | 319 | } | ||
346 | 320 | | |||
347 | void KGraphViewerPart::slotSetCursor(const QCursor& cursor) | 321 | void KGraphViewerPart::slotSetCursor(const QCursor &cursor) | ||
348 | { | 322 | { | ||
349 | d->m_widget->setCursor(cursor); | 323 | d->m_widget->setCursor(cursor); | ||
350 | } | 324 | } | ||
351 | 325 | | |||
352 | void KGraphViewerPart::slotUnsetCursor() | 326 | void KGraphViewerPart::slotUnsetCursor() | ||
353 | { | 327 | { | ||
354 | d->m_widget->unsetCursor(); | 328 | d->m_widget->unsetCursor(); | ||
355 | } | 329 | } | ||
356 | 330 | | |||
357 | void KGraphViewerPart::slotSetLayoutMethod(LayoutMethod method) | 331 | void KGraphViewerPart::slotSetLayoutMethod(LayoutMethod method) | ||
358 | { | 332 | { | ||
359 | setLayoutMethod(method); | 333 | setLayoutMethod(method); | ||
360 | } | 334 | } | ||
361 | 335 | | |||
362 | void KGraphViewerPart::setLayoutMethod(LayoutMethod method) | 336 | void KGraphViewerPart::setLayoutMethod(LayoutMethod method) | ||
363 | { | 337 | { | ||
364 | d->m_layoutMethod = method; | 338 | d->m_layoutMethod = method; | ||
365 | } | 339 | } | ||
366 | 340 | | |||
367 | void KGraphViewerPart::centerOnNode(const QString& nodeId) | 341 | void KGraphViewerPart::centerOnNode(const QString &nodeId) | ||
368 | { | 342 | { | ||
369 | d->m_widget->centerOnNode(nodeId); | 343 | d->m_widget->centerOnNode(nodeId); | ||
370 | } | 344 | } | ||
371 | 345 | | |||
372 | void KGraphViewerPart::selectNode(const QString& nodeId) | 346 | void KGraphViewerPart::selectNode(const QString &nodeId) | ||
373 | { | 347 | { | ||
374 | slotSelectNode(nodeId); | 348 | slotSelectNode(nodeId); | ||
375 | } | 349 | } | ||
376 | 350 | | |||
377 | void KGraphViewerPart::setLayoutCommand(const QString& command) | 351 | void KGraphViewerPart::setLayoutCommand(const QString &command) | ||
378 | { | 352 | { | ||
379 | d->m_widget->setLayoutCommand(command); | 353 | d->m_widget->setLayoutCommand(command); | ||
380 | } | 354 | } | ||
381 | 355 | | |||
382 | void KGraphViewerPart::setPannerPosition(KGraphViewerInterface::PannerPosition position) | 356 | void KGraphViewerPart::setPannerPosition(KGraphViewerInterface::PannerPosition position) | ||
383 | { | 357 | { | ||
384 | d->m_widget->viewBevActivated(position); | 358 | d->m_widget->viewBevActivated(position); | ||
385 | } | 359 | } | ||
Show All 18 Lines | 377 | { | |||
404 | d->m_widget->zoomIn(); | 378 | d->m_widget->zoomIn(); | ||
405 | } | 379 | } | ||
406 | 380 | | |||
407 | void KGraphViewerPart::zoomOut() | 381 | void KGraphViewerPart::zoomOut() | ||
408 | { | 382 | { | ||
409 | d->m_widget->zoomOut(); | 383 | d->m_widget->zoomOut(); | ||
410 | } | 384 | } | ||
411 | 385 | | |||
412 | void KGraphViewerPart::slotRenameNode(const QString& oldNodeName, const QString& newNodeName) | 386 | void KGraphViewerPart::slotRenameNode(const QString &oldNodeName, const QString &newNodeName) | ||
413 | { | 387 | { | ||
414 | d->m_widget->graph()->renameNode(oldNodeName,newNodeName); | 388 | d->m_widget->graph()->renameNode(oldNodeName, newNodeName); | ||
415 | } | 389 | } | ||
416 | 390 | | |||
417 | } | 391 | } | ||
418 | 392 | | |||
419 | #include "kgraphviewer_part.moc" | 393 | #include "kgraphviewer_part.moc" |