equal
deleted
inserted
replaced
43 #include <hbeffect.h> |
43 #include <hbeffect.h> |
44 #include "hbeffectinternal_p.h" |
44 #include "hbeffectinternal_p.h" |
45 #define HB_DROPD0WN_ITEM_TYPE "HB_DROPDOWN" |
45 #define HB_DROPD0WN_ITEM_TYPE "HB_DROPDOWN" |
46 #endif |
46 #endif |
47 |
47 |
|
48 #include <hbtapgesture.h> |
|
49 |
48 HbComboBoxPrivate::HbComboBoxPrivate( ): |
50 HbComboBoxPrivate::HbComboBoxPrivate( ): |
49 HbWidgetPrivate ( ), |
51 HbWidgetPrivate ( ), |
50 mLineEdit ( 0 ), |
52 mLineEdit ( 0 ), |
51 mTextItem ( 0 ), |
53 mTextItem ( 0 ), |
52 mButton ( 0 ), |
54 mButton ( 0 ), |
88 |
90 |
89 void HbComboBoxPrivate::createPrimitives( ) |
91 void HbComboBoxPrivate::createPrimitives( ) |
90 { |
92 { |
91 Q_Q( HbComboBox ); |
93 Q_Q( HbComboBox ); |
92 |
94 |
|
95 |
93 mTextItem = q->style()->createPrimitive( HbStyle::P_ComboBox_text, q ); |
96 mTextItem = q->style()->createPrimitive( HbStyle::P_ComboBox_text, q ); |
94 HbStyle::setItemName( mTextItem, "combobox_labelfield" ); |
97 HbStyle::setItemName( mTextItem, "combobox_labelfield" ); |
95 |
98 |
96 mBackgroundItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_background, q ); |
99 mBackgroundItem = q->style( )->createPrimitive( HbStyle::P_ComboBox_background, q ); |
97 HbStyle::setItemName( mBackgroundItem, "text_background" ); |
100 HbStyle::setItemName( mBackgroundItem, "text_background" ); |
101 |
104 |
102 mButtonTouchAreaItem = q->style( )->createPrimitive( |
105 mButtonTouchAreaItem = q->style( )->createPrimitive( |
103 HbStyle::P_ComboBoxButton_toucharea, q ); |
106 HbStyle::P_ComboBoxButton_toucharea, q ); |
104 static_cast<HbTouchArea*>(mButtonTouchAreaItem)->installEventFilter( q ); |
107 static_cast<HbTouchArea*>(mButtonTouchAreaItem)->installEventFilter( q ); |
105 q->setHandlesChildEvents(true); |
108 q->setHandlesChildEvents(true); |
|
109 |
|
110 static_cast<HbTouchArea*>(mButtonTouchAreaItem)->grabGesture( Qt::TapGesture ); |
106 } |
111 } |
107 |
112 |
108 void HbComboBoxPrivate::touchAreaPressEvent( ) |
113 void HbComboBoxPrivate::touchAreaPressEvent( ) |
109 { |
114 { |
110 Q_Q( HbComboBox ); |
115 Q_Q( HbComboBox ); |
111 if (q->count() > 0) { |
116 if (q->count() > 0) { |
112 HbWidgetFeedback::triggered(q, Hb::InstantPressed); |
117 HbWidgetFeedback::triggered(q, Hb::InstantPressed); |
113 } |
118 } |
114 mIsDown = true; |
119 mIsDown = true; |
132 void HbComboBoxPrivate::touchAreaClicked( ) |
137 void HbComboBoxPrivate::touchAreaClicked( ) |
133 { |
138 { |
134 Q_Q( HbComboBox ); |
139 Q_Q( HbComboBox ); |
135 if ( mModel && mModel->rowCount( ) ) { |
140 if ( mModel && mModel->rowCount( ) ) { |
136 addDropDownToScene(); |
141 addDropDownToScene(); |
|
142 mDropDown->setVisible( true ); |
137 if( !mDropDown->mList ) { |
143 if( !mDropDown->mList ) { |
138 mDropDown->createList( ); |
144 mDropDown->createList( ); |
139 mDropDown->mList->setModel( mModel ); |
145 mDropDown->mList->setModel( mModel ); |
140 q->connect( mDropDown->mList, SIGNAL( activated( QModelIndex ) ), q, |
146 q->connect( mDropDown->mList, SIGNAL( activated( QModelIndex ) ), q, |
141 SLOT( _q_textChanged( QModelIndex ) ) ); |
147 SLOT( _q_textChanged( QModelIndex ) ) ); |
154 mDropDown->mList->setCurrentIndex(mModel->index( 0, 0 ), QItemSelectionModel::Select); |
160 mDropDown->mList->setCurrentIndex(mModel->index( 0, 0 ), QItemSelectionModel::Select); |
155 } |
161 } |
156 #ifdef HB_EFFECTS |
162 #ifdef HB_EFFECTS |
157 HbEffect::start(mDropDown, HB_DROPD0WN_ITEM_TYPE, "appear"); |
163 HbEffect::start(mDropDown, HB_DROPD0WN_ITEM_TYPE, "appear"); |
158 #endif |
164 #endif |
159 positionDropDown( ); |
165 positionDropDown( ); |
160 mDropDown->setVisible( true ); |
|
161 } |
166 } |
162 } |
167 } |
163 |
168 |
164 void HbComboBoxPrivate::vkbOpened( ) |
169 void HbComboBoxPrivate::vkbOpened( ) |
165 { |
170 { |
182 addDropDownToScene(); |
187 addDropDownToScene(); |
183 if( !mDropDown->mList ) { |
188 if( !mDropDown->mList ) { |
184 mDropDown->createList(); |
189 mDropDown->createList(); |
185 q->connect( mDropDown->mList, SIGNAL( activated( QModelIndex ) ), q, |
190 q->connect( mDropDown->mList, SIGNAL( activated( QModelIndex ) ), q, |
186 SLOT( _q_textChanged( QModelIndex ) ) ); |
191 SLOT( _q_textChanged( QModelIndex ) ) ); |
|
192 |
187 } |
193 } |
188 mDropDown->mList->setModel( aModel ); |
194 mDropDown->mList->setModel( aModel ); |
189 if ( aIndex.isValid( ) ) { |
195 if ( aIndex.isValid( ) ) { |
190 mDropDown->mList->scrollTo( aIndex, HbAbstractItemView::PositionAtTop ); |
196 mDropDown->mList->scrollTo( aIndex, HbAbstractItemView::PositionAtTop ); |
191 mDropDown->mList->setCurrentIndex(mCurrentIndex, QItemSelectionModel::Select); |
197 mDropDown->mList->setCurrentIndex(mCurrentIndex, QItemSelectionModel::Select); |
542 } |
548 } |
543 QGraphicsScene *scene1 = mDropDown->scene( ); |
549 QGraphicsScene *scene1 = mDropDown->scene( ); |
544 if( scene1 ) |
550 if( scene1 ) |
545 { |
551 { |
546 scene1->installEventFilter( mDropDown ); |
552 scene1->installEventFilter( mDropDown ); |
|
553 //scene1->grabGesture( Qt::TapGesture ); |
547 } |
554 } |
548 mIsDropwnToSceneAdded = true; |
555 mIsDropwnToSceneAdded = true; |
549 } |
556 } |
550 } |
557 } |
551 void HbComboBoxPrivate::setCurrentIndex( const QModelIndex &mi ) |
558 void HbComboBoxPrivate::setCurrentIndex( const QModelIndex &mi ) |
573 currentIndexChanged( mCurrentIndex ); |
580 currentIndexChanged( mCurrentIndex ); |
574 } |
581 } |
575 } |
582 } |
576 |
583 |
577 void HbComboBoxPrivate::currentIndexChanged( const QModelIndex &index ) |
584 void HbComboBoxPrivate::currentIndexChanged( const QModelIndex &index ) |
578 { |
585 { |
579 Q_Q( HbComboBox ); |
586 Q_Q( HbComboBox ); |
580 emit q->currentIndexChanged( index.row( ) ); |
587 emit q->currentIndexChanged( index.row( ) ); |
581 emit q->currentIndexChanged( q->itemText ( mCurrentIndex.row( ) ) ); |
588 emit q->currentIndexChanged( q->itemText ( mCurrentIndex.row( ) ) ); |
582 } |
589 } |
583 |
590 |