
#ifndef DIAGRAMITEM_H
#define DIAGRAMITEM_H

#include <QGraphicsPixmapItem>
#include <QList>

QT_BEGIN_NAMESPACE
class QPixmap;
class QGraphicsItem;
class QGraphicsScene;
class QTextEdit;
class QGraphicsSceneMouseEvent;
class QGraphicsSceneDragDropEvent;
class QMenu;
class QGraphicsSceneContextMenuEvent;
class QPainter;
class QStyleOptionGraphicsItem;
class QWidget;
class QPolygonF;
QT_END_NAMESPACE

class Arrow;
class Arrow2;
class ItemInfo;
//////
// сохраняем уникальный идентификатор каждого итема
// возьмем для начала - время создания в юникс-формате
//////
//! [0]


class DiagramItem : public QGraphicsPolygonItem
{
public:
    enum { Type = UserType + 15 };
    enum DiagramType { Step, Conditional, StartEnd, Io };

    DiagramItem(DiagramType diagramType, QMenu *contextMenu,
        QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);

    DiagramItem(ItemInfo info,QGraphicsScene *scene=0);

    void removeArrow(Arrow2 *arrow);
    void removeArrows();
    void setText(QGraphicsItem *item, QString text);
    void setWeight(QGraphicsItem *item, int weight);
    void setNumber(QGraphicsItem *item, int num);

    DiagramType diagramType() const
    { return myDiagramType; }

    QPolygonF polygon() const
    { return myPolygon; }

    void addArrow(Arrow2 *arrow);

    int ArrowsCount() const
    {return arrows.count();}

    Arrow2 *arrowAt(int i) const
    {return arrows[i];}

    QPixmap image() const;
    int type() const
    { return Type;}
	int id() const
		{ return ID;}
	QString comment() const
		{ return Com;}
	int returnNumber() const
		{ return NUMBERB;}

	void setID(int id);
        void setWeightNum(int WEIGHT);
        void setNumberNum(int num);
        void setNumberB(int num);
	void setCom(QString text);
        void setWei(int wei);
        int weightNum() const
        {return weight;}
        ItemInfo getItemInfo();

	//нужно стобы вызвать ф-ю контекстного меню из diagramscene
	void contextMenu(QGraphicsSceneContextMenuEvent *event)
	{
		contextMenuEvent(event);
	}


protected:
	void dropEvent ( QGraphicsSceneDragDropEvent * event );
    void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
    QVariant itemChange(GraphicsItemChange change, const QVariant &value);

private:
    DiagramType myDiagramType;
    QPolygonF myPolygon;
	int ID;
        int NUMBERB;
        int weight;
	QString Com;
    QMenu *myContextMenu;
    QList<Arrow2 *> arrows;
        //DiagramScene *scene;

};
//! [0]

#endif
