/***************************************************************************
 *   Copyright 2007-2008 Wouter Haffmans <cheetah@simply-life.net>         *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU General Public License as        *
 *   published by the Free Software Foundation; either version 2 of        *
 *   the License or (at your option) version 3 or any later version        *
 *   accepted by the membership of KDE e.V. (or its successor approved     *
 *   by the membership of KDE e.V.), which shall act as a proxy            *
 *   defined in Section 14 of version 3 of the license.                    *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ***************************************************************************/

#ifndef GRAPHICSLINESITEM_H
#define GRAPHICSLINESITEM_H

#include <QAbstractGraphicsShapeItem>

/**
 * This graphics item draws lines from one point to the next and so on. It's
 * similar to a polygon item, except that it will not be closed at the end, and
 * that the item is not filled with the brush.
 */
class GraphicsLinesItem : public QAbstractGraphicsShapeItem
{
public:
    explicit GraphicsLinesItem(QGraphicsItem *parent = 0);
    explicit GraphicsLinesItem(const QVector<QPointF> points, QGraphicsItem *parent = 0);
    explicit GraphicsLinesItem(const QPointF point, QGraphicsItem *parent = 0);

    ~GraphicsLinesItem();

    QVector<QPointF> points() const;

    virtual void paint(QPainter *painter,
            const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
    virtual QPainterPath shape() const;
    virtual QRectF boundingRect() const;

    void    setPoints(QVector<QPointF> points);
    void    addPoint(QPointF point);

    qint16  tag() const;
    void    setTag(qint16 tag);

private:
    QVector<QPointF> m_points;
    QPainterPath    m_path; // Cached path
    QRectF          m_boundingRect; // Cached bounding rectangle
    qint16          m_tag; // Arbitrary tag
};

#endif
