Changeset View
Changeset View
Standalone View
Standalone View
src/part/kgraphviewer_interface.h
Show All 13 Lines | |||||
14 | // You should have received a copy of the GNU Lesser General Public | 14 | // You should have received a copy of the GNU Lesser General Public | ||
15 | // License along with this library; if not, write to the Free Software | 15 | // License along with this library; if not, write to the Free Software | ||
16 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 16 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | // 02110-1301 USA | 17 | // 02110-1301 USA | ||
18 | 18 | | |||
19 | #ifndef KGRAPHVIEWER_INTERFACE_H | 19 | #ifndef KGRAPHVIEWER_INTERFACE_H | ||
20 | #define KGRAPHVIEWER_INTERFACE_H | 20 | #define KGRAPHVIEWER_INTERFACE_H | ||
21 | 21 | | |||
22 | #include <QObject> | | |||
23 | #include <QMap> | 22 | #include <QMap> | ||
23 | #include <QObject> | ||||
24 | 24 | | |||
25 | namespace KParts | 25 | namespace KParts { | ||
26 | { | | |||
27 | class Part; | 26 | class Part; | ||
28 | } | 27 | } | ||
29 | class QCursor; | 28 | class QCursor; | ||
30 | 29 | | |||
31 | extern "C" { | 30 | extern "C" { | ||
32 | typedef struct Agraph_s graph_t; | 31 | typedef struct Agraph_s graph_t; | ||
33 | } | 32 | } | ||
34 | 33 | | |||
35 | 34 | namespace KGraphViewer { | |||
36 | namespace KGraphViewer | | |||
37 | { | | |||
38 | /** | 35 | /** | ||
39 | * KGraphViewerInterface is an interface implemented by KGraphViewer to | 36 | * KGraphViewerInterface is an interface implemented by KGraphViewer to | ||
40 | * allow developers access to the KGraphViewerPart in ways that are not | 37 | * allow developers access to the KGraphViewerPart in ways that are not | ||
41 | * possible through the normal KPart interface. | 38 | * possible through the normal KPart interface. | ||
42 | * | 39 | * | ||
43 | * Note that besides the functions below here, KGraphViewer also has | 40 | * Note that besides the functions below here, KGraphViewer also has | ||
44 | * some signals you can connect to. They aren't in this class cause | 41 | * some signals you can connect to. They aren't in this class cause | ||
45 | * we can't have signals without having a QObject, which | 42 | * we can't have signals without having a QObject, which | ||
46 | * KGraphViewerInterface is not. To see a list of signals, take a look at kgraphviewer_part.h | 43 | * KGraphViewerInterface is not. To see a list of signals, take a look at | ||
44 | * kgraphviewer_part.h | ||||
47 | * | 45 | * | ||
48 | * See the example code below for how to connect to these.. | 46 | * See the example code below for how to connect to these.. | ||
49 | * | 47 | * | ||
50 | * Use it like this: | 48 | * Use it like this: | ||
51 | * \code | 49 | * \code | ||
52 | * // fetch the Part.. | 50 | * // fetch the Part.. | ||
53 | * KPluginFactory *factory = KPluginLoader("kgraphviewerpart").factory(); | 51 | * KPluginFactory *factory = KPluginLoader("kgraphviewerpart").factory(); | ||
54 | * if (factory) { | 52 | * if (factory) { | ||
55 | * KParts::ReadOnlyPart* part = factory->create<KParts::ReadOnlyPart>(this); | 53 | * KParts::ReadOnlyPart* part = | ||
54 | * factory->create<KParts::ReadOnlyPart>(this); | ||||
56 | * | 55 | * | ||
57 | * // cast the part to the KGraphViewerInterface... | 56 | * // cast the part to the KGraphViewerInterface... | ||
58 | * KGraphViewerInterface* graph = qobject_cast<KGraphViewerInterface*>( part ); | 57 | * KGraphViewerInterface* graph = qobject_cast<KGraphViewerInterface*>( | ||
59 | * if( ! graph ) | 58 | * part ); if( ! graph ) | ||
60 | * { | 59 | * { | ||
61 | * // This should not happen | 60 | * // This should not happen | ||
62 | * return; | 61 | * return; | ||
63 | * } | 62 | * } | ||
64 | * // now use the interface in all sorts of ways... | 63 | * // now use the interface in all sorts of ways... | ||
65 | * } | 64 | * } | ||
66 | * \endcode | 65 | * \endcode | ||
67 | * | 66 | * | ||
68 | * @author Milian Wolff <mail@milianw.de> | 67 | * @author Milian Wolff <mail@milianw.de> | ||
69 | * | 68 | * | ||
70 | * | 69 | * | ||
71 | * WARNING: This is highly experimental and no kind of BC guarantees are given! | 70 | * WARNING: This is highly experimental and no kind of BC guarantees are given! | ||
72 | * TODO: documentation | 71 | * TODO: documentation | ||
73 | */ | 72 | */ | ||
74 | class KGraphViewerInterface | 73 | class KGraphViewerInterface { | ||
75 | { | | |||
76 | public: | 74 | public: | ||
77 | enum LayoutMethod | 75 | enum LayoutMethod { ExternalProgram, InternalLibrary }; | ||
78 | { | | |||
79 | ExternalProgram, | | |||
80 | InternalLibrary | | |||
81 | }; | | |||
82 | 76 | | |||
83 | virtual void setLayoutMethod(LayoutMethod method) = 0; | 77 | virtual void setLayoutMethod(LayoutMethod method) = 0; | ||
84 | virtual void zoomIn() = 0; | 78 | virtual void zoomIn() = 0; | ||
85 | virtual void zoomOut() = 0; | 79 | virtual void zoomOut() = 0; | ||
86 | virtual void zoomBy(double factor) = 0; | 80 | virtual void zoomBy(double factor) = 0; | ||
87 | virtual void setZoomFactor(double factor) = 0; | 81 | virtual void setZoomFactor(double factor) = 0; | ||
88 | 82 | | |||
89 | enum PannerPosition { TopLeft, TopRight, BottomLeft, BottomRight, Auto }; | 83 | enum PannerPosition { TopLeft, TopRight, BottomLeft, BottomRight, Auto }; | ||
90 | virtual void setPannerPosition(PannerPosition position) = 0; | 84 | virtual void setPannerPosition(PannerPosition position) = 0; | ||
91 | virtual void setPannerEnabled(bool enabled) = 0; | 85 | virtual void setPannerEnabled(bool enabled) = 0; | ||
92 | 86 | | |||
93 | virtual void setLayoutCommand(const QString& command) = 0; | 87 | virtual void setLayoutCommand(const QString &command) = 0; | ||
94 | 88 | | |||
95 | virtual void selectNode(const QString& nodeId) = 0; | 89 | virtual void selectNode(const QString &nodeId) = 0; | ||
96 | virtual void centerOnNode(const QString& nodeId) = 0; | 90 | virtual void centerOnNode(const QString &nodeId) = 0; | ||
97 | 91 | | |||
98 | // Slots | 92 | // Slots | ||
99 | virtual void slotHide(KParts::Part* part) = 0; | 93 | virtual void slotHide(KParts::Part *part) = 0; | ||
100 | virtual void slotUpdate() = 0; | 94 | virtual void slotUpdate() = 0; | ||
101 | virtual void prepareAddNewElement(const QMap<QString,QString>& attribs) = 0; | 95 | virtual void | ||
96 | prepareAddNewElement(const QMap<QString, QString> &attribs) = 0; | ||||
102 | virtual void prepareAddNewEdge(const QMap<QString,QString>& attribs) = 0; | 97 | virtual void prepareAddNewEdge(const QMap<QString, QString> &attribs) = 0; | ||
103 | virtual void setReadOnly() = 0; | 98 | virtual void setReadOnly() = 0; | ||
104 | virtual void setReadWrite() = 0; | 99 | virtual void setReadWrite() = 0; | ||
105 | virtual void saveTo(const QString& fileName) = 0; | 100 | virtual void saveTo(const QString &fileName) = 0; | ||
106 | virtual void slotRemoveNode(const QString&) = 0; | 101 | virtual void slotRemoveNode(const QString &) = 0; | ||
107 | virtual void slotRemoveNodeFromSubgraph(const QString& nodeName, const QString& subgraphName) = 0; | 102 | virtual void slotRemoveNodeFromSubgraph(const QString &nodeName, | ||
103 | const QString &subgraphName) = 0; | ||||
108 | virtual void slotRemoveSubgraph(const QString&) = 0; | 104 | virtual void slotRemoveSubgraph(const QString &) = 0; | ||
109 | virtual void slotAddAttribute(const QString&) = 0; | 105 | virtual void slotAddAttribute(const QString &) = 0; | ||
110 | virtual void slotSetAttribute(const QString& elementId, const QString& attributeName, const QString& attributeValue) = 0; | 106 | virtual void slotSetAttribute(const QString &elementId, | ||
107 | const QString &attributeName, | ||||
108 | const QString &attributeValue) = 0; | ||||
111 | virtual void slotRemoveAttribute(const QString&,const QString&) = 0; | 109 | virtual void slotRemoveAttribute(const QString &, const QString &) = 0; | ||
112 | virtual void slotSetGraphAttributes(const QMap<QString,QString>& attribs) = 0; | 110 | virtual void | ||
111 | slotSetGraphAttributes(const QMap<QString, QString> &attribs) = 0; | ||||
113 | virtual void slotAddNewNode(const QMap<QString,QString>& attribs) = 0; | 112 | virtual void slotAddNewNode(const QMap<QString, QString> &attribs) = 0; | ||
114 | virtual void slotAddNewNodeToSubgraph(const QMap<QString,QString>& attribs, const QString& subgraph) = 0; | 113 | virtual void slotAddNewNodeToSubgraph(const QMap<QString, QString> &attribs, | ||
115 | virtual void slotAddExistingNodeToSubgraph(const QMap<QString,QString>& attribs, const QString& subgraph) = 0; | 114 | const QString &subgraph) = 0; | ||
116 | virtual void slotMoveExistingNodeToMainGraph(const QMap<QString,QString>& attribs) = 0; | 115 | virtual void | ||
116 | slotAddExistingNodeToSubgraph(const QMap<QString, QString> &attribs, | ||||
117 | const QString &subgraph) = 0; | ||||
118 | virtual void | ||||
119 | slotMoveExistingNodeToMainGraph(const QMap<QString, QString> &attribs) = 0; | ||||
117 | virtual void slotAddNewSubgraph(const QMap<QString,QString>& attribs) = 0; | 120 | virtual void slotAddNewSubgraph(const QMap<QString, QString> &attribs) = 0; | ||
118 | virtual void slotAddNewEdge(const QString& src, const QString& tgt, const QMap<QString,QString>& attribs) = 0; | 121 | virtual void slotAddNewEdge(const QString &src, const QString &tgt, | ||
122 | const QMap<QString, QString> &attribs) = 0; | ||||
119 | virtual void slotRemoveEdge(const QString& id) = 0; | 123 | virtual void slotRemoveEdge(const QString &id) = 0; | ||
120 | virtual void slotRemoveElement(const QString& id) = 0; | 124 | virtual void slotRemoveElement(const QString &id) = 0; | ||
121 | virtual void slotSelectNode(const QString&) = 0; | 125 | virtual void slotSelectNode(const QString &) = 0; | ||
122 | virtual void slotSetHighlighting(bool highlightingValue) = 0; | 126 | virtual void slotSetHighlighting(bool highlightingValue) = 0; | ||
123 | virtual void slotPrepareToSelect() = 0; | 127 | virtual void slotPrepareToSelect() = 0; | ||
124 | virtual void slotSetCursor(const QCursor& cursor) = 0; | 128 | virtual void slotSetCursor(const QCursor &cursor) = 0; | ||
125 | virtual void slotUnsetCursor() = 0; | 129 | virtual void slotUnsetCursor() = 0; | ||
126 | virtual void slotSetLayoutMethod(LayoutMethod method) = 0; | 130 | virtual void slotSetLayoutMethod(LayoutMethod method) = 0; | ||
127 | virtual void slotRenameNode(const QString& oldName, const QString& newName) = 0; | 131 | virtual void slotRenameNode(const QString &oldName, | ||
132 | const QString &newName) = 0; | ||||
128 | virtual bool slotLoadLibrary(graph_t* graph) = 0; | 133 | virtual bool slotLoadLibrary(graph_t *graph) = 0; | ||
129 | virtual void setBackgroundColor(const QColor& color) = 0; | 134 | virtual void setBackgroundColor(const QColor &color) = 0; | ||
130 | 135 | | |||
131 | | ||||
132 | protected: | 136 | protected: | ||
133 | KGraphViewerInterface() {} | 137 | KGraphViewerInterface() {} | ||
134 | virtual ~KGraphViewerInterface() {} | 138 | virtual ~KGraphViewerInterface() {} | ||
135 | }; | 139 | }; | ||
136 | 140 | | |||
137 | } | 141 | } // namespace KGraphViewer | ||
138 | 142 | | |||
139 | Q_DECLARE_INTERFACE(KGraphViewer::KGraphViewerInterface, "org.kde.KGraphViewerInterface") | 143 | Q_DECLARE_INTERFACE(KGraphViewer::KGraphViewerInterface, | ||
144 | "org.kde.KGraphViewerInterface") | ||||
140 | 145 | | |||
141 | #endif // KGRAPHVIEWER_INTERFACE_H | 146 | #endif // KGRAPHVIEWER_INTERFACE_H |