--- a/phonebookui/pbkcommonui/src/cntcollectionview.cpp Tue Jul 06 14:05:47 2010 +0300
+++ b/phonebookui/pbkcommonui/src/cntcollectionview.cpp Wed Aug 18 09:39:00 2010 +0300
@@ -16,12 +16,13 @@
*/
#include "cntcollectionview.h"
-#include "cntfetchcontactsview.h"
+#include "cntfetchcontactpopup.h"
#include "cntgroupdeletepopup.h"
#include "cntcollectionlistmodel.h"
#include "cntextensionmanager.h"
#include "cntglobal.h"
#include "cntfavourite.h"
+#include "cntdetailconst.h"
#include "cntdebug.h"
#include <cntuiextensionfactory.h>
@@ -30,7 +31,7 @@
#include <hblistview.h>
#include <hblistviewitem.h>
#include <hbmenu.h>
-#include <hbnotificationdialog.h>
+#include <hbdevicenotificationdialog.h>
#include <hbinputdialog.h>
#include <hbdialog.h>
#include <hbaction.h>
@@ -41,6 +42,7 @@
#include <hbparameterlengthlimiter.h>
#include <QActionGroup>
+#include <QApplication>
#include <QList>
const char *CNT_COLLECTIONVIEW_XML = ":/xml/contacts_collections.docml";
@@ -61,7 +63,6 @@
mNewGroupAction(NULL),
mDeleteGroupsAction(NULL),
mHandledContact(NULL),
- mFetchView(NULL),
mActionGroup(NULL)
{
bool ok = false;
@@ -98,8 +99,10 @@
groups->setChecked(true);
mFindAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:find"));
- mFindAction->setEnabled(false);
+ connect(mFindAction, SIGNAL(triggered()), this, SLOT(showNamesViewWithFinder()));
mExtensionAction = static_cast<HbAction*> (mDocumentLoader.findObject("cnt:activity"));
+
+ connect( qApp, SIGNAL(aboutToQuit()), this, SLOT(notifyNewGroup()));
}
/*!
@@ -111,9 +114,6 @@
delete mHandledContact;
mHandledContact = NULL;
-
- delete mFetchView;
- mFetchView = NULL;
}
/*!
@@ -159,9 +159,6 @@
mModel = new CntCollectionListModel(getContactManager(), mExtensionManager, this);
mListView->setModel(mModel);
- mFetchView = new CntFetchContacts(*mViewManager->contactManager( SYMBIAN_BACKEND ));
- connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleNewGroupMembers()));
-
CNT_EXIT
}
@@ -188,6 +185,16 @@
}
/*!
+Go back to previous view
+*/
+void CntCollectionView::showNamesViewWithFinder()
+{
+ CntViewParameters viewParameters;
+ viewParameters.insert(EExtraAction, CNT_FIND_ACTION);
+ mViewManager->back(viewParameters);
+}
+
+/*!
Called after user clicked on the listview.
*/
void CntCollectionView::openGroup(const QModelIndex &index)
@@ -227,7 +234,7 @@
else
{
CntViewParameters viewParameters;
- viewParameters.insert(EViewId, FavoritesMemberView);
+ viewParameters.insert(EViewId, favoritesMemberView);
QVariant var;
var.setValue(favoriteGroup);
viewParameters.insert(ESelectedGroupContact, var);
@@ -257,7 +264,7 @@
else
{
int id = item->modelIndex().data(Qt::UserRole).toInt();
- QVariant data( item->modelIndex().row() );
+ QVariant data( id );
int favoriteGrpId = CntFavourite::favouriteGroupId(mViewManager->contactManager(SYMBIAN_BACKEND));
@@ -280,22 +287,20 @@
void CntCollectionView::handleMenu(HbAction* action)
{
- int row = action->data().toInt();
HbMenu *menuItem = static_cast<HbMenu*>(sender());
- QModelIndex index = mModel->index(row, 0);
-
- int id = index.data(Qt::UserRole).toInt();
if ( action == menuItem->actions().first() )
- {
+ {
+ int id = action->data().toInt();
+ QModelIndex index = mModel->indexOfGroup(id);
openGroup(index);
- }
+ }
else if (action == menuItem->actions().at(1))
- {
-
+ {
+ int id = action->data().toInt();
QContact groupContact = getContactManager()->contact(id);
deleteGroup(groupContact);
- }
+ }
}
@@ -307,6 +312,7 @@
HbLineEdit *lineEdit = popup->lineEdit();
lineEdit->setInputMethodHints(Qt::ImhNoPredictiveText);
+ lineEdit->setMaxLength( CNT_GROUPNAME_MAXLENGTH );
popup->setPromptText(hbTrId("txt_phob_title_new_group_name"));
popup->clearActions();
@@ -343,43 +349,81 @@
QSet<QContactLocalId> contactsSet = contactsList.toSet();
// Select some contact(s) to add to the group
- QString groupNameCreated(mHandledContact->displayLabel());
- mFetchView->setDetails(HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupNameCreated),
- hbTrId("txt_common_button_save"));
- mFetchView->displayContacts(HbAbstractItemView::MultiSelection, contactsSet);
+ QString groupNameCreated = mHandledContact->displayLabel();
+ if (groupNameCreated.isEmpty())
+ {
+ groupNameCreated = hbTrId("txt_phob_list_unnamed");
+ }
+
+ CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup(
+ HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupNameCreated),
+ hbTrId("txt_common_button_save"),
+ *mViewManager->contactManager(SYMBIAN_BACKEND));
+ connect( popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), this, SLOT(handleNewGroupMembers(QSet<QContactLocalId>)) );
+ connect( popup, SIGNAL(fetchCancelled()), this, SLOT(handleCancelGroupMembers()) );
+
+ popup->setSelectedContacts( contactsSet );
+ popup->showPopup();
}
}
-void CntCollectionView::handleNewGroupMembers()
+void CntCollectionView::handleNewGroupMembers( QSet<QContactLocalId> aIds )
{
- mSelectedContactsSet = mFetchView->getSelectedContacts();
- if ( !mFetchView->wasCanceled() && mSelectedContactsSet.size() ) {
+ mSelectedContactsSet = aIds;
+
+ if ( aIds.size() > 0 )
+ {
saveNewGroup(mHandledContact);
-
+
CntViewParameters viewParameters;
viewParameters.insert(EViewId, groupMemberView);
+
QVariant var;
var.setValue(*mHandledContact);
viewParameters.insert(ESelectedGroupContact, var);
mViewManager->changeView(viewParameters);
}
-
- QString groupNameCreated(mHandledContact->displayLabel());
- HbNotificationDialog::launchDialog(HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_new_group_1_created")).arg(groupNameCreated));
+ else
+ {
+ mModel->addGroup(mHandledContact->localId());
+ mDeleteGroupsAction->setEnabled(true);
+ }
+ notifyNewGroup();
+}
- // Refresh the page
- refreshDataModel();
+void CntCollectionView::handleCancelGroupMembers()
+{
+ mSelectedContactsSet.clear();
+ mModel->addGroup(mHandledContact->localId());
mDeleteGroupsAction->setEnabled(true);
+
+ notifyNewGroup();
+}
- delete mHandledContact;
- mHandledContact = NULL;
+void CntCollectionView::notifyNewGroup()
+{
+ if (mHandledContact != NULL)
+ {
+ QString groupNameCreated = mHandledContact->displayLabel();
+ if (groupNameCreated.isEmpty())
+ {
+ groupNameCreated = hbTrId("txt_phob_list_unnamed");
+ }
+ HbDeviceNotificationDialog::notification(QString(),
+ HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_new_group_1_created")).arg(groupNameCreated));
+
+ delete mHandledContact;
+ mHandledContact = NULL;
+ }
}
void CntCollectionView::refreshDataModel()
{
mListView->setModel(0);
+
delete mModel;
- mModel = 0;
+ mModel = NULL;
+
mModel = new CntCollectionListModel(getContactManager(), mExtensionManager, this);
mListView->setModel(mModel);
}
@@ -388,20 +432,22 @@
{
mHandledContact = new QContact(group);
QString name = mHandledContact->displayLabel();
+ if (name.isEmpty())
+ {
+ name = hbTrId("txt_phob_list_unnamed");
+ }
HbLabel *headingLabel = new HbLabel();
headingLabel->setPlainText(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(name));
HbMessageBox::question(hbTrId("txt_phob_dialog_only_group_will_be_removed_contac")
- , this, SLOT(handleDeleteGroup(HbAction*)),
- hbTrId("txt_common_button_delete"), hbTrId("txt_common_button_cancel"), headingLabel);
+ , this, SLOT(handleDeleteGroup(int)), HbMessageBox::Delete | HbMessageBox::Cancel,
+ headingLabel);
}
-void CntCollectionView::handleDeleteGroup(HbAction* action)
+void CntCollectionView::handleDeleteGroup(int action)
{
- HbMessageBox *note = static_cast<HbMessageBox*>(sender());
-
- if (note && action == note->actions().first())
+ if (action == HbMessageBox::Delete)
{
getContactManager()->removeContact(mHandledContact->localId());
mModel->removeGroup(mHandledContact->localId());