59 } |
59 } |
60 |
60 |
61 void HbComboDropDown::createList( ) |
61 void HbComboDropDown::createList( ) |
62 { |
62 { |
63 mList = new HbListView( this ); |
63 mList = new HbListView( this ); |
64 mList->setLongPressEnabled( false ); |
|
65 HbComboListViewItem *protoType = new HbComboListViewItem( this ); |
64 HbComboListViewItem *protoType = new HbComboListViewItem( this ); |
66 mList->setItemPrototype( protoType ); |
65 mList->setItemPrototype( protoType ); |
67 HbStyle::setItemName( mList, "list" ); |
66 HbStyle::setItemName( mList, "list" ); |
68 mList->setUniformItemSizes( true ); |
67 mList->setUniformItemSizes( true ); |
69 mList->setSelectionMode( HbAbstractItemView::SingleSelection ); |
68 mList->setSelectionMode( HbAbstractItemView::SingleSelection ); |
87 bool accepted = false; |
86 bool accepted = false; |
88 |
87 |
89 if ( isVisible( ) ) { |
88 if ( isVisible( ) ) { |
90 switch( event->type( ) ) |
89 switch( event->type( ) ) |
91 { |
90 { |
92 case QEvent::GraphicsSceneMousePress: |
|
93 case QEvent::GraphicsSceneMouseDoubleClick: |
|
94 { |
|
95 if( !vkbOpened ) { |
|
96 //if vkb is not opened and dropdown is not clicked then dismiss drop down |
|
97 if( !( this->isUnderMouse( ) ) ) { |
|
98 HbWidgetFeedback::triggered( this, Hb::InstantPopupClosed ); |
|
99 setVisible( false ); |
|
100 comboPrivate->q_ptr->setProperty("state","normal"); |
|
101 backgroundPressed = true; |
|
102 accepted = true; |
|
103 } |
|
104 } else { |
|
105 //if vkb is opened then dismiss drop down only if click happened outside drop down and |
|
106 //vkb area |
|
107 if( comboPrivate->mEditable ) { |
|
108 HbEditorInterface editorInterface( comboPrivate->q_ptr ); |
|
109 HbVkbHost *host = editorInterface.vkbHost( ); |
|
110 if( host ) { |
|
111 //get the scene rect of vkb |
|
112 QGraphicsWidget *vkbWidget = host->activeKeypad( )->asGraphicsWidget( ); |
|
113 QRectF tmp = host->applicationArea( ); |
|
114 QRectF vkbArea = vkbWidget->mapToScene( tmp ).boundingRect( ); |
|
115 QGraphicsSceneMouseEvent *mouseEvent = |
|
116 static_cast< QGraphicsSceneMouseEvent * >( event ); |
|
117 if( !( this->isUnderMouse( ) ) && |
|
118 !vkbArea.contains( mouseEvent->scenePos( ) ) ) { |
|
119 HbWidgetFeedback::triggered( this, Hb::InstantPopupClosed ); |
|
120 setVisible( false ); |
|
121 comboPrivate->q_ptr->setProperty( "state", "normal" ); |
|
122 backgroundPressed = true; |
|
123 accepted = true; |
|
124 } |
|
125 } |
|
126 } |
|
127 } |
|
128 } |
|
129 break; |
|
130 case QEvent::Gesture: |
91 case QEvent::Gesture: |
131 { |
92 { |
132 if( !this->isUnderMouse( ) ) { |
93 if( !this->isUnderMouse( ) ) { |
133 //if its a pan gesture then don't accept the event so that list can be scrolled |
94 //if its a pan gesture then don't accept the event so that list can be scrolled |
134 //even if mouse is outside drop down area. Also tap might finish outside the |
95 //even if mouse is outside drop down area. Also tap might finish outside the |
135 //dropdown area |
96 //dropdown area |
136 if( QGestureEvent *gestureEvent = static_cast<QGestureEvent *>( event ) ) { |
97 if( QGestureEvent *gestureEvent = static_cast<QGestureEvent *>( event ) ) { |
137 HbTapGesture *tapGesture = qobject_cast<HbTapGesture *>(gestureEvent->gesture(Qt::TapGesture)); |
98 HbTapGesture *tapGesture = qobject_cast<HbTapGesture *>(gestureEvent->gesture(Qt::TapGesture)); |
138 if( !qobject_cast<HbPanGesture *>( |
99 if( tapGesture && tapGesture->state() == Qt::GestureStarted ) { |
139 gestureEvent->gesture( Qt::PanGesture ) ) && |
100 if( !vkbOpened ) { |
140 !(tapGesture && tapGesture->state() != Qt::GestureStarted)) { |
101 //if vkb is not opened and dropdown is not clicked then dismiss drop down |
141 accepted = true; |
102 if( !( this->isUnderMouse( ) ) ) { |
|
103 HbWidgetFeedback::triggered( this, Hb::InstantPopupClosed ); |
|
104 setVisible( false ); |
|
105 comboPrivate->q_ptr->setProperty("state","normal"); |
|
106 backgroundPressed = true; |
|
107 accepted = true; |
|
108 } |
|
109 } else { |
|
110 //if vkb is opened then dismiss drop down only if click happened outside drop down and |
|
111 //vkb area |
|
112 if( comboPrivate->mEditable ) { |
|
113 HbEditorInterface editorInterface( comboPrivate->q_ptr ); |
|
114 HbVkbHost *host = editorInterface.vkbHost( ); |
|
115 if( host ) { |
|
116 //get the scene rect of vkb |
|
117 QGraphicsWidget *vkbWidget = host->activeKeypad( )->asGraphicsWidget( ); |
|
118 QRectF tmp = host->applicationArea( ); |
|
119 QRectF vkbArea = vkbWidget->mapToScene( tmp ).boundingRect( ); |
|
120 //QGraphicsSceneMouseEvent *mouseEvent = |
|
121 // static_cast< QGraphicsSceneMouseEvent * >( event ); |
|
122 if( !( this->isUnderMouse( ) ) && |
|
123 !vkbArea.contains( /*mouseEvent->scenePos( )*/ tapGesture->sceneStartPos() ) ) { |
|
124 HbWidgetFeedback::triggered( this, Hb::InstantPopupClosed ); |
|
125 setVisible( false ); |
|
126 comboPrivate->q_ptr->setProperty( "state", "normal" ); |
|
127 backgroundPressed = true; |
|
128 accepted = true; |
|
129 } |
|
130 } |
|
131 } |
|
132 } |
|
133 } else { |
|
134 if( !qobject_cast<HbPanGesture *>( |
|
135 gestureEvent->gesture( Qt::PanGesture ) ) && |
|
136 !(tapGesture && tapGesture->state() != Qt::GestureStarted)) { |
|
137 accepted = true; |
|
138 } |
142 } |
139 } |
143 } |
140 } |
144 } |
141 } |
145 } |
142 } |
146 break; |
143 break; |