15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "cntnamesview_p.h" |
18 #include "cntnamesview_p.h" |
19 #include "cntactionlauncher.h" |
19 #include "cntactionlauncher.h" |
20 #include "cntfetchcontactsview.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 |
25 |
25 #include <cntuiextensionfactory.h> |
26 #include <cntuiextensionfactory.h> |
26 #include <cntuisocialextension.h> |
27 #include <cntuisocialextension.h> |
27 |
28 |
28 #include <qapplication.h> |
|
29 #include <hbabstractviewitem.h> |
29 #include <hbabstractviewitem.h> |
30 #include <hbaction.h> |
30 #include <hbaction.h> |
31 #include <hbmenu.h> |
31 #include <hbmenu.h> |
32 #include <hbtoolbar.h> |
32 #include <hbtoolbar.h> |
33 #include <hbmainwindow.h> |
33 #include <hbmainwindow.h> |
135 mBanner = static_cast<HbGroupBox*> (document()->findWidget("banner")); |
134 mBanner = static_cast<HbGroupBox*> (document()->findWidget("banner")); |
136 mSearchPanel = static_cast<HbSearchPanel*> (document()->findWidget("searchPanel")); |
135 mSearchPanel = static_cast<HbSearchPanel*> (document()->findWidget("searchPanel")); |
137 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(hideFinder())); |
136 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(hideFinder())); |
138 connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, SLOT(setFilter(QString))); |
137 connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, SLOT(setFilter(QString))); |
139 |
138 |
140 CNT_EXIT |
139 HbMainWindow* win = mView->mainWindow(); |
|
140 CntApplication* cntApp = static_cast<CntApplication*>(qApp); |
|
141 connect(win, SIGNAL(viewReady()), cntApp, SIGNAL(applicationReady())); |
|
142 |
|
143 #ifdef __WINS__ |
|
144 mView->menu()->addAction("Change Orientation", this, SLOT(switchOrientation()) ); |
|
145 #endif |
|
146 CNT_EXIT |
|
147 } |
|
148 |
|
149 void CntNamesViewPrivate::switchOrientation() |
|
150 { |
|
151 HbMainWindow* win = mView->mainWindow(); |
|
152 Qt::Orientation orientation = win->orientation(); |
|
153 |
|
154 win->setOrientation( orientation == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal ); |
141 } |
155 } |
142 |
156 |
143 CntNamesViewPrivate::~CntNamesViewPrivate() |
157 CntNamesViewPrivate::~CntNamesViewPrivate() |
144 { |
158 { |
145 CNT_ENTRY |
159 CNT_ENTRY |
146 |
|
147 delete mFetchView; |
|
148 mFetchView = NULL; |
|
149 |
160 |
150 delete mListModel; |
161 delete mListModel; |
151 mListModel = NULL; |
162 mListModel = NULL; |
152 |
163 |
153 delete mLoader; |
164 delete mLoader; |
213 if (aArgs.value(ESelectedAction) == CNT_CREATE_ACTION || aArgs.value(ESelectedAction) == CNT_EDIT_ACTION) |
224 if (aArgs.value(ESelectedAction) == CNT_CREATE_ACTION || aArgs.value(ESelectedAction) == CNT_EDIT_ACTION) |
214 { |
225 { |
215 setScrollPosition(aArgs.value(ESelectedContact).value<QContact>().localId()); |
226 setScrollPosition(aArgs.value(ESelectedContact).value<QContact>().localId()); |
216 } |
227 } |
217 |
228 |
218 if ( aArgs.value( EFinder ).toString() == "show" ) |
229 if ( aArgs.value( EExtraAction ).toString() == CNT_FIND_ACTION ) |
219 { |
230 { |
220 showFinder(); |
231 showFinder(); |
221 } |
232 } |
222 |
233 |
223 CNT_EXIT |
234 CNT_EXIT |
224 } |
235 } |
225 |
236 |
226 void CntNamesViewPrivate::deactivate() |
237 void CntNamesViewPrivate::deactivate() |
227 { |
238 { |
228 CNT_ENTRY |
239 CNT_ENTRY |
229 |
240 HbMainWindow* win = mView->mainWindow(); |
230 // in UTs there is no mainwindow and therefore calling HbView::visibleItems() would cause a crash |
241 // in UTs there is no mainwindow and therefore calling HbView::visibleItems() would cause a crash |
231 if (mView->mainWindow() != NULL) |
242 if ( win != NULL) |
232 { |
243 { |
233 if (!(mView->visibleItems() & Hb::AllItems)) |
244 if (!(mView->visibleItems() & Hb::AllItems)) |
234 { |
245 { |
235 hideFinder(); |
246 hideFinder(); |
236 } |
247 } |
237 } |
248 |
238 |
249 CntApplication* cntApp = static_cast<CntApplication*>(qApp); |
|
250 disconnect(win, SIGNAL(viewReady()), cntApp, SIGNAL(applicationReady())); |
|
251 } |
239 delete mMenuBuilder; |
252 delete mMenuBuilder; |
240 mMenuBuilder = NULL; |
253 mMenuBuilder = NULL; |
241 |
254 |
242 CNT_EXIT |
255 CNT_EXIT |
243 } |
256 } |
424 } |
437 } |
425 |
438 |
426 void CntNamesViewPrivate::deleteMultipleContacts() |
439 void CntNamesViewPrivate::deleteMultipleContacts() |
427 { |
440 { |
428 CNT_ENTRY |
441 CNT_ENTRY |
429 |
442 CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( |
430 if (!mFetchView) { |
443 hbTrId("txt_phob_title_delete_contacts"), |
431 mFetchView = new CntFetchContacts(*mViewManager->contactManager( SYMBIAN_BACKEND )); |
444 hbTrId("txt_common_button_delete"), |
432 connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleDeleteMultipleContacts())); |
445 *mViewManager->contactManager(SYMBIAN_BACKEND)); |
433 } |
446 connect(popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), |
434 |
447 this, SLOT(handleDeleteMultipleContacts(QSet<QContactLocalId>)) ); |
435 mFetchView->setDetails(hbTrId("txt_phob_title_delete_contacts"),hbTrId("txt_common_button_delete")); |
448 |
436 QSet<QContactLocalId> emptyContactsSet; |
449 popup->showPopup(); |
437 |
450 CNT_EXIT |
438 // Pop up a list of contacts for deletion |
451 } |
439 mFetchView->displayContacts(HbAbstractItemView::MultiSelection, emptyContactsSet); |
452 |
440 CNT_EXIT |
453 void CntNamesViewPrivate::handleDeleteMultipleContacts( QSet<QContactLocalId> aIds ) |
441 } |
454 { |
442 |
455 CNT_ENTRY |
443 void CntNamesViewPrivate::handleDeleteMultipleContacts() |
456 |
444 { |
|
445 CNT_ENTRY |
|
446 |
|
447 QSet<QContactLocalId> selectedContacts = mFetchView->getSelectedContacts(); |
|
448 |
|
449 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
457 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
450 if ( !mFetchView->wasCanceled() && !selectedContacts.isEmpty() ) { |
458 foreach ( QContactLocalId id, aIds ) |
451 foreach ( QContactLocalId id, selectedContacts.values() ) |
459 { |
452 { |
460 manager->removeContact( id ); |
453 manager->removeContact( id ); |
461 } |
454 } |
|
455 } |
|
456 |
|
457 delete mFetchView; |
|
458 mFetchView = NULL; |
|
459 |
462 |
460 CNT_EXIT |
463 CNT_EXIT |
461 } |
464 } |
462 |
465 |
463 void CntNamesViewPrivate::showContactView( const QModelIndex& aIndex ) |
466 void CntNamesViewPrivate::showContactView( const QModelIndex& aIndex ) |
473 void CntNamesViewPrivate::showContactView( QContact& aContact ) |
476 void CntNamesViewPrivate::showContactView( QContact& aContact ) |
474 { |
477 { |
475 CNT_ENTRY |
478 CNT_ENTRY |
476 |
479 |
477 CntViewParameters args; |
480 CntViewParameters args; |
478 args.insert(EViewId, commLauncherView); |
481 args.insert(EViewId, contactCardView); |
479 if (aContact.localId() == mListModel->myCardId() && aContact.details().count() <= 4) |
482 if (aContact.localId() == mListModel->myCardId() && aContact.details().count() <= 4) |
480 { |
483 { |
481 args.insert(EViewId, myCardView); |
484 args.insert(EViewId, myCardView); |
482 } |
485 } |
483 |
486 |