1 #ifndef __BLOCKITEM_H__
2 #define __BLOCKITEM_H__
9 #include <QtXmlPatterns>
12 #include "AbstractBoxItem.h"
13 class AbstractBoxItem;
19 #include "Exception.h"
26 A BoxItem may represent a functional block or a group block within a group item, itslef
27 within a scene. What says what it represents is refBlock, i.e. if refBlock->isFunctionalBlock()
28 or refBlock->isGroupBlock() returns true.
30 class BoxItem : public AbstractBoxItem {
34 enum Position { Free = 0, Left , Right, Top, Bottom, TopLeft, BottomLeft, TopRight, BottomRight }; // if not Free, glue the box to the desired border
35 enum SpanType { NoSpan = 0, HSpan = 1, VSpan = 2 };
37 BoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent, int _lock = NoLock, SpanType _span = NoSpan, Position _position = Free) throw(Exception);
38 BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent, int _lock = NoLock, SpanType _span = NoSpan, Position _position = Free) throw(Exception);
41 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
44 inline GroupItem *getChildGroupItem() { return childGroupItem; }
45 inline Position getPosition() { return position; }
46 inline SpanType getSpan() { return span; }
49 inline void setChildGroupItem(GroupItem* item) { childGroupItem = item; }
50 inline void setPosition(Position _position) { position = _position; }
51 inline void setSpan(SpanType _span) { span = _span; }
58 void moveTo(QPointF dest);
59 void loadFunctional(QDomElement funcElement) throw(Exception);
60 void save(QXmlStreamWriter& writer);
62 void updateMinimumSize(); // modify the minimum size
63 bool updateGeometry(ChangeType type); // modify the originPoint and the total dimension
70 void mousePressEvent(QGraphicsSceneMouseEvent *event);
71 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
72 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
73 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
74 void hoverMoveEvent( QGraphicsSceneHoverEvent *event);
79 A BoxItem is always graphically within a GroupItem, inside the same scene.
81 A BoxItem may also be the graphical view of a GroupBlock. In this case, there exists a child scene
82 containing a GroupItem. insideGroup atribute refers to this GroupItem and thus, may be NULL if the current
83 blockItem represents a functional block
85 GroupItem *childGroupItem;
88 friend QDataStream &operator<<(QDataStream &out, BoxItem &b);
89 friend QDataStream &operator>>(QDataStream &in, BoxItem &b);
93 void itemMustBeDeleted(QGraphicsItem*);
98 QDataStream & operator <<(QDataStream &out, BoxItem &b);
99 QDataStream & operator >>(QDataStream &in, BoxItem &b);
101 #endif // __BLOCKITEM_H__