summaryrefslogtreecommitdiffstats
path: root/shared/flickablearea.h
blob: 37d657948cefd3d436746faaf8c680dc9b8c0013 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: qt-info@nokia.com
**
** This software, including documentation, is protected by copyright
** controlled by Nokia Corporation.  You may use this software in
** accordance with the terms and conditions contained in the Qt Phone
** Demo License Agreement.
**
****************************************************************************/

#ifndef FLICKABLEAREA_H
#define FLICKABLEAREA_H

#include <QGraphicsWidget>


class FlickableArea : public QGraphicsWidget
{
    Q_OBJECT

public:
    FlickableArea(QGraphicsItem *parent = 0);

    bool isFlickable() const;
    void setFlickable(bool enabled);

    int threshold(Qt::Orientation orientation) const;
    void setThreshold(Qt::Orientation orientation, int value);

    QRectF flickableRect() const;
    void setFlickableRect(const QRectF &rect);

protected:
    bool eventFilter(QObject *object, QEvent *event);
    QVariant itemChange(GraphicsItemChange change, const QVariant &value);

    virtual void mouseSlideStarted(const QPointF &pos) = 0;
    virtual void mouseSlideMoved(const QPointF &pos) = 0;
    virtual void mouseSlideFinished(const QPointF &pos) = 0;

private:
    int m_hthreshold;
    int m_vthreshold;
    bool m_isPressed;
    bool m_isSliding;
    bool m_isFlickable;
    QPointF m_clickPos;
    QRectF m_flickableRect;
};

#endif