Changeset View
Changeset View
Standalone View
Standalone View
src/part/kgraphviewer_part.h
Show All 13 Lines | 1 | /* This file is part of KGraphViewer. | |||
---|---|---|---|---|---|
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 | #ifndef _KGRAPHVIEWERPART_H_ | 19 | #ifndef _KGRAPHVIEWERPART_H_ | ||
20 | #define _KGRAPHVIEWERPART_H_ | 20 | #define _KGRAPHVIEWERPART_H_ | ||
21 | 21 | | |||
22 | #include <kparts/part.h> | | |||
23 | #include <KParts/ReadOnlyPart> | 22 | #include <KParts/ReadOnlyPart> | ||
24 | #include <KPluginFactory> | 23 | #include <KPluginFactory> | ||
24 | #include <kparts/part.h> | ||||
25 | 25 | | |||
26 | #include "kgraphviewer_interface.h" | 26 | #include "kgraphviewer_interface.h" | ||
27 | 27 | | |||
28 | class KAboutData; | 28 | class KAboutData; | ||
29 | 29 | | |||
30 | class QWidget; | 30 | class QWidget; | ||
31 | 31 | | |||
32 | namespace KGraphViewer | 32 | namespace KGraphViewer | ||
33 | { | 33 | { | ||
34 | | ||||
35 | class DotGraph; | 34 | class DotGraph; | ||
36 | 35 | | |||
37 | class KGraphViewerPartPrivate; | 36 | class KGraphViewerPartPrivate; | ||
38 | 37 | | |||
39 | /** | 38 | /** | ||
40 | * This is a "Part". It that does all the real work in a KPart | 39 | * This is a "Part". It that does all the real work in a KPart | ||
41 | * application. | 40 | * application. | ||
42 | * | 41 | * | ||
43 | * @short Main Part | 42 | * @short Main Part | ||
44 | * @author Gael de Chalendar <kleag@free.fr> | 43 | * @author Gael de Chalendar <kleag@free.fr> | ||
45 | */ | 44 | */ | ||
46 | class KGraphViewerPart : public KParts::ReadOnlyPart, public KGraphViewerInterface | 45 | class KGraphViewerPart : public KParts::ReadOnlyPart, public KGraphViewerInterface | ||
47 | { | 46 | { | ||
48 | Q_OBJECT | 47 | Q_OBJECT | ||
49 | Q_INTERFACES(KGraphViewer::KGraphViewerInterface) | 48 | Q_INTERFACES(KGraphViewer::KGraphViewerInterface) | ||
50 | 49 | | |||
51 | //BEGIN: KGraphViewerInterface | 50 | // BEGIN: KGraphViewerInterface | ||
52 | public: | 51 | public: | ||
53 | void setLayoutMethod(LayoutMethod method) override; | 52 | void setLayoutMethod(LayoutMethod method) override; | ||
54 | void centerOnNode(const QString& nodeId) override; | 53 | void centerOnNode(const QString &nodeId) override; | ||
55 | void selectNode(const QString& nodeId) override; | 54 | void selectNode(const QString &nodeId) override; | ||
56 | void setLayoutCommand(const QString& command) override; | 55 | void setLayoutCommand(const QString &command) override; | ||
57 | void setPannerPosition(PannerPosition position) override; | 56 | void setPannerPosition(PannerPosition position) override; | ||
58 | void setPannerEnabled(bool enabled) override; | 57 | void setPannerEnabled(bool enabled) override; | ||
59 | void zoomBy(double factor) override; | 58 | void zoomBy(double factor) override; | ||
60 | void setZoomFactor(double factor) override; | 59 | void setZoomFactor(double factor) override; | ||
61 | void zoomIn() override; | 60 | void zoomIn() override; | ||
62 | void zoomOut() override; | 61 | void zoomOut() override; | ||
63 | void setBackgroundColor(const QColor& color) override; | 62 | void setBackgroundColor(const QColor &color) override; | ||
64 | 63 | | |||
65 | public: | 64 | public: | ||
66 | /** | 65 | /** | ||
67 | * Default constructor | 66 | * Default constructor | ||
68 | */ | 67 | */ | ||
69 | KGraphViewerPart(QWidget *parentWidget, QObject *parent, const QVariantList &); | 68 | KGraphViewerPart(QWidget *parentWidget, QObject *parent, const QVariantList &); | ||
70 | 69 | | |||
71 | | ||||
72 | /** | 70 | /** | ||
73 | * Destructor | 71 | * Destructor | ||
74 | */ | 72 | */ | ||
75 | ~KGraphViewerPart() override; | 73 | ~KGraphViewerPart() override; | ||
76 | 74 | | |||
77 | // Return information about the part | 75 | // Return information about the part | ||
78 | static KAboutData* createAboutData(); | 76 | static KAboutData *createAboutData(); | ||
79 | 77 | | |||
80 | Q_SIGNALS: | 78 | Q_SIGNALS: | ||
81 | void graphLoaded(); | 79 | void graphLoaded(); | ||
82 | void newNodeAdded(const QString&); | 80 | void newNodeAdded(const QString &); | ||
83 | void newEdgeAdded(const QString&, const QString&); | 81 | void newEdgeAdded(const QString &, const QString &); | ||
84 | /** signals that the user has activated a remove edge command */ | 82 | /** signals that the user has activated a remove edge command */ | ||
85 | void removeEdge(const QString&); | 83 | void removeEdge(const QString &); | ||
86 | /** signals that the user has activated a remove element command */ | 84 | /** signals that the user has activated a remove element command */ | ||
87 | void removeElement(const QString&); | 85 | void removeElement(const QString &); | ||
88 | void selectionIs(const QList<QString>, const QPoint&); | 86 | void selectionIs(const QList<QString>, const QPoint &); | ||
89 | void contextMenuEvent(const QString&, const QPoint&); | 87 | void contextMenuEvent(const QString &, const QPoint &); | ||
90 | /** let the application tweak the created edge if necessary */ | 88 | /** let the application tweak the created edge if necessary */ | ||
91 | void newEdgeFinished( | 89 | void newEdgeFinished(const QString &, const QString &, const QMap<QString, QString> &); | ||
92 | const QString&, const QString&, | | |||
93 | const QMap<QString, QString>&); | | |||
94 | /// emitted when the mouse enters a node, a subgraph or an edge. The parameter is the hovered element id | 90 | /// emitted when the mouse enters a node, a subgraph or an edge. The parameter is the hovered element id | ||
95 | void hoverEnter(const QString&); | 91 | void hoverEnter(const QString &); | ||
96 | /// emitted when the mouse leaves a node, a subgraph or an edge. The parameter is the hovered element id | 92 | /// emitted when the mouse leaves a node, a subgraph or an edge. The parameter is the hovered element id | ||
97 | void hoverLeave(const QString&); | 93 | void hoverLeave(const QString &); | ||
98 | 94 | | |||
99 | public Q_SLOTS: | 95 | public Q_SLOTS: | ||
100 | void slotHide(KParts::Part* part) override; | 96 | void slotHide(KParts::Part *part) override; | ||
101 | void slotUpdate() override; | 97 | void slotUpdate() override; | ||
102 | void prepareAddNewElement(const QMap<QString,QString>& attribs) override; | 98 | void prepareAddNewElement(const QMap<QString, QString> &attribs) override; | ||
103 | void prepareAddNewEdge(const QMap<QString,QString>& attribs) override; | 99 | void prepareAddNewEdge(const QMap<QString, QString> &attribs) override; | ||
104 | void setReadOnly() override; | 100 | void setReadOnly() override; | ||
105 | void setReadWrite() override; | 101 | void setReadWrite() override; | ||
106 | void saveTo(const QString& fileName) override; | 102 | void saveTo(const QString &fileName) override; | ||
107 | void slotRemoveNode(const QString&) override; | 103 | void slotRemoveNode(const QString &) override; | ||
108 | void slotRemoveNodeFromSubgraph( | 104 | void slotRemoveNodeFromSubgraph(const QString &nodeName, const QString &subgraphName) override; | ||
109 | const QString& nodeName, | | |||
110 | const QString& subgraphName) override; | | |||
111 | void slotRemoveSubgraph(const QString&) override; | 105 | void slotRemoveSubgraph(const QString &) override; | ||
112 | void slotAddAttribute(const QString&) override; | 106 | void slotAddAttribute(const QString &) override; | ||
113 | void slotSetAttribute(const QString& elementId, const QString& attributeName, const QString& attributeValue) override; | 107 | void slotSetAttribute(const QString &elementId, const QString &attributeName, const QString &attributeValue) override; | ||
114 | void slotRemoveAttribute(const QString&,const QString&) override; | 108 | void slotRemoveAttribute(const QString &, const QString &) override; | ||
115 | void slotSetGraphAttributes(const QMap<QString,QString>& attribs) override; | 109 | void slotSetGraphAttributes(const QMap<QString, QString> &attribs) override; | ||
116 | void slotAddNewNode(const QMap<QString,QString>& attribs) override; | 110 | void slotAddNewNode(const QMap<QString, QString> &attribs) override; | ||
117 | void slotAddNewNodeToSubgraph(const QMap<QString,QString>& attribs, const QString& subgraph) override; | 111 | void slotAddNewNodeToSubgraph(const QMap<QString, QString> &attribs, const QString &subgraph) override; | ||
118 | void slotAddExistingNodeToSubgraph(const QMap<QString,QString>& attribs, const QString& subgraph) override; | 112 | void slotAddExistingNodeToSubgraph(const QMap<QString, QString> &attribs, const QString &subgraph) override; | ||
119 | void slotMoveExistingNodeToMainGraph(const QMap<QString,QString>& attribs) override; | 113 | void slotMoveExistingNodeToMainGraph(const QMap<QString, QString> &attribs) override; | ||
120 | void slotAddNewSubgraph(const QMap<QString,QString>& attribs) override; | 114 | void slotAddNewSubgraph(const QMap<QString, QString> &attribs) override; | ||
121 | void slotAddNewEdge(const QString& src, const QString& tgt, const QMap<QString,QString>& attribs) override; | 115 | void slotAddNewEdge(const QString &src, const QString &tgt, const QMap<QString, QString> &attribs) override; | ||
122 | void slotRemoveEdge(const QString& id) override; | 116 | void slotRemoveEdge(const QString &id) override; | ||
123 | void slotRemoveElement(const QString& id) override; | 117 | void slotRemoveElement(const QString &id) override; | ||
124 | void slotSelectNode(const QString&) override; | 118 | void slotSelectNode(const QString &) override; | ||
125 | void slotSetHighlighting(bool highlightingValue) override; | 119 | void slotSetHighlighting(bool highlightingValue) override; | ||
126 | void slotPrepareToSelect() override; | 120 | void slotPrepareToSelect() override; | ||
127 | void slotSetCursor(const QCursor& cursor) override; | 121 | void slotSetCursor(const QCursor &cursor) override; | ||
128 | void slotUnsetCursor() override; | 122 | void slotUnsetCursor() override; | ||
129 | bool closeUrl() override; | 123 | bool closeUrl() override; | ||
130 | bool slotLoadLibrary(graph_t* graph) override; | 124 | bool slotLoadLibrary(graph_t *graph) override; | ||
131 | void slotSetLayoutMethod(LayoutMethod method) override; | 125 | void slotSetLayoutMethod(LayoutMethod method) override; | ||
132 | void slotRenameNode(const QString& oldNodeName, const QString& newNodeName) override; | 126 | void slotRenameNode(const QString &oldNodeName, const QString &newNodeName) override; | ||
133 | 127 | | |||
134 | /* inline DotGraph* graph() {return m_widget->graph();} | 128 | /* inline DotGraph* graph() {return m_widget->graph();} | ||
135 | inline const DotGraph* graph() const {return m_widget->graph();}*/ | 129 | inline const DotGraph* graph() const {return m_widget->graph();}*/ | ||
136 | 130 | | |||
137 | | ||||
138 | protected: | 131 | protected: | ||
139 | /** | 132 | /** | ||
140 | * This must be implemented by each part. Use openUrl to open a file | 133 | * This must be implemented by each part. Use openUrl to open a file | ||
141 | */ | 134 | */ | ||
142 | bool openFile() override; | 135 | bool openFile() override; | ||
143 | 136 | | |||
144 | private: | 137 | private: | ||
145 | KGraphViewerPartPrivate * const d; | 138 | KGraphViewerPartPrivate *const d; | ||
146 | }; | 139 | }; | ||
147 | 140 | | |||
148 | } | 141 | } | ||
149 | #endif // _KGRAPHVIEWERPART_H_ | 142 | #endif // _KGRAPHVIEWERPART_H_ |