From 5de3dd4762ca33a0f92e79ffa4fe2ff67069d531 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 24 Feb 2010 01:49:02 +0000 Subject: Added KDE3 version of ktechlab git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktechlab@1095338 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/icndocument.h | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 src/icndocument.h (limited to 'src/icndocument.h') diff --git a/src/icndocument.h b/src/icndocument.h new file mode 100644 index 0000000..7a5b126 --- /dev/null +++ b/src/icndocument.h @@ -0,0 +1,280 @@ +/*************************************************************************** + * Copyright (C) 2005 by David Saxton * + * david@bluehaze.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef ICNDOCUMENT_H +#define ICNDOCUMENT_H + +#include "itemdocument.h" + + +class Cells; +class CNItem; +class CNItemGroup; +class Connector; +class ECNode; +class FlowContainer; +class Node; +class NodeGroup; + +typedef QValueList > ConnectorList; +typedef QValueList > NodeList; +typedef QValueList NodeGroupList; +typedef QValueList > GuardedNodeGroupList; + +/** +@author David Saxton +*/ +class ICNDocument : public ItemDocument +{ +Q_OBJECT +public: + ICNDocument( const QString &caption, KTechlab *ktechlab, const char *name ); + virtual ~ICNDocument(); + + enum hit_score + { + hs_none = 0, + hs_connector = 4, + hs_item = 1000 + }; + + virtual View *createView( ViewContainer *viewContainer, uint viewAreaId, const char *name = 0l ); + + /** + * Will attempt to create an item with the given id at position p. Some item + * (such as PIC/START) have restrictions, and can only have one instance of + * themselves on the canvas, and adds the operation to the undo list + */ + virtual Item* addItem( const QString &id, const QPoint &p, bool newItem ); + /** + * Creates a connector between two nodes, and returns a pointer to it + * and adds the operation to the undo list + */ + Connector* createConnector( const QString &startNodeId, const QString &endNodeId, QPointList *pointList = 0L ); + /** + * short for casting whatever itemWithID(id) returns + */ + CNItem* cnItemWithID( const QString &id ); + /** + * Returns a pointer to a node on the canvas with the given id, + * or NULL if no such node exists + */ + Node* nodeWithID( const QString &id ); + /** + * Returns a pointer to a Connector on the canvas with the given id, + * or NULL if no such Connector exists + */ + Connector* connectorWithID( const QString &id ); + /** + * Adds a QCanvasItem to the delete list to be deleted, + * when flushDeleteList() is called + */ + virtual void appendDeleteList( QCanvasItem *qcanvasItem ); + /** + * Permantly deletes all items that have been added to the delete list with + * the appendDeleteList( QCanvasItem *qcanvasItem ) function. + */ + virtual void flushDeleteList(); + /** + * Reinherit this function to perform special checks on whether the two + * given QCanvasItems (either nodes or connectors or both) can be + * connected together. + */ + virtual bool canConnect( QCanvasItem *qcanvasItem1, QCanvasItem *qcanvasItem2 ) const; + virtual void copy(); + virtual void selectAll(); + + + virtual bool registerItem( QCanvasItem *qcanvasItem ); + /** + * Returns a pointer to the 2-dimension array of ICNDocument cells. + */ + Cells *cells() const { return m_cells; } + /** + * Returns true if the cell-reference given by x and y is valid (i.e. + * greater than 0, but within the m_cells boundary) + */ + inline bool isValidCellReference( const uint x, const uint y ) const + { + return ( xm_leftArrow; + } + + static QPixmap rightArrow() + { + return self()->m_rightArrow; + } + + static QPixmap upArrow() + { + return self()->m_upArrow; + } + + static QPixmap downArrow() + { + return self()->m_downArrow; + } + +protected: + DirCursor(); + void initCursors(); + + static DirCursor *m_self; + QPixmap m_leftArrow; + QPixmap m_rightArrow; + QPixmap m_upArrow; + QPixmap m_downArrow; +}; + + +#endif -- cgit v1.2.3