15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "nmuiheaders.h" |
18 #include "nmuiheaders.h" |
19 |
19 |
20 static const QString NmContactsServiceName = "com.nokia.services.phonebookservices"; |
20 static const QString NmContactsServiceName = "phonebookservices"; |
21 static const QString NmContactsInterfaceName = "Fetch"; |
21 static const QString NmContactsInterfaceName = "com.nokia.symbian.IContactsFetch"; |
22 static const QString NmContactsOperationName = "fetch(QString,QString,QString)"; |
22 static const QString NmContactsOperationName = "multiFetch(QString,QString)"; |
23 |
23 |
24 static const int NmMaxRows = 10000; |
24 static const int NmMaxRows = 10000; |
25 |
25 |
26 /*! |
26 /*! |
27 widget is created using AD/docml |
27 widget is created using AD/docml |
34 mLabel(NULL), |
34 mLabel(NULL), |
35 mRecipientsEditor(NULL), |
35 mRecipientsEditor(NULL), |
36 mLaunchContactsPickerButton(NULL) |
36 mLaunchContactsPickerButton(NULL) |
37 { |
37 { |
38 NM_FUNCTION; |
38 NM_FUNCTION; |
39 |
39 |
40 // Load the widgets from nmeditorview.docml. The names match to the definitions in that docml. |
40 // Load the widgets from nmeditorview.docml. The names match to the definitions in that docml. |
41 mWidget = qobject_cast<HbWidget *> |
41 mWidget = qobject_cast<HbWidget *> |
42 (mDocumentLoader.findWidget(mObjectPrefix + "Field")); |
42 (mDocumentLoader.findWidget(mObjectPrefix + "Field")); |
43 |
43 |
44 mLabel = qobject_cast<HbLabel *> |
44 mLabel = qobject_cast<HbLabel *> |
45 (mDocumentLoader.findWidget(mObjectPrefix + "Label")); |
45 (mDocumentLoader.findWidget(mObjectPrefix + "Label")); |
46 |
46 |
47 mRecipientsEditor = qobject_cast<NmRecipientLineEdit *> |
47 mRecipientsEditor = qobject_cast<NmRecipientLineEdit *> |
48 (mDocumentLoader.findWidget(mObjectPrefix + "Edit")); |
48 (mDocumentLoader.findWidget(mObjectPrefix + "Edit")); |
49 if (mRecipientsEditor) { |
49 if (mRecipientsEditor) { |
50 mRecipientsEditor->setMaxRows(NmMaxRows); |
50 mRecipientsEditor->setMaxRows(NmMaxRows); |
51 } |
51 } |
52 |
52 |
53 mLaunchContactsPickerButton = qobject_cast<HbPushButton *> |
53 mLaunchContactsPickerButton = qobject_cast<HbPushButton *> |
54 (mDocumentLoader.findWidget(mObjectPrefix + "Button")); |
54 (mDocumentLoader.findWidget(mObjectPrefix + "Button")); |
55 if (mLaunchContactsPickerButton) { |
55 if (mLaunchContactsPickerButton) { |
56 mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts)); |
56 mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts)); |
57 } |
57 } |
58 |
58 |
59 createConnections(); |
59 createConnections(); |
60 } |
60 } |
61 |
61 |
63 Creates connections for this class items |
63 Creates connections for this class items |
64 */ |
64 */ |
65 void NmRecipientField::createConnections() |
65 void NmRecipientField::createConnections() |
66 { |
66 { |
67 NM_FUNCTION; |
67 NM_FUNCTION; |
68 |
68 |
69 connect(mRecipientsEditor, SIGNAL(textChanged(const QString &)), |
69 connect(mRecipientsEditor, SIGNAL(textChanged(const QString &)), |
70 this, SIGNAL(textChanged(const QString &))); |
70 this, SIGNAL(textChanged(const QString &))); |
71 connect(mRecipientsEditor, SIGNAL(cursorPositionChanged(int, int)), |
71 connect(mRecipientsEditor, SIGNAL(cursorPositionChanged(int, int)), |
72 this, SIGNAL(cursorPositionChanged(int, int))); |
72 this, SIGNAL(cursorPositionChanged(int, int))); |
73 connect(mRecipientsEditor, SIGNAL(editingFinished()), |
73 connect(mRecipientsEditor, SIGNAL(editingFinished()), |
74 this, SIGNAL(editingFinished())); |
74 this, SIGNAL(editingFinished())); |
75 connect(mRecipientsEditor, SIGNAL(selectionChanged()), |
75 connect(mRecipientsEditor, SIGNAL(selectionChanged()), |
76 this, SIGNAL(selectionChanged())); |
76 this, SIGNAL(selectionChanged())); |
77 connect(mLaunchContactsPickerButton, SIGNAL(pressed()), |
77 connect(mLaunchContactsPickerButton, SIGNAL(pressed()), |
78 this, SIGNAL(launchContactsPickerButtonClicked())); |
78 this, SIGNAL(launchContactsPickerButtonClicked())); |
79 connect(mLaunchContactsPickerButton, SIGNAL(pressed()), |
79 connect(mLaunchContactsPickerButton, SIGNAL(pressed()), |
80 this, SLOT(launchContactsPicker())); |
80 this, SLOT(launchContactsPicker())); |
81 } |
81 } |
82 |
82 |
83 |
83 |
84 /*! |
84 /*! |
93 Widget height |
93 Widget height |
94 */ |
94 */ |
95 qreal NmRecipientField::height() |
95 qreal NmRecipientField::height() |
96 { |
96 { |
97 NM_FUNCTION; |
97 NM_FUNCTION; |
98 |
98 |
99 return mWidget->geometry().height(); |
99 return mWidget->geometry().height(); |
100 } |
100 } |
101 |
101 |
102 /*! |
102 /*! |
103 editor |
103 editor |
104 */ |
104 */ |
105 NmRecipientLineEdit *NmRecipientField::editor() const |
105 NmRecipientLineEdit *NmRecipientField::editor() const |
106 { |
106 { |
107 NM_FUNCTION; |
107 NM_FUNCTION; |
108 |
108 |
109 return mRecipientsEditor; |
109 return mRecipientsEditor; |
110 } |
110 } |
111 |
111 |
112 |
112 |
113 /*! |
113 /*! |
114 LineEdit contents |
114 LineEdit contents |
115 */ |
115 */ |
116 const QString NmRecipientField::text() const |
116 const QString NmRecipientField::text() const |
117 { |
117 { |
118 NM_FUNCTION; |
118 NM_FUNCTION; |
119 |
119 |
120 return mRecipientsEditor->text(); |
120 return mRecipientsEditor->text(); |
121 } |
121 } |
122 |
122 |
123 |
123 |
124 /*! |
124 /*! |
125 Slot setText |
125 Slot setText |
126 */ |
126 */ |
127 void NmRecipientField::setText(const QString &newText) |
127 void NmRecipientField::setText(const QString &newText) |
128 { |
128 { |
129 NM_FUNCTION; |
129 NM_FUNCTION; |
130 |
130 |
131 if (newText != mRecipientsEditor->text()) { |
131 if (newText != mRecipientsEditor->text()) { |
132 mRecipientsEditor->setText(newText); |
132 mRecipientsEditor->setText(newText); |
133 emit textChanged(newText); |
133 emit textChanged(newText); |
134 } |
134 } |
135 } |
135 } |
139 This Slot launches the contacts-picker |
139 This Slot launches the contacts-picker |
140 */ |
140 */ |
141 void NmRecipientField::launchContactsPicker() |
141 void NmRecipientField::launchContactsPicker() |
142 { |
142 { |
143 NM_FUNCTION; |
143 NM_FUNCTION; |
144 |
144 |
145 XQApplicationManager mAppmgr; |
145 XQApplicationManager mAppmgr; |
146 XQAiwRequest *launchContactsPickerRequest; |
146 XQAiwRequest *launchContactsPickerRequest; |
147 |
147 |
148 bool isEmbeded = true; |
148 bool isEmbeded = true; |
149 launchContactsPickerRequest = mAppmgr.create(NmContactsServiceName, NmContactsInterfaceName, |
149 launchContactsPickerRequest = mAppmgr.create(NmContactsServiceName, NmContactsInterfaceName, |
150 NmContactsOperationName, isEmbeded); |
150 NmContactsOperationName, isEmbeded); |
151 |
151 |
152 if (launchContactsPickerRequest) { |
152 if (launchContactsPickerRequest) { |
153 connect(launchContactsPickerRequest, SIGNAL(requestOk(QVariant)), |
153 connect(launchContactsPickerRequest, SIGNAL(requestOk(QVariant)), |
154 mRecipientsEditor, SLOT(addSelectedContacts(QVariant))); |
154 mRecipientsEditor, SLOT(addSelectedContacts(QVariant))); |
155 } |
155 } |
156 else { |
156 else { |
157 // Failed creating request |
157 // Failed creating request |
158 NM_ERROR(1,"XQApplicationManager: failed creating fecth contactspicker request"); |
158 NM_ERROR(1,"XQApplicationManager: failed creating fecth contactspicker request"); |
159 return; |
159 return; |
160 } |
160 } |
161 |
161 |
162 QVariantList args; |
162 QVariantList args; |
163 args << hbTrId("txt_mail_select_contacts"); |
163 args << hbTrId("txt_mail_select_contacts"); |
164 args << KCntActionEmail; |
164 args << KCntActionEmail; |
165 args << KCntFilterDisplayAll; |
165 launchContactsPickerRequest->setArguments(args); |
166 launchContactsPickerRequest->setArguments(args); |
166 |
167 |
|
168 // Send request |
167 // Send request |
169 if (!launchContactsPickerRequest->send()) { |
168 if (!launchContactsPickerRequest->send()) { |
170 //Failed sending request |
169 //Failed sending request |
171 NM_ERROR(1,"XQApplicationManager: failed sending request"); |
170 NM_ERROR(1,"XQApplicationManager: failed sending request"); |
172 } |
171 } |
173 |
172 |
174 delete launchContactsPickerRequest; |
173 delete launchContactsPickerRequest; |
175 launchContactsPickerRequest = NULL; |
174 launchContactsPickerRequest = NULL; |
176 } |
175 } |