/* * Copyright (c) 2012 Mateusz Piękos * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #pragma once #include #include #include #include #include #include #include "TextDialog.h" #include "FreehandLineItem.h" namespace Swift { class GView : public QGraphicsView { Q_OBJECT; public: enum Mode { Rubber, Line, Rect, Circle, HandLine, FilledHandLine, Text, Polygon, Select }; GView(QGraphicsScene* scene, QWidget* parent = 0); void setLineWidth(int i); void setLineColor(QColor color); QColor getLineColor(); void setBrushColor(QColor color); QColor getBrushColor(); void setMode(Mode mode); void mouseMoveEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); QGraphicsItem* getItem(const QString id) const; void addItem(QGraphicsItem* item, QString id); void setIDPrefix(QString prefix); void clear(); public slots: void moveUpSelectedItem(); void moveDownSelectedItem(); private: QString getNewID(); int zValue; bool mousePressed; QPen pen; QBrush brush; Mode mode; QGraphicsItem* lastItem; QGraphicsRectItem* selectionRect; TextDialog* textDialog; QMap items_; SimpleIDGenerator idGenerator; QString idPrefix; signals: void lastItemChanged(QGraphicsItem* item); }; }