15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "cntgroupselectionpopup.h" |
18 #include "cntgroupselectionpopup.h" |
19 |
19 |
20 #include <hblabel.h> |
|
21 #include <hbgroupbox.h> |
20 #include <hbgroupbox.h> |
22 #include <hbaction.h> |
21 #include <hbaction.h> |
23 #include <hbsearchpanel.h> |
22 #include <hbsearchpanel.h> |
24 #include <hblistviewitem.h> |
23 #include <hblistviewitem.h> |
|
24 #include <hbindexfeedback.h> |
|
25 #include <hbscrollbar.h> |
25 #include <hbtextitem.h> |
26 #include <hbtextitem.h> |
26 #include <qtcontacts.h> |
27 #include <qtcontacts.h> |
27 #include <QStringListModel> |
|
28 #include <QGraphicsWidget> |
28 #include <QGraphicsWidget> |
29 #include <mobcntmodel.h> |
29 #include <mobcntmodel.h> |
30 #include <hbmainwindow.h> |
30 #include <hbmainwindow.h> |
|
31 #include <hbparameterlengthlimiter.h> |
31 |
32 |
32 |
33 |
33 CntGroupSelectionPopup::CntGroupSelectionPopup(QContactManager *manager, QContact *contact, QGraphicsItem *parent): |
34 CntGroupSelectionPopup::CntGroupSelectionPopup(QContactManager *manager, QContact *contact, QGraphicsItem *parent): |
34 HbDialog(parent), |
35 HbDialog(parent), |
35 mListView(NULL), |
36 mListView(NULL), |
36 mEmptyListLabel(NULL), |
37 mEmptyListLabel(NULL), |
37 mContactManager(manager), |
38 mContactManager(manager), |
38 mContact(contact) |
39 mContact(contact) |
39 { |
40 { |
40 QList<QContactSortOrder> sortOrders; |
41 QList<QContactSortOrder> sortOrders; |
41 QContactSortOrder sortOrderFirstName; |
42 QContactSortOrder sortOrderFirstName; |
42 sortOrderFirstName.setDetailDefinitionName(QContactName::DefinitionName, QContactName::FieldFirst); |
43 sortOrderFirstName.setDetailDefinitionName(QContactName::DefinitionName, QContactName::FieldFirst); |
43 sortOrderFirstName.setCaseSensitivity(Qt::CaseInsensitive); |
44 sortOrderFirstName.setCaseSensitivity(Qt::CaseInsensitive); |
44 sortOrders.append(sortOrderFirstName); |
45 sortOrders.append(sortOrderFirstName); |
74 { |
75 { |
75 QContactName groupContactName = mContact->detail( QContactName::DefinitionName ); |
76 QContactName groupContactName = mContact->detail( QContactName::DefinitionName ); |
76 QString groupName(groupContactName.value( QContactName::FieldCustomLabel )); |
77 QString groupName(groupContactName.value( QContactName::FieldCustomLabel )); |
77 |
78 |
78 HbGroupBox *headingLabel = new HbGroupBox(this); |
79 HbGroupBox *headingLabel = new HbGroupBox(this); |
79 headingLabel->setHeading(hbTrId("txt_phob_title_members_of_1_group").arg(groupName)); |
80 headingLabel->setHeading(HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupName)); |
80 |
81 |
81 setHeadingWidget(headingLabel); |
82 setHeadingWidget(headingLabel); |
82 |
83 |
83 mListView = new HbListView(this); |
84 mListView = new HbListView(this); |
84 QContactRelationshipFilter rFilter; |
85 QContactRelationshipFilter rFilter; |
99 // Set the select option for those contacts in the selectionModel |
100 // Set the select option for those contacts in the selectionModel |
100 mListView->setModel(mCntModel); |
101 mListView->setModel(mCntModel); |
101 // set the listview to multiSelection mode, this will bring MarkAll functionality (from Orbit) |
102 // set the listview to multiSelection mode, this will bring MarkAll functionality (from Orbit) |
102 mListView->setSelectionMode(HbAbstractItemView::MultiSelection); |
103 mListView->setSelectionMode(HbAbstractItemView::MultiSelection); |
103 mListView->setFrictionEnabled(true); |
104 mListView->setFrictionEnabled(true); |
104 mListView->setScrollingStyle(HbScrollArea::PanOrFlick); |
105 mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
|
106 mListView->verticalScrollBar()->setInteractive(true); |
105 HbListViewItem *prototype = mListView->listItemPrototype(); |
107 HbListViewItem *prototype = mListView->listItemPrototype(); |
106 prototype->setGraphicsSize(HbListViewItem::Thumbnail); |
108 prototype->setGraphicsSize(HbListViewItem::Thumbnail); |
|
109 HbIndexFeedback *indexFeedback = new HbIndexFeedback(this); |
|
110 indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter); |
|
111 indexFeedback->setItemView(mListView); |
107 |
112 |
108 for (int i=0; i < countContacts; i++ ) |
113 for (int i=0; i < countContacts; i++ ) |
109 { |
114 { |
110 // get QContact from QContactId |
115 // get QContact from QContactId |
111 QContact contactInList = mContactManager->contact(contactsLocalIdList.at(i)); |
116 QContact contactInList = mContactManager->contact(contactsLocalIdList.at(i)); |
114 } |
119 } |
115 |
120 |
116 setTimeout(HbPopup::NoTimeout); |
121 setTimeout(HbPopup::NoTimeout); |
117 setDismissPolicy(HbPopup::NoDismiss); |
122 setDismissPolicy(HbPopup::NoDismiss); |
118 setModal(true); |
123 setModal(true); |
|
124 setAttribute(Qt::WA_DeleteOnClose, true); |
119 |
125 |
120 // Note that the layout takes ownership of the item(s) it contains. |
126 // Note that the layout takes ownership of the item(s) it contains. |
121 if (!mCntModel->rowCount()) |
127 if (!mCntModel->rowCount()) |
122 { |
128 { |
123 mListView->setVisible(false); |
129 mListView->setVisible(false); |
134 { |
140 { |
135 mContainerLayout->addItem(mListView); |
141 mContainerLayout->addItem(mListView); |
136 } |
142 } |
137 mContainerLayout->addItem(mSearchPanel); |
143 mContainerLayout->addItem(mSearchPanel); |
138 mContainerWidget->setLayout(mContainerLayout); |
144 mContainerWidget->setLayout(mContainerLayout); |
139 mContainerWidget->setPreferredHeight(mainWindow()->size().height()); |
145 HbMainWindow* window = mainWindow(); |
|
146 if ( window ) |
|
147 { |
|
148 mContainerWidget->setPreferredHeight(window->size().height()); |
|
149 } |
140 mContainerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
150 mContainerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
141 |
151 |
142 setContentWidget(mContainerWidget); |
152 setContentWidget(mContainerWidget); |
143 |
153 |
144 HbAction *mPrimaryAction = new HbAction(hbTrId("Save")); |
154 HbAction *mPrimaryAction = new HbAction(hbTrId("Save"), this); |
145 setPrimaryAction(mPrimaryAction); |
155 addAction(mPrimaryAction); |
146 |
156 |
147 HbAction *mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel")); |
157 HbAction *mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"), this); |
148 setSecondaryAction(mSecondaryAction); |
158 addAction(mSecondaryAction); |
149 } |
159 } |
150 |
160 |
151 void CntGroupSelectionPopup::saveNewGroup() |
161 bool CntGroupSelectionPopup::saveNewGroup() |
152 { |
162 { |
153 // Save the relationship from the selection model of the member selection list |
163 // Save the relationship from the selection model of the member selection list |
154 QModelIndexList indexes = mListView->selectionModel()->selection().indexes(); |
164 QModelIndexList indexes = mListView->selectionModel()->selection().indexes(); |
155 |
165 |
156 for (int i = 0; i < indexes.count(); i++) |
166 for (int i = 0; i < indexes.count(); i++) |
165 relationship.setSecond(contact.id()); |
175 relationship.setSecond(contact.id()); |
166 |
176 |
167 // save relationship |
177 // save relationship |
168 mContactManager->saveRelationship(&relationship); |
178 mContactManager->saveRelationship(&relationship); |
169 } |
179 } |
170 } |
180 |
171 |
181 return indexes.count() > 0; |
172 void CntGroupSelectionPopup::saveOldGroup() |
182 } |
|
183 |
|
184 bool CntGroupSelectionPopup::saveOldGroup() |
173 { |
185 { |
174 // Use relationship filter to get list of contacts in the relationship (if any) |
186 // Use relationship filter to get list of contacts in the relationship (if any) |
175 QContactRelationshipFilter rFilter; |
187 QContactRelationshipFilter rFilter; |
176 rFilter.setRelationshipType(QContactRelationship::HasMember); |
188 rFilter.setRelationshipType(QContactRelationship::HasMember); |
177 rFilter.setRelatedContactRole(QContactRelationship::First); |
189 rFilter.setRelatedContactRole(QContactRelationship::First); |
226 } |
238 } |
227 // save & remove relationships |
239 // save & remove relationships |
228 QMap<int, QContactManager::Error> errors; |
240 QMap<int, QContactManager::Error> errors; |
229 mContactManager->removeRelationships(removedRelationships, &errors); |
241 mContactManager->removeRelationships(removedRelationships, &errors); |
230 mContactManager->saveRelationships(&addedRelationships, &errors); |
242 mContactManager->saveRelationships(&addedRelationships, &errors); |
|
243 |
|
244 return (removedRelationships.count() > 0 || addedRelationships.count() > 0); |
231 } |
245 } |
232 |
246 |
233 void CntGroupSelectionPopup::closeFind() |
247 void CntGroupSelectionPopup::closeFind() |
234 { |
248 { |
235 if (mSearchPanel) |
249 if (mSearchPanel) |