143 |
150 |
144 mModel = new QStandardItemModel(); |
151 mModel = new QStandardItemModel(); |
145 |
152 |
146 QContactPhoneNumber confCallNumber = mGroupContact->detail<QContactPhoneNumber>(); |
153 QContactPhoneNumber confCallNumber = mGroupContact->detail<QContactPhoneNumber>(); |
147 if(!confCallNumber.number().isEmpty()) |
154 if(!confCallNumber.number().isEmpty()) |
148 { |
155 { |
149 /* |
156 /* |
150 * Internationalization support, activate the following code |
157 * Internationalization support, activate the following code |
151 * when support available from Orbit |
158 * when support available from Orbit |
152 */ |
159 */ |
153 //populatelist(hbTrId("txt_phob_dblist_conference_call"), HbIcon("qtg_large_call_group"),HbNumberGrouping::formatPhoneNumber(confCallNumber.number())); |
160 //populatelist(hbTrId("txt_phob_dblist_conference_call"), HbIcon("qtg_large_call_group"),HbNumberGrouping::formatPhoneNumber(confCallNumber.number())); |
154 populatelist(hbTrId("txt_phob_dblist_conference_call"), HbIcon("qtg_large_call_group"),confCallNumber.number()); |
161 populatelist(hbTrId("txt_phob_dblist_conference_call"), HbIcon("qtg_large_call_group"),confCallNumber.number(),"call"); |
155 } |
162 } |
156 |
163 |
157 populatelist(hbTrId("txt_phob_dblist_send_message"),HbIcon("qtg_large_message_group"),hbTrId("txt_phob_dblist_send_message_val_members")); |
164 populatelist(hbTrId("txt_phob_dblist_send_message"),HbIcon("qtg_large_message_group"),hbTrId("txt_phob_dblist_send_message_val_members"),"message"); |
158 populatelist(hbTrId("txt_phob_dblist_email"),HbIcon("qtg_large_email_group"),hbTrId("txt_phob_dblist_send_message_val_members")); |
165 populatelist(hbTrId("txt_phob_dblist_email"),HbIcon("qtg_large_email_group"),hbTrId("txt_phob_dblist_send_message_val_members"),"email"); |
159 |
166 |
160 mListView->setModel(mModel); |
167 mListView->setModel(mModel); |
161 mListView->setSelectionMode(HbAbstractItemView::NoSelection); |
168 mListView->setSelectionMode(HbAbstractItemView::NoSelection); |
162 |
169 |
163 } |
170 connect(mListView, SIGNAL(activated(const QModelIndex&)), |
164 |
171 this, SLOT(listItemSelected(const QModelIndex&))); |
165 void CntGroupActionsView:: populatelist(QString primaryText,HbIcon icon,QString secondaryText) |
172 |
|
173 } |
|
174 |
|
175 void CntGroupActionsView::populatelist(QString primaryText,HbIcon icon,QString secondaryText,QString action) |
166 { |
176 { |
167 QList<QStandardItem*> items; |
177 QList<QStandardItem*> items; |
168 QStandardItem *labelItem = new QStandardItem(); |
178 QStandardItem *labelItem = new QStandardItem(); |
169 |
179 |
170 QStringList textList; |
180 QStringList textList; |
171 |
181 |
172 textList << primaryText << secondaryText; |
182 textList << primaryText << secondaryText; |
173 |
183 |
174 labelItem->setData(textList, Qt::DisplayRole); |
184 labelItem->setData(textList, Qt::DisplayRole); |
175 labelItem->setData(icon, Qt::DecorationRole); |
185 labelItem->setData(icon, Qt::DecorationRole); |
|
186 labelItem->setData(action, Qt::UserRole+1); |
176 |
187 |
177 items << labelItem ; |
188 items << labelItem ; |
178 mModel->appendRow(items); |
189 mModel->appendRow(items); |
179 } |
190 } |
|
191 |
|
192 void CntGroupActionsView::listItemSelected(const QModelIndex &index) |
|
193 { |
|
194 if (index.isValid()) { |
|
195 //reset flags |
|
196 mPopupCount=0; |
|
197 mActionParams.clear(); |
|
198 |
|
199 QString action = mModel->item(index.row())->data(Qt::UserRole+1).toString(); |
|
200 |
|
201 //conference call |
|
202 if (action.compare("call", Qt::CaseInsensitive) == 0 ) { |
|
203 CntActionLauncher* other = new CntActionLauncher(*mViewManager->contactManager(SYMBIAN_BACKEND), action); |
|
204 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
|
205 other->execute(*mGroupContact, QContactDetail()); |
|
206 } |
|
207 //group email, message |
|
208 else { |
|
209 QContactRelationshipFilter relationshipFilter; |
|
210 relationshipFilter.setRelationshipType(QContactRelationship::HasMember); |
|
211 relationshipFilter.setRelatedContactRole(QContactRelationship::First); |
|
212 relationshipFilter.setRelatedContactId(mGroupContact->id()); |
|
213 QList<QContactLocalId> groupMembers = mViewManager->contactManager(SYMBIAN_BACKEND)->contactIds(relationshipFilter); |
|
214 |
|
215 for (int i = 0;i<groupMembers.count();i++) { |
|
216 QContact contact = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(groupMembers.at(i)); |
|
217 QContactDetail preferredDetail = contact.preferredDetail(action); |
|
218 //use preferred detail if exits |
|
219 if (!preferredDetail.isEmpty()) { |
|
220 if(action.compare("message", Qt::CaseInsensitive) == 0) { |
|
221 QContactPhoneNumber phoneNumber = contact.detail<QContactPhoneNumber>(); |
|
222 mActionParams.append(phoneNumber.number()); |
|
223 } |
|
224 else { |
|
225 QContactEmailAddress email = contact.detail<QContactEmailAddress>(); |
|
226 mActionParams.append(email.emailAddress()); |
|
227 } |
|
228 } |
|
229 else { |
|
230 CntActionPopup *actionPopup = new CntActionPopup(&contact); |
|
231 if(actionPopup->showActionPopup(action)) { |
|
232 //increment actionpopup counter |
|
233 mPopupCount++; |
|
234 |
|
235 connect( actionPopup, SIGNAL(executeContactAction(QContact&, QContactDetail, QString)), this, |
|
236 SLOT(executeAction(QContact&, QContactDetail, QString))); |
|
237 connect(actionPopup, SIGNAL(actionPopupCancelPressed()), this, SLOT(actionCancelled())); |
|
238 } |
|
239 else { |
|
240 delete actionPopup; |
|
241 } |
|
242 } |
|
243 } |
|
244 //no popup dialog, execute action |
|
245 if (mPopupCount==0) { |
|
246 QVariantMap map; |
|
247 QVariant params; |
|
248 params.setValue(mActionParams); |
|
249 map.insert(action,params); |
|
250 CntActionLauncher* other = new CntActionLauncher(*mViewManager->contactManager(SYMBIAN_BACKEND), action); |
|
251 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
|
252 other->execute(*mGroupContact, QContactDetail(), map); |
|
253 } |
|
254 } |
|
255 } |
|
256 } |
|
257 |
|
258 void CntGroupActionsView::executeAction(QContact& contact, QContactDetail detail, QString action) |
|
259 { |
|
260 Q_UNUSED(contact); |
|
261 |
|
262 if (action.compare("message", Qt::CaseInsensitive) == 0) { |
|
263 QContactPhoneNumber phoneNumber = static_cast<QContactPhoneNumber>(detail); |
|
264 mActionParams.append(phoneNumber.number()); |
|
265 } |
|
266 else if (action.compare("email", Qt::CaseInsensitive) == 0) { |
|
267 QContactEmailAddress email = static_cast<QContactEmailAddress>(detail); |
|
268 mActionParams.append(email.emailAddress()); |
|
269 } |
|
270 |
|
271 //actionpopup executed, decrement counter |
|
272 mPopupCount--; |
|
273 if (mPopupCount==0) { |
|
274 QVariantMap map; |
|
275 QVariant params; |
|
276 params.setValue(mActionParams); |
|
277 map.insert(action,params); |
|
278 |
|
279 CntActionLauncher* other = new CntActionLauncher(*mViewManager->contactManager(SYMBIAN_BACKEND), action); |
|
280 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
|
281 other->execute(*mGroupContact, QContactDetail(), map); |
|
282 } |
|
283 } |
|
284 |
|
285 void CntGroupActionsView::actionCancelled() |
|
286 { |
|
287 //actionpopup cancelled, decrement counter |
|
288 mPopupCount--; |
|
289 } |
|
290 |
|
291 |
|
292 void CntGroupActionsView::actionExecuted(CntActionLauncher* aAction) |
|
293 { |
|
294 //cleanup |
|
295 aAction->deleteLater(); |
|
296 } |
|
297 |