249 } |
267 } |
250 |
268 |
251 void CpCertView::deleteList() |
269 void CpCertView::deleteList() |
252 { |
270 { |
253 mSelectAll = EFalse; |
271 mSelectAll = EFalse; |
254 HbDialog popup; |
272 mPopup = new HbDialog(); |
255 popup.setDismissPolicy(HbDialog::NoDismiss); |
273 |
|
274 mPopup->setDismissPolicy(HbDialog::NoDismiss); |
256 // Set the label as heading widget |
275 // Set the label as heading widget |
257 popup.setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_setlabel_certificates")))); |
276 mPopup->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_setlabel_certificates")))); |
258 |
277 |
259 std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); |
278 std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); |
260 |
279 |
261 HbListView* selectAllView = q_check_ptr(new HbListView(this)); |
280 mSelectAllView = q_check_ptr(new HbListView(this)); |
262 QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this)); |
281 QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this)); |
263 // Populate the model with content |
282 // Populate the model with content |
264 std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem())); |
283 std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem())); |
265 selectAllItem->setData(QString("Select All"),Qt::DisplayRole); |
284 selectAllItem->setData(QString("Select All"),Qt::DisplayRole); |
266 selectAllModel->appendRow(selectAllItem.get()); |
285 selectAllModel->appendRow(selectAllItem.get()); |
267 selectAllItem.release(); |
286 selectAllItem.release(); |
268 |
287 |
269 connect(selectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll())); |
288 connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll())); |
270 selectAllView->setModel(selectAllModel); |
289 mSelectAllView->setModel(selectAllModel); |
271 selectAllView->setSelectionMode(HbListView::MultiSelection); |
290 mSelectAllView->setSelectionMode(HbListView::MultiSelection); |
272 layout->addItem(selectAllView); |
291 layout->addItem(mSelectAllView); |
273 |
292 |
274 mListView = q_check_ptr(new HbListView(this)); |
293 mListView = q_check_ptr(new HbListView(this)); |
275 // Connect to "activated" signal |
294 // Connect to "activated" signal |
276 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); |
295 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); |
277 |
296 |
278 // Create a model |
297 // Create a model |
279 QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this)); |
298 QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this)); |
280 TInt count=0; |
299 TInt count=0; |
281 QT_TRAP_THROWING( count = refreshListL()); |
300 QT_TRAP_THROWING( count = refreshListL()); |
282 RArray<TInt> selectionIndex; |
|
283 QT_TRAP_THROWING(CleanupClosePushL(selectionIndex)); |
|
284 |
301 |
285 for(TInt index = 0; index < count ; ++index) |
302 for(TInt index = 0; index < count ; ++index) |
286 { |
303 { |
287 const CCTCertInfo* cert = certAt(index); |
304 const CCTCertInfo* cert = certAt(index); |
288 if( cert->IsDeletable() ) |
305 if( cert->IsDeletable() ) |
302 layout->addItem(mListView); |
319 layout->addItem(mListView); |
303 |
320 |
304 std::auto_ptr<HbWidget> widget( q_check_ptr(new HbWidget())); |
321 std::auto_ptr<HbWidget> widget( q_check_ptr(new HbWidget())); |
305 widget->setLayout(layout.get()); |
322 widget->setLayout(layout.get()); |
306 layout.release(); |
323 layout.release(); |
307 popup.setContentWidget(widget.get()); |
324 mPopup->setContentWidget(widget.get()); |
308 widget.release(); |
325 widget.release(); |
309 |
326 |
310 popup.setPrimaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete")))); |
327 mPopup->setPrimaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete")))); |
311 popup.setSecondaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_button_cancel")))); |
328 mPopup->setSecondaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_button_cancel")))); |
312 popup.setTimeout(HbPopup::NoTimeout); |
329 mPopup->setTimeout(HbPopup::NoTimeout); |
313 |
330 |
314 // Launch popup syncronously |
331 // Launch popup syncronously |
315 HbAction* result = popup.exec(); |
332 mPopup->open(this, SLOT(handleMultipleDelete(HbAction*))); |
316 if(result == popup.primaryAction()) |
333 |
|
334 } |
|
335 |
|
336 void CpCertView::handleMultipleDelete(HbAction* action) |
|
337 { |
|
338 if(action == mPopup->primaryAction()) |
317 { |
339 { |
318 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
340 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
319 QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes(); |
341 QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes(); |
320 TInt deleteCount = mWidgetItemsToRemove.count(); |
342 TInt deleteCount = mWidgetItemsToRemove.count(); |
321 // start deleting from end of array so that the indexes do not changes of the ones |
343 // start deleting from end of array so that the indexes do not changes of the ones |
323 RArray<TInt> actualIndex; |
345 RArray<TInt> actualIndex; |
324 QT_TRAP_THROWING(CleanupClosePushL(actualIndex)); |
346 QT_TRAP_THROWING(CleanupClosePushL(actualIndex)); |
325 for (TInt index = deleteCount-1; index>= 0 ; --index) |
347 for (TInt index = deleteCount-1; index>= 0 ; --index) |
326 { |
348 { |
327 TInt selectedItemIndex = mWidgetItemsToRemove[index].row(); |
349 TInt selectedItemIndex = mWidgetItemsToRemove[index].row(); |
328 actualIndex.Append( selectionIndex[selectedItemIndex] ); |
350 actualIndex.Append( mSelectionIndex[selectedItemIndex] ); |
329 } |
351 } |
330 deleteCerts(actualIndex); |
352 deleteCerts(actualIndex); |
331 CleanupStack::PopAndDestroy(&actualIndex); |
353 CleanupStack::PopAndDestroy(&actualIndex); |
332 } |
354 } |
333 CleanupStack::PopAndDestroy(&selectionIndex); |
|
334 mListView->deleteLater(); |
355 mListView->deleteLater(); |
335 mListView = NULL; |
356 mListView = NULL; |
336 selectAllView->deleteLater(); |
357 mSelectAllView->deleteLater(); |
337 selectAllView = NULL; |
358 mSelectAllView = NULL; |
|
359 delete mPopup; |
|
360 mPopup = NULL; |
338 } |
361 } |
339 |
362 |
340 void CpCertView::moveCert() |
363 void CpCertView::moveCert() |
341 { |
364 { |
342 mSelectAll = EFalse; |
365 mSelectAll = EFalse; |
343 HbDialog popup; |
366 mPopup = new HbDialog(); |
344 popup.setDismissPolicy(HbDialog::NoDismiss); |
367 mPopup->setDismissPolicy(HbDialog::NoDismiss); |
345 // Set the label as heading widget |
368 // Set the label as heading widget |
346 if(mCertView == EPersonalView) |
369 if(mCertView == EPersonalView) |
347 { |
370 { |
348 popup.setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Device")))); |
371 mPopup->setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Device")))); |
349 } |
372 } |
350 else if(mCertView == EDeviceView) |
373 else if(mCertView == EDeviceView) |
351 { |
374 { |
352 popup.setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Personal")))); |
375 mPopup->setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Personal")))); |
353 } |
376 } |
354 |
377 |
355 std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); |
378 std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical))); |
356 |
379 |
357 HbListView* selectAllView = q_check_ptr(new HbListView(this)); |
380 mSelectAllView = q_check_ptr(new HbListView(this)); |
358 QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this)); |
381 QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this)); |
359 // Populate the model with content |
382 // Populate the model with content |
360 std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem())); |
383 std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem())); |
361 selectAllItem->setData(QString("Select All"),Qt::DisplayRole); |
384 selectAllItem->setData(QString("Select All"),Qt::DisplayRole); |
362 selectAllModel->appendRow(selectAllItem.get()); |
385 selectAllModel->appendRow(selectAllItem.get()); |
363 selectAllItem.release(); |
386 selectAllItem.release(); |
364 connect(selectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll())); |
387 connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll())); |
365 selectAllView->setModel(selectAllModel); |
388 mSelectAllView->setModel(selectAllModel); |
366 selectAllView->setSelectionMode(HbListView::MultiSelection); |
389 mSelectAllView->setSelectionMode(HbListView::MultiSelection); |
367 layout->addItem(selectAllView); |
390 layout->addItem(mSelectAllView); |
368 |
391 |
369 mListView = q_check_ptr(new HbListView(this)); |
392 mListView = q_check_ptr(new HbListView(this)); |
370 // Connect to "activated" signal |
393 // Connect to "activated" signal |
371 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); |
394 connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); |
372 |
395 |
373 // Create a model |
396 // Create a model |
374 QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this)); |
397 QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this)); |
375 TInt count =0; |
398 TInt count =0; |
376 QT_TRAP_THROWING(count = refreshListL()); |
399 QT_TRAP_THROWING(count = refreshListL()); |
377 RArray<TInt> selectionIndex; |
|
378 QT_TRAP_THROWING(CleanupClosePushL(selectionIndex)); |
|
379 for(TInt index = 0; index < count ; ++index) |
400 for(TInt index = 0; index < count ; ++index) |
380 { |
401 { |
381 // Populate the model with content |
402 // Populate the model with content |
382 std::auto_ptr<QStandardItem> certItem(q_check_ptr(new QStandardItem())); |
403 std::auto_ptr<QStandardItem> certItem(q_check_ptr(new QStandardItem())); |
383 QString certificateLabel = certLabel(index); |
404 QString certificateLabel = certLabel(index); |
384 certItem->setData( certificateLabel, Qt::DisplayRole); |
405 certItem->setData( certificateLabel, Qt::DisplayRole); |
385 model->appendRow(certItem.get()); |
406 model->appendRow(certItem.get()); |
386 selectionIndex.Append(index); |
407 mSelectionIndex.Append(index); |
387 certItem.release(); |
408 certItem.release(); |
388 } |
409 } |
389 |
410 |
390 // Set the model to the list view |
411 // Set the model to the list view |
391 mListView->setModel(model); |
412 mListView->setModel(model); |
393 layout->addItem(mListView); |
414 layout->addItem(mListView); |
394 |
415 |
395 std::auto_ptr<HbWidget> widget(q_check_ptr(new HbWidget())); |
416 std::auto_ptr<HbWidget> widget(q_check_ptr(new HbWidget())); |
396 widget->setLayout(layout.get()); |
417 widget->setLayout(layout.get()); |
397 layout.release(); |
418 layout.release(); |
398 popup.setContentWidget(widget.get()); |
419 mPopup->setContentWidget(widget.get()); |
399 widget.release(); |
420 widget.release(); |
400 |
421 |
401 popup.setPrimaryAction(q_check_ptr(new HbAction(tr("Yes"),&popup))); |
422 mPopup->setPrimaryAction(q_check_ptr(new HbAction(tr("Yes")))); |
402 popup.setSecondaryAction(q_check_ptr(new HbAction(tr("No"),&popup))); |
423 mPopup->setSecondaryAction(q_check_ptr(new HbAction(tr("No")))); |
403 popup.setTimeout(HbPopup::NoTimeout); |
424 mPopup->setTimeout(HbPopup::NoTimeout); |
404 |
425 |
405 // Launch popup syncronously |
426 // Launch popup syncronously |
406 HbAction* result = popup.exec(); |
427 mPopup->open(this, SLOT(handleMoveCertDialog(HbAction*))); |
407 if(result == popup.primaryAction()) |
428 } |
|
429 |
|
430 void CpCertView::handleMoveCertDialog(HbAction* action) |
|
431 { |
|
432 if(action == mPopup->primaryAction()) |
408 { |
433 { |
409 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
434 QItemSelectionModel *selectionModel = mListView->selectionModel(); |
410 QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes(); |
435 QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes(); |
411 TInt deleteCount = mWidgetItemsToRemove.count(); |
436 TInt deleteCount = mWidgetItemsToRemove.count(); |
412 // start deleting from end of array so that the indexes do not changes of the ones |
437 // start deleting from end of array so that the indexes do not changes of the ones |
414 RArray<TInt> actualIndex; |
439 RArray<TInt> actualIndex; |
415 QT_TRAP_THROWING(CleanupClosePushL(actualIndex)); |
440 QT_TRAP_THROWING(CleanupClosePushL(actualIndex)); |
416 for (TInt index = deleteCount-1; index>= 0 ; --index) |
441 for (TInt index = deleteCount-1; index>= 0 ; --index) |
417 { |
442 { |
418 TInt selectedItemIndex = mWidgetItemsToRemove[index].row(); |
443 TInt selectedItemIndex = mWidgetItemsToRemove[index].row(); |
419 actualIndex.Append(selectionIndex[selectedItemIndex]); |
444 actualIndex.Append(mSelectionIndex[selectedItemIndex]); |
420 } |
445 } |
421 moveCertList(actualIndex); |
446 moveCertList(actualIndex); |
422 CleanupStack::PopAndDestroy(&actualIndex); |
447 CleanupStack::PopAndDestroy(&actualIndex); |
423 } |
448 } |
424 CleanupStack::PopAndDestroy(&selectionIndex); |
|
425 mListView->deleteLater(); |
449 mListView->deleteLater(); |
426 mListView = NULL; |
450 mListView = NULL; |
427 selectAllView->deleteLater(); |
451 mSelectAllView->deleteLater(); |
428 selectAllView = NULL; |
452 mSelectAllView = NULL; |
|
453 delete mPopup; |
|
454 mPopup = NULL; |
429 } |
455 } |
430 |
456 |
431 void CpCertView::selectAll() |
457 void CpCertView::selectAll() |
432 { |
458 { |
433 if(mSelectAll == EFalse) |
459 if(mSelectAll == EFalse) |
460 deleteMsg = "Delete %1 items?"; |
487 deleteMsg = "Delete %1 items?"; |
461 sCount.setNum(count); |
488 sCount.setNum(count); |
462 } |
489 } |
463 |
490 |
464 deleteMsg = deleteMsg.arg(sCount); |
491 deleteMsg = deleteMsg.arg(sCount); |
465 note.setText(deleteMsg); |
492 mNote->setText(deleteMsg); |
466 note.setPrimaryAction(q_check_ptr(new HbAction("Yes"))); |
493 mNote->setPrimaryAction(q_check_ptr(new HbAction("Yes"))); |
467 note.setSecondaryAction(q_check_ptr(new HbAction("No"))); |
494 mNote->setSecondaryAction(q_check_ptr(new HbAction("No"))); |
468 note.setTimeout(HbPopup::NoTimeout); |
495 mNote->setTimeout(HbPopup::NoTimeout); |
469 HbAction* result = note.exec(); |
496 mNote->open(this,SLOT(handleDeleteDialog(HbAction*))); |
470 |
497 |
471 if (result != note.primaryAction() || count == 0 ) |
498 } |
|
499 |
|
500 void CpCertView::handleDeleteDialog(HbAction* action) |
|
501 { |
|
502 |
|
503 TInt count = mIndexList.Count(); |
|
504 |
|
505 if (action != mNote->primaryAction() || count == 0 ) |
472 { |
506 { |
473 return; |
507 return; |
474 } |
508 } |
475 |
509 |
476 RPointerArray<CCTCertInfo> errCerts; |
510 RPointerArray<CCTCertInfo> errCerts; |
477 QT_TRAP_THROWING(CleanupClosePushL(errCerts)); |
511 QT_TRAP_THROWING(CleanupClosePushL(errCerts)); |
478 |
512 |
479 for(TInt index = 0; index < count; ++index) |
513 for(TInt index = 0; index < count; ++index) |
480 { |
514 { |
481 const CCTCertInfo* entry = certAt(indexList[index]); |
515 const CCTCertInfo* entry = certAt(mIndexList[index]); |
482 |
516 |
483 if( mCertView == EPersonalView || mCertView == EAuthorityView ) |
517 if( mCertView == EPersonalView || mCertView == EAuthorityView ) |
484 { |
518 { |
485 QT_TRAP_THROWING( mCertDataContainer->iWrapper->DeleteCertL( |
519 QT_TRAP_THROWING( mCertDataContainer->iWrapper->DeleteCertL( |
486 mCertDataContainer->CertManager(), *entry )); |
520 mCertDataContainer->CertManager(), *entry )); |
722 moveCertList(pos); |
758 moveCertList(pos); |
723 } |
759 } |
724 |
760 |
725 void CpCertView::moveCertList(RArray<TInt>& indexList) |
761 void CpCertView::moveCertList(RArray<TInt>& indexList) |
726 { |
762 { |
727 HbMessageBox note(HbMessageBox::MessageTypeQuestion); |
763 |
728 note.setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_info_move")))); |
764 mIndexList = indexList; |
|
765 mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
766 mNote->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_info_move")))); |
729 if( mCertView == EPersonalView ) |
767 if( mCertView == EPersonalView ) |
730 { |
768 { |
731 note.setText(hbTrId("txt_certificate_manager_info_device_certificates_c")); |
769 mNote->setText(hbTrId("txt_certificate_manager_info_device_certificates_c")); |
732 } |
770 } |
733 else if( mCertView == EDeviceView ) |
771 else if( mCertView == EDeviceView ) |
734 { |
772 { |
735 note.setText("Use of Personal certificates may require user confirmation. Proceed?"); |
773 mNote->setText("Use of Personal certificates may require user confirmation. Proceed?"); |
736 } |
774 } |
737 |
775 |
738 note.setPrimaryAction(q_check_ptr(new HbAction("Yes"))); |
776 mNote->setPrimaryAction(q_check_ptr(new HbAction("Yes"))); |
739 note.setSecondaryAction(q_check_ptr(new HbAction("No"))); |
777 mNote->setSecondaryAction(q_check_ptr(new HbAction("No"))); |
740 note.setTimeout(HbPopup::NoTimeout); |
778 mNote->setTimeout(HbPopup::NoTimeout); |
741 note.setIconVisible (EFalse); |
779 mNote->setIconVisible (EFalse); |
742 HbAction* result = note.exec(); |
780 mNote->open(this,SLOT(handleMoveDialog(HbAction*))); |
743 |
781 } |
744 if (result != note.primaryAction()) |
782 |
|
783 void CpCertView::handleMoveDialog(HbAction* action) |
|
784 { |
|
785 |
|
786 if (action != mNote->primaryAction()) |
745 { |
787 { |
746 return; |
788 return; |
747 } |
789 } |
748 |
790 |
749 TInt count = indexList.Count(); |
791 TInt count = mIndexList.Count(); |
750 |
792 |
751 for(TInt index = 0 ; index < count; ++index) |
793 for(TInt index = 0 ; index < count; ++index) |
752 { |
794 { |
753 CCTCertInfo* entry = NULL; |
795 CCTCertInfo* entry = NULL; |
754 if(mCertView == EPersonalView) |
796 if(mCertView == EPersonalView) |
755 { |
797 { |
756 entry = mCertDataContainer->iUserLabelEntries[ indexList[index] ]->iUserEntry; |
798 entry = mCertDataContainer->iUserLabelEntries[ mIndexList[index] ]->iUserEntry; |
757 } |
799 } |
758 else if(mCertView == EDeviceView) |
800 else if(mCertView == EDeviceView) |
759 { |
801 { |
760 entry = mCertDataContainer->iDeviceLabelEntries[ indexList[index] ]->iDeviceEntry; |
802 entry = mCertDataContainer->iDeviceLabelEntries[ mIndexList[index] ]->iDeviceEntry; |
761 } |
803 } |
762 |
804 |
763 // Move key first |
805 // Move key first |
764 TCTKeyAttributeFilter keyFilter; |
806 TCTKeyAttributeFilter keyFilter; |
765 keyFilter.iKeyId = entry->SubjectKeyId(); |
807 keyFilter.iKeyId = entry->SubjectKeyId(); |