aboutsummaryrefslogtreecommitdiff
path: root/src/views/msliderview.h
blob: f5bb05cf46abbb1d23adab91b52bff0d779969a1 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#ifndef MSLIDERVIEW_H
#define MSLIDERVIEW_H

#include "mwidgetview.h"
#include <mslidermodel.h>
#include <msliderstyle.h>

class MSliderViewPrivate;
class MSlider;

/*!
    \class MSliderView
    \brief Standard view is used to visualize sliders and seekbars.

    \ingroup views

    \section MSliderViewOverview Overview
        Slider view class renders slider and seekbars.

        Outlook of sliders and seekbars can be changed using the styling
        attributes defined in MSliderStyle and MWidgetStyle.

    \section MSliderViewInteractions Interactions
        A slider (seekbar) can be in one of the following functional states:
        - Released: default state.
        - Pressed: when slider handle is tapped.
        Tapping slider handle will catch it and then slider will fall into Pressed state.
        In this state slider handle follows tapping point (is dragged).
        Slider value is changed by draging slider handle to required place.
        If slider groove is tapped, slider thumb will be moved to that place
        and slider will fall into Pressed state.

    \section MSliderViewOpenIssues Open issues
        - Animated slider handle moving (when dragging or tapping slider groove) not supported yet.

    \sa MSliderStyle MWidgetView
*/

class M_EXPORT MSliderView : public MWidgetView
{
    Q_OBJECT
    M_VIEW(MSliderModel, MSliderStyle)

public:
    /*!
        \brief Constructs toolbar view.
        \param Pointer to the controller.
     */
    MSliderView(MSlider *controller);

    /*!
        \brief Destructs the view.
     */
    virtual ~MSliderView();

protected:
    /*!
        \brief Updates MSliderView class instance when current style is changed.

        Called when MSliderStyle class instance is changed (usually)
        during initialization.
     */
    virtual void applyStyle();

    /*!
        \brief Mouse press event handler.

        Accepted when clicking onto slider groove. Ignored clicking outside
        of slider groove. Timer event will be generated which set slider
        state to Pressed
     */
    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);

    /*!
        \brief Mouse press event handler.

        Releases slider handle. Slider falls back into Released state and
        MSlider::sliderReleased() signal is emitted.
     */
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

    /*!
        \brief Mouse move event handler.

        If slider is in pressed State drags slider thumb. As slider handle is dragged
        MSlider::valueChanged(int) signal is emitted.
     */
    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);

    /*!
        \brief Cancel event handler.

        Sets slider back to Released state.
     */
    virtual void cancelEvent(MCancelEvent *event);

    /*!
        \brief Updates MSliderView class instance when current model is changed.

        Called when MSliderModel (MSeekBarModel) class instance is changed
        (usually) during initialization.
     */
    virtual void setupModel();

    /*!
        \brief Updates MSliderView class instance when some component
                   of underlying model is modified.
        \param List containing the names of modified model components.

        Called when some field of underlying MSliderModel (MSeekBarModel)
        class instance is modified and view shuold reflect that modification.
     */
    virtual void updateData(const QList<const char *>& modifications);

    /*!
      \brief Timer event handler

      Called when timer event occures.
      */
    virtual void timerEvent(QTimerEvent* event);

    /*!
      \brief Timer event handler

      Called when timer event occures.
      */
    virtual void hideEvent(QHideEvent* event);

    MSliderViewPrivate *const d_ptr;

private:
    Q_DISABLE_COPY(MSliderView)
    Q_DECLARE_PRIVATE(MSliderView)

private Q_SLOTS:
    /*!
      \brief Lowers slider handle indicator
      */
    void lowerSliderHandleIndicator();

#ifdef UNIT_TEST
    //! Test unit is defined as a friend of production code to access private members
    friend class Ut_MSliderView;
#endif // UNIT_TEST

};

#endif