35 #include <hbaction.h> |
35 #include <hbaction.h> |
36 #include <hbstyleoption_p.h> |
36 #include <hbstyleoption_p.h> |
37 |
37 |
38 HbSelectionDialogMarkWidget::HbSelectionDialogMarkWidget(QGraphicsItem *parent):HbWidget(parent),mBackgroundItem(0){ |
38 HbSelectionDialogMarkWidget::HbSelectionDialogMarkWidget(QGraphicsItem *parent):HbWidget(parent),mBackgroundItem(0){ |
39 chkMark = new HbCheckBox(this); |
39 chkMark = new HbCheckBox(this); |
40 chkMark->setText("Mark All"); |
40 chkMark->setText(hbTrId("txt_common_list_mark_all_items")); |
41 lbCounter = new HbTextItem(this); |
41 lbCounter = new HbTextItem(this); |
42 HbStyle::setItemName(chkMark,"checkbox"); |
42 HbStyle::setItemName(chkMark,"checkbox"); |
43 HbStyle::setItemName(lbCounter,"counter"); |
43 HbStyle::setItemName(lbCounter,"counter"); |
44 createPrimitives(); |
44 createPrimitives(); |
45 } |
45 } |
46 |
46 |
47 void HbSelectionDialogMarkWidget::createPrimitives() |
47 void HbSelectionDialogMarkWidget::createPrimitives() |
48 { |
48 { |
49 if ( !mBackgroundItem ) { |
49 if ( !mBackgroundItem ) { |
50 mBackgroundItem = style( )->createPrimitive( HbStyle::P_TumbleView_background , this ); |
50 mBackgroundItem = HbStylePrivate::createPrimitive( HbStylePrivate::P_TumbleView_background , this ); |
51 style()->setItemName( mBackgroundItem , "background" ); |
51 HbStyle::setItemName( mBackgroundItem , "background" ); |
52 } |
52 } |
53 } |
53 } |
54 |
54 |
55 void HbSelectionDialogMarkWidget::updatePrimitives() |
55 void HbSelectionDialogMarkWidget::updatePrimitives() |
56 { |
56 { |
57 HbStyleOption option; |
57 HbStyleOption option; |
58 initStyleOption( &option ); |
58 initStyleOption( &option ); |
59 |
59 |
60 if ( mBackgroundItem ) { |
60 if ( mBackgroundItem ) { |
61 style( )->updatePrimitive( mBackgroundItem , HbStyle::P_TumbleView_background , &option ); |
61 HbStylePrivate::updatePrimitive( mBackgroundItem , HbStylePrivate::P_TumbleView_background , &option ); |
62 } |
62 } |
63 } |
63 } |
64 |
64 |
65 /*! |
65 /*! |
66 \reimp |
66 \reimp |
195 if(!markWidget){ |
195 if(!markWidget){ |
196 markWidget = new HbSelectionDialogMarkWidget(this); |
196 markWidget = new HbSelectionDialogMarkWidget(this); |
197 HbStyle::setItemName(markWidget,"markwidget"); |
197 HbStyle::setItemName(markWidget,"markwidget"); |
198 setProperty("multiSelection",true); |
198 setProperty("multiSelection",true); |
199 connect(markWidget->chkMark,SIGNAL(stateChanged ( int )),this,SLOT(_q_checkboxclicked(int))); |
199 connect(markWidget->chkMark,SIGNAL(stateChanged ( int )),this,SLOT(_q_checkboxclicked(int))); |
|
200 repolish(); |
200 updateCounter(); |
201 updateCounter(); |
201 } |
202 } |
202 } |
203 } |
203 else{ |
204 else{ |
204 delete markWidget; markWidget = 0; |
205 delete markWidget; markWidget = 0; |
205 HbStyle::setItemName(markWidget,""); |
206 HbStyle::setItemName(markWidget,""); |
206 setProperty("multiSelection",false); |
207 setProperty("multiSelection",false); |
|
208 repolish(); |
207 } |
209 } |
208 } |
210 } |
209 |
211 |
210 void HbSelectionDialogContentWidget::connectSlots() |
212 void HbSelectionDialogContentWidget::connectSlots() |
211 { |
213 { |
212 QObject::connect(mListView,SIGNAL(activated(const QModelIndex&)),this,SLOT(_q_listItemSelected(QModelIndex))); |
214 QObject::connect(mListView,SIGNAL(activated(const QModelIndex&)),this,SLOT(_q_listItemSelected(QModelIndex))); |
|
215 QObject::connect(mListView->model(),SIGNAL(rowsRemoved(const QModelIndex& ,int,int)),this,SLOT(modelChanged(const QModelIndex&,int,int))); |
|
216 QObject::connect(mListView->model(),SIGNAL(rowsInserted(const QModelIndex& ,int,int)),this,SLOT(modelChanged(const QModelIndex&,int,int))); |
|
217 } |
|
218 |
|
219 void HbSelectionDialogContentWidget::modelChanged(const QModelIndex &parent, int start,int end) |
|
220 { |
|
221 Q_UNUSED(parent); |
|
222 Q_UNUSED(start); |
|
223 Q_UNUSED(end); |
|
224 updateCounter(); |
213 } |
225 } |
214 |
226 |
215 void HbSelectionDialogContentWidget::createListWidget() |
227 void HbSelectionDialogContentWidget::createListWidget() |
216 { |
228 { |
217 if(mListView){ |
229 if(mListView){ |
276 showActions(mSelectionMode); |
288 showActions(mSelectionMode); |
277 } |
289 } |
278 |
290 |
279 void HbSelectionDialogPrivate::showActions(HbAbstractItemView::SelectionMode selectionMode) |
291 void HbSelectionDialogPrivate::showActions(HbAbstractItemView::SelectionMode selectionMode) |
280 { |
292 { |
281 Q_Q(HbSelectionDialog); |
293 Q_Q(HbSelectionDialog); |
282 if(selectionMode == HbAbstractItemView::SingleSelection){ |
294 if(selectionMode == HbAbstractItemView::SingleSelection){ |
283 delete action1;action1=0;delete action2;action2=0; |
295 |
284 action1=new HbAction(hbTrId("txt_common_button_cancel"),q); |
296 if(action1) { |
285 q->addAction(action1); |
297 q->disconnect(action1,SIGNAL(triggered()),q,SLOT(accept())); |
286 q->connect(action1,SIGNAL(triggered()),q,SLOT(reject())); |
298 q->removeAction(action1); |
287 } |
299 action1 = 0; |
288 else{ |
300 } |
289 delete action1;action1=0;delete action2;action2=0; |
301 if(action2 == NULL){ |
290 action1=new HbAction(hbTrId("txt_common_button_ok"),q); |
302 action2 =new HbAction(hbTrId("txt_common_button_cancel"),q); |
291 q->addAction(action1); |
303 q->connect(action2,SIGNAL(triggered()),q,SLOT(reject())); |
292 q->connect(action1,SIGNAL(triggered()),q,SLOT(accept())); |
304 q->insertAction(0,action2); |
293 action2=new HbAction(hbTrId("txt_common_button_cancel"),q); |
305 } |
294 q->addAction(action2); |
306 } |
295 q->connect(action2,SIGNAL(triggered()),q,SLOT(reject())); |
307 else{ |
296 } |
308 |
|
309 if(action2 == NULL){ |
|
310 action2 =new HbAction(hbTrId("txt_common_button_cancel"),q); |
|
311 q->connect(action2,SIGNAL(triggered()),q,SLOT(reject())); |
|
312 q->insertAction(0,action2); |
|
313 } |
|
314 if(action1 == NULL){ |
|
315 action1 =new HbAction(hbTrId("txt_common_button_ok"),q); |
|
316 q->connect(action1,SIGNAL(triggered()),q,SLOT(accept())); |
|
317 q->insertAction(action2,action1); |
|
318 } |
|
319 } |
297 } |
320 } |
298 |
321 |
299 void HbSelectionDialogPrivate::setSelectionMode(HbAbstractItemView::SelectionMode mode) |
322 void HbSelectionDialogPrivate::setSelectionMode(HbAbstractItemView::SelectionMode mode) |
300 { |
323 { |
301 Q_Q(HbSelectionDialog); |
324 Q_Q(HbSelectionDialog); |
429 HbSelectionDialogContentWidget* cWidget = qobject_cast<HbSelectionDialogContentWidget*>(q->contentWidget()); |
452 HbSelectionDialogContentWidget* cWidget = qobject_cast<HbSelectionDialogContentWidget*>(q->contentWidget()); |
430 if(cWidget){ |
453 if(cWidget){ |
431 cWidget->createListView(); |
454 cWidget->createListView(); |
432 setSelectionMode(mSelectionMode); |
455 setSelectionMode(mSelectionMode); |
433 cWidget->mListView->setModel(model); |
456 cWidget->mListView->setModel(model); |
|
457 cWidget->updateCounter(); |
|
458 cWidget->connectSlots(); |
434 } |
459 } |
435 } |
460 } |
436 |
461 |
437 void HbSelectionDialogPrivate::setWidgetItems(const QList<HbListWidgetItem*> &items,bool transferOwnership,int currentIndex) |
462 void HbSelectionDialogPrivate::setWidgetItems(const QList<HbListWidgetItem*> &items,bool transferOwnership,int currentIndex) |
438 { |
463 { |