File indexing completed on 2024-12-08 11:06:52
0001 // 0002 // C++ Interface: flowicndocument 0003 // 0004 // Description: 0005 // 0006 // 0007 // Author: Zoltan P <zoltan.padrah@gmail.com>, (C) 2008 0008 // 0009 // Copyright: See COPYING file that comes with this distribution 0010 // 0011 // 0012 #ifndef FLOWICNDOCUMENT_H 0013 #define FLOWICNDOCUMENT_H 0014 0015 #include <icndocument.h> 0016 0017 class Node; 0018 class FPNode; 0019 0020 typedef QMap<QString, FPNode *> FPNodeMap; 0021 0022 /** 0023 A document holding a flow-diagram 0024 @author Zoltan P <zoltan.padrah@gmail.com> 0025 */ 0026 class FlowICNDocument : public ICNDocument 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 FlowICNDocument(const QString &caption); 0032 0033 ~FlowICNDocument() override; 0034 0035 /** 0036 * Reinherit this function to perform special checks on whether the two 0037 * given QCanvasItems (either nodes or connectors or both) can be 0038 * connected together. 0039 */ 0040 bool canConnect(KtlQCanvasItem *qcanvasItem1, KtlQCanvasItem *qcanvasItem2) const override; 0041 0042 /** 0043 * Splits Connector con into two connectors at point pos2, and creates a connector from the node 0044 * to the intersection of the two new connectors. If pointList is non-null, then the new connector 0045 * from the node will be assigned those points 0046 */ 0047 Connector *createConnector(Node *node, Connector *con, const QPoint &pos2, QPointList *pointList = nullptr) override; 0048 /** 0049 * Splits con1 and con2 into two new connectors each at points pos1 and pos2, and creates a new connector 0050 * between the two points of intersection given by pos1 and pos2. If pointList is non-null, then the new 0051 * connector between the two points will be assigned those points 0052 */ 0053 Connector *createConnector(Connector *con1, Connector *con2, const QPoint &pos1, const QPoint &pos2, QPointList *pointList = nullptr) override; 0054 /** 0055 * Creates a connector between two nodes, and returns a pointer to it 0056 * and adds the operation to the undo list 0057 */ 0058 Connector *createConnector(const QString &startNodeId, const QString &endNodeId, QPointList *pointList = nullptr) override; 0059 0060 /** 0061 * Returns a pointer to a node on the canvas with the given id, 0062 * or nullptr if no such node exists 0063 */ 0064 Node *nodeWithID(const QString &id) override; 0065 FPNode *getFPnodeWithID(const QString &id); 0066 /** 0067 * Assigns the orphan nodes into NodeGroups. You shouldn't call this 0068 * function directly - instead use ItemDocument::requestEvent. 0069 */ 0070 void slotAssignNodeGroups() override; 0071 0072 /** 0073 * Permantly deletes all items that have been added to the delete list with 0074 * the appendDeleteList( KtlQCanvasItem *qcanvasItem ) function. 0075 */ 0076 void flushDeleteList() override; 0077 0078 /** 0079 * registers (adds to the document) an item (a connector or a node) 0080 * @param qcanvasItem the item to be registered 0081 * @return true if succeeded, false if it didn't 0082 */ 0083 bool registerItem(KtlQCanvasItem *qcanvasItem) override; 0084 void unregisterUID(const QString &uid) override; 0085 NodeList nodeList() const override; 0086 0087 protected: 0088 /** 0089 * If there are two connectors joined to a node, then they can be merged 0090 * into one connector. The node will not be removed. 0091 * @param fpnode The node between the two connectors 0092 * @returns true if it was successful in merging the connectors 0093 */ 0094 bool joinConnectors(FPNode *fpnode); 0095 /** 0096 * Selects all nodes on the document. Should be overridden. 0097 */ 0098 void selectAllNodes() override; 0099 0100 /** 0101 * deletes all the elements containde in the nodeList. Should be overridden. 0102 */ 0103 void deleteAllNodes() override; 0104 0105 /// the list of flownodes in the documents 0106 FPNodeMap m_flowNodeList; 0107 }; 0108 0109 #endif