phonebookui/pbkcommonui/src/cntcollectionlistmodel.cpp
changeset 31 2a11b5b00470
parent 27 de1630741fbe
child 37 fd64c38c277d
equal deleted inserted replaced
27:de1630741fbe 31:2a11b5b00470
   107         return false;
   107         return false;
   108     }
   108     }
   109     
   109     
   110     beginRemoveRows(parent, row, row);
   110     beginRemoveRows(parent, row, row);
   111     mDataPointer->mDataList.removeAt(row);
   111     mDataPointer->mDataList.removeAt(row);
   112     if (mDataPointer->mExtensions.remove(row) > 0)
       
   113     {
       
   114         // if extension group was deleted, refresh the indices of extension group map
       
   115         QList<int> keyList = mDataPointer->mExtensions.keys();
       
   116         qSort(keyList);
       
   117         
       
   118         for (int i = 0;i < keyList.count();i++)
       
   119         {
       
   120             if (keyList.at(i) > row)
       
   121             {
       
   122                 CntUiGroupSupplier* groupSupplier = mDataPointer->mExtensions.take(keyList.at(i));
       
   123                 mDataPointer->mExtensions.insert(keyList.at(i) - 1, groupSupplier);
       
   124             }
       
   125         }
       
   126     }
       
   127 
       
   128     endRemoveRows();
   112     endRemoveRows();
   129 
   113 
   130     return true;
   114     return true;
   131 }
   115 }
   132 
   116 
   135 */
   119 */
   136 void CntCollectionListModel::removeGroup(int localId)
   120 void CntCollectionListModel::removeGroup(int localId)
   137 {
   121 {
   138     for (int i = 0;i < rowCount();i++)
   122     for (int i = 0;i < rowCount();i++)
   139     {
   123     {
   140         if (mDataPointer->mDataList.at(i)[2] == localId)
   124         // extension items have 4 items in the list, we don't allow those to be deleted from here
       
   125         if (mDataPointer->mDataList.at(i)[2] == localId && mDataPointer->mDataList.at(i).count() < 4)
   141         {
   126         {
   142             removeRow(i);
   127             removeRow(i);
   143             break;
   128             break;
   144         }
   129         }
   145     }
   130     }
   219            displayList.append(names);
   204            displayList.append(names);
   220            displayList.append(hbTrId("(%1)").arg(groupMemberIds.count()));
   205            displayList.append(hbTrId("(%1)").arg(groupMemberIds.count()));
   221        }
   206        }
   222        else
   207        else
   223        {
   208        {
   224        displayList.append(hbTrId("txt_phob_dblist_favorites_val_no_favorites_selecte")); // as this isn't supported yet
   209            displayList.append(hbTrId("txt_phob_dblist_favorites_val_no_favorites_selecte"));
   225        }
   210        }
   226 
   211 
   227     }
   212     }
   228     dataList.append(displayList);
   213     dataList.append(displayList);
   229     dataList.append(QStringList("qtg_large_favourites"));
   214     dataList.append(QStringList("qtg_large_favourites"));
   230     dataList.append(mFavoriteGroupId); // as favorites doesn't really have a contact Id, -1 is used
   215     dataList.append(mFavoriteGroupId);
   231     mDataPointer->mDataList.append(dataList);
   216     mDataPointer->mDataList.append(dataList);
   232 }
   217 }
   233 
   218 
   234 /*!
   219 /*!
   235 Initialize extension groups
   220 Initialize extension groups
   356                 {
   341                 {
   357                     displayList.append(hbTrId("No members selected"));
   342                     displayList.append(hbTrId("No members selected"));
   358                 }
   343                 }
   359                 dataList.append(displayList);
   344                 dataList.append(displayList);
   360                 
   345                 
   361                 // icon, default for now always
   346                 // Default if no image for group 
   362                 dataList.append(QStringList("qtg_large_custom"));
   347                 bool icon = false;
   363                 
   348                 QList<QContactAvatar> details = contact.details<QContactAvatar>();
       
   349                 for (int i = 0;i < details.count();i++)
       
   350                 {
       
   351                     if (details.at(i).imageUrl().isValid())
       
   352                     {
       
   353                         dataList.append(QStringList(details.at(i).imageUrl().toString()));
       
   354                         icon = true;
       
   355                         break;
       
   356                     }
       
   357                 }
       
   358                 if(!icon)
       
   359                 {
       
   360                     dataList.append(QStringList("qtg_large_custom"));
       
   361                 }
       
   362  
   364                 // contact Id for identification
   363                 // contact Id for identification
   365                 dataList.append(groupContactIds.at(i));
   364                 dataList.append(groupContactIds.at(i));
   366                 
   365                 
   367                 mDataPointer->mDataList.append(dataList);
   366                 mDataPointer->mDataList.append(dataList);
   368             }
   367             }