src/hbwidgets/popups/hbselectiondialog_p.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
equal deleted inserted replaced
28:b7da29130b0e 30:80e4d18b72f5
   290     Q_UNUSED(index)
   290     Q_UNUSED(index)
   291     if(mListView->selectionMode()== HbAbstractItemView::SingleSelection || mListView->selectionMode()== HbAbstractItemView::NoSelection){
   291     if(mListView->selectionMode()== HbAbstractItemView::SingleSelection || mListView->selectionMode()== HbAbstractItemView::NoSelection){
   292        d->close();
   292        d->close();
   293     }
   293     }
   294     updateCounter();
   294     updateCounter();
   295     //d->_p_SelectionChanged();
       
   296 }
   295 }
   297 
   296 
   298 
   297 
   299 void HbSelectionDialogContentWidget::modelChanged(const QModelIndex &parent, int start,int end)
   298 void HbSelectionDialogContentWidget::modelChanged(const QModelIndex &parent, int start,int end)
   300 {
   299 {
   350 
   349 
   351 HbSelectionDialogPrivate::HbSelectionDialogPrivate()
   350 HbSelectionDialogPrivate::HbSelectionDialogPrivate()
   352     :HbDialogPrivate()
   351     :HbDialogPrivate()
   353 {
   352 {
   354     bOwnItems = false;
   353     bOwnItems = false;
   355     action1 = action2 = 0;
   354 //    action1 = action2 = 0;
   356 }
   355 }
   357 
   356 
   358 HbSelectionDialogPrivate::~HbSelectionDialogPrivate()
   357 HbSelectionDialogPrivate::~HbSelectionDialogPrivate()
   359 {
   358 {
   360     clearItems(bOwnItems);    
   359     clearItems(bOwnItems);    
   379 void HbSelectionDialogPrivate::_p_SelectionChanged()
   378 void HbSelectionDialogPrivate::_p_SelectionChanged()
   380 {
   379 {
   381     Q_Q(HbSelectionDialog);
   380     Q_Q(HbSelectionDialog);
   382     if(mSelectionMode == HbAbstractItemView::MultiSelection)
   381     if(mSelectionMode == HbAbstractItemView::MultiSelection)
   383     {
   382     {
       
   383         if(action1){
       
   384             QItemSelectionModel *model = 0;
       
   385             model = selectionModel();
       
   386             if(model->selectedRows().count()==0)
       
   387                 action1->setEnabled(false);
       
   388             else
       
   389                 action1->setEnabled(true);
       
   390         }
   384         emit q->selectionChanged();
   391         emit q->selectionChanged();
   385     }
   392     }
   386 }
   393 }
   387 
   394 
   388 void HbSelectionDialogPrivate::showActions(HbAbstractItemView::SelectionMode selectionMode)
   395 void HbSelectionDialogPrivate::showActions(HbAbstractItemView::SelectionMode selectionMode)
   389 {
   396 {
   390     Q_Q(HbSelectionDialog);
   397     Q_Q(HbSelectionDialog);
   391     if(selectionMode == HbAbstractItemView::SingleSelection || selectionMode == HbAbstractItemView::NoSelection){
   398     if(selectionMode == HbAbstractItemView::SingleSelection || selectionMode == HbAbstractItemView::NoSelection){
   392 
       
   393         if(action1) {
   399         if(action1) {
   394             q->disconnect(action1,SIGNAL(triggered()),q,SLOT(accept()));
   400             q->disconnect(action1,SIGNAL(triggered()),q,SLOT(accept()));
   395             q->removeAction(action1);
   401             q->removeAction(action1);
   396         }
   402         }
   397         if(action2 == NULL){
   403         if(action2 == NULL){
   398         action2 =new HbAction(hbTrId("txt_common_button_cancel"),q);
   404             action2 =new HbAction(hbTrId("txt_common_button_cancel"),q);
   399         q->connect(action2,SIGNAL(triggered()),q,SLOT(reject()));
       
   400         }
   405         }
   401         if(q->actions().contains(action2) == false){
   406         if(q->actions().contains(action2) == false){
       
   407             q->connect(action2,SIGNAL(triggered()),q,SLOT(reject()));
   402             q->insertAction(0,action2);
   408             q->insertAction(0,action2);
   403         }
   409         }
   404     }
   410     }
   405     else{
   411     else{
   406 
   412 
   407         if(action2 == NULL){
   413         if(action2 == NULL){
   408             action2 =new HbAction(hbTrId("txt_common_button_cancel"),q);
   414             action2 =new HbAction(hbTrId("txt_common_button_cancel"),q);
       
   415         }    
       
   416         if(q->actions().contains(action2) == false){
   409             q->connect(action2,SIGNAL(triggered()),q,SLOT(reject()));
   417             q->connect(action2,SIGNAL(triggered()),q,SLOT(reject()));
   410             q->insertAction(0,action2);
   418             q->insertAction(0,action2);
   411         }    
   419         }
   412         if(q->actions().contains(action2) == false)
       
   413             q->insertAction(0,action2);
       
   414 
       
   415         if(action1 == NULL){
   420         if(action1 == NULL){
   416             action1 =new HbAction(hbTrId("txt_common_button_ok"),q);
   421             action1 =new HbAction(hbTrId("txt_common_button_ok"),q);
       
   422         }    
       
   423         if(q->actions().contains(action1) == false)
       
   424         {
   417             q->connect(action1,SIGNAL(triggered()),q,SLOT(accept()));
   425             q->connect(action1,SIGNAL(triggered()),q,SLOT(accept()));
   418         }    
       
   419        if(q->actions().contains(action1) == false)
       
   420         {
       
   421             q->insertAction(q->actions().first(),action1);
   426             q->insertAction(q->actions().first(),action1);
   422         }
   427         }
   423     }
   428     }
   424     
   429     
   425 }
   430 }