54
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cntgroupmemberview_p.h"
|
|
19 |
#include "cntfetchcontactpopup.h"
|
|
20 |
#include "cntcontactcardheadingitem.h"
|
|
21 |
#include "cntglobal.h"
|
|
22 |
#include "cntimagelabel.h"
|
|
23 |
#include "cntimageutility.h"
|
61
|
24 |
#include "cntthumbnailmanager.h"
|
54
|
25 |
#include <hbnotificationdialog.h>
|
|
26 |
#include <hbmessagebox.h>
|
|
27 |
#include <hbmenu.h>
|
|
28 |
#include <hblistview.h>
|
|
29 |
#include <hblistviewitem.h>
|
|
30 |
#include <hbframebackground.h>
|
|
31 |
#include <hbindexfeedback.h>
|
|
32 |
#include <hbscrollbar.h>
|
|
33 |
#include <hbview.h>
|
|
34 |
#include <hbaction.h>
|
|
35 |
#include <hblabel.h>
|
|
36 |
#include <hbparameterlengthlimiter.h>
|
|
37 |
#include <cntlistmodel.h>
|
|
38 |
#include <hbmainwindow.h>
|
|
39 |
#include <xqservicerequest.h>
|
|
40 |
|
|
41 |
#include "cntdocumentloader.h"
|
|
42 |
|
|
43 |
const char *CNT_GROUPMEMBERVIEW_XML = ":/xml/contacts_groupmembers.docml";
|
|
44 |
|
|
45 |
/*!
|
|
46 |
\class CntGroupMemberViewPrivate
|
|
47 |
\brief
|
|
48 |
|
|
49 |
This is the group members view class that shows list of contacts for a user group. View contains a listview that shows actual contacts that
|
|
50 |
have been added to a particular group. There is also toolbar and menu for navigating between different views. Instance of this class is
|
|
51 |
created by our viewmanager but view itself is owned by the mainwindow which will also delete it in the end.
|
|
52 |
|
|
53 |
*/
|
|
54 |
|
|
55 |
/*!
|
|
56 |
Constructor, initialize member variables.
|
|
57 |
\a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0)
|
|
58 |
|
|
59 |
*/
|
|
60 |
CntGroupMemberViewPrivate::CntGroupMemberViewPrivate() :
|
|
61 |
mGroupContact(NULL),
|
|
62 |
mViewManager(NULL),
|
|
63 |
mHeadingItem(NULL),
|
|
64 |
mModel(NULL),
|
|
65 |
mImageLabel(NULL),
|
|
66 |
mListView(NULL),
|
|
67 |
mAvatar(NULL)
|
|
68 |
{
|
|
69 |
mDocument = new CntDocumentLoader;
|
|
70 |
|
|
71 |
bool ok;
|
|
72 |
mDocument->load( CNT_GROUPMEMBERVIEW_XML, &ok );
|
|
73 |
if ( !ok ){
|
|
74 |
qFatal( "Unable to load %S", CNT_GROUPMEMBERVIEW_XML );
|
|
75 |
}
|
|
76 |
|
|
77 |
mView = static_cast<HbView*>( mDocument->findWidget("view") );
|
|
78 |
|
|
79 |
//back button
|
|
80 |
mSoftkey = new HbAction(Hb::BackNaviAction, mView);
|
|
81 |
connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView()));
|
|
82 |
|
|
83 |
mImageLabel = static_cast<CntImageLabel*>(mDocument->findWidget("editViewImage"));
|
|
84 |
connect( mImageLabel, SIGNAL(iconClicked()), this, SLOT(openImageEditor()) );
|
|
85 |
connect( mImageLabel, SIGNAL(iconLongPressed(const QPointF&)), this, SLOT(drawImageMenu(const QPointF&)) );
|
|
86 |
|
|
87 |
mListView = static_cast<HbListView*>( mDocument->findWidget("listView") );
|
|
88 |
connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), this,
|
|
89 |
SLOT(showContextMenu(HbAbstractViewItem*,QPointF)));
|
|
90 |
connect(mListView, SIGNAL(activated (const QModelIndex&)), this,
|
|
91 |
SLOT(showContactView(const QModelIndex&)));
|
|
92 |
|
|
93 |
mHeadingItem = static_cast<CntContactCardHeadingItem*>( mDocument->findWidget("editViewHeading") );
|
|
94 |
connect(mHeadingItem, SIGNAL(passShortPressed(const QPointF&)), this, SLOT(openImageEditor()) );
|
|
95 |
connect(mHeadingItem, SIGNAL(passLongPressed(const QPointF&)), this, SLOT(drawImageMenu(const QPointF&)));
|
|
96 |
|
|
97 |
// menu actions
|
|
98 |
mEditGroupAction = static_cast<HbAction*>( mDocument->findObject("cnt:editgroupdetails"));
|
|
99 |
connect(mEditGroupAction, SIGNAL(triggered()), this, SLOT(editGroup()));
|
|
100 |
|
|
101 |
// toolbar actions
|
|
102 |
mManageAction = static_cast<HbAction*>( mDocument->findObject("cnt:managemembers"));
|
|
103 |
connect(mManageAction, SIGNAL(triggered()), this, SLOT(manageMembers()));
|
|
104 |
mDeleteAction = static_cast<HbAction*>( mDocument->findObject("cnt:deletegroup"));
|
|
105 |
connect(mDeleteAction, SIGNAL(triggered()), this, SLOT(deleteGroup()));
|
|
106 |
mShowActionsAction = static_cast<HbAction*>( mDocument->findObject("cnt:groupactions"));
|
|
107 |
connect(mShowActionsAction, SIGNAL(triggered()), this, SLOT(openGroupActions()));
|
|
108 |
}
|
|
109 |
|
|
110 |
/*!
|
|
111 |
Destructor
|
|
112 |
*/
|
|
113 |
CntGroupMemberViewPrivate::~CntGroupMemberViewPrivate()
|
|
114 |
{
|
|
115 |
mView->deleteLater();
|
|
116 |
|
|
117 |
delete mGroupContact;
|
|
118 |
mGroupContact = NULL;
|
|
119 |
|
|
120 |
delete mModel;
|
|
121 |
mModel = NULL;
|
|
122 |
|
|
123 |
delete mAvatar;
|
|
124 |
mAvatar = NULL;
|
|
125 |
}
|
|
126 |
|
|
127 |
void CntGroupMemberViewPrivate::setOrientation(Qt::Orientation orientation)
|
|
128 |
{
|
|
129 |
if (orientation == Qt::Vertical)
|
|
130 |
{
|
|
131 |
// reading "portrait" section
|
|
132 |
mDocument->load( CNT_GROUPMEMBERVIEW_XML, "portrait" );
|
|
133 |
}
|
|
134 |
else
|
|
135 |
{
|
|
136 |
// reading "landscape" section
|
|
137 |
mDocument->load( CNT_GROUPMEMBERVIEW_XML, "landscape" );
|
|
138 |
}
|
|
139 |
}
|
|
140 |
|
61
|
141 |
void CntGroupMemberViewPrivate::activate( const CntViewParameters aArgs )
|
54
|
142 |
{
|
|
143 |
mArgs = aArgs;
|
61
|
144 |
mViewManager = &mEngine->viewManager();
|
|
145 |
mThumbnailManager = &mEngine->thumbnailManager();
|
|
146 |
|
|
147 |
connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)),
|
|
148 |
this, SLOT(thumbnailReady(QPixmap, void*, int, int)));
|
|
149 |
|
54
|
150 |
if (mView->navigationAction() != mSoftkey)
|
|
151 |
{
|
|
152 |
mView->setNavigationAction(mSoftkey);
|
|
153 |
}
|
|
154 |
|
|
155 |
QVariant contact = mArgs.value( ESelectedGroupContact );
|
|
156 |
mGroupContact = new QContact( contact.value<QContact>() );
|
|
157 |
|
|
158 |
HbMainWindow* window = mView->mainWindow();
|
|
159 |
if ( window )
|
|
160 |
{
|
|
161 |
connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation)));
|
|
162 |
setOrientation(window->orientation());
|
|
163 |
}
|
|
164 |
|
|
165 |
mHeadingItem->setGroupDetails(mGroupContact);
|
|
166 |
|
|
167 |
// avatar
|
|
168 |
QList<QContactAvatar> details = mGroupContact->details<QContactAvatar>();
|
|
169 |
for (int i = 0;i < details.count();i++)
|
|
170 |
{
|
|
171 |
if (details.at(i).imageUrl().isValid())
|
|
172 |
{
|
|
173 |
mAvatar = new QContactAvatar(details.at(i));
|
61
|
174 |
mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString());
|
54
|
175 |
break;
|
|
176 |
}
|
|
177 |
}
|
|
178 |
|
|
179 |
// create list & model
|
|
180 |
mListView->setFrictionEnabled(true);
|
|
181 |
mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
|
|
182 |
mListView->verticalScrollBar()->setInteractive(true);
|
|
183 |
mListView->setUniformItemSizes(true);
|
61
|
184 |
|
|
185 |
HbFrameBackground frame;
|
|
186 |
frame.setFrameGraphicsName("qtg_fr_list_normal");
|
|
187 |
frame.setFrameType(HbFrameDrawer::NinePieces);
|
|
188 |
|
|
189 |
HbListViewItem* prototype = mListView->listItemPrototype();
|
|
190 |
prototype->setGraphicsSize(HbListViewItem::Thumbnail);
|
|
191 |
prototype->setDefaultFrame(frame);
|
|
192 |
|
54
|
193 |
HbIndexFeedback *indexFeedback = new HbIndexFeedback(mView);
|
|
194 |
indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter);
|
|
195 |
indexFeedback->setItemView(mListView);
|
|
196 |
|
61
|
197 |
// if no contacts are present, then disable the Manage Members toolbar
|
|
198 |
QContactDetailFilter filter;
|
|
199 |
filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType);
|
|
200 |
filter.setValue(QLatin1String(QContactType::TypeContact));
|
|
201 |
|
|
202 |
QList<QContactLocalId> contactIds = getContactManager()->contactIds(filter);
|
|
203 |
if (contactIds.isEmpty())
|
|
204 |
{
|
|
205 |
mManageAction->setEnabled(false);
|
|
206 |
}
|
54
|
207 |
|
|
208 |
createModel();
|
|
209 |
|
|
210 |
if (mArgs.value(ESelectedAction).toString() == CNT_SAVE_ACTION)
|
|
211 |
{
|
|
212 |
QString name = getContactManager()->synthesizedContactDisplayLabel(*mGroupContact);
|
|
213 |
HbNotificationDialog::launchDialog(HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_new_group_1_created").arg(name)));
|
|
214 |
}
|
|
215 |
}
|
|
216 |
|
|
217 |
void CntGroupMemberViewPrivate::deactivate()
|
|
218 |
{
|
|
219 |
}
|
|
220 |
|
|
221 |
void CntGroupMemberViewPrivate::showPreviousView()
|
|
222 |
{
|
|
223 |
Q_Q(CntGroupMemberView);
|
|
224 |
|
|
225 |
emit q->backPressed();
|
|
226 |
|
|
227 |
//save the contact if avatar has been changed.
|
61
|
228 |
QContact contact = getContactManager()->contact(mGroupContact->localId());
|
54
|
229 |
if ( contact != *mGroupContact )
|
|
230 |
{
|
|
231 |
getContactManager()->saveContact(mGroupContact);
|
|
232 |
}
|
|
233 |
mViewManager->back(mArgs);
|
|
234 |
}
|
|
235 |
|
|
236 |
void CntGroupMemberViewPrivate::openGroupActions()
|
|
237 |
{
|
|
238 |
QVariant var;
|
|
239 |
var.setValue(*mGroupContact);
|
|
240 |
|
|
241 |
mArgs.insert(EViewId, groupActionsView);
|
|
242 |
mArgs.insert(ESelectedGroupContact, var);
|
|
243 |
mViewManager->changeView(mArgs);
|
|
244 |
}
|
|
245 |
|
|
246 |
void CntGroupMemberViewPrivate::manageMembers()
|
|
247 |
{
|
|
248 |
QContactRelationshipFilter membersFilter;
|
|
249 |
membersFilter.setRelationshipType(QContactRelationship::HasMember);
|
|
250 |
membersFilter.setRelatedContactRole(QContactRelationship::First);
|
|
251 |
membersFilter.setRelatedContactId(mGroupContact->id());
|
|
252 |
|
|
253 |
mOriginalGroupMembers = getContactManager()->contactIds(membersFilter);
|
|
254 |
|
|
255 |
QContactName contactName = mGroupContact->detail( QContactName::DefinitionName );
|
|
256 |
QString groupName = contactName.value( QContactName::FieldCustomLabel );
|
|
257 |
if (groupName.isEmpty())
|
|
258 |
{
|
|
259 |
groupName = hbTrId("txt_phob_list_unnamed");
|
|
260 |
}
|
|
261 |
|
|
262 |
CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup(
|
|
263 |
HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupName),
|
|
264 |
hbTrId("txt_common_button_save"),
|
61
|
265 |
mEngine->contactManager(SYMBIAN_BACKEND));
|
54
|
266 |
connect( popup, SIGNAL(fetchReady(QSet<QContactLocalId>)),this, SLOT(handleManageMembers(QSet<QContactLocalId>)) );
|
|
267 |
popup->setSelectedContacts( mOriginalGroupMembers.toSet() );
|
|
268 |
popup->showPopup();
|
|
269 |
}
|
|
270 |
|
|
271 |
void CntGroupMemberViewPrivate::handleManageMembers( QSet<QContactLocalId> aIds )
|
|
272 |
{
|
|
273 |
QList<QContactRelationship> removedMemberships;
|
|
274 |
QList<QContactRelationship> addedMemberships;
|
|
275 |
|
|
276 |
QSet<QContactLocalId> removedMembers = mOriginalGroupMembers.toSet() - aIds;
|
|
277 |
setRelationship(removedMembers, removedMemberships);
|
|
278 |
|
|
279 |
QSet<QContactLocalId> addedMembers = aIds - mOriginalGroupMembers.toSet();
|
|
280 |
setRelationship(addedMembers, addedMemberships);
|
|
281 |
|
|
282 |
if (!addedMemberships.isEmpty())
|
|
283 |
{
|
61
|
284 |
getContactManager()->saveRelationships(&addedMemberships, NULL);
|
54
|
285 |
}
|
|
286 |
|
|
287 |
if (!removedMemberships.isEmpty())
|
|
288 |
{
|
61
|
289 |
getContactManager()->removeRelationships(removedMemberships, NULL);
|
54
|
290 |
}
|
|
291 |
}
|
|
292 |
|
|
293 |
void CntGroupMemberViewPrivate::createModel()
|
|
294 |
{
|
|
295 |
QContactRelationshipFilter rFilter;
|
|
296 |
rFilter.setRelationshipType(QContactRelationship::HasMember);
|
|
297 |
rFilter.setRelatedContactRole(QContactRelationship::First);
|
|
298 |
rFilter.setRelatedContactId(mGroupContact->id());
|
61
|
299 |
|
54
|
300 |
mModel = new CntListModel(getContactManager(), rFilter, false);
|
|
301 |
mListView->setModel(mModel);
|
|
302 |
}
|
|
303 |
|
|
304 |
void CntGroupMemberViewPrivate::editGroup()
|
|
305 |
{
|
|
306 |
mArgs.insert(EViewId, groupEditorView);
|
|
307 |
QVariant var;
|
|
308 |
var.setValue(*mGroupContact);
|
|
309 |
mArgs.insert(ESelectedGroupContact, var);
|
|
310 |
mViewManager->changeView(mArgs);
|
|
311 |
}
|
|
312 |
|
|
313 |
void CntGroupMemberViewPrivate::deleteGroup()
|
|
314 |
{
|
|
315 |
QContactName contactName = mGroupContact->detail( QContactName::DefinitionName );
|
|
316 |
QString groupName = contactName.value( QContactName::FieldCustomLabel );
|
|
317 |
if (groupName.isNull())
|
|
318 |
{
|
|
319 |
groupName = hbTrId("txt_phob_list_unnamed");
|
|
320 |
}
|
|
321 |
|
|
322 |
HbLabel *headingLabel = new HbLabel();
|
|
323 |
headingLabel->setPlainText(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(groupName));
|
|
324 |
|
|
325 |
HbMessageBox::question(hbTrId("txt_phob_dialog_only_group_will_be_removed_contac"), this, SLOT(handleDeleteGroup(int)),
|
|
326 |
HbMessageBox::Delete | HbMessageBox::Cancel, headingLabel);
|
|
327 |
}
|
|
328 |
|
|
329 |
void CntGroupMemberViewPrivate::handleDeleteGroup(int action)
|
|
330 |
{
|
|
331 |
if (action == HbMessageBox::Delete)
|
|
332 |
{
|
|
333 |
getContactManager()->removeContact(mGroupContact->localId());
|
|
334 |
showPreviousView();
|
|
335 |
}
|
|
336 |
}
|
|
337 |
|
|
338 |
/*!
|
|
339 |
Called when a list item is longpressed
|
|
340 |
*/
|
|
341 |
void CntGroupMemberViewPrivate::showContextMenu(HbAbstractViewItem *aItem, const QPointF &aCoords)
|
|
342 |
{
|
|
343 |
QVariant data( aItem->modelIndex().row() );
|
|
344 |
|
|
345 |
QModelIndex index = aItem->modelIndex();
|
|
346 |
|
|
347 |
HbMenu *menu = new HbMenu();
|
|
348 |
menu->setAttribute(Qt::WA_DeleteOnClose);
|
|
349 |
menu->setPreferredPos( aCoords );
|
|
350 |
|
|
351 |
HbAction *removeFromGroupAction = 0;
|
|
352 |
HbAction *openContactAction = 0;
|
|
353 |
HbAction *editContactAction = 0;
|
|
354 |
HbAction *sendToHsAction = 0;
|
|
355 |
|
|
356 |
openContactAction = menu->addAction(hbTrId("txt_common_menu_open"));
|
|
357 |
editContactAction = menu->addAction(hbTrId("txt_common_menu_edit"));
|
|
358 |
removeFromGroupAction = menu->addAction(hbTrId("txt_phob_menu_remove_from_group"));
|
|
359 |
sendToHsAction = menu->addAction(hbTrId("txt_phob_menu_send_to_homescreen"));
|
|
360 |
|
|
361 |
openContactAction->setData( data );
|
|
362 |
editContactAction->setData( data );
|
|
363 |
removeFromGroupAction->setData( data );
|
|
364 |
sendToHsAction->setData( data );
|
|
365 |
|
|
366 |
menu->open(this, SLOT(handleMenu(HbAction*)));
|
|
367 |
}
|
|
368 |
|
|
369 |
void CntGroupMemberViewPrivate::handleMenu(HbAction* action)
|
|
370 |
{
|
|
371 |
int row = action->data().toInt();
|
|
372 |
HbMenu *menuItem = static_cast<HbMenu*>(sender());
|
|
373 |
QModelIndex index = mModel->index(row);
|
|
374 |
|
|
375 |
if ( action == menuItem->actions().first() )
|
|
376 |
{
|
|
377 |
showContactView(index);
|
|
378 |
}
|
|
379 |
else if (action == menuItem->actions().at(1))
|
|
380 |
{
|
|
381 |
editContact(index);
|
|
382 |
}
|
|
383 |
else if (action == menuItem->actions().at(2))
|
|
384 |
{
|
|
385 |
removeFromGroup(index);
|
|
386 |
}
|
|
387 |
else if (action == menuItem->actions().at(3))
|
|
388 |
{
|
|
389 |
sendToHs(index);
|
|
390 |
}
|
|
391 |
}
|
|
392 |
|
|
393 |
/*!
|
|
394 |
Called after user clicked on the listview.
|
|
395 |
*/
|
|
396 |
void CntGroupMemberViewPrivate::sendToHs(const QModelIndex &index)
|
|
397 |
{
|
|
398 |
QVariantHash preferences;
|
|
399 |
preferences["contactId"] = mModel->contact(index).id().localId();
|
|
400 |
|
|
401 |
XQServiceRequest snd("com.nokia.symbian.IHomeScreenClient",
|
|
402 |
"addWidget(QString,QVariantHash)",
|
|
403 |
false);
|
|
404 |
snd << QString("contactwidgethsplugin");
|
|
405 |
snd << preferences;
|
|
406 |
snd.send();
|
|
407 |
}
|
|
408 |
|
|
409 |
/*!
|
|
410 |
Called after user clicked on the listview.
|
|
411 |
*/
|
|
412 |
void CntGroupMemberViewPrivate::showContactView(const QModelIndex &index)
|
|
413 |
{
|
|
414 |
mArgs.insert(EViewId, contactCardView);
|
|
415 |
QVariant var;
|
|
416 |
var.setValue(mModel->contact(index));
|
|
417 |
mArgs.insert(ESelectedContact, var);
|
|
418 |
QVariant varGroup;
|
|
419 |
varGroup.setValue(*mGroupContact);
|
|
420 |
mArgs.insert(ESelectedGroupContact, varGroup);
|
|
421 |
mViewManager->changeView(mArgs);
|
|
422 |
|
|
423 |
}
|
|
424 |
|
|
425 |
void CntGroupMemberViewPrivate::removeFromGroup(const QModelIndex &index)
|
|
426 |
{
|
|
427 |
// get contact id using index
|
|
428 |
QContact selectedContact = mModel->contact(index);
|
|
429 |
QContactRelationship relationship;
|
|
430 |
relationship.setRelationshipType(QContactRelationship::HasMember);
|
|
431 |
relationship.setFirst(mGroupContact->id());
|
|
432 |
relationship.setSecond(selectedContact.id());
|
|
433 |
getContactManager()->removeRelationship(relationship);
|
|
434 |
}
|
|
435 |
|
|
436 |
void CntGroupMemberViewPrivate::editContact(const QModelIndex &index)
|
|
437 |
{
|
|
438 |
|
|
439 |
mArgs.insert(EViewId, editView);
|
|
440 |
QVariant var;
|
|
441 |
var.setValue(mModel->contact(index));
|
|
442 |
mArgs.insert(ESelectedContact, var);
|
|
443 |
mViewManager->changeView(mArgs);
|
|
444 |
}
|
|
445 |
|
|
446 |
void CntGroupMemberViewPrivate::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error)
|
|
447 |
{
|
|
448 |
Q_UNUSED(data);
|
|
449 |
Q_UNUSED(id);
|
|
450 |
Q_UNUSED(error);
|
|
451 |
if (!error)
|
|
452 |
{
|
|
453 |
HbIcon icon(pixmap);
|
|
454 |
mHeadingItem->setIcon(icon);
|
|
455 |
|
|
456 |
mImageLabel->clear();
|
|
457 |
mImageLabel->setIcon(pixmap);
|
|
458 |
}
|
|
459 |
}
|
|
460 |
|
|
461 |
void CntGroupMemberViewPrivate::openImageEditor()
|
|
462 |
{
|
|
463 |
QVariant var;
|
|
464 |
var.setValue(*mGroupContact);
|
|
465 |
|
|
466 |
// only group contact is assigned since we want to only
|
|
467 |
// change the groups image
|
|
468 |
mArgs.insert(ESelectedGroupContact, var);
|
|
469 |
|
|
470 |
mArgs.insert(EViewId, imageEditorView );
|
|
471 |
|
|
472 |
mViewManager->changeView( mArgs );
|
|
473 |
}
|
|
474 |
|
|
475 |
QContactManager* CntGroupMemberViewPrivate::getContactManager()
|
|
476 |
{
|
61
|
477 |
return &mEngine->contactManager(SYMBIAN_BACKEND);
|
54
|
478 |
}
|
|
479 |
|
61
|
480 |
void CntGroupMemberViewPrivate::setRelationship(QSet<QContactLocalId> &aLocalIds,
|
54
|
481 |
QList<QContactRelationship> &aRelationshipList)
|
|
482 |
{
|
61
|
483 |
foreach (QContactLocalId localId, aLocalIds) {
|
|
484 |
QContactId id;
|
|
485 |
id.setLocalId(localId);
|
54
|
486 |
QContactRelationship membership;
|
|
487 |
membership.setRelationshipType(QContactRelationship::HasMember);
|
|
488 |
membership.setFirst(mGroupContact->id());
|
61
|
489 |
membership.setSecond(id);
|
54
|
490 |
aRelationshipList.append(membership);
|
|
491 |
}
|
|
492 |
}
|
|
493 |
|
|
494 |
/*!
|
|
495 |
Draw the image specific content menu
|
|
496 |
*/
|
|
497 |
void CntGroupMemberViewPrivate::drawImageMenu(const QPointF &aCoords)
|
|
498 |
{
|
|
499 |
HbMenu *menu = new HbMenu();
|
|
500 |
HbAction *changeImageAction = menu->addAction(hbTrId("txt_phob_menu_change_picture"), this, SLOT(openImageEditor()));
|
|
501 |
if (mAvatar && !mAvatar->imageUrl().isEmpty())
|
|
502 |
{
|
61
|
503 |
menu->addAction(hbTrId("txt_phob_menu_remove_image"), this, SLOT(removeImage()));
|
54
|
504 |
}
|
|
505 |
menu->setPreferredPos(aCoords);
|
|
506 |
menu->open();
|
|
507 |
}
|
|
508 |
|
|
509 |
|
|
510 |
void CntGroupMemberViewPrivate::removeImage()
|
|
511 |
{
|
|
512 |
if (mAvatar)
|
|
513 |
{
|
|
514 |
if (!mAvatar->imageUrl().isEmpty())
|
|
515 |
{
|
|
516 |
bool success = mGroupContact->removeDetail(mAvatar);
|
|
517 |
// Check if image removable.
|
|
518 |
CntImageUtility imageUtility;
|
|
519 |
if(imageUtility.isImageRemovable(mAvatar->imageUrl().toString()))
|
|
520 |
{
|
|
521 |
imageUtility.removeImage(mAvatar->imageUrl().toString());
|
|
522 |
}
|
|
523 |
mAvatar->setImageUrl(QUrl());
|
|
524 |
mImageLabel->clear();
|
|
525 |
mImageLabel->setAvatarIcon(HbIcon("qtg_large_add_group_picture"));
|
|
526 |
mHeadingItem->setIcon(HbIcon("qtg_large_add_group_picture"));
|
|
527 |
getContactManager()->saveContact(mGroupContact);
|
|
528 |
}
|
|
529 |
}
|
|
530 |
}
|
|
531 |
|
|
532 |
|
|
533 |
|
|
534 |
// end of file
|