70 HbInputMethod* mInput; |
70 HbInputMethod* mInput; |
71 int numRows; |
71 int numRows; |
72 int numCandidates; |
72 int numCandidates; |
73 int longestStringWidth; |
73 int longestStringWidth; |
74 HbFrameItem *mFrameBackground; |
74 HbFrameItem *mFrameBackground; |
|
75 bool mCandidateCommitted; |
75 }; |
76 }; |
76 |
77 |
77 HbCandidateListPrivate::HbCandidateListPrivate(HbInputMethod* input) |
78 HbCandidateListPrivate::HbCandidateListPrivate(HbInputMethod* input) |
78 : mInput(input), |
79 : mInput(input), |
79 numRows(HbCandListDefaultNumRows), |
80 numRows(HbCandListDefaultNumRows), |
80 numCandidates(0), |
81 numCandidates(0), |
81 longestStringWidth(0), |
82 longestStringWidth(0), |
82 mFrameBackground(0) |
83 mFrameBackground(0), |
|
84 mCandidateCommitted(false) |
83 { |
85 { |
84 Q_Q(HbCandidateList); |
86 Q_Q(HbCandidateList); |
85 |
87 |
86 mList = new HbListWidget(q); |
88 mList = new HbListWidget(q); |
87 mList->setEnabledAnimations(HbAbstractItemView::None); |
89 mList->setEnabledAnimations(HbAbstractItemView::None); |
162 Q_D(HbCandidateList); |
164 Q_D(HbCandidateList); |
163 |
165 |
164 d->setPriority(HbPopupPrivate::VirtualKeyboard + 1); // Should be shown on top of virtual keyboard. |
166 d->setPriority(HbPopupPrivate::VirtualKeyboard + 1); // Should be shown on top of virtual keyboard. |
165 d->initFrameIcon(); |
167 d->initFrameIcon(); |
166 |
168 |
167 #if QT_VERSION >= 0x040600 |
|
168 // Make sure the preview pane never steals focus. |
169 // Make sure the preview pane never steals focus. |
169 setFlag(QGraphicsItem::ItemIsPanel, true); |
170 setFlag(QGraphicsItem::ItemIsPanel, true); |
170 setActive(false); |
171 setActive(false); |
171 |
172 |
172 // enable drop shadow for the preview pane |
173 // enable drop shadow for the preview pane |
173 QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; |
174 QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; |
174 effect->setBlurRadius(8); |
175 effect->setBlurRadius(8); |
175 setGraphicsEffect(effect); |
176 setGraphicsEffect(effect); |
176 #endif |
|
177 |
177 |
178 setTimeout(NoTimeout); |
178 setTimeout(NoTimeout); |
179 setAttribute(Qt::WA_InputMethodEnabled, false); |
179 setAttribute(Qt::WA_InputMethodEnabled, false); |
180 connect(d->mList, SIGNAL(activated(HbListWidgetItem*)), this, SLOT(itemActivated(HbListWidgetItem*))); |
180 connect(d->mList, SIGNAL(activated(HbListWidgetItem*)), this, SLOT(itemActivated(HbListWidgetItem*))); |
181 connect(d->mList, SIGNAL(longPressed(HbListWidgetItem*, const QPointF&)), this, SLOT(itemActivated(HbListWidgetItem*))); |
181 connect(d->mList, SIGNAL(longPressed(HbListWidgetItem*, const QPointF&)), this, SLOT(itemActivated(HbListWidgetItem*))); |
240 if (event->key() == Qt::Key_Space |
240 if (event->key() == Qt::Key_Space |
241 || event->key() == Qt::Key_Enter |
241 || event->key() == Qt::Key_Enter |
242 || event->key() == Qt::Key_Return |
242 || event->key() == Qt::Key_Return |
243 || event->key() == Qt::Key_Right |
243 || event->key() == Qt::Key_Right |
244 || event->key() == Qt::Key_Left) { |
244 || event->key() == Qt::Key_Left) { |
245 d->mInput->candidatePopupClosed(event->key()); |
245 if (!d->mCandidateCommitted) { |
|
246 emit candidateSelected(event->key(), currentCandidate()); |
|
247 d->mCandidateCommitted = true; |
|
248 } |
246 hide(); |
249 hide(); |
247 } |
250 } |
248 } |
251 } |
249 |
252 |
250 /*! |
253 /*! |
261 */ |
264 */ |
262 void HbCandidateList::itemActivated(HbListWidgetItem *item) |
265 void HbCandidateList::itemActivated(HbListWidgetItem *item) |
263 { |
266 { |
264 Q_UNUSED(item); |
267 Q_UNUSED(item); |
265 Q_D(HbCandidateList); |
268 Q_D(HbCandidateList); |
266 |
269 if (!d->mCandidateCommitted) { |
267 d->mInput->candidatePopupClosed(); |
270 emit candidateSelected(0, currentCandidate()); |
|
271 d->mCandidateCommitted = true; |
|
272 } |
268 hide(); |
273 hide(); |
269 } |
274 } |
270 |
275 |
271 /*! |
276 /*! |
272 Returns the currently selected candidate on the list. |
277 Returns the currently selected candidate on the list. |
291 /*! |
296 /*! |
292 this event handler is called, for Hide events, is delivered after the widget has been hidden. |
297 this event handler is called, for Hide events, is delivered after the widget has been hidden. |
293 */ |
298 */ |
294 void HbCandidateList::hideEvent(QHideEvent * event) |
299 void HbCandidateList::hideEvent(QHideEvent * event) |
295 { |
300 { |
|
301 Q_D(HbCandidateList); |
|
302 d->mCandidateCommitted = false; |
296 HbDialog::hideEvent(event); |
303 HbDialog::hideEvent(event); |
297 } |
304 } |
298 |
305 |
299 void HbCandidateList::updatePrimitives() |
306 void HbCandidateList::updatePrimitives() |
300 { |
307 { |