~faenil/ubuntu-ui-toolkit/flickableBasedScrollView

« back to all changes in this revision

Viewing changes to src/Ubuntu/Components/plugin/privates/gesturedetector.h

  • Committer: Andrea Bernabei
  • Date: 2015-11-25 11:50:10 UTC
  • mfrom: (1681.2.44 staging)
  • Revision ID: andrea.bernabei@canonical.com-20151125115010-vpxkm2lze1hav9q9
mergeĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2015 Canonical Ltd.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU Lesser General Public License as published by
6
 
 * the Free Software Foundation; version 3.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU Lesser General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU Lesser General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Authors: Zsombor Egri <zsombor.egri@canonical.com>
17
 
 */
18
 
 
19
 
#ifndef GESTUREDETECTOR_H
20
 
#define GESTUREDETECTOR_H
21
 
 
22
 
#include <QtCore/QObject>
23
 
#include <QtCore/QPointF>
24
 
#include <QtCore/QList>
25
 
 
26
 
/*
27
 
 * A simple gesture detection filter class that can be used in components to detect
28
 
 * various gestures. Yet swipe from bottom up is the only gesture handled.
29
 
 * It does not grab or consume the event from the environment, acts as a filter.
30
 
 */
31
 
class QTouchEvent;
32
 
class QQuickItem;
33
 
class GestureDetector : public QObject
34
 
{
35
 
    Q_OBJECT
36
 
public:
37
 
    enum Status {
38
 
        Ready,
39
 
        Started,
40
 
        Detected,
41
 
        Completed
42
 
    };
43
 
    explicit GestureDetector(QObject *parent = 0);
44
 
    ~GestureDetector();
45
 
 
46
 
    bool isDetecting();
47
 
 
48
 
    void setItemFilter(QObject *item);
49
 
    void removeItemFilter(QObject *item);
50
 
 
51
 
    bool handleTouchEvent(QObject *target, QTouchEvent *event);
52
 
 
53
 
Q_SIGNALS:
54
 
    void statusChanged(Status status);
55
 
 
56
 
    void bottomUpSwipeDetected();
57
 
 
58
 
public Q_SLOTS:
59
 
 
60
 
protected:
61
 
    bool eventFilter(QObject *target, QEvent *event);
62
 
 
63
 
    void setStatus(Status status);
64
 
 
65
 
private:
66
 
    QList<QObject*> m_filteredItems;
67
 
    QPointF m_startPoint;
68
 
    QQuickItem *m_owner;
69
 
    Status m_status;
70
 
    bool m_bottomUpSwipeDetected:1;
71
 
};
72
 
 
73
 
#endif // GESTUREDETECTOR_H