cnitemgroup.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 CANVASITEMGROUP_H
00012 #define CANVASITEMGROUP_H
00013 
00014 #include "itemgroup.h"
00015 
00016 
00017 class CNItem;
00018 class Item;
00019 class ICNDocument;
00020 class Component;
00021 class Connector;
00022 class FlowPart;
00023 class Node;
00024 class ECNode;
00025 class FPNode;
00026 class ICNDocument;
00027 class QCanvasItem;
00028 class QCanvasItemList;
00029 
00030 typedef QValueList<QGuardedPtr<Item> > ItemList;
00031 typedef QValueList<QGuardedPtr<Node> > NodeList;
00032 typedef QValueList<QGuardedPtr<Connector> > ConnectorList;
00033 
00037 class CNItemGroup : public ItemGroup
00038 {
00039 Q_OBJECT
00040 public:
00041         CNItemGroup( ICNDocument *icnDocument, const char *name = 0 );
00042         ~CNItemGroup();
00043         
00049         bool addItem( Item *item );
00055         bool addNode( Node *node );
00059         bool addConnector( Connector *con );
00064         virtual bool addQCanvasItem( QCanvasItem *qcanvasItem );
00068         virtual void setItems( QCanvasItemList list );
00072         void removeItem( Item *item );
00076         void removeNode( Node *node );
00080         void removeConnector( Connector *con );
00084         virtual void removeQCanvasItem( QCanvasItem *qcanvasItem );
00088         virtual bool contains( QCanvasItem *qcanvasItem ) const;
00092         uint nodeCount() const { return m_nodeCount; }
00096         uint connectorCount() const { return m_connectorCount; }
00101         uint count() const { return itemCount()+m_nodeCount+m_connectorCount; }
00105         virtual void setSelected( bool sel );
00109         void setOrientationAngle( int angleDegrees );
00113         void setOrientationFlipped( bool flipped );
00117         void setFlowPartOrientation( unsigned orientation );
00121         void setComponentOrientation( int angleDegrees, bool flipped );
00125         virtual void mergeGroup( ItemGroup *group );
00130         virtual void removeAllItems();
00136         virtual void deleteAllItems();
00142         NodeList nodes( bool excludeParented = true ) const;
00148         ConnectorList connectors( bool excludeParented = true ) const;
00152         QStringList itemIDs();
00157         bool canRotate() const;
00162         bool canFlip() const;
00163 
00164 public slots:
00168         void slotSetOrientation0() { setOrientationAngle(0); }
00172         void slotSetOrientation90() { setOrientationAngle(90); }
00176         void slotSetOrientation180() { setOrientationAngle(180); }
00180         void slotSetOrientation270() { setOrientationAngle(-90); }
00184         void slotRotateCW();
00188         void slotRotateCCW();
00192         void slotFlip();
00193 
00194 signals:
00195         void connectorAdded( Connector *con );
00196         void connectorRemoved( Connector *con );
00197         void nodeAdded( Node *node );
00198         void nodeRemoved( Node *node );
00199 
00200 protected:
00201         void updateInfo();
00202         void getActiveItem();
00203         void setActiveItem( Item *item );
00204 
00205 private:
00206         ICNDocument *p_icnDocument;
00207         ConnectorList m_connectorList;
00208         NodeList m_nodeList;
00209         uint m_connectorCount;
00210         uint m_nodeCount;
00211         int m_currentLevel; // We can only accept CNItems of one level
00212 };
00213 
00214 #endif

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