121 void HbGroupBoxContentWidget::setType(GroupBoxType type) |
122 void HbGroupBoxContentWidget::setType(GroupBoxType type) |
122 { |
123 { |
123 if( groupBoxType != type ){ |
124 if( groupBoxType != type ){ |
124 groupBoxType = type; |
125 groupBoxType = type; |
125 // set dynamic properties for type |
126 // set dynamic properties for type |
126 if(groupBoxType == GroupBoxCollapsingContainer) |
127 if(groupBoxType == GroupBoxCollapsingContainer){ |
127 setProperty("groupBoxType",3); |
128 setProperty("groupBoxType",3); |
128 else if(groupBoxType == GroupBoxRichLabel) |
129 } |
|
130 else if(groupBoxType == GroupBoxRichLabel){ |
|
131 contentPressed = false; |
129 setProperty("groupBoxType",2); |
132 setProperty("groupBoxType",2); |
130 |
133 } |
131 if(groupBoxType != GroupBoxSimpleLabel){ |
134 if(groupBoxType != GroupBoxSimpleLabel){ |
132 createPrimitives(); |
135 createPrimitives(); |
133 //createConnection(); |
136 //createConnection(); |
134 } |
137 } |
135 } |
138 } |
140 |
143 |
141 Sets HbGroupBoxContentWidget content |
144 Sets HbGroupBoxContentWidget content |
142 */ |
145 */ |
143 void HbGroupBoxContentWidget::setContentWidget( HbWidget *widget ) |
146 void HbGroupBoxContentWidget::setContentWidget( HbWidget *widget ) |
144 { |
147 { |
145 if ( widget == mContent ) { |
148 if ( widget != mContent ) { |
146 return; |
149 // delete old content set |
147 } |
150 if ( mContent ) { |
148 |
151 delete mContent; |
149 // delete old content set |
152 mContent = 0; |
150 if ( mContent ) { |
153 } |
151 delete mContent; |
154 mContent = widget; |
152 mContent = 0; |
155 style()->setItemName( mContent , "content" ); |
153 } |
156 mContent->setParentItem( this); |
154 // if NULL widget is passed don't do anything |
|
155 if ( !widget ) { |
|
156 return; |
|
157 } |
|
158 |
|
159 mContent = widget; |
|
160 style()->setItemName( mContent , "content" ); |
|
161 mContent->setParentItem( this); |
|
162 |
|
163 if(groupBoxType == GroupBoxRichLabel){ |
|
164 contentPressed = false; |
|
165 } |
157 } |
166 } |
158 } |
167 |
159 |
168 /*! |
160 /*! |
169 Returns the pointer for \a primitive passed. |
161 Returns the pointer for \a primitive passed. |
274 void HbGroupBoxContentWidget::gestureEvent(QGestureEvent *event) |
267 void HbGroupBoxContentWidget::gestureEvent(QGestureEvent *event) |
275 { |
268 { |
276 if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
269 if(HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { |
277 switch(tap->state()) { |
270 switch(tap->state()) { |
278 case Qt::GestureStarted: // |
271 case Qt::GestureStarted: // |
|
272 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),Qt::TapGesture); |
|
273 if (!tap->property(HbPrivate::ThresholdRect.latin1()).toRect().isValid()) { |
|
274 tap->setProperty(HbPrivate::ThresholdRect.latin1(), mapRectToScene(boundingRect()).toRect()); |
|
275 } |
|
276 |
279 contentPressed=true; |
277 contentPressed=true; |
280 updatePrimitives(); |
278 updatePrimitives(); |
281 break; |
279 break; |
282 case Qt::GestureCanceled: // Reset state |
280 case Qt::GestureCanceled: // Reset state |
|
281 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant()); |
|
282 |
283 contentPressed=false; |
283 contentPressed=false; |
284 updatePrimitives(); |
284 updatePrimitives(); |
285 break; |
285 break; |
286 case Qt::GestureUpdated: |
286 case Qt::GestureUpdated: |
287 if(tap->tapStyleHint() == HbTapGesture::TapAndHold) { |
287 if(tap->tapStyleHint() == HbTapGesture::TapAndHold) { |
288 emit longPress(event->mapToGraphicsScene(tap->position())); |
288 emit longPress(event->mapToGraphicsScene(tap->position())); |
289 } |
289 } |
290 break; |
290 break; |
291 case Qt::GestureFinished: // emit clicked |
291 case Qt::GestureFinished: // emit clicked |
|
292 scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant()); |
292 contentPressed=false; |
293 contentPressed=false; |
293 updatePrimitives(); |
294 updatePrimitives(); |
294 if(tap->tapStyleHint() == HbTapGesture::Tap) { |
295 if(tap->tapStyleHint() == HbTapGesture::Tap) { |
295 emit clicked(); |
296 emit clicked(); |
296 } |
297 } |