cnitem.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003-2005 by David Saxton                               *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #ifndef CNITEM_H
00012 #define CNITEM_H
00013 
00014 #include "item.h"
00015 #include "ciwidgetmgr.h"
00016 
00017 
00018 class Button;
00019 class CNItem;
00020 class ICNDocument;
00021 class Connector;
00022 class DoubleSpinBox;
00023 class LibraryItem;
00024 class Node;
00025 class QSlider;
00026 class QString;
00027 class QToolButton;
00028 class QWMatrix;
00029 class Slider;
00030 class Text;
00031 
00032 
00033 class NodeInfo
00034 {
00035 public:
00036         NodeInfo();
00037         
00038         QString id; // External id (ICNDocument scope)
00039         Node *node; //Pointer to the node
00040         double x; // X position relative to item
00041         double y; // Y position relative to item
00042         int orientation; // Orientation relative to item
00043 };
00044 
00045 typedef QMap<QString, QString> StringMap;
00046 typedef QMap<QString, NodeInfo> NodeMap; // Internal id, node info
00047 typedef QValueList<QGuardedPtr<Connector> > ConnectorList;
00048 typedef QMap<QString, QGuardedPtr<Text> > TextMap;
00049 
00058 class CNItem : public Item, public CIWidgetMgr
00059 {
00060 Q_OBJECT
00061 public:
00062         CNItem( ICNDocument *_icnView, bool newItem, const QString &id );
00063         virtual ~CNItem();
00064         
00068         int rtti() const;
00075         Node* createNode( double _x, double _y, int orientation, const QString &name, uint type );
00080         bool removeNode( const QString &name );
00084         void setInitialPos( const QPoint &pos );
00088         void snap( int newx = -1, int newy = -1 );
00092         Node *getClosestNode( const QPoint &pos );
00096         ConnectorList connectorList();
00097         virtual bool preResize( QRect sizeRect );
00098         virtual bool mousePressEvent( const EventInfo &eventInfo );
00099         virtual bool mouseReleaseEvent( const EventInfo &eventInfo );
00100         virtual bool mouseDoubleClickEvent ( const EventInfo &eventInfo );
00101         virtual bool mouseMoveEvent( const EventInfo &eventInfo );
00102         virtual bool wheelEvent( const EventInfo &eventInfo );
00103         virtual void enterEvent();
00104         virtual void leaveEvent();
00111         virtual void updateConnectorPoints( bool add );
00116         QString nodeId( const QString &internalNodeId );
00120         Node *childNode( const QString &childId );
00126         NodeMap nodeMap() const { return m_nodeMap; }
00130         TextMap textMap() const { return m_textMap; }
00131         virtual void setVisible( bool yes );
00132         virtual void updateZ( int baseZ );
00133 
00134         virtual ItemData itemData() const;
00135         virtual void restoreFromItemData( const ItemData &itemData );
00136         virtual void updateNodeLevels();
00137         
00138 public slots:
00142         virtual void moveBy( double dx, double dy );
00151         virtual void removeItem();
00155         virtual void updateAttachedPositioning();
00156         
00157 protected:
00158         virtual void reparented( Item *oldParent, Item *newParent );
00159         virtual void drawShape( QPainter &p );
00160         virtual void postResize();
00169         Text* addDisplayText( const QString &id, const QRect & pos, const QString &display, bool internal = true, int flags = Qt::AlignHCenter | Qt::AlignVCenter );
00170         void setDisplayText( const QString &id, const QString &display );
00174         void removeDisplayText( const QString &id );
00178         virtual void initPainter( QPainter &p );
00179         
00180         QPoint m_offset;
00181         QGuardedPtr<ICNDocument> p_icnDocument;
00182         TextMap m_textMap;
00183         NodeMap m_nodeMap;
00184         QColor m_selectedCol;
00185         QColor m_brushCol;
00186         bool b_pointsAdded;
00187 };
00188 typedef QValueList<CNItem*> CNItemList;
00189 
00190 #endif
00191 

Generated on Tue May 8 17:05:28 2007 for KTechLab by  doxygen 1.5.1