33 #include "hbeffectinternal_p.h" |
33 #include "hbeffectinternal_p.h" |
34 #define HB_GROUPBOX_HEADING_TYPE "HB_GROUPBOX_HEADING" |
34 #define HB_GROUPBOX_HEADING_TYPE "HB_GROUPBOX_HEADING" |
35 #endif |
35 #endif |
36 #ifdef HB_GESTURE_FW |
36 #ifdef HB_GESTURE_FW |
37 #include <hbtapgesture.h> |
37 #include <hbtapgesture.h> |
|
38 #include <hbnamespace_p.h> |
38 #include <QGesture> |
39 #include <QGesture> |
|
40 #include <QGraphicsScene> |
39 #endif |
41 #endif |
40 |
42 |
41 #include <QGraphicsSceneMouseEvent> |
43 #include <QGraphicsSceneMouseEvent> |
42 |
44 |
43 /* |
45 /* |
53 HbGroupBoxHeadingWidget::HbGroupBoxHeadingWidget( QGraphicsItem *parent ) : |
55 HbGroupBoxHeadingWidget::HbGroupBoxHeadingWidget( QGraphicsItem *parent ) : |
54 HbWidget( parent ), |
56 HbWidget( parent ), |
55 mIconItem( 0 ), |
57 mIconItem( 0 ), |
56 mTextItem( 0 ), |
58 mTextItem( 0 ), |
57 mBackgroundItem( 0 ), |
59 mBackgroundItem( 0 ), |
58 collapsable( true ), |
|
59 collapsed( false), |
|
60 marqueeEnabled( false ), |
60 marqueeEnabled( false ), |
61 headingPressed(false), |
61 headingPressed(false), |
62 groupBoxType( GroupBoxTypeUnknown ) |
62 groupBoxType( GroupBoxTypeUnknown ) |
63 { |
63 { |
64 groupBox = qgraphicsitem_cast<HbGroupBox*>( parent ); |
64 groupBox = qgraphicsitem_cast<HbGroupBox*>( parent ); |
78 internal |
78 internal |
79 init |
79 init |
80 */ |
80 */ |
81 void HbGroupBoxHeadingWidget::init( ) |
81 void HbGroupBoxHeadingWidget::init( ) |
82 { |
82 { |
83 |
|
84 createPrimitives( ); |
83 createPrimitives( ); |
85 if ( groupBoxType == GroupBoxCollapsingContainer ){ |
|
86 createConnection( ); |
|
87 } |
|
88 #ifdef HB_GESTURE_FW |
84 #ifdef HB_GESTURE_FW |
89 grabGesture( Qt::TapGesture ); |
85 grabGesture( Qt::TapGesture ); |
90 #endif |
86 #endif |
91 } |
87 } |
92 |
88 |
93 /* |
89 /* |
94 create primitives |
90 create primitives |
95 */ |
91 */ |
96 void HbGroupBoxHeadingWidget::createPrimitives() |
92 void HbGroupBoxHeadingWidget::createPrimitives() |
97 { |
93 { |
98 if( groupBoxType == GroupBoxCollapsingContainer && collapsable ){ |
94 if( groupBoxType == GroupBoxCollapsingContainer && groupBox->isCollapsable() ){ |
99 if ( !mIconItem ) { |
95 if ( !mIconItem ) { |
100 mIconItem = style( )->createPrimitive( HbStyle::P_GroupBoxHeading_icon , this ); |
96 mIconItem = style( )->createPrimitive( HbStyle::P_GroupBoxHeading_icon , this ); |
101 } |
97 } |
102 } |
98 } |
103 else if ( mIconItem ) { |
99 else if ( mIconItem ) { |
179 } |
175 } |
180 |
176 |
181 if( groupBoxType == GroupBoxCollapsingContainer ){ |
177 if( groupBoxType == GroupBoxCollapsingContainer ){ |
182 createConnection(); |
178 createConnection(); |
183 // collapsed is false by default for CollapsingContainer |
179 // collapsed is false by default for CollapsingContainer |
184 collapsed = false; |
180 //collapsed = false; |
185 // marquee is disabled by default for CollapsingContainer |
181 // marquee is disabled by default for CollapsingContainer |
186 marqueeEnabled = false; |
182 marqueeEnabled = false; |
187 } |
183 } |
188 |
184 |
189 if( groupBoxType == GroupBoxSimpleLabel ){ |
185 if( groupBoxType == GroupBoxSimpleLabel ){ |
198 internal |
194 internal |
199 Sets the groupbox heading widgets text |
195 Sets the groupbox heading widgets text |
200 */ |
196 */ |
201 void HbGroupBoxHeadingWidget::setHeading( const QString &text ) |
197 void HbGroupBoxHeadingWidget::setHeading( const QString &text ) |
202 { |
198 { |
203 if( headingText == text ) |
199 if( headingText != text ){ |
204 return; |
200 headingText = text; |
205 |
201 |
206 headingText = text; |
202 HbStyleOptionGroupBox groupBoxOption; |
207 |
203 initStyleOption( &groupBoxOption ); |
208 HbStyleOptionGroupBox groupBoxOption; |
204 if ( groupBoxType == GroupBoxCollapsingContainer ) { |
209 initStyleOption( &groupBoxOption ); |
205 style( )->updatePrimitive( mTextItem , HbStyle::P_GroupBoxHeading_text , &groupBoxOption ); |
210 if ( groupBoxType == GroupBoxCollapsingContainer ) { |
206 } |
211 style( )->updatePrimitive( mTextItem , HbStyle::P_GroupBoxHeading_text , &groupBoxOption ); |
207 else { |
212 } |
208 style( )->updatePrimitive( mTextItem , HbStyle::P_GroupBoxMarquee_text , &groupBoxOption ); |
213 else { |
209 } |
214 style( )->updatePrimitive( mTextItem , HbStyle::P_GroupBoxMarquee_text , &groupBoxOption ); |
|
215 } |
210 } |
216 } |
211 } |
217 |
212 |
218 /*! |
213 /*! |
219 internal |
214 internal |
220 Sets marquee for groupbox heading |
215 Sets marquee for groupbox heading |
221 */ |
216 */ |
222 void HbGroupBoxHeadingWidget::setMarqueeHeading( bool marquee ) |
217 void HbGroupBoxHeadingWidget::setMarqueeHeading( bool marquee ) |
223 { |
218 { |
224 if( marqueeEnabled == marquee ) |
219 if( marqueeEnabled != marquee ){ |
225 return; |
220 marqueeEnabled = marquee; |
226 |
221 |
227 marqueeEnabled = marquee; |
222 HbStyleOptionGroupBox groupBoxOption; |
228 |
223 initStyleOption( &groupBoxOption ); |
229 HbStyleOptionGroupBox groupBoxOption; |
224 style()->updatePrimitive( mTextItem, HbStyle::P_GroupBoxMarquee_text, &groupBoxOption); |
230 initStyleOption( &groupBoxOption ); |
225 } |
231 style()->updatePrimitive( mTextItem, HbStyle::P_GroupBoxMarquee_text, &groupBoxOption); |
|
232 } |
226 } |
233 |
227 |
234 /*! |
228 /*! |
235 |
229 |
236 \deprecated HbGroupBoxHeadingWidget::primitive(HbStyle::Primitive) |
230 \deprecated HbGroupBoxHeadingWidget::primitive(HbStyle::Primitive) |
261 to fill in all the information themselves. |
255 to fill in all the information themselves. |
262 */ |
256 */ |
263 void HbGroupBoxHeadingWidget::initStyleOption( HbStyleOptionGroupBox *option ) const |
257 void HbGroupBoxHeadingWidget::initStyleOption( HbStyleOptionGroupBox *option ) const |
264 { |
258 { |
265 HbWidget::initStyleOption( option ); |
259 HbWidget::initStyleOption( option ); |
266 option->collapsed = collapsed; |
260 //option->collapsed = collapsed; |
|
261 option->collapsed = groupBox->isCollapsed(); |
267 option->heading = headingText; |
262 option->heading = headingText; |
268 option->marqueeEnabled = marqueeEnabled; |
263 option->marqueeEnabled = marqueeEnabled; |
269 // state & type info reqd fo background primitve updation |
264 // state & type info reqd fo background primitve updation |
270 if ( headingPressed ) { |
265 if ( headingPressed ) { |
271 option->state = QStyle::State_On; |
266 option->state = QStyle::State_On; |
282 \reimp |
277 \reimp |
283 */ |
278 */ |
284 QVariant HbGroupBoxHeadingWidget::itemChange( GraphicsItemChange change, const QVariant &value ) |
279 QVariant HbGroupBoxHeadingWidget::itemChange( GraphicsItemChange change, const QVariant &value ) |
285 { |
280 { |
286 switch ( change ) { |
281 switch ( change ) { |
287 case ItemVisibleHasChanged: { |
282 case ItemVisibleChange: |
288 /*if (value.toBool() == true){ |
283 case ItemSceneHasChanged: |
289 if (mTextItem) { |
|
290 HbStyleOptionGroupBox groupBoxOption; |
|
291 initStyleOption(&groupBoxOption); |
|
292 style()->updatePrimitive( mTextItem, HbStyle::P_GroupBoxHeading_text, &groupBoxOption); |
|
293 } |
|
294 }*/ |
|
295 } |
|
296 break; |
|
297 |
|
298 case ItemSceneHasChanged: { |
|
299 if(!value.isNull()) |
|
300 |
|
301 |
|
302 updatePrimitives(); |
284 updatePrimitives(); |
303 } |
285 break; |
304 break; |
|
305 |
|
306 case ItemChildAddedChange: |
286 case ItemChildAddedChange: |
307 case ItemChildRemovedChange: |
287 case ItemChildRemovedChange: |
308 repolish(); |
288 repolish(); |
309 break; |
289 break; |
310 default: |
290 default: |
387 { |
367 { |
388 if(HbTapGesture *tap = qobject_cast<HbTapGesture*>( event->gesture( Qt::TapGesture ) ) ) { |
368 if(HbTapGesture *tap = qobject_cast<HbTapGesture*>( event->gesture( Qt::TapGesture ) ) ) { |
389 switch( tap->state() ) { |
369 switch( tap->state() ) { |
390 case Qt::GestureStarted: // |
370 case Qt::GestureStarted: // |
391 { |
371 { |
392 if ( !collapsable ){ |
372 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),Qt::TapGesture); |
|
373 if (!tap->property(HbPrivate::ThresholdRect.latin1()).toRect().isValid()) { |
|
374 tap->setProperty(HbPrivate::ThresholdRect.latin1(), mapRectToScene(boundingRect()).toRect()); |
|
375 } |
|
376 |
|
377 if ( !(groupBox->isCollapsable( )) ){ |
393 event->ignore( tap ); |
378 event->ignore( tap ); |
394 return; |
379 return; |
395 } |
380 } |
396 if ( collapsable ) { |
381 if ( groupBox->isCollapsable( ) ) { |
397 HbWidgetFeedback::triggered( this, Hb::InstantPressed, Hb::ModifierCollapsedItem ); |
382 HbWidgetFeedback::triggered( this, Hb::InstantPressed, Hb::ModifierCollapsedItem ); |
398 } |
383 } |
399 else { |
384 else { |
400 HbWidgetFeedback::triggered( this, Hb::InstantPressed ); |
385 HbWidgetFeedback::triggered( this, Hb::InstantPressed ); |
401 } |
386 } |
411 } |
396 } |
412 |
397 |
413 break; |
398 break; |
414 case Qt::GestureCanceled: // Reset state |
399 case Qt::GestureCanceled: // Reset state |
415 { |
400 { |
|
401 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant()); |
|
402 |
416 headingPressed = false; |
403 headingPressed = false; |
417 |
404 |
418 HbStyleOptionGroupBox groupBoxOption; |
405 HbStyleOptionGroupBox groupBoxOption; |
419 initStyleOption( &groupBoxOption ); |
406 initStyleOption( &groupBoxOption ); |
420 style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption ); |
407 style()->updatePrimitive( mBackgroundItem , HbStyle::P_GroupBoxHeading_background , &groupBoxOption ); |
422 setProperty( "state", "normal" ); |
409 setProperty( "state", "normal" ); |
423 break; |
410 break; |
424 } |
411 } |
425 case Qt::GestureFinished: // emit clicked |
412 case Qt::GestureFinished: // emit clicked |
426 { |
413 { |
427 if ( collapsable ) { |
414 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant()); |
|
415 |
|
416 if ( groupBox->isCollapsable( ) ) { |
428 HbWidgetFeedback::triggered( this, Hb::InstantReleased, Hb::ModifierCollapsedItem ); |
417 HbWidgetFeedback::triggered( this, Hb::InstantReleased, Hb::ModifierCollapsedItem ); |
429 } else { |
418 } else { |
430 HbWidgetFeedback::triggered( this, Hb::InstantReleased ); |
419 HbWidgetFeedback::triggered( this, Hb::InstantReleased ); |
431 } |
420 } |
432 |
421 |
434 if ( mIconItem && mIconItem->isUnderMouse( ) ) { |
423 if ( mIconItem && mIconItem->isUnderMouse( ) ) { |
435 #ifdef HB_EFFECTS |
424 #ifdef HB_EFFECTS |
436 HbEffect::start( mIconItem, HB_GROUPBOX_HEADING_TYPE, "iconclick" ); |
425 HbEffect::start( mIconItem, HB_GROUPBOX_HEADING_TYPE, "iconclick" ); |
437 #endif |
426 #endif |
438 } |
427 } |
439 emit clicked( !collapsed ); |
428 emit clicked( !(groupBox->isCollapsed()) ); |
440 } |
429 } |
441 // background primitive updation, upon mouse release |
430 // background primitive updation, upon mouse release |
442 headingPressed = false; |
431 headingPressed = false; |
443 |
432 |
444 HbStyleOptionGroupBox groupBoxOption; |
433 HbStyleOptionGroupBox groupBoxOption; |