1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbWidgets module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #include "hbprogressiveslider.h" |
|
27 #include "hbprogressiveslider_p.h" |
|
28 #include "hbprogressslidercontrol_p.h" |
|
29 #include "hbstyleoption.h" |
|
30 #include "hbglobal_p.h" |
|
31 |
|
32 HbProgressiveSliderPrivate::HbProgressiveSliderPrivate() |
|
33 :mControl(0) |
|
34 { |
|
35 } |
|
36 |
|
37 |
|
38 HbProgressiveSliderPrivate::~HbProgressiveSliderPrivate() |
|
39 { |
|
40 } |
|
41 |
|
42 |
|
43 void HbProgressiveSliderPrivate::init() |
|
44 { |
|
45 } |
|
46 |
|
47 void HbProgressiveSliderPrivate::setOrientation(Qt::Orientation orientation) |
|
48 { |
|
49 mControl->setOrientation(orientation); |
|
50 HbProgressBarPrivate::setOrientation(orientation); |
|
51 } |
|
52 |
|
53 /*! |
|
54 \deprecated |
|
55 |
|
56 This class is deprecated and please use HbProgressSlider instead. |
|
57 |
|
58 */ |
|
59 |
|
60 /*! |
|
61 \deprecated HbProgressiveSlider::HbProgressiveSlider(QGraphicsItem *) |
|
62 is deprecated. |
|
63 |
|
64 Constructs a progressslider of a given \a parent. |
|
65 |
|
66 \sa HbRatingSlider |
|
67 */ |
|
68 HbProgressiveSlider::HbProgressiveSlider(QGraphicsItem *parent) : |
|
69 HbProgressBar(*new HbProgressiveSliderPrivate,HbProgressBar::SimpleProgressBar,parent) |
|
70 { |
|
71 HB_DEPRECATED("HbProgressiveSlider(QGraphicsItem *parent) is deprecated."); |
|
72 Q_D( HbProgressiveSlider ); |
|
73 d->q_ptr = this; |
|
74 d->init(); |
|
75 } |
|
76 |
|
77 /*! |
|
78 \deprecated HbProgressiveSlider::HbProgressiveSlider(HbProgressiveSliderPrivate &,QGraphicsItem *) |
|
79 is deprecated. |
|
80 |
|
81 Constructs a progressslider of a given \a parent. |
|
82 |
|
83 \sa HbRatingSlider |
|
84 */ |
|
85 HbProgressiveSlider::HbProgressiveSlider(HbProgressiveSliderPrivate &dd,QGraphicsItem *parent) : |
|
86 HbProgressBar( dd,HbProgressBar::SimpleProgressBar,parent) |
|
87 { |
|
88 HB_DEPRECATED("HbProgressiveSlider(HbProgressiveSliderPrivate &,QGraphicsItem *) is deprecated."); |
|
89 Q_D( HbProgressiveSlider ); |
|
90 d->init(); |
|
91 } |
|
92 |
|
93 |
|
94 /*! |
|
95 Destructor for the progressslider. |
|
96 */ |
|
97 HbProgressiveSlider::~HbProgressiveSlider() |
|
98 { |
|
99 } |
|
100 |
|
101 |
|
102 void HbProgressiveSlider::resizeEvent ( QGraphicsSceneResizeEvent * event ) |
|
103 { |
|
104 HbProgressBar::resizeEvent(event); |
|
105 } |
|
106 |
|
107 |
|
108 /*! |
|
109 Sets the current value of the progress slider. |
|
110 |
|
111 The progress slider forces the value to be within the legal range: \b |
|
112 minimum <= \c value <= \b maximum. |
|
113 |
|
114 \sa value() |
|
115 */ |
|
116 void HbProgressiveSlider::setSliderValue(int value) |
|
117 { |
|
118 Q_D( HbProgressiveSlider ); |
|
119 d->mControl->setValue(value); |
|
120 } |
|
121 |
|
122 /*! |
|
123 Returns the current slider value . |
|
124 |
|
125 The default value is \c 0. |
|
126 |
|
127 \sa setSliderValue() |
|
128 */ |
|
129 int HbProgressiveSlider::sliderValue() const |
|
130 { |
|
131 Q_D(const HbProgressiveSlider ); |
|
132 return d->mControl->value(); |
|
133 } |
|
134 |
|
135 |
|
136 /*! |
|
137 Returns \c true whether the slider is pressed down. |
|
138 */ |
|
139 |
|
140 bool HbProgressiveSlider::isSliderDown() const |
|
141 { |
|
142 return true; //TODO:do sometheing here |
|
143 } |
|
144 |
|
145 |
|
146 /*! |
|
147 set the tooltip text . |
|
148 \sa handleToolTip() |
|
149 */ |
|
150 void HbProgressiveSlider::setHandleToolTip(const QString &text) |
|
151 { |
|
152 Q_D(HbProgressiveSlider); |
|
153 d->mControl->setToolTip(text); |
|
154 } |
|
155 |
|
156 |
|
157 /*! |
|
158 Returns the current tooltip text value . |
|
159 \sa setHandleToolTip() |
|
160 */ |
|
161 QString HbProgressiveSlider::handleToolTip() const |
|
162 { |
|
163 Q_D(const HbProgressiveSlider); |
|
164 return d->mControl->toolTip(); |
|
165 } |
|
166 |
|
167 |
|
168 void HbProgressiveSlider::setInvertedAppearance(bool inverted) |
|
169 { |
|
170 Q_D( HbProgressiveSlider ); |
|
171 if(d->mControl->invertedAppearance() != inverted) { |
|
172 d->mControl->setInvertedAppearance(inverted); |
|
173 } |
|
174 HbProgressBar::setInvertedAppearance(inverted); |
|
175 } |
|
176 |
|
177 |
|
178 /*! |
|
179 Sets the Icon for the progressslider thumb. |
|
180 */ |
|
181 void HbProgressiveSlider::setThumbIcon(const HbIcon &icon) |
|
182 { |
|
183 Q_D( HbProgressiveSlider ); |
|
184 d->mControl->setHandleIcon(icon.iconName()); |
|
185 } |
|
186 |
|
187 HbIcon HbProgressiveSlider::thumbIcon() const |
|
188 { |
|
189 Q_D( const HbProgressiveSlider ); |
|
190 return HbIcon(d->mControl->handleIcon()); |
|
191 } |
|
192 |
|
193 /*! |
|
194 Returns \c true whether slider tracking is enabled. |
|
195 |
|
196 The default value is \c true. |
|
197 |
|
198 If tracking is enabled, the slider emits the |
|
199 valueChanged( ) signal while the slider is being dragged. If |
|
200 tracking is disabled, the slider emits the valueChanged( ) signal |
|
201 only when the user releases the slider. |
|
202 |
|
203 \sa HbSlider::setTracking( ) |
|
204 */ |
|
205 bool HbProgressiveSlider::hasTracking( ) const |
|
206 { |
|
207 Q_D( const HbProgressiveSlider ); |
|
208 return d->mControl->hasTracking( ); |
|
209 } |
|
210 |
|
211 /*! |
|
212 Sets whether the slider tracking is enabled. |
|
213 |
|
214 \sa HbSlider::hasTracking( ) |
|
215 */ |
|
216 void HbProgressiveSlider::setTracking( bool enable ) |
|
217 { |
|
218 Q_D( HbProgressiveSlider ); |
|
219 d->mControl->setTracking( enable ); |
|
220 } |
|
221 |
|
222 void HbProgressiveSlider::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
223 { |
|
224 Q_UNUSED(event);//TODO:check this |
|
225 } |
|
226 |
|
227 |
|
228 void HbProgressiveSlider::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
229 { |
|
230 Q_UNUSED(event); |
|
231 } |
|
232 |
|
233 void HbProgressiveSlider::setGeometry(const QRectF & rect) |
|
234 { |
|
235 Q_D(HbProgressiveSlider); |
|
236 HbProgressBar::setGeometry(rect); |
|
237 d->mControl->setGeometry(QRectF(0,0,rect.width(),rect.height())); |
|
238 } |
|
239 |
|
240 |
|
241 /*void HbProgressiveSlider::initStyleOption(HbStyleOption *hboption) const |
|
242 { |
|
243 HbProgressBar::initStyleOption(hboption); |
|
244 }*/ |
|
245 |
|
246 |
|
247 void HbProgressiveSlider::updatePrimitives() |
|
248 { |
|
249 HbProgressBar::updatePrimitives(); |
|
250 |
|
251 Q_D(HbProgressiveSlider); |
|
252 d->mControl->updatePrimitives(); |
|
253 |
|
254 |
|
255 } |
|
256 |
|
257 /*! |
|
258 Sets the Thumbwidget for the progressslider.If passes NULL it uses previously set thumbwidget |
|
259 \a Pointer to the widget to set as thumbitem.Ownership is transferred to slider. |
|
260 The thumb item can be hidden by setting QGraphicsItem::ItemIsFocusable flag to false. |
|
261 |
|
262 \sa thumbItem() |
|
263 */ |
|
264 void HbProgressiveSlider::setThumbItem(QGraphicsWidget* thumbItem) |
|
265 { |
|
266 Q_D(HbProgressiveSlider); |
|
267 |
|
268 if (HbWidget *widget = qobject_cast<HbWidget *>(thumbItem)) { |
|
269 widget->setAttribute(Hb::InteractionDisabled, true); |
|
270 } |
|
271 d->mControl->setHandleItem(thumbItem); |
|
272 if(!flags().testFlag(ItemIsFocusable)) { |
|
273 d->mControl->setHandleVisible(false); |
|
274 } |
|
275 } |
|
276 |
|
277 /*! |
|
278 Returns the Thumbwidget set as the thumbItem.Returns 0 if no thumb item set by user. |
|
279 \sa setThumbItem() |
|
280 */ |
|
281 QGraphicsWidget* HbProgressiveSlider::thumbItem() const |
|
282 { |
|
283 Q_D(const HbProgressiveSlider); |
|
284 |
|
285 return static_cast<QGraphicsWidget*>(d->mControl->handleItem()); |
|
286 } |
|
287 |
|
288 |
|
289 void HbProgressiveSlider::showEvent( QShowEvent * event ) |
|
290 { |
|
291 HbProgressBar::showEvent(event); |
|
292 } |
|
293 |
|
294 QVariant HbProgressiveSlider::itemChange(GraphicsItemChange change,const QVariant & value) |
|
295 { |
|
296 return HbProgressBar::itemChange(change, value); |
|
297 } |
|
298 |
|