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