##// END OF EJS Templates
Add missing include for QObject...
Samuli Piippo -
r2731:450ab64fa5cd
parent child
Show More
@@ -1,109 +1,110
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2014 Digia Plc
3 ** Copyright (C) 2014 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the Qt Enterprise Chart API. It exists purely as an
24 // This file is not part of the Qt Enterprise Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef SCROLLER_P_H
30 #ifndef SCROLLER_P_H
31 #define SCROLLER_P_H
31 #define SCROLLER_P_H
32
32
33 #include <QtCharts/QChartGlobal>
33 #include <QtCharts/QChartGlobal>
34 #include <QtCore/QObject>
34 #include <QtCore/QBasicTimer>
35 #include <QtCore/QBasicTimer>
35 #include <QtCore/QTime>
36 #include <QtCore/QTime>
36 #include <QtCore/QPointF>
37 #include <QtCore/QPointF>
37
38
38 class QGraphicsSceneMouseEvent;
39 class QGraphicsSceneMouseEvent;
39
40
40 QT_CHARTS_BEGIN_NAMESPACE
41 QT_CHARTS_BEGIN_NAMESPACE
41
42
42 class Scroller;
43 class Scroller;
43 class QLegend;
44 class QLegend;
44
45
45 class ScrollTicker : public QObject
46 class ScrollTicker : public QObject
46 {
47 {
47 Q_OBJECT
48 Q_OBJECT
48 public:
49 public:
49 explicit ScrollTicker(Scroller *scroller, QObject *parent = 0);
50 explicit ScrollTicker(Scroller *scroller, QObject *parent = 0);
50 void start(int interval);
51 void start(int interval);
51 void stop();
52 void stop();
52 protected:
53 protected:
53 void timerEvent(QTimerEvent *event);
54 void timerEvent(QTimerEvent *event);
54
55
55 private:
56 private:
56 QBasicTimer m_timer;
57 QBasicTimer m_timer;
57 Scroller *m_scroller;
58 Scroller *m_scroller;
58 };
59 };
59
60
60 class Scroller
61 class Scroller
61 {
62 {
62 public:
63 public:
63 enum State {
64 enum State {
64 Idle,
65 Idle,
65 Pressed,
66 Pressed,
66 Move,
67 Move,
67 Scroll
68 Scroll
68 };
69 };
69
70
70 Scroller();
71 Scroller();
71 virtual ~Scroller();
72 virtual ~Scroller();
72
73
73 virtual void setOffset(const QPointF &point) = 0;
74 virtual void setOffset(const QPointF &point) = 0;
74 virtual QPointF offset() const = 0;
75 virtual QPointF offset() const = 0;
75
76
76 void move(const QPointF &delta);
77 void move(const QPointF &delta);
77 void scrollTo(const QPointF &delta);
78 void scrollTo(const QPointF &delta);
78
79
79 void handleMousePressEvent(QGraphicsSceneMouseEvent *event);
80 void handleMousePressEvent(QGraphicsSceneMouseEvent *event);
80 void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event);
81 void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event);
81 void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
82 void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
82
83
83 void scrollTick();
84 void scrollTick();
84
85
85 private:
86 private:
86 void startTicker(int interval);
87 void startTicker(int interval);
87 void stopTicker();
88 void stopTicker();
88
89
89 private:
90 private:
90 void calculateSpeed(const QPointF &position);
91 void calculateSpeed(const QPointF &position);
91 void lowerSpeed(QPointF &speed, qreal maxSpeed = 100);
92 void lowerSpeed(QPointF &speed, qreal maxSpeed = 100);
92
93
93 private:
94 private:
94 ScrollTicker m_ticker;
95 ScrollTicker m_ticker;
95 QTime m_timeStamp;
96 QTime m_timeStamp;
96 QPointF m_speed;
97 QPointF m_speed;
97 QPointF m_fraction;
98 QPointF m_fraction;
98 int m_timeTresholdMin;
99 int m_timeTresholdMin;
99 int m_timeTresholdMax;
100 int m_timeTresholdMax;
100
101
101 State m_state;
102 State m_state;
102 QPointF m_pressPos;
103 QPointF m_pressPos;
103 QPointF m_lastPos;
104 QPointF m_lastPos;
104 qreal m_treshold;
105 qreal m_treshold;
105 };
106 };
106
107
107 QT_CHARTS_END_NAMESPACE
108 QT_CHARTS_END_NAMESPACE
108
109
109 #endif /* SCROLLER_P_H */
110 #endif /* SCROLLER_P_H */
General Comments 0
You need to be logged in to leave comments. Login now