--- a/phonebookui/pbkcommonui/src/cnthistoryview.cpp Tue Jul 06 14:05:47 2010 +0300
+++ b/phonebookui/pbkcommonui/src/cnthistoryview.cpp Wed Aug 18 09:39:00 2010 +0300
@@ -30,9 +30,12 @@
#include <hbparameterlengthlimiter.h>
#include <hbmainwindow.h>
#include <hbframebackground.h>
+#include <QTimer>
+#include <qtcontacts.h>
#include "cnthistoryviewitem.h"
#include "cntglobal.h"
+#include "cntdebug.h"
const char *CNT_HISTORYVIEW_XML = ":/xml/contacts_history.docml";
@@ -99,6 +102,9 @@
*/
void CntHistoryView::deactivate()
{
+ QContactManager* cm = mViewMgr->contactManager(SYMBIAN_BACKEND);
+ disconnect(cm, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)),
+ this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&)));
}
/**
@@ -108,11 +114,18 @@
{
mViewMgr = aMgr;
mArgs = aArgs;
+
+ QContactManager* cm = mViewMgr->contactManager(SYMBIAN_BACKEND);
mContact = new QContact(mArgs.value(ESelectedContact).value<QContact>());
// Set history view heading
HbGroupBox* groupBox = static_cast<HbGroupBox*>(docLoader()->findWidget(QString("groupBox")));
- groupBox->setHeading(hbTrId("txt_phob_subtitle_history_with_1").arg(mContact->displayLabel()));
+ QString name = mContact->displayLabel();
+ if (name.isEmpty())
+ {
+ name = hbTrId("txt_phob_list_unnamed");
+ }
+ groupBox->setHeading(hbTrId("txt_phob_subtitle_history_with_1").arg(name));
//construct listview
mHistoryListView = static_cast<HbListView*>(docLoader()->findWidget(QString("listView")));
@@ -125,8 +138,7 @@
// Connect listview items to respective slots
connect(mHistoryListView, SIGNAL(activated(const QModelIndex &)),
this, SLOT(itemActivated(const QModelIndex &)));
- mHistoryModel = new CntHistoryModel(mContact->localId(),
- mViewMgr->contactManager(SYMBIAN_BACKEND));
+ mHistoryModel = new CntHistoryModel(mContact->localId(), cm);
mHistoryListView->setModel(mHistoryModel); //ownership is not taken
//start listening to the events amount changing in the model
@@ -150,6 +162,9 @@
HbMainWindow* mainWindow = mView->mainWindow();
connect(mainWindow, SIGNAL(orientationChanged(Qt::Orientation)),
this, SLOT(updateScrollingPosition()));
+
+ connect(cm, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)),
+ this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&)));
}
/*!
@@ -171,19 +186,21 @@
{
// Ask the use if they want to clear the history
QString name = mContact->displayLabel();
+ if (name.isEmpty())
+ {
+ name = hbTrId("txt_phob_list_unnamed");
+ }
HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_clear_communications_history_with_1")).arg(name), this,
- SLOT(handleClearHistory(HbAction*)), hbTrId("txt_common_button_delete"), hbTrId("txt_common_button_cancel"));
+ SLOT(handleClearHistory(int)), HbMessageBox::Delete | HbMessageBox::Cancel);
}
/*
Handle the selected action for clearing history
*/
-void CntHistoryView::handleClearHistory(HbAction *action)
+void CntHistoryView::handleClearHistory(int action)
{
- HbMessageBox *note = static_cast<HbMessageBox*>(sender());
-
- if (note && action == note->actions().first())
+ if (action == HbMessageBox::Delete)
{
mHistoryModel->clearHistory();
}
@@ -213,17 +230,17 @@
operation = "dial(QString)";
args << number;
createRequest = true;
+
+ // TODO: Using XQApplicationManager is not working with calls
+ // The factory method cannot create a request. Find out why
+ createRequest = false;
+ QString service("com.nokia.symbian.ICallDial");
+ QString type("dial(QString,int)");
+ XQServiceRequest snd(interface, operation, false);
+ snd << number.toString() << mContact->localId();
+ snd.send();
}
- // TODO: Using XQApplicationManager is not working with calls
- // The factory method cannot create a request. Find out why
- createRequest = false;
- QString service("com.nokia.symbian.ICallDial");
- QString type("dial(QString)");
- XQServiceRequest snd(interface, operation, false);
- snd << number.toString();
- snd.send();
-
} else if ( flags & CntMessage ) {
// Open conversation view
QVariant id = index.data(CntConverstaionIdRole);
@@ -262,6 +279,27 @@
}
/*!
+Go back to the root view
+*/
+void CntHistoryView::showRootView()
+{
+ mViewMgr->back( mArgs, true );
+}
+
+
+void CntHistoryView::contactDeletedFromOtherSource(const QList<QContactLocalId>& contactIds)
+{
+ CNT_ENTRY
+ if ( contactIds.contains(mContact->localId()) )
+ {
+ // Do not switch to the previous view immediately. List views are
+ // not updated properly if this is not done in the event loop
+ QTimer::singleShot(0, this, SLOT(showRootView()));
+ }
+ CNT_EXIT
+}
+
+/*!
Show or hide the clear history menu
*/
void CntHistoryView::showClearHistoryMenu()