File indexing completed on 2024-05-19 15:27:50
0001 // interface.h 0002 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org> 0003 0004 // This library is free software; you can redistribute it and/or 0005 // modify it under the terms of the GNU Lesser General Public 0006 // License as published by the Free Software Foundation; either 0007 // version 2.1 of the License, or (at your option) any later version. 0008 0009 // This library is distributed in the hope that it will be useful, 0010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 // Lesser General Public License for more details. 0013 0014 // You should have received a copy of the GNU Lesser General Public 0015 // License along with this library; if not, write to the Free Software 0016 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0017 // 02110-1301 USA 0018 0019 #ifndef KGRAPHVIEWER_INTERFACE_H 0020 #define KGRAPHVIEWER_INTERFACE_H 0021 0022 #include <QMap> 0023 #include <QObject> 0024 0025 namespace KParts 0026 { 0027 class Part; 0028 } 0029 class QCursor; 0030 0031 extern "C" { 0032 typedef struct Agraph_s graph_t; 0033 } 0034 0035 namespace KGraphViewer 0036 { 0037 /** 0038 * KGraphViewerInterface is an interface implemented by KGraphViewer to 0039 * allow developers access to the KGraphViewerPart in ways that are not 0040 * possible through the normal KPart interface. 0041 * 0042 * Note that besides the functions below here, KGraphViewer also has 0043 * some signals you can connect to. They aren't in this class cause 0044 * we can't have signals without having a QObject, which 0045 * KGraphViewerInterface is not. To see a list of signals, take a look at kgraphviewer_part.h 0046 * 0047 * See the example code below for how to connect to these.. 0048 * 0049 * Use it like this: 0050 * \code 0051 * // fetch the Part.. 0052 * KPluginFactory *factory = KPluginFactory::loadFactory(KPluginMetaData("kgraphviewerpart")).plugin; 0053 * if (factory) { 0054 * KParts::ReadOnlyPart* part = factory->create<KParts::ReadOnlyPart>(this); 0055 * 0056 * // cast the part to the KGraphViewerInterface... 0057 * KGraphViewerInterface* graph = qobject_cast<KGraphViewerInterface*>( part ); 0058 * if( ! graph ) 0059 * { 0060 * // This should not happen 0061 * return; 0062 * } 0063 * // now use the interface in all sorts of ways... 0064 * } 0065 * \endcode 0066 * 0067 * @author Milian Wolff <mail@milianw.de> 0068 * 0069 * 0070 * WARNING: This is highly experimental and no kind of BC guarantees are given! 0071 * TODO: documentation 0072 */ 0073 class KGraphViewerInterface 0074 { 0075 public: 0076 enum LayoutMethod { ExternalProgram, InternalLibrary }; 0077 0078 virtual void setLayoutMethod(LayoutMethod method) = 0; 0079 virtual void zoomIn() = 0; 0080 virtual void zoomOut() = 0; 0081 virtual void zoomBy(double factor) = 0; 0082 virtual void setZoomFactor(double factor) = 0; 0083 0084 enum PannerPosition { TopLeft, TopRight, BottomLeft, BottomRight, Auto }; 0085 virtual void setPannerPosition(PannerPosition position) = 0; 0086 virtual void setPannerEnabled(bool enabled) = 0; 0087 0088 virtual void setLayoutCommand(const QString &command) = 0; 0089 0090 virtual void selectNode(const QString &nodeId) = 0; 0091 virtual void centerOnNode(const QString &nodeId) = 0; 0092 0093 // Slots 0094 virtual void slotHide(KParts::Part *part) = 0; 0095 virtual void slotUpdate() = 0; 0096 virtual void prepareAddNewElement(const QMap<QString, QString> &attribs) = 0; 0097 virtual void prepareAddNewEdge(const QMap<QString, QString> &attribs) = 0; 0098 virtual void setReadOnly() = 0; 0099 virtual void setReadWrite() = 0; 0100 virtual void saveTo(const QString &fileName) = 0; 0101 virtual void slotRemoveNode(const QString &) = 0; 0102 virtual void slotRemoveNodeFromSubgraph(const QString &nodeName, const QString &subgraphName) = 0; 0103 virtual void slotRemoveSubgraph(const QString &) = 0; 0104 virtual void slotAddAttribute(const QString &) = 0; 0105 virtual void slotSetAttribute(const QString &elementId, const QString &attributeName, const QString &attributeValue) = 0; 0106 virtual void slotRemoveAttribute(const QString &, const QString &) = 0; 0107 virtual void slotSetGraphAttributes(const QMap<QString, QString> &attribs) = 0; 0108 virtual void slotAddNewNode(const QMap<QString, QString> &attribs) = 0; 0109 virtual void slotAddNewNodeToSubgraph(const QMap<QString, QString> &attribs, const QString &subgraph) = 0; 0110 virtual void slotAddExistingNodeToSubgraph(const QMap<QString, QString> &attribs, const QString &subgraph) = 0; 0111 virtual void slotMoveExistingNodeToMainGraph(const QMap<QString, QString> &attribs) = 0; 0112 virtual void slotAddNewSubgraph(const QMap<QString, QString> &attribs) = 0; 0113 virtual void slotAddNewEdge(const QString &src, const QString &tgt, const QMap<QString, QString> &attribs) = 0; 0114 virtual void slotRemoveEdge(const QString &id) = 0; 0115 virtual void slotRemoveElement(const QString &id) = 0; 0116 virtual void slotSelectNode(const QString &) = 0; 0117 virtual void slotSetHighlighting(bool highlightingValue) = 0; 0118 virtual void slotPrepareToSelect() = 0; 0119 virtual void slotSetCursor(const QCursor &cursor) = 0; 0120 virtual void slotUnsetCursor() = 0; 0121 virtual void slotSetLayoutMethod(LayoutMethod method) = 0; 0122 virtual void slotRenameNode(const QString &oldName, const QString &newName) = 0; 0123 virtual bool slotLoadLibrary(graph_t *graph) = 0; 0124 virtual void setBackgroundColor(const QColor &color) = 0; 0125 0126 protected: 0127 KGraphViewerInterface() 0128 { 0129 } 0130 virtual ~KGraphViewerInterface() 0131 { 0132 } 0133 }; 0134 0135 } 0136 0137 Q_DECLARE_INTERFACE(KGraphViewer::KGraphViewerInterface, "org.kde.KGraphViewerInterface") 0138 0139 #endif // KGRAPHVIEWER_INTERFACE_H