83 { |
79 { |
84 } |
80 } |
85 |
81 |
86 void CntFavoritesView::openSelectionPopup() |
82 void CntFavoritesView::openSelectionPopup() |
87 { |
83 { |
|
84 /* |
88 QSet<QContactLocalId> emptySet; |
85 QSet<QContactLocalId> emptySet; |
89 |
|
90 if (!mFetchView) { |
86 if (!mFetchView) { |
91 mFetchView = new CntFetchContacts(*getContactManager()); |
87 mFetchView = new CntFetchContacts(*getContactManager()); |
92 connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleMemberSelection())); |
88 connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleMemberSelection())); |
93 } |
89 } |
94 mFetchView->setDetails(hbTrId("txt_phob_subtitle_favorites"), hbTrId("txt_common_button_save")); |
90 mFetchView->setDetails(hbTrId("txt_phob_subtitle_favorites"), hbTrId("txt_common_button_save")); |
95 mFetchView->displayContacts(HbAbstractItemView::MultiSelection, emptySet); |
91 mFetchView->displayContacts(HbAbstractItemView::MultiSelection, emptySet); |
|
92 */ |
|
93 CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( |
|
94 hbTrId("txt_phob_subtitle_favorites"), |
|
95 hbTrId("txt_common_button_save"), |
|
96 *getContactManager()); |
|
97 connect(popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), |
|
98 this, SLOT(handleMemberSelection(QSet<QContactLocalId>))); |
|
99 popup->showPopup(); |
96 } |
100 } |
97 |
101 |
98 void CntFavoritesView::handleMemberSelection() |
102 void CntFavoritesView::handleMemberSelection( QSet<QContactLocalId> aIds ) |
99 { |
103 { |
100 QSet<QContactLocalId> members = mFetchView->getSelectedContacts(); |
104 //QSet<QContactLocalId> members = mFetchView->getSelectedContacts(); |
101 QList<QContactRelationship> memberships; |
105 //bool saveChanges = !mFetchView->wasCanceled(); |
102 bool saveChanges = !mFetchView->wasCanceled(); |
|
103 |
106 |
104 delete mFetchView; |
107 //delete mFetchView; |
105 mFetchView = 0; |
108 //mFetchView = 0; |
106 |
109 |
107 if (!saveChanges || members.count() == 0) { |
110 //if (!saveChanges || members.count() == 0) |
|
111 if ( aIds.isEmpty() ) |
|
112 { |
108 showPreviousView(); |
113 showPreviousView(); |
109 return; |
|
110 } |
114 } |
111 |
115 else |
112 foreach (QContactLocalId id, members) { |
116 { |
113 QContact contact = getContactManager()->contact(id); |
117 QList<QContactRelationship> memberships; |
114 QContactRelationship membership; |
118 foreach (QContactLocalId id, aIds) { |
115 membership.setRelationshipType(QContactRelationship::HasMember); |
119 QContact contact = getContactManager()->contact(id); |
116 membership.setFirst(mContact->id()); |
120 QContactRelationship membership; |
117 membership.setSecond(contact.id()); |
121 membership.setRelationshipType(QContactRelationship::HasMember); |
118 memberships.append(membership); |
122 membership.setFirst(mContact->id()); |
|
123 membership.setSecond(contact.id()); |
|
124 memberships.append(membership); |
|
125 } |
|
126 |
|
127 if (!memberships.isEmpty()) { |
|
128 QMap<int, QContactManager::Error> errors; |
|
129 getContactManager()->saveRelationships(&memberships, &errors); |
|
130 } |
|
131 |
|
132 CntViewParameters viewParameters; |
|
133 viewParameters.insert(EViewId, favoritesMemberView); |
|
134 QVariant var; |
|
135 var.setValue(*mContact); |
|
136 viewParameters.insert(ESelectedGroupContact, var); |
|
137 mViewManager->changeView(viewParameters); |
119 } |
138 } |
120 |
|
121 if (!memberships.isEmpty()) { |
|
122 QMap<int, QContactManager::Error> errors; |
|
123 getContactManager()->saveRelationships(&memberships, &errors); |
|
124 } |
|
125 |
|
126 CntViewParameters viewParameters; |
|
127 viewParameters.insert(EViewId, FavoritesMemberView); |
|
128 QVariant var; |
|
129 var.setValue(*mContact); |
|
130 viewParameters.insert(ESelectedGroupContact, var); |
|
131 mViewManager->changeView(viewParameters); |
|
132 } |
139 } |
133 |
140 |
134 void CntFavoritesView::setOrientation(Qt::Orientation orientation) |
141 void CntFavoritesView::setOrientation(Qt::Orientation orientation) |
135 { |
142 { |
136 if (orientation == Qt::Vertical) |
143 if (orientation == Qt::Vertical) |