--- a/src/hbwidgets/widgets/hbcombobox_p.cpp Tue Jul 06 14:36:53 2010 +0300
+++ b/src/hbwidgets/widgets/hbcombobox_p.cpp Wed Aug 18 10:05:37 2010 +0300
@@ -84,10 +84,14 @@
return;
}
- if ( !mDropDown->scene() || !mDropDown->scene( )->property( "destructed" ).isValid( ) ) {
- delete mDropDown;
- mDropDown = 0;
+ //if drop down is added to scene then remove it from scene so that scene does not deletes
+ //drop down again
+ if( mDropDown->scene() ) {
+ q->scene()->removeItem(mDropDown);
}
+
+ delete mDropDown;
+ mDropDown = 0;
}
void HbComboBoxPrivate::init( )
@@ -99,16 +103,16 @@
{
Q_Q( HbComboBox );
- mTextItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_text, q );
+ mTextItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBox_text, q );
HbStyle::setItemName( mTextItem, "combobox_labelfield" );
- mBackgroundItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_background, q );
+ mBackgroundItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBox_background, q );
HbStyle::setItemName( mBackgroundItem, "text_background" );
- mButton = q->style( )->createPrimitive( HbStyle::P_ComboBox_button, q );
+ mButton = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBox_button, q );
HbStyle::setItemName( mButton, "combobox_button" );
- mButtonTouchAreaItem = q->style( )->createPrimitive( HbStyle::P_ComboBoxButton_toucharea, q );
+ mButtonTouchAreaItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_ComboBoxButton_toucharea, q );
static_cast<HbTouchArea*>( mButtonTouchAreaItem )->grabGesture( Qt::TapGesture );
}
@@ -121,7 +125,10 @@
}
mIsDown = true;
q->updatePrimitives( );
- q->setProperty( "state", "pressed" );
+ //Update the state only when valid model is there
+ if ( mModel && mModel->rowCount( ) ) {
+ q->setProperty( "state", "pressed" );
+ }
}
void HbComboBoxPrivate::touchAreaReleaseEvent( )
@@ -238,6 +245,22 @@
}
}
+void HbComboBoxPrivate::resetGeometryChangeFlag( )
+{
+ Q_Q( HbComboBox );
+ QGraphicsWidget *p = q;
+ if( widgetGeometryChange.count() > 0 ) {
+ while ( p->parentWidget( ) ) {
+ p = p->parentWidget( );
+ if ( !widgetGeometryChange.value( p ) ) {
+ //if earlier geometry change flag was disabled then disable this flag
+ p->setFlag( QGraphicsItem::ItemSendsGeometryChanges, false );
+ }
+ }
+ widgetGeometryChange.clear();
+ }
+}
+
void HbComboBoxPrivate::positionDropDown( )
{
Q_Q( HbComboBox );
@@ -253,7 +276,7 @@
if( q->mainWindow( )->orientation( ) == Qt::Horizontal ) {
if( mDropDownRowsInLandscape == -1 ) {
HbStyleParameters params;
- q->style( )->parameters( params );
+ q->style()->parameters( params );
params.addParameter( "max-rows-in-dropdown" );
q->polish( params );
mDropDownRowsInLandscape = params.value( "max-rows-in-dropdown" ).toInt( );
@@ -262,7 +285,7 @@
} else if( q->mainWindow( )->orientation( ) == Qt::Vertical ) {
if( mDropDownRowsInPortrait == -1 ) {
HbStyleParameters params;
- q->style( )->parameters( params );
+ q->style()->parameters( params );
params.addParameter( "max-rows-in-dropdown" );
q->polish( params );
mDropDownRowsInPortrait = params.value( "max-rows-in-dropdown" ).toInt( );
@@ -388,6 +411,15 @@
QGraphicsWidget *p = q;
while ( p->parentWidget( ) ) {
p = p->parentWidget( );
+ //cache the original geometry change flag of parent widget
+ QGraphicsItem::GraphicsItemFlags itemFlags = p->flags( );
+ bool geometryFlagEnabled = itemFlags & QGraphicsItem::ItemSendsGeometryChanges;
+ widgetGeometryChange.insert(p, geometryFlagEnabled);
+
+ //This flag is being set since geometry change notification is required for properly
+ //positioning drop down when its visible and combobox position is changed for example
+ //when orientation change happens.
+ p->setFlag( QGraphicsItem::ItemSendsGeometryChanges );
}
mDropDown->setZValue( p->zValue( ) + 1 );
}
@@ -403,7 +435,7 @@
} else {
HbStyleOptionComboBox comboBoxOption;
q->initStyleOption( &comboBoxOption );
- q->style( )->updatePrimitive( mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption );
+ HbStylePrivate::updatePrimitive( mTextItem, HbStylePrivate::P_ComboBox_text, &comboBoxOption );
}
mCurrentIndex = aIndex;
} else {
@@ -600,8 +632,8 @@
} else {
HbStyleOptionComboBox comboBoxOption;
q->initStyleOption(&comboBoxOption);
- q->style( )->updatePrimitive(
- mTextItem, HbStyle::P_ComboBox_text, &comboBoxOption );
+ HbStylePrivate::updatePrimitive(
+ mTextItem, HbStylePrivate::P_ComboBox_text, &comboBoxOption );
}
}
currentIndexChanged( mCurrentIndex );