#ifndef TOURPLAYERITEM_H #define TOURPLAYERITEM_H #include #include #include class DrawType : public QObject { Q_OBJECT Q_PROPERTY(int type READ type WRITE setType NOTIFY typeChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) public: explicit DrawType(QObject* parent = Q_NULLPTR) : QObject(parent) , m_type(0) , m_color(Qt::transparent) {} bool isValid() const { return (m_color.value() != 0) && (m_type != 0); } int type() const { return m_type; } QColor color() const { return m_color; } public slots: void setType(int type) { if (m_type == type) return; m_type = type; emit typeChanged(m_type); } void setColor(const QColor &color) { if (m_color == color) return; m_color = color; emit colorChanged(m_color); } signals: void typeChanged(int type); void colorChanged(const QColor &color); private: int m_type; QColor m_color; }; class TourPlayerItem : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(QQmlListProperty drawTypes READ drawTypes) public: enum DrawTypes { DrawTypeNormal=1, DrawTypeBackward, DrawTypeWorkRegion, DrawTypeContainerRegionSingle, DrawTypeContainerRegionDouble, DrawTypeOffline, }; Q_ENUM(DrawTypes) public: explicit TourPlayerItem(QQuickItem *parent = Q_NULLPTR); QQmlListProperty drawTypes(); void appendDrawType(DrawType* drawType); int drawTypeCount() const; DrawType *drawType(int index) const; void clearDrawTypes(); static QString drawTypeToString(int value); // QQuickPaintedItem interface public: virtual void paint(QPainter *painter) Q_DECL_OVERRIDE; signals: public slots: private: static void appendDrawType(QQmlListProperty* prop, DrawType* drawType); static int drawTypeCount(QQmlListProperty* prop); static DrawType* drawType(QQmlListProperty* prop, int index); static void clearDrawTypes(QQmlListProperty* prop); private: QVector m_drawTypes; bool m_isValid; }; #endif // TOURPLAYERITEM_H