phonebookui/pbkcommonui/src/cntcollectionview.cpp
changeset 71 7cc7d74059f9
parent 65 ae724a111993
--- a/phonebookui/pbkcommonui/src/cntcollectionview.cpp	Thu Sep 02 20:16:15 2010 +0300
+++ b/phonebookui/pbkcommonui/src/cntcollectionview.cpp	Fri Sep 17 08:27:32 2010 +0300
@@ -39,6 +39,8 @@
 #include <hbgroupbox.h>
 #include <hbmessagebox.h>
 #include <hbparameterlengthlimiter.h>
+#include <hbeffect.h>
+#include <hbtoolbar.h>
 
 #include <QActionGroup>
 #include <QApplication>
@@ -75,6 +77,9 @@
         qFatal("Unable to read :/xml/contacts_collections.docml");
     }
     
+    // disable toolbar effects
+    HbEffect::disable(mView->toolBar());
+    
     //back button
     mSoftkey = new HbAction(Hb::BackNaviAction, mView);
     connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView()));
@@ -156,6 +161,7 @@
     mListView->listItemPrototype()->setGraphicsSize(HbListViewItem::LargeIcon);
     mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape);
     mModel = new CntCollectionListModel( mEngine, this);
+    connect(mModel, SIGNAL(groupCountChanged()), this, SLOT(groupCountChanged()));
     mListView->setModel(mModel);
     
     CNT_EXIT
@@ -343,7 +349,6 @@
         mHandledContact->saveDetail(&groupName);
         getContactManager()->saveContact(mHandledContact);
         
-        // Select some contact(s) to add to the group
         QString groupNameCreated = mHandledContact->displayLabel();
         if (groupNameCreated.isEmpty())
         {
@@ -358,9 +363,6 @@
        QList<QContactLocalId> contactIds = getContactManager()->contactIds(gFilter);   
        if (contactIds.isEmpty())
        {
-           mModel->addGroup(mHandledContact->localId());
-           mDeleteGroupsAction->setEnabled(true);
-               
            notifyNewGroup();
        }      
        else
@@ -395,19 +397,13 @@
         viewParameters.insert(ESelectedGroupContact, var);
         mViewManager->changeView(viewParameters);
     }
-    else
-    {
-        mModel->addGroup(mHandledContact->localId());
-        mDeleteGroupsAction->setEnabled(true);
-    }
+
     notifyNewGroup();
 }
 
 void CntCollectionView::handleCancelGroupMembers()
 {
     mSelectedContactsSet.clear();
-    mModel->addGroup(mHandledContact->localId());
-    mDeleteGroupsAction->setEnabled(true);
     
     notifyNewGroup();
 }
@@ -437,6 +433,7 @@
     mModel = NULL;
     
     mModel = new CntCollectionListModel(mEngine, this);
+    connect(mModel, SIGNAL(groupCountChanged()), this, SLOT(groupCountChanged()));
     mListView->setModel(mModel);
 }
 
@@ -462,17 +459,6 @@
     if (action == HbMessageBox::Delete)
     {
         getContactManager()->removeContact(mHandledContact->localId());
-        mModel->removeGroup(mHandledContact->localId());
-        
-        // disable delete group(s) button if only favorites group is present
-        QContactDetailFilter groupFilter;
-        groupFilter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType);
-        groupFilter.setValue(QLatin1String(QContactType::TypeGroup));
-        QList<QContactLocalId> groupContactIds = getContactManager()->contactIds(groupFilter);
-        if (groupContactIds.count() < 2)
-        {
-            mDeleteGroupsAction->setEnabled(false);
-        }
     }
     
     delete mHandledContact;
@@ -495,21 +481,23 @@
     
     if (groupDeletePopup && action == groupDeletePopup->actions().first())
     {
-        QList<QContactLocalId> deletedList = groupDeletePopup->deleteGroup();
-        foreach (QContactLocalId id, deletedList)
-        {
-            mModel->removeGroup(id);
-        }
-        
-        // disable delete group(s) button if only favorites group is present
-        QContactDetailFilter groupFilter;
-        groupFilter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType);
-        groupFilter.setValue(QLatin1String(QContactType::TypeGroup));
-        QList<QContactLocalId> groupContactIds = getContactManager()->contactIds(groupFilter);
-        if (groupContactIds.count() < 2)
-        {
-            mDeleteGroupsAction->setEnabled(false);
-        }
+        groupDeletePopup->deleteGroup();
+    }
+}
+
+void CntCollectionView::groupCountChanged()
+{
+    QContactDetailFilter groupFilter;
+    groupFilter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType);
+    groupFilter.setValue(QLatin1String(QContactType::TypeGroup));
+    QList<QContactLocalId> groupContactIds = getContactManager()->contactIds(groupFilter);
+    if (groupContactIds.count() < 2)
+    {
+        mDeleteGroupsAction->setEnabled(false);
+    }
+    else
+    {
+        mDeleteGroupsAction->setEnabled(true);
     }
 }