59 mListView(NULL), |
60 mListView(NULL), |
60 mEmptyList(NULL), |
61 mEmptyList(NULL), |
61 mBanner(NULL), |
62 mBanner(NULL), |
62 mSearchPanel(NULL), |
63 mSearchPanel(NULL), |
63 mLoader(NULL), |
64 mLoader(NULL), |
64 mLayout(NULL), |
65 mVirtualKeyboard(NULL), |
|
66 mNamesAction(NULL), |
65 mMenuBuilder(NULL), |
67 mMenuBuilder(NULL), |
66 mHandledContactId(0), |
68 mHandledContactId(0), |
67 mFetchView(NULL), |
69 mFetchView(NULL), |
68 mIsDefault(true), |
70 mIsDefault(true), |
69 mId( namesView ), |
71 mId( namesView ), |
70 mActionGroup(NULL) |
72 mActionGroup(NULL), |
71 { |
73 mFocusedContact(0) |
|
74 { |
|
75 CNT_ENTRY |
|
76 |
72 bool ok; |
77 bool ok; |
73 document()->load( CNT_CONTACTLIST_XML, &ok); |
78 document()->load( CNT_CONTACTLIST_XML, &ok); |
74 if (!ok) { |
79 if (!ok) { |
75 qFatal("Unable to read %S", CNT_CONTACTLIST_XML); |
80 qFatal("Unable to read %S", CNT_CONTACTLIST_XML); |
76 } |
81 } |
|
82 |
|
83 document()->load( CNT_CONTACTLIST_XML, "no_find"); |
|
84 |
77 mView = static_cast<HbView*> (document()->findWidget("view")); |
85 mView = static_cast<HbView*> (document()->findWidget("view")); |
78 |
86 |
79 mVirtualKeyboard = new HbStaticVkbHost(mView); |
87 mVirtualKeyboard = new HbStaticVkbHost(mView); |
80 connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(handleKeypadOpen())); |
88 connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(handleKeypadOpen())); |
81 connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(handleKeypadClose())); |
89 connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(handleKeypadClose())); |
82 |
90 |
83 mSoftkey = new HbAction(Hb::BackNaviAction, mView); |
91 mSoftkey = new HbAction(Hb::BackNaviAction, mView); |
84 |
92 connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
|
93 |
85 mNewContact = static_cast<HbAction*> (document()->findObject("cnt:newcontact")); |
94 mNewContact = static_cast<HbAction*> (document()->findObject("cnt:newcontact")); |
|
95 mNewContact->setParent(mView); |
|
96 connect(mNewContact, SIGNAL(triggered()), this, SLOT(createNewContact())); |
|
97 |
86 mMultipleDeleter = static_cast<HbAction*> (document()->findObject("cnt:delete")); |
98 mMultipleDeleter = static_cast<HbAction*> (document()->findObject("cnt:delete")); |
|
99 mMultipleDeleter->setParent(mView); |
|
100 connect(mMultipleDeleter, SIGNAL(triggered()), this, SLOT(deleteMultipleContacts())); |
|
101 |
87 HbAction* findContacts = static_cast<HbAction*> (document()->findObject("cnt:find")); |
102 HbAction* findContacts = static_cast<HbAction*> (document()->findObject("cnt:find")); |
|
103 findContacts->setParent(mView); |
|
104 connect(findContacts, SIGNAL(triggered()), this, SLOT(showFinder())); |
|
105 |
88 HbAction* groups = static_cast<HbAction*> (document()->findObject("cnt:groups")); |
106 HbAction* groups = static_cast<HbAction*> (document()->findObject("cnt:groups")); |
89 HbAction* names = static_cast<HbAction*> (document()->findObject("cnt:names")); |
107 groups->setParent(mView); |
|
108 connect(groups, SIGNAL(triggered()), this, SLOT(showCollectionView())); |
|
109 |
|
110 mNamesAction = static_cast<HbAction*> (document()->findObject("cnt:names")); |
|
111 mNamesAction->setParent(mView); |
|
112 |
90 mImportSim = static_cast<HbAction*> (document()->findObject("cnt:importsim")); |
113 mImportSim = static_cast<HbAction*> (document()->findObject("cnt:importsim")); |
|
114 mImportSim->setParent(mView); |
|
115 connect(mImportSim, SIGNAL(triggered()), this, SLOT(importSim())); |
91 |
116 |
92 mActionGroup = new QActionGroup(this); |
117 mActionGroup = new QActionGroup(this); |
93 groups->setActionGroup(mActionGroup); |
118 groups->setActionGroup(mActionGroup); |
94 names->setActionGroup(mActionGroup); |
119 mNamesAction->setActionGroup(mActionGroup); |
95 |
120 |
96 HbAction* extension = static_cast<HbAction*> (document()->findObject("cnt:activity")); |
121 HbAction* extension = static_cast<HbAction*> (document()->findObject("cnt:activity")); |
|
122 extension->setParent(mView); |
|
123 connect(extension, SIGNAL(triggered()), this, SLOT(handleExtensionAction())); |
97 |
124 |
98 connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
125 HbAction* settings = static_cast<HbAction*>(document()->findObject("cnt:settings") ); |
99 connect(mNewContact, SIGNAL(triggered()), this, SLOT(createNewContact())); |
126 settings->setParent(mView); |
100 connect(mMultipleDeleter, SIGNAL(triggered()), this, SLOT(deleteMultipleContacts())); |
127 connect( settings, SIGNAL(triggered()), this, SLOT(showSettings()) ); |
101 connect(findContacts, SIGNAL(triggered()), this, SLOT(showFinder())); |
128 |
102 connect(groups, SIGNAL(triggered()), this, SLOT(showCollectionView())); |
129 HbMenu* viewMenu = static_cast<HbMenu*>(document()->findObject("viewMenu") ); |
103 connect(mImportSim, SIGNAL(triggered()), this, SLOT(importSim())); |
130 viewMenu->setParent(mView); |
104 connect(extension, SIGNAL(triggered()), this, SLOT(handleExtensionAction())); |
131 |
105 connect(list(), SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), this, |
132 connect(list(), SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), this, |
106 SLOT(showContextMenu(HbAbstractViewItem*,QPointF))); |
133 SLOT(showContextMenu(HbAbstractViewItem*,QPointF))); |
107 connect(list(), SIGNAL(activated (const QModelIndex&)), this, |
134 connect(list(), SIGNAL(activated (const QModelIndex&)), this, |
108 SLOT(showContactView(const QModelIndex&))); |
135 SLOT(showContactView(const QModelIndex&))); |
109 |
136 |
110 HbAction* settings = static_cast<HbAction*>(document()->findObject("cnt:settings") ); |
137 mEmptyList = static_cast<HbLabel*> (document()->findWidget("emptyLabel")); |
111 connect( settings, SIGNAL(triggered()), this, SLOT(showSettings()) ); |
138 mBanner = static_cast<HbGroupBox*> (document()->findWidget("banner")); |
|
139 mSearchPanel = static_cast<HbSearchPanel*> (document()->findWidget("searchPanel")); |
|
140 connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(hideFinder())); |
|
141 connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, SLOT(setFilter(QString))); |
|
142 |
|
143 CNT_EXIT |
112 } |
144 } |
113 |
145 |
114 CntNamesViewPrivate::~CntNamesViewPrivate() |
146 CntNamesViewPrivate::~CntNamesViewPrivate() |
115 { |
147 { |
116 mView->deleteLater(); |
148 CNT_ENTRY |
117 |
149 |
118 delete mListModel; |
150 delete mListModel; |
119 mListModel = NULL; |
151 mListModel = NULL; |
120 |
152 |
121 delete mListView; |
|
122 mListView = NULL; |
|
123 |
|
124 delete mSearchPanel; |
|
125 mSearchPanel = NULL; |
|
126 |
|
127 delete mEmptyList; |
|
128 mEmptyList = NULL; |
|
129 |
|
130 delete mBanner; |
|
131 mBanner = NULL; |
|
132 |
|
133 delete mLoader; |
153 delete mLoader; |
134 mLoader = NULL; |
154 mLoader = NULL; |
135 |
155 |
136 delete mVirtualKeyboard; |
156 delete mVirtualKeyboard; |
137 mVirtualKeyboard = NULL; |
157 mVirtualKeyboard = NULL; |
138 |
158 |
139 delete mMenuBuilder; |
159 delete mMenuBuilder; |
140 mMenuBuilder = NULL; |
160 mMenuBuilder = NULL; |
|
161 |
|
162 delete mView; |
|
163 mView = NULL; |
|
164 |
|
165 CNT_EXIT |
141 } |
166 } |
142 |
167 |
143 void CntNamesViewPrivate::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
168 void CntNamesViewPrivate::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
144 { |
169 { |
|
170 CNT_ENTRY |
|
171 |
145 Q_UNUSED( aArgs ) |
172 Q_UNUSED( aArgs ) |
146 mViewManager = aMgr; |
173 mViewManager = aMgr; |
|
174 |
147 if (!mListModel) { |
175 if (!mListModel) { |
148 QContactSortOrder sortOrderFirstName; |
|
149 sortOrderFirstName.setDetailDefinitionName(QContactName::DefinitionName, |
|
150 QContactName::FieldFirstName); |
|
151 sortOrderFirstName.setCaseSensitivity(Qt::CaseInsensitive); |
|
152 |
|
153 QContactSortOrder sortOrderLastName; |
|
154 sortOrderLastName.setDetailDefinitionName(QContactName::DefinitionName, |
|
155 QContactName::FieldLastName); |
|
156 sortOrderLastName.setCaseSensitivity(Qt::CaseInsensitive); |
|
157 |
|
158 QList<QContactSortOrder> sortOrders; |
|
159 sortOrders.append(sortOrderFirstName); |
|
160 sortOrders.append(sortOrderLastName); |
|
161 |
|
162 QContactDetailFilter filter; |
176 QContactDetailFilter filter; |
163 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
177 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
164 QString typeContact = QContactType::TypeContact; |
178 QString typeContact = QContactType::TypeContact; |
165 filter.setValue(typeContact); |
179 filter.setValue(typeContact); |
166 |
180 |
167 mListModel = new CntListModel(mViewManager->contactManager(SYMBIAN_BACKEND), filter, sortOrders); |
181 mListModel = new CntListModel(mViewManager->contactManager(SYMBIAN_BACKEND), filter); |
168 list()->setModel(mListModel); |
182 list()->setModel(mListModel); |
169 |
183 setFocusedContact(); |
170 } |
184 } |
171 |
185 |
172 HbAction* names = static_cast<HbAction*> (document()->findObject("cnt:names")); |
186 mNamesAction->setChecked(true); |
173 names->setChecked(true); |
|
174 |
187 |
175 mMenuBuilder = new CntActionMenuBuilder( mListModel->myCardId() ); |
188 mMenuBuilder = new CntActionMenuBuilder( mListModel->myCardId() ); |
176 connect( mMenuBuilder, SIGNAL(deleteContact(QContact&)), this, SLOT(deleteContact(QContact&)) ); |
189 connect( mMenuBuilder, SIGNAL(deleteContact(QContact&)), this, SLOT(deleteContact(QContact&)) ); |
177 connect( mMenuBuilder, SIGNAL(editContact(QContact&)), this, SLOT(showContactEditorView(QContact&)) ); |
190 connect( mMenuBuilder, SIGNAL(editContact(QContact&)), this, SLOT(showContactEditorView(QContact&)) ); |
178 connect( mMenuBuilder, SIGNAL(openContact(QContact&)), this, SLOT(showContactView(QContact&)) ); |
191 connect( mMenuBuilder, SIGNAL(openContact(QContact&)), this, SLOT(showContactView(QContact&)) ); |
187 |
200 |
188 QContactManager* contactManager = aMgr->contactManager( SYMBIAN_BACKEND ); |
201 QContactManager* contactManager = aMgr->contactManager( SYMBIAN_BACKEND ); |
189 // make connections unique, that is, duplicate connections are not connected again |
202 // make connections unique, that is, duplicate connections are not connected again |
190 connect(contactManager, SIGNAL(contactsAdded(const QList<QContactLocalId>&)), |
203 connect(contactManager, SIGNAL(contactsAdded(const QList<QContactLocalId>&)), |
191 this, SLOT(handleContactAddition(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
204 this, SLOT(handleContactAddition(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
192 connect(contactManager, SIGNAL(contactsChanged(const QList<QContactLocalId>&)), |
|
193 this, SLOT(handleContactChanged(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
|
194 connect(contactManager, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
205 connect(contactManager, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
195 this, SLOT(handleContactRemoval(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
206 this, SLOT(handleContactRemoval(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
196 connect(contactManager, SIGNAL(selfContactIdChanged(const QContactLocalId&, const QContactLocalId&)), |
207 connect(contactManager, SIGNAL(selfContactIdChanged(const QContactLocalId&, const QContactLocalId&)), |
197 this, SLOT(handleSelfContactIdChange(const QContactLocalId&, const QContactLocalId&)), Qt::UniqueConnection); |
208 this, SLOT(handleSelfContactIdChange(const QContactLocalId&, const QContactLocalId&)), Qt::UniqueConnection); |
|
209 |
|
210 setScrollPosition(); |
|
211 |
|
212 CNT_EXIT |
198 } |
213 } |
199 |
214 |
200 void CntNamesViewPrivate::deactivate() |
215 void CntNamesViewPrivate::deactivate() |
201 { |
216 { |
|
217 CNT_ENTRY |
|
218 |
202 hideFinder(); |
219 hideFinder(); |
203 |
220 |
204 delete mMenuBuilder; |
221 delete mMenuBuilder; |
205 mMenuBuilder = NULL; |
222 mMenuBuilder = NULL; |
|
223 |
|
224 CNT_EXIT |
206 } |
225 } |
207 |
226 |
208 void CntNamesViewPrivate::disableDeleteAction() |
227 void CntNamesViewPrivate::disableDeleteAction() |
209 { |
228 { |
|
229 CNT_ENTRY |
|
230 |
210 bool multipleContacts = mListModel->rowCount() >= CNT_MIN_ROW_COUNT; |
231 bool multipleContacts = mListModel->rowCount() >= CNT_MIN_ROW_COUNT; |
211 mMultipleDeleter->setEnabled(multipleContacts); |
232 mMultipleDeleter->setEnabled(multipleContacts); |
|
233 |
|
234 CNT_EXIT |
|
235 } |
|
236 |
|
237 void CntNamesViewPrivate::focusLineEdit() |
|
238 { |
|
239 CNT_ENTRY |
|
240 |
|
241 HbLineEdit *editor = static_cast<HbLineEdit*>(mSearchPanel->primitive("lineedit")); |
|
242 editor->setInputMethodHints(Qt::ImhNoPredictiveText); |
|
243 |
|
244 if (editor) |
|
245 { |
|
246 editor->setText(""); |
|
247 editor->setFocus(); |
|
248 } |
|
249 |
|
250 CNT_EXIT |
212 } |
251 } |
213 |
252 |
214 void CntNamesViewPrivate::setFilter(const QString &filterString) |
253 void CntNamesViewPrivate::setFilter(const QString &filterString) |
215 { |
254 { |
|
255 CNT_ENTRY |
|
256 |
216 QStringList searchList = filterString.split(QRegExp("\\s+"), QString::SkipEmptyParts); |
257 QStringList searchList = filterString.split(QRegExp("\\s+"), QString::SkipEmptyParts); |
217 QContactDetailFilter filter; |
258 QContactDetailFilter filter; |
218 filter.setDetailDefinitionName(QContactDisplayLabel::DefinitionName, |
259 filter.setDetailDefinitionName(QContactDisplayLabel::DefinitionName, |
219 QContactDisplayLabel::FieldLabel); |
260 QContactDisplayLabel::FieldLabel); |
220 filter.setMatchFlags(QContactFilter::MatchStartsWith); |
261 filter.setMatchFlags(QContactFilter::MatchStartsWith); |
221 filter.setValue(searchList); |
262 filter.setValue(searchList); |
222 |
263 |
223 mListModel->setFilterAndSortOrder(filter); |
264 mListModel->setFilter(filter); |
224 |
265 |
225 if (mListModel->rowCount() == 0) { |
266 if (mListModel->rowCount() == 0) |
226 layout()->removeItem(list()); |
267 { |
227 layout()->insertItem(1, emptyLabel()); |
268 document()->load( CNT_CONTACTLIST_XML, "find_empty" ); |
228 list()->setVisible(false); |
269 } |
229 emptyLabel()->setVisible(true); |
270 else |
230 } |
271 { |
231 else { |
272 document()->load( CNT_CONTACTLIST_XML, "find_list" ); |
232 layout()->removeItem(emptyLabel()); |
273 } |
233 layout()->insertItem(1, list()); |
274 |
234 emptyLabel()->setVisible(false); |
275 CNT_EXIT |
235 list()->setVisible(true); |
276 } |
236 } |
277 |
|
278 void CntNamesViewPrivate::handleKeypadOpen() |
|
279 { |
|
280 CNT_ENTRY |
|
281 |
|
282 mView->setMaximumHeight(mVirtualKeyboard->applicationArea().height()); |
|
283 |
|
284 CNT_EXIT |
|
285 } |
|
286 |
|
287 void CntNamesViewPrivate::handleKeypadClose() |
|
288 { |
|
289 CNT_ENTRY |
|
290 |
|
291 mView->setMaximumHeight(-1); |
|
292 |
|
293 CNT_EXIT |
|
294 } |
|
295 |
|
296 void CntNamesViewPrivate::showFinder() |
|
297 { |
|
298 CNT_ENTRY |
|
299 |
|
300 focusLineEdit(); |
|
301 |
|
302 mView->hideItems(Hb::AllItems); |
|
303 |
237 mListModel->showMyCard(false); |
304 mListModel->showMyCard(false); |
238 } |
305 |
239 |
|
240 void CntNamesViewPrivate::handleKeypadOpen() |
|
241 { |
|
242 qreal searchHeight = search()->size().height(); |
|
243 qreal bannerHeight = groupBox()->size().height(); |
|
244 qreal heightToSet = mView->size().height() - mVirtualKeyboard->keyboardArea().height() |
|
245 - searchHeight - bannerHeight; |
|
246 |
|
247 list()->setMaximumHeight(heightToSet); |
|
248 emptyLabel()->setMaximumHeight(heightToSet); |
|
249 } |
|
250 |
|
251 void CntNamesViewPrivate::handleKeypadClose() |
|
252 { |
|
253 list()->setMaximumHeight(mView->size().height()); |
|
254 emptyLabel()->setMaximumHeight(mView->size().height()); |
|
255 } |
|
256 |
|
257 void CntNamesViewPrivate::showBanner(const QString aText) |
|
258 { |
|
259 layout()->insertItem(0, groupBox()); |
|
260 groupBox()->setHeading(aText); |
|
261 groupBox()->setVisible(true); |
|
262 } |
|
263 |
|
264 void CntNamesViewPrivate::hideBanner() |
|
265 { |
|
266 layout()->removeItem(groupBox()); |
|
267 groupBox()->setVisible(false); |
|
268 } |
|
269 |
|
270 void CntNamesViewPrivate::showFinder() |
|
271 { |
|
272 showBanner(hbTrId("txt_phob_subtitle_find_all_contacts")); |
|
273 |
|
274 mView->toolBar()->hide(); |
|
275 mImportSim->setVisible(false); |
306 mImportSim->setVisible(false); |
276 mNewContact->setVisible(false); |
307 mNewContact->setVisible(false); |
277 mMultipleDeleter->setVisible(false); |
308 mMultipleDeleter->setVisible(false); |
278 |
309 |
279 setFilter(QString()); |
310 CNT_EXIT |
280 |
|
281 list()->setVisible(true); |
|
282 layout()->addItem(search()); |
|
283 search()->setVisible(true); |
|
284 |
|
285 mListModel->showMyCard(false); |
|
286 } |
311 } |
287 |
312 |
288 void CntNamesViewPrivate::hideFinder() |
313 void CntNamesViewPrivate::hideFinder() |
289 { |
314 { |
290 if ( mSearchPanel ) |
315 CNT_ENTRY |
291 { |
316 |
292 search()->setCriteria( QString() ); |
317 mVirtualKeyboard->closeKeypad(); |
293 layout()->removeItem(emptyLabel()); |
318 mView->setMaximumHeight(-1); |
294 layout()->removeItem(search()); |
319 |
295 emptyLabel()->setVisible(false); |
320 document()->load( CNT_CONTACTLIST_XML, "no_find" ); |
296 search()->setVisible(false); |
321 mView->showItems(Hb::AllItems); |
297 |
322 |
298 hideBanner(); |
323 mListModel->showMyCard(true); |
299 |
324 |
300 layout()->addItem(list()); |
325 QContactDetailFilter filter; |
301 list()->setVisible(true); |
326 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
302 |
327 QString typeContact = QContactType::TypeContact; |
303 QContactDetailFilter filter; |
328 filter.setValue(typeContact); |
304 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
329 |
305 QString typeContact = QContactType::TypeContact; |
330 mListModel->setFilter(filter); |
306 filter.setValue(typeContact); |
331 |
307 |
332 mNewContact->setVisible(true); |
308 mListModel->setFilterAndSortOrder(filter); |
333 mImportSim->setVisible(true); |
309 mListModel->showMyCard(true); |
334 mMultipleDeleter->setVisible(true); |
310 |
335 |
311 mNewContact->setVisible(true); |
336 CNT_EXIT |
312 mImportSim->setVisible(true); |
|
313 mMultipleDeleter->setVisible(true); |
|
314 mView->toolBar()->show(); |
|
315 } |
|
316 } |
337 } |
317 |
338 |
318 bool CntNamesViewPrivate::isFinderVisible() |
339 bool CntNamesViewPrivate::isFinderVisible() |
319 { |
340 { |
|
341 CNT_ENTRY |
|
342 |
320 bool isVisible = false; |
343 bool isVisible = false; |
321 if ( mSearchPanel ) |
344 if ( mSearchPanel ) |
322 { |
345 { |
323 isVisible = mSearchPanel->isVisible(); |
346 isVisible = mSearchPanel->isVisible(); |
324 } |
347 } |
|
348 |
|
349 CNT_EXIT |
325 return isVisible; |
350 return isVisible; |
326 } |
351 } |
327 |
352 |
328 void CntNamesViewPrivate::showPreviousView() |
353 void CntNamesViewPrivate::showPreviousView() |
329 { |
354 { |
|
355 CNT_ENTRY |
|
356 |
330 if ( !isFinderVisible() ) |
357 if ( !isFinderVisible() ) |
331 { |
358 { |
332 qApp->quit(); |
359 mViewManager->back( CntViewParameters() ); |
333 } |
360 } |
334 hideFinder(); |
361 else |
|
362 { |
|
363 hideFinder(); |
|
364 } |
|
365 |
|
366 CNT_EXIT |
335 } |
367 } |
336 |
368 |
337 void CntNamesViewPrivate::handleExtensionAction() |
369 void CntNamesViewPrivate::handleExtensionAction() |
338 { |
370 { |
339 for(int i = 0;i < mExtensionManager.pluginCount();i++) |
371 CNT_ENTRY |
|
372 |
|
373 for (int i = 0; i < mExtensionManager.pluginCount(); i++) |
340 { |
374 { |
341 CntUiSocialExtension* socialExtension = mExtensionManager.pluginAt(i)->socialExtension(); |
375 CntUiSocialExtension* socialExtension = mExtensionManager.pluginAt(i)->socialExtension(); |
342 if (socialExtension) |
376 if (socialExtension) |
343 { |
377 { |
344 CntViewParameters params; |
378 CntViewParameters params; |
345 socialExtension->handleToolbarAction(params); |
379 socialExtension->handleToolbarAction(params); |
346 if (params.count()) |
380 if (params.count()) |
347 { |
381 { |
|
382 setFocusedContact(); |
348 mViewManager->changeView(params); |
383 mViewManager->changeView(params); |
349 break; |
384 break; |
350 } |
385 } |
351 } |
386 } |
352 } |
387 } |
|
388 |
|
389 CNT_EXIT |
353 } |
390 } |
354 |
391 |
355 void CntNamesViewPrivate::createNewContact() |
392 void CntNamesViewPrivate::createNewContact() |
356 { |
393 { |
|
394 CNT_ENTRY |
|
395 |
357 QContact newContact; |
396 QContact newContact; |
358 newContact.setType( QContactType::TypeContact ); |
397 newContact.setType( QContactType::TypeContact ); |
359 |
398 |
360 showContactEditorView(newContact); |
399 showContactEditorView(newContact); |
|
400 |
|
401 CNT_EXIT |
361 } |
402 } |
362 |
403 |
363 void CntNamesViewPrivate::deleteContact(QContact& aContact) |
404 void CntNamesViewPrivate::deleteContact(QContact& aContact) |
364 { |
405 { |
|
406 CNT_ENTRY |
|
407 |
365 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
408 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
366 QString name = manager->synthesizedDisplayLabel(aContact); |
409 QString name = manager->synthesizedDisplayLabel(aContact); |
367 |
410 |
368 mHandledContactId = aContact.localId(); |
411 mHandledContactId = aContact.localId(); |
369 |
412 |
370 HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(HbAction*)), |
413 HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(HbAction*)), |
371 hbTrId("txt_phob_button_delete"), hbTrId("txt_common_button_cancel")); |
414 hbTrId("txt_common_button_delete"), hbTrId("txt_common_button_cancel")); |
|
415 |
|
416 CNT_EXIT |
372 } |
417 } |
373 |
418 |
374 void CntNamesViewPrivate::deleteMultipleContacts() |
419 void CntNamesViewPrivate::deleteMultipleContacts() |
375 { |
420 { |
|
421 CNT_ENTRY |
|
422 |
376 if (!mFetchView) { |
423 if (!mFetchView) { |
377 mFetchView = new CntFetchContacts(mViewManager->contactManager( SYMBIAN_BACKEND )); |
424 mFetchView = new CntFetchContacts(mViewManager->contactManager( SYMBIAN_BACKEND )); |
378 connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleDeleteMultipleContacts())); |
425 connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleDeleteMultipleContacts())); |
379 } |
426 } |
380 |
427 |
381 mFetchView->setDetails(hbTrId("txt_phob_title_delete_contacts"),hbTrId("txt_phob_button_delete")); |
428 mFetchView->setDetails(hbTrId("txt_phob_title_delete_contacts"),hbTrId("txt_common_button_delete")); |
382 QSet<QContactLocalId> emptyContactsSet; |
429 QSet<QContactLocalId> emptyContactsSet; |
383 |
430 |
384 // Pop up a list of contacts for deletion |
431 // Pop up a list of contacts for deletion |
385 mFetchView->displayContacts(CntFetchContacts::popup, |
432 mFetchView->displayContacts(CntFetchContacts::popup, |
386 HbAbstractItemView::MultiSelection, |
433 HbAbstractItemView::MultiSelection, |
387 emptyContactsSet); |
434 emptyContactsSet); |
|
435 CNT_EXIT |
388 } |
436 } |
389 |
437 |
390 void CntNamesViewPrivate::handleDeleteMultipleContacts() |
438 void CntNamesViewPrivate::handleDeleteMultipleContacts() |
391 { |
439 { |
|
440 CNT_ENTRY |
|
441 |
392 QSet<QContactLocalId> selectedContacts = mFetchView->getSelectedContacts(); |
442 QSet<QContactLocalId> selectedContacts = mFetchView->getSelectedContacts(); |
393 |
443 |
394 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
444 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
395 if ( !mFetchView->wasCanceled() && !selectedContacts.isEmpty() ) { |
445 if ( !mFetchView->wasCanceled() && !selectedContacts.isEmpty() ) { |
396 foreach ( QContactLocalId id, selectedContacts.values() ) |
446 foreach ( QContactLocalId id, selectedContacts.values() ) |
435 menu->setPreferredPos( aPoint ); |
498 menu->setPreferredPos( aPoint ); |
436 menu->setAttribute( Qt::WA_DeleteOnClose, true ); |
499 menu->setAttribute( Qt::WA_DeleteOnClose, true ); |
437 menu->open(); |
500 menu->open(); |
438 } |
501 } |
439 |
502 |
440 |
503 CNT_EXIT |
441 } |
504 } |
442 |
505 |
443 void CntNamesViewPrivate::executeAction( QContact& aContact, QString aAction ) |
506 void CntNamesViewPrivate::executeAction( QContact& aContact, QString aAction ) |
444 { |
507 { |
|
508 CNT_ENTRY |
|
509 |
445 CntActionLauncher* other = new CntActionLauncher( aAction ); |
510 CntActionLauncher* other = new CntActionLauncher( aAction ); |
446 connect(other, SIGNAL(actionExecuted(CntAction*)), this, SLOT(actionExecuted(CntAction*))); |
511 connect(other, SIGNAL(actionExecuted(CntAction*)), this, SLOT(actionExecuted(CntAction*))); |
447 other->execute(aContact, QContactDetail()); |
512 other->execute(aContact, QContactDetail()); |
|
513 |
|
514 CNT_EXIT |
448 } |
515 } |
449 |
516 |
450 void CntNamesViewPrivate::actionExecuted(CntActionLauncher* aAction) |
517 void CntNamesViewPrivate::actionExecuted(CntActionLauncher* aAction) |
451 { |
518 { |
|
519 CNT_ENTRY |
|
520 |
452 aAction->deleteLater(); |
521 aAction->deleteLater(); |
|
522 |
|
523 CNT_EXIT |
453 } |
524 } |
454 |
525 |
455 void CntNamesViewPrivate::handleDeleteContact( HbAction* aAction ) |
526 void CntNamesViewPrivate::handleDeleteContact( HbAction* aAction ) |
456 { |
527 { |
|
528 CNT_ENTRY |
|
529 |
457 HbMessageBox *note = static_cast<HbMessageBox*>(sender()); |
530 HbMessageBox *note = static_cast<HbMessageBox*>(sender()); |
458 |
531 |
459 if (note && aAction == note->actions().first()) |
532 if (note && aAction == note->actions().first()) |
460 { |
533 { |
461 mViewManager->contactManager( SYMBIAN_BACKEND )->removeContact(mHandledContactId); |
534 mViewManager->contactManager( SYMBIAN_BACKEND )->removeContact(mHandledContactId); |
462 } |
535 } |
463 |
536 |
464 mHandledContactId = 0; |
537 mHandledContactId = 0; |
|
538 |
|
539 CNT_EXIT |
465 } |
540 } |
466 |
541 |
467 void CntNamesViewPrivate::showContactEditorView(QContact& aContact) |
542 void CntNamesViewPrivate::showContactEditorView(QContact& aContact) |
468 { |
543 { |
|
544 CNT_ENTRY |
|
545 |
|
546 setFocusedContact(); |
469 CntViewParameters args; |
547 CntViewParameters args; |
470 args.insert(EViewId, editView); |
548 args.insert(EViewId, editView); |
471 |
549 |
472 QVariant contact; |
550 QVariant contact; |
473 contact.setValue(aContact); |
551 contact.setValue(aContact); |
474 args.insert(ESelectedContact, contact); |
552 args.insert(ESelectedContact, contact); |
475 |
553 |
476 mViewManager->changeView(args); |
554 mViewManager->changeView(args); |
|
555 |
|
556 CNT_EXIT |
477 } |
557 } |
478 |
558 |
479 void CntNamesViewPrivate::showCollectionView() |
559 void CntNamesViewPrivate::showCollectionView() |
480 { |
560 { |
|
561 CNT_ENTRY |
|
562 |
|
563 setFocusedContact(); |
481 CntViewParameters args; |
564 CntViewParameters args; |
482 args.insert(EViewId, collectionView); |
565 args.insert(EViewId, collectionView); |
483 mViewManager->changeView(args); |
566 mViewManager->changeView(args); |
|
567 |
|
568 CNT_EXIT |
484 } |
569 } |
485 |
570 |
486 void CntNamesViewPrivate::importSim() |
571 void CntNamesViewPrivate::importSim() |
487 { |
572 { |
488 CntViewParameters args; |
573 CNT_ENTRY |
489 args.insert(EViewId, importsView); |
574 |
490 mViewManager->changeView(args); |
575 setFocusedContact(); |
|
576 CntViewParameters args; |
|
577 args.insert(EViewId, importsView); |
|
578 mViewManager->changeView(args); |
|
579 |
|
580 CNT_EXIT |
491 } |
581 } |
492 |
582 |
493 void CntNamesViewPrivate::showSettings() |
583 void CntNamesViewPrivate::showSettings() |
494 { |
584 { |
|
585 CNT_ENTRY |
|
586 |
|
587 setFocusedContact(); |
495 CntViewParameters args; |
588 CntViewParameters args; |
496 args.insert( EViewId, settingsView ); |
589 args.insert( EViewId, settingsView ); |
497 mViewManager->changeView( args ); |
590 mViewManager->changeView( args ); |
|
591 |
|
592 CNT_EXIT |
498 } |
593 } |
499 |
594 |
500 void CntNamesViewPrivate::handleContactAddition(const QList<QContactLocalId>& aAddedList) |
595 void CntNamesViewPrivate::handleContactAddition(const QList<QContactLocalId>& aAddedList) |
501 { |
596 { |
502 QContact contact = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(aAddedList.last()); |
597 CNT_ENTRY |
503 list()->scrollTo(mListModel->indexOfContact(contact)); |
598 |
|
599 Q_UNUSED(aAddedList); |
504 disableDeleteAction(); |
600 disableDeleteAction(); |
505 } |
601 |
506 |
602 CNT_EXIT |
507 void CntNamesViewPrivate::handleContactChanged(const QList<QContactLocalId>& aChangedList) |
603 } |
508 { |
604 |
509 QContact contact = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(aChangedList.last()); |
605 void CntNamesViewPrivate::handleContactRemoval(const QList<QContactLocalId>& aRemovedList) |
510 list()->scrollTo(mListModel->indexOfContact(contact)); |
606 { |
|
607 CNT_ENTRY |
|
608 |
|
609 Q_UNUSED(aRemovedList); |
511 disableDeleteAction(); |
610 disableDeleteAction(); |
512 } |
611 |
513 |
612 CNT_EXIT |
514 void CntNamesViewPrivate::handleContactRemoval(const QList<QContactLocalId>& aRemovedList) |
|
515 { |
|
516 Q_UNUSED(aRemovedList); |
|
517 QModelIndex index = list()->selectionModel()->currentIndex(); |
|
518 if (index.isValid()) |
|
519 list()->scrollTo(index); |
|
520 |
|
521 disableDeleteAction(); |
|
522 } |
613 } |
523 |
614 |
524 void CntNamesViewPrivate::handleSelfContactIdChange(const QContactLocalId& aOldId, const QContactLocalId& aNewId) |
615 void CntNamesViewPrivate::handleSelfContactIdChange(const QContactLocalId& aOldId, const QContactLocalId& aNewId) |
525 { |
616 { |
|
617 CNT_ENTRY |
|
618 |
526 Q_UNUSED(aOldId); |
619 Q_UNUSED(aOldId); |
527 Q_UNUSED(aNewId); |
620 Q_UNUSED(aNewId); |
528 disableDeleteAction(); |
621 disableDeleteAction(); |
|
622 |
|
623 CNT_EXIT |
|
624 } |
|
625 |
|
626 void CntNamesViewPrivate::setScrollPosition() |
|
627 { |
|
628 CNT_ENTRY |
|
629 |
|
630 // Scroll to the focused contact |
|
631 if ( mFocusedContact > 0 ) |
|
632 { |
|
633 QContactManager* contactManager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
|
634 QContact c = contactManager->contact(mFocusedContact); |
|
635 list()->scrollTo(mListModel->indexOfContact(c), HbAbstractItemView::PositionAtCenter); |
|
636 } |
|
637 |
|
638 CNT_EXIT |
529 } |
639 } |
530 |
640 |
531 //// lazy accessors |
641 //// lazy accessors |
532 HbListView* CntNamesViewPrivate::list() |
642 HbListView* CntNamesViewPrivate::list() |
533 { |
643 { |
|
644 CNT_ENTRY |
|
645 |
534 if (!mListView) { |
646 if (!mListView) { |
535 mListView = static_cast<HbListView*> (mLoader->findWidget("listView")); |
647 mListView = static_cast<HbListView*> (mLoader->findWidget("listView")); |
536 HbListViewItem *prototype = mListView->listItemPrototype(); |
|
537 prototype->setGraphicsSize(HbListViewItem::Thumbnail); |
|
538 |
648 |
539 mListView->setFrictionEnabled(true); |
649 mListView->setFrictionEnabled(true); |
540 mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
650 mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
541 mListView->listItemPrototype()->setGraphicsSize(HbListViewItem::Thumbnail); |
651 mListView->listItemPrototype()->setGraphicsSize(HbListViewItem::Thumbnail); |
542 mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); |
652 mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); |