20 #include "cntfetchcontactpopup.h" |
20 #include "cntfetchcontactpopup.h" |
21 #include "cntextensionmanager.h" |
21 #include "cntextensionmanager.h" |
22 #include "cntglobal.h" |
22 #include "cntglobal.h" |
23 #include "cntdebug.h" |
23 #include "cntdebug.h" |
24 #include "cntapplication.h" |
24 #include "cntapplication.h" |
|
25 #include <cntabstractengine.h> |
25 |
26 |
26 #include <cntuiextensionfactory.h> |
27 #include <cntuiextensionfactory.h> |
27 #include <cntuisocialextension.h> |
28 #include <cntuisocialextension.h> |
28 |
29 |
29 #include <hbabstractviewitem.h> |
30 #include <hbabstractviewitem.h> |
37 #include <hblistview.h> |
38 #include <hblistview.h> |
38 #include <hblistviewitem.h> |
39 #include <hblistviewitem.h> |
39 #include <hblineedit.h> |
40 #include <hblineedit.h> |
40 #include <hbindexfeedback.h> |
41 #include <hbindexfeedback.h> |
41 #include <hbscrollbar.h> |
42 #include <hbscrollbar.h> |
42 #include <hbgroupbox.h> |
|
43 #include <hbsearchpanel.h> |
43 #include <hbsearchpanel.h> |
44 #include <hbtoolbar.h> |
44 #include <hbtoolbar.h> |
45 #include <hbframebackground.h> |
45 #include <hbframebackground.h> |
46 #include <hbshrinkingvkbhost.h> |
46 #include <hbshrinkingvkbhost.h> |
47 #include <hbmessagebox.h> |
47 #include <hbmessagebox.h> |
50 #include <QInputContext> |
50 #include <QInputContext> |
51 |
51 |
52 const char *CNT_CONTACTLIST_XML = ":/xml/contacts_namelist.docml"; |
52 const char *CNT_CONTACTLIST_XML = ":/xml/contacts_namelist.docml"; |
53 static const int CNT_MIN_ROW_COUNT = 2; |
53 static const int CNT_MIN_ROW_COUNT = 2; |
54 |
54 |
55 CntNamesViewPrivate::CntNamesViewPrivate(CntExtensionManager &extensionManager) : |
55 CntNamesViewPrivate::CntNamesViewPrivate() : |
56 QObject(), |
56 QObject(), |
57 mExtensionManager(extensionManager), |
|
58 mViewManager(NULL), |
57 mViewManager(NULL), |
59 mListModel(NULL), |
58 mListModel(NULL), |
60 mListView(NULL), |
59 mListView(NULL), |
61 mEmptyList(NULL), |
60 mEmptyList(NULL), |
62 mBanner(NULL), |
|
63 mSearchPanel(NULL), |
61 mSearchPanel(NULL), |
64 mLoader(NULL), |
62 mLoader(NULL), |
65 mVirtualKeyboard(NULL), |
63 mVirtualKeyboard(NULL), |
66 mNamesAction(NULL), |
64 mNamesAction(NULL), |
67 mMenuBuilder(NULL), |
65 mMenuBuilder(NULL), |
131 SLOT(showContextMenu(HbAbstractViewItem*,QPointF))); |
129 SLOT(showContextMenu(HbAbstractViewItem*,QPointF))); |
132 connect(list(), SIGNAL(activated (const QModelIndex&)), this, |
130 connect(list(), SIGNAL(activated (const QModelIndex&)), this, |
133 SLOT(showContactView(const QModelIndex&))); |
131 SLOT(showContactView(const QModelIndex&))); |
134 |
132 |
135 mEmptyList = static_cast<HbLabel*> (document()->findWidget("emptyLabel")); |
133 mEmptyList = static_cast<HbLabel*> (document()->findWidget("emptyLabel")); |
136 mBanner = static_cast<HbGroupBox*> (document()->findWidget("banner")); |
|
137 mSearchPanel = static_cast<HbSearchPanel*> (document()->findWidget("searchPanel")); |
134 mSearchPanel = static_cast<HbSearchPanel*> (document()->findWidget("searchPanel")); |
138 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(hideFinder())); |
135 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(hideFinder())); |
139 connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, SLOT(setFilter(QString))); |
136 connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, SLOT(setFilter(QString))); |
140 |
137 |
141 HbMainWindow* win = mView->mainWindow(); |
138 HbMainWindow* win = mView->mainWindow(); |
197 QContactDetailFilter filter; |
194 QContactDetailFilter filter; |
198 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
195 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
199 QString typeContact = QContactType::TypeContact; |
196 QString typeContact = QContactType::TypeContact; |
200 filter.setValue(typeContact); |
197 filter.setValue(typeContact); |
201 |
198 |
202 mListModel = new CntListModel(mViewManager->contactManager(SYMBIAN_BACKEND), filter); |
199 mListModel = new CntListModel( &mEngine->contactManager(SYMBIAN_BACKEND), filter); |
203 list()->setModel(mListModel); |
200 list()->setModel(mListModel); |
204 } |
201 } |
205 |
202 |
206 mNamesAction->setChecked(true); |
203 mNamesAction->setChecked(true); |
207 |
204 |
216 mView->setNavigationAction(mSoftkey); |
213 mView->setNavigationAction(mSoftkey); |
217 } |
214 } |
218 |
215 |
219 changeDeleteActionStatus(); |
216 changeDeleteActionStatus(); |
220 |
217 |
221 QContactManager* contactManager = aMgr->contactManager( SYMBIAN_BACKEND ); |
218 QContactManager* contactManager = &mEngine->contactManager( SYMBIAN_BACKEND ); |
222 // make connections unique, that is, duplicate connections are not connected again |
219 // make connections unique, that is, duplicate connections are not connected again |
223 connect(contactManager, SIGNAL(contactsAdded(const QList<QContactLocalId>&)), |
220 connect(contactManager, SIGNAL(contactsAdded(const QList<QContactLocalId>&)), |
224 this, SLOT(handleContactAddition(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
221 this, SLOT(handleContactAddition(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
225 connect(contactManager, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
222 connect(contactManager, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
226 this, SLOT(handleContactRemoval(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
223 this, SLOT(handleContactRemoval(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
268 void CntNamesViewPrivate::focusLineEdit() |
265 void CntNamesViewPrivate::focusLineEdit() |
269 { |
266 { |
270 CNT_ENTRY |
267 CNT_ENTRY |
271 |
268 |
272 HbLineEdit *editor = static_cast<HbLineEdit*>(mSearchPanel->primitive("lineedit")); |
269 HbLineEdit *editor = static_cast<HbLineEdit*>(mSearchPanel->primitive("lineedit")); |
273 editor->setObjectName("focusLineEdit"); |
|
274 editor->setInputMethodHints(Qt::ImhNoPredictiveText); |
|
275 |
|
276 if (editor) |
270 if (editor) |
277 { |
271 { |
|
272 editor->setObjectName("focusLineEdit"); |
|
273 editor->setInputMethodHints(Qt::ImhNoPredictiveText); |
278 editor->setText(""); |
274 editor->setText(""); |
279 editor->setFocus(); |
275 editor->setFocus(); |
280 |
276 |
281 // This opens the VKB |
277 // This opens the VKB |
282 QInputContext *ic = qApp->inputContext(); |
278 QInputContext *ic = qApp->inputContext(); |
321 { |
316 { |
322 CNT_ENTRY |
317 CNT_ENTRY |
323 |
318 |
324 mListModel->showMyCard(false); |
319 mListModel->showMyCard(false); |
325 |
320 |
|
321 HbListViewItem* proto = mListView->listItemPrototype(); |
|
322 proto->setTextFormat( Qt::RichText ); |
|
323 |
|
324 mView->hideItems(Hb::AllItems); |
|
325 |
326 focusLineEdit(); |
326 focusLineEdit(); |
327 |
|
328 mView->hideItems(Hb::AllItems); |
|
329 |
|
330 mImportSim->setVisible(false); |
|
331 mNewContact->setVisible(false); |
|
332 mMultipleDeleter->setVisible(false); |
|
333 HbAction* settings = static_cast<HbAction*>(document()->findObject("cnt:settings") ); |
|
334 settings->setVisible(false); |
|
335 |
327 |
336 CNT_EXIT |
328 CNT_EXIT |
337 } |
329 } |
338 |
330 |
339 void CntNamesViewPrivate::hideFinder() |
331 void CntNamesViewPrivate::hideFinder() |
341 CNT_ENTRY |
333 CNT_ENTRY |
342 |
334 |
343 document()->load( CNT_CONTACTLIST_XML, "no_find" ); |
335 document()->load( CNT_CONTACTLIST_XML, "no_find" ); |
344 mView->showItems(Hb::AllItems); |
336 mView->showItems(Hb::AllItems); |
345 |
337 |
|
338 HbListViewItem* proto = mListView->listItemPrototype(); |
|
339 proto->setTextFormat( Qt::PlainText ); |
|
340 |
346 mListModel->showMyCard(true); |
341 mListModel->showMyCard(true); |
347 |
342 |
348 if (mFilterChanged) |
343 if (mFilterChanged) |
349 { |
344 { |
350 QContactDetailFilter filter; |
345 QContactDetailFilter filter; |
353 filter.setValue(typeContact); |
348 filter.setValue(typeContact); |
354 mListModel->setFilter(filter); |
349 mListModel->setFilter(filter); |
355 mFilterChanged = false; |
350 mFilterChanged = false; |
356 } |
351 } |
357 |
352 |
358 mNewContact->setVisible(true); |
|
359 mImportSim->setVisible(true); |
|
360 mMultipleDeleter->setVisible(true); |
|
361 HbAction* settings = static_cast<HbAction*>(document()->findObject("cnt:settings") ); |
|
362 settings->setVisible(true); |
|
363 |
|
364 CNT_EXIT |
353 CNT_EXIT |
365 } |
354 } |
366 |
355 |
367 bool CntNamesViewPrivate::isFinderVisible() |
356 bool CntNamesViewPrivate::isFinderVisible() |
368 { |
357 { |
395 } |
384 } |
396 |
385 |
397 void CntNamesViewPrivate::handleExtensionAction() |
386 void CntNamesViewPrivate::handleExtensionAction() |
398 { |
387 { |
399 CNT_ENTRY |
388 CNT_ENTRY |
400 |
389 CntExtensionManager& mgr = mEngine->extensionManager(); |
401 for (int i = 0; i < mExtensionManager.pluginCount(); i++) |
390 for (int i = 0; i < mgr.pluginCount(); i++) |
402 { |
391 { |
403 CntUiSocialExtension* socialExtension = mExtensionManager.pluginAt(i)->socialExtension(); |
392 CntUiSocialExtension* socialExtension = mgr.pluginAt(i)->socialExtension(); |
404 if (socialExtension) |
393 if (socialExtension) |
405 { |
394 { |
406 CntViewParameters params; |
395 CntViewParameters params; |
407 socialExtension->handleToolbarAction(params); |
396 socialExtension->handleToolbarAction(params); |
408 if (params.count()) |
397 if (params.count()) |
451 { |
440 { |
452 CNT_ENTRY |
441 CNT_ENTRY |
453 CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( |
442 CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( |
454 hbTrId("txt_phob_title_delete_contacts"), |
443 hbTrId("txt_phob_title_delete_contacts"), |
455 hbTrId("txt_common_button_delete"), |
444 hbTrId("txt_common_button_delete"), |
456 *mViewManager->contactManager(SYMBIAN_BACKEND)); |
445 mEngine->contactManager(SYMBIAN_BACKEND)); |
457 connect(popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), |
446 connect(popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), |
458 this, SLOT(handleDeleteMultipleContacts(QSet<QContactLocalId>)) ); |
447 this, SLOT(handleDeleteMultipleContacts(QSet<QContactLocalId>)) ); |
459 |
448 QSet<QContactLocalId> ids; |
|
449 popup->setSelectedContacts(ids); |
460 popup->showPopup(); |
450 popup->showPopup(); |
461 CNT_EXIT |
451 CNT_EXIT |
462 } |
452 } |
463 |
453 |
464 void CntNamesViewPrivate::handleDeleteMultipleContacts( QSet<QContactLocalId> aIds ) |
454 void CntNamesViewPrivate::handleDeleteMultipleContacts( QSet<QContactLocalId> aIds ) |
465 { |
455 { |
466 CNT_ENTRY |
456 CNT_ENTRY |
467 |
457 |
468 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
458 mEngine->contactManager( SYMBIAN_BACKEND ).removeContacts(aIds.toList(), NULL); |
469 foreach ( QContactLocalId id, aIds ) |
|
470 { |
|
471 manager->removeContact( id ); |
|
472 } |
|
473 |
459 |
474 CNT_EXIT |
460 CNT_EXIT |
475 } |
461 } |
476 |
462 |
477 void CntNamesViewPrivate::showContactView( const QModelIndex& aIndex ) |
463 void CntNamesViewPrivate::showContactView( const QModelIndex& aIndex ) |
527 |
513 |
528 void CntNamesViewPrivate::executeAction( QContact& aContact, QContactDetail aDetail, QString aAction ) |
514 void CntNamesViewPrivate::executeAction( QContact& aContact, QContactDetail aDetail, QString aAction ) |
529 { |
515 { |
530 CNT_ENTRY |
516 CNT_ENTRY |
531 |
517 |
532 CntActionLauncher* other = new CntActionLauncher( *mViewManager->contactManager(SYMBIAN_BACKEND), aAction ); |
518 CntActionLauncher* other = new CntActionLauncher( mEngine->contactManager(SYMBIAN_BACKEND), aAction ); |
533 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
519 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
534 other->execute(aContact, aDetail); |
520 other->execute(aContact, aDetail); |
535 |
521 |
536 CNT_EXIT |
522 CNT_EXIT |
537 } |
523 } |
634 |
620 |
635 Q_UNUSED(aOldId); |
621 Q_UNUSED(aOldId); |
636 Q_UNUSED(aNewId); |
622 Q_UNUSED(aNewId); |
637 changeDeleteActionStatus(); |
623 changeDeleteActionStatus(); |
638 |
624 |
|
625 list()->scrollTo(mListModel->index(0)); |
|
626 |
639 CNT_EXIT |
627 CNT_EXIT |
640 } |
628 } |
641 |
629 |
642 void CntNamesViewPrivate::setScrollPosition(int focusedContact) |
630 void CntNamesViewPrivate::setScrollPosition(int focusedContact) |
643 { |
631 { |
644 CNT_ENTRY |
632 CNT_ENTRY |
645 |
633 |
646 // Scroll to the focused contact |
634 // Scroll to the focused contact |
647 if ( focusedContact > 0 ) |
635 if ( focusedContact > 0 ) |
648 { |
636 { |
649 QContactManager* contactManager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
637 QContactManager& contactManager = mEngine->contactManager( SYMBIAN_BACKEND ); |
650 QContact c = contactManager->contact(focusedContact); |
638 QContact c = contactManager.contact(focusedContact); |
651 list()->scrollTo(mListModel->indexOfContact(c), HbAbstractItemView::EnsureVisible); |
639 list()->scrollTo(mListModel->indexOfContact(c), HbAbstractItemView::EnsureVisible); |
652 } |
640 } |
653 |
641 |
654 CNT_EXIT |
642 CNT_EXIT |
655 } |
643 } |
669 mListView->verticalScrollBar()->setInteractive(true); |
657 mListView->verticalScrollBar()->setInteractive(true); |
670 |
658 |
671 HbFrameBackground frame; |
659 HbFrameBackground frame; |
672 frame.setFrameGraphicsName("qtg_fr_list_normal"); |
660 frame.setFrameGraphicsName("qtg_fr_list_normal"); |
673 frame.setFrameType(HbFrameDrawer::NinePieces); |
661 frame.setFrameType(HbFrameDrawer::NinePieces); |
674 mListView->itemPrototypes().first()->setDefaultFrame(frame); |
662 |
|
663 HbListViewItem* prototype = mListView->listItemPrototype(); |
|
664 prototype->setDefaultFrame( frame ); |
675 |
665 |
676 mListView->setUniformItemSizes(true); |
666 mListView->setUniformItemSizes(true); |
677 mListView->setItemRecycling(true); |
667 mListView->setItemRecycling(true); |
678 |
668 |
679 HbIndexFeedback *indexFeedback = new HbIndexFeedback(mView); |
669 HbIndexFeedback *indexFeedback = new HbIndexFeedback(mView); |