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> |
45 #include <hbframebackground.h> |
45 #include <hbframebackground.h> |
46 #include <hbshrinkingvkbhost.h> |
46 #include <hbshrinkingvkbhost.h> |
47 #include <hbmessagebox.h> |
47 #include <hbmessagebox.h> |
48 #include <hbparameterlengthlimiter.h> |
48 #include <hbparameterlengthlimiter.h> |
49 |
49 |
|
50 #include <QInputContext> |
|
51 |
50 const char *CNT_CONTACTLIST_XML = ":/xml/contacts_namelist.docml"; |
52 const char *CNT_CONTACTLIST_XML = ":/xml/contacts_namelist.docml"; |
51 static const int CNT_MIN_ROW_COUNT = 2; |
53 static const int CNT_MIN_ROW_COUNT = 2; |
52 |
54 |
53 CntNamesViewPrivate::CntNamesViewPrivate(CntExtensionManager &extensionManager) : |
55 CntNamesViewPrivate::CntNamesViewPrivate(CntExtensionManager &extensionManager) : |
54 QObject(), |
56 QObject(), |
135 mBanner = static_cast<HbGroupBox*> (document()->findWidget("banner")); |
136 mBanner = static_cast<HbGroupBox*> (document()->findWidget("banner")); |
136 mSearchPanel = static_cast<HbSearchPanel*> (document()->findWidget("searchPanel")); |
137 mSearchPanel = static_cast<HbSearchPanel*> (document()->findWidget("searchPanel")); |
137 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(hideFinder())); |
138 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(hideFinder())); |
138 connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, SLOT(setFilter(QString))); |
139 connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, SLOT(setFilter(QString))); |
139 |
140 |
140 CNT_EXIT |
141 HbMainWindow* win = mView->mainWindow(); |
|
142 CntApplication* cntApp = static_cast<CntApplication*>(qApp); |
|
143 connect(win, SIGNAL(viewReady()), cntApp, SIGNAL(applicationReady())); |
|
144 |
|
145 #ifdef __WINS__ |
|
146 mView->menu()->addAction("Change Orientation", this, SLOT(switchOrientation()) ); |
|
147 #endif |
|
148 CNT_EXIT |
|
149 } |
|
150 |
|
151 void CntNamesViewPrivate::switchOrientation() |
|
152 { |
|
153 HbMainWindow* win = mView->mainWindow(); |
|
154 Qt::Orientation orientation = win->orientation(); |
|
155 |
|
156 win->setOrientation( orientation == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal ); |
141 } |
157 } |
142 |
158 |
143 CntNamesViewPrivate::~CntNamesViewPrivate() |
159 CntNamesViewPrivate::~CntNamesViewPrivate() |
144 { |
160 { |
145 CNT_ENTRY |
161 CNT_ENTRY |
170 void CntNamesViewPrivate::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
186 void CntNamesViewPrivate::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
171 { |
187 { |
172 CNT_ENTRY |
188 CNT_ENTRY |
173 |
189 |
174 mViewManager = aMgr; |
190 mViewManager = aMgr; |
|
191 if (mView->mainWindow() != NULL && !(mView->visibleItems() & Hb::AllItems)) |
|
192 { |
|
193 hideFinder(); |
|
194 } |
175 |
195 |
176 if (!mListModel) { |
196 if (!mListModel) { |
177 QContactDetailFilter filter; |
197 QContactDetailFilter filter; |
178 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
198 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
179 QString typeContact = QContactType::TypeContact; |
199 QString typeContact = QContactType::TypeContact; |
210 if (aArgs.value(ESelectedAction) == CNT_CREATE_ACTION || aArgs.value(ESelectedAction) == CNT_EDIT_ACTION) |
230 if (aArgs.value(ESelectedAction) == CNT_CREATE_ACTION || aArgs.value(ESelectedAction) == CNT_EDIT_ACTION) |
211 { |
231 { |
212 setScrollPosition(aArgs.value(ESelectedContact).value<QContact>().localId()); |
232 setScrollPosition(aArgs.value(ESelectedContact).value<QContact>().localId()); |
213 } |
233 } |
214 |
234 |
|
235 if ( aArgs.value( EExtraAction ).toString() == CNT_FIND_ACTION ) |
|
236 { |
|
237 showFinder(); |
|
238 } |
|
239 |
215 CNT_EXIT |
240 CNT_EXIT |
216 } |
241 } |
217 |
242 |
218 void CntNamesViewPrivate::deactivate() |
243 void CntNamesViewPrivate::deactivate() |
219 { |
244 { |
220 CNT_ENTRY |
245 CNT_ENTRY |
221 |
246 HbMainWindow* win = mView->mainWindow(); |
222 if (!(mView->visibleItems() & Hb::AllItems)) |
247 if ( win != NULL) |
223 { |
248 { |
224 hideFinder(); |
249 CntApplication* cntApp = static_cast<CntApplication*>(qApp); |
225 } |
250 disconnect(win, SIGNAL(viewReady()), cntApp, SIGNAL(applicationReady())); |
226 |
251 } |
227 delete mMenuBuilder; |
252 delete mMenuBuilder; |
228 mMenuBuilder = NULL; |
253 mMenuBuilder = NULL; |
229 |
254 |
230 CNT_EXIT |
255 CNT_EXIT |
231 } |
256 } |
293 mView->hideItems(Hb::AllItems); |
328 mView->hideItems(Hb::AllItems); |
294 |
329 |
295 mImportSim->setVisible(false); |
330 mImportSim->setVisible(false); |
296 mNewContact->setVisible(false); |
331 mNewContact->setVisible(false); |
297 mMultipleDeleter->setVisible(false); |
332 mMultipleDeleter->setVisible(false); |
|
333 HbAction* settings = static_cast<HbAction*>(document()->findObject("cnt:settings") ); |
|
334 settings->setVisible(false); |
298 |
335 |
299 CNT_EXIT |
336 CNT_EXIT |
300 } |
337 } |
301 |
338 |
302 void CntNamesViewPrivate::hideFinder() |
339 void CntNamesViewPrivate::hideFinder() |
303 { |
340 { |
304 CNT_ENTRY |
341 CNT_ENTRY |
305 |
|
306 mVirtualKeyboard->closeKeypad(); |
|
307 mView->setMaximumHeight(-1); |
|
308 |
342 |
309 document()->load( CNT_CONTACTLIST_XML, "no_find" ); |
343 document()->load( CNT_CONTACTLIST_XML, "no_find" ); |
310 mView->showItems(Hb::AllItems); |
344 mView->showItems(Hb::AllItems); |
311 |
345 |
312 mListModel->showMyCard(true); |
346 mListModel->showMyCard(true); |
395 void CntNamesViewPrivate::deleteContact(QContact& aContact) |
431 void CntNamesViewPrivate::deleteContact(QContact& aContact) |
396 { |
432 { |
397 CNT_ENTRY |
433 CNT_ENTRY |
398 |
434 |
399 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
435 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
400 QString name = manager->synthesizedDisplayLabel(aContact); |
436 QString name = manager->synthesizedContactDisplayLabel(aContact); |
|
437 if (name.isEmpty()) |
|
438 { |
|
439 name = hbTrId("txt_phob_list_unnamed"); |
|
440 } |
401 |
441 |
402 mHandledContactId = aContact.localId(); |
442 mHandledContactId = aContact.localId(); |
403 |
443 |
404 HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(HbAction*)), |
444 HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(int)), |
405 hbTrId("txt_common_button_delete"), hbTrId("txt_common_button_cancel")); |
445 HbMessageBox::Delete | HbMessageBox::Cancel); |
406 |
446 |
407 CNT_EXIT |
447 CNT_EXIT |
408 } |
448 } |
409 |
449 |
410 void CntNamesViewPrivate::deleteMultipleContacts() |
450 void CntNamesViewPrivate::deleteMultipleContacts() |
411 { |
451 { |
412 CNT_ENTRY |
452 CNT_ENTRY |
413 |
453 CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( |
414 if (!mFetchView) { |
454 hbTrId("txt_phob_title_delete_contacts"), |
415 mFetchView = new CntFetchContacts(*mViewManager->contactManager( SYMBIAN_BACKEND )); |
455 hbTrId("txt_common_button_delete"), |
416 connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleDeleteMultipleContacts())); |
456 *mViewManager->contactManager(SYMBIAN_BACKEND)); |
417 } |
457 connect(popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), |
418 |
458 this, SLOT(handleDeleteMultipleContacts(QSet<QContactLocalId>)) ); |
419 mFetchView->setDetails(hbTrId("txt_phob_title_delete_contacts"),hbTrId("txt_common_button_delete")); |
459 |
420 QSet<QContactLocalId> emptyContactsSet; |
460 popup->showPopup(); |
421 |
461 CNT_EXIT |
422 // Pop up a list of contacts for deletion |
462 } |
423 mFetchView->displayContacts(HbAbstractItemView::MultiSelection, emptyContactsSet); |
463 |
424 CNT_EXIT |
464 void CntNamesViewPrivate::handleDeleteMultipleContacts( QSet<QContactLocalId> aIds ) |
425 } |
465 { |
426 |
466 CNT_ENTRY |
427 void CntNamesViewPrivate::handleDeleteMultipleContacts() |
467 |
428 { |
|
429 CNT_ENTRY |
|
430 |
|
431 QSet<QContactLocalId> selectedContacts = mFetchView->getSelectedContacts(); |
|
432 |
|
433 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
468 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
434 if ( !mFetchView->wasCanceled() && !selectedContacts.isEmpty() ) { |
469 foreach ( QContactLocalId id, aIds ) |
435 foreach ( QContactLocalId id, selectedContacts.values() ) |
470 { |
436 { |
471 manager->removeContact( id ); |
437 manager->removeContact( id ); |
472 } |
438 } |
|
439 } |
|
440 |
|
441 delete mFetchView; |
|
442 mFetchView = NULL; |
|
443 |
473 |
444 CNT_EXIT |
474 CNT_EXIT |
445 } |
475 } |
446 |
476 |
447 void CntNamesViewPrivate::showContactView( const QModelIndex& aIndex ) |
477 void CntNamesViewPrivate::showContactView( const QModelIndex& aIndex ) |
457 void CntNamesViewPrivate::showContactView( QContact& aContact ) |
487 void CntNamesViewPrivate::showContactView( QContact& aContact ) |
458 { |
488 { |
459 CNT_ENTRY |
489 CNT_ENTRY |
460 |
490 |
461 CntViewParameters args; |
491 CntViewParameters args; |
462 args.insert(EViewId, commLauncherView); |
492 args.insert(EViewId, contactCardView); |
463 if (aContact.localId() == mListModel->myCardId() && aContact.details().count() <= 4) |
493 if (aContact.localId() == mListModel->myCardId() && aContact.details().count() <= 4) |
464 { |
494 { |
465 args.insert(EViewId, myCardView); |
495 args.insert(EViewId, myCardView); |
466 } |
496 } |
467 |
497 |
512 aAction->deleteLater(); |
543 aAction->deleteLater(); |
513 |
544 |
514 CNT_EXIT |
545 CNT_EXIT |
515 } |
546 } |
516 |
547 |
517 void CntNamesViewPrivate::handleDeleteContact( HbAction* aAction ) |
548 void CntNamesViewPrivate::handleDeleteContact( int aAction ) |
518 { |
549 { |
519 CNT_ENTRY |
550 CNT_ENTRY |
520 |
551 |
521 HbMessageBox *note = static_cast<HbMessageBox*>(sender()); |
552 if (aAction == HbMessageBox::Delete) |
522 |
|
523 if (note && aAction == note->actions().first()) |
|
524 { |
553 { |
525 mViewManager->contactManager( SYMBIAN_BACKEND )->removeContact(mHandledContactId); |
554 mViewManager->contactManager( SYMBIAN_BACKEND )->removeContact(mHandledContactId); |
526 } |
555 } |
527 |
556 |
528 mHandledContactId = 0; |
557 mHandledContactId = 0; |