38 |
38 |
39 CntPhoneNumberViewItem::CntPhoneNumberViewItem( QGraphicsItem* aParent ) : |
39 CntPhoneNumberViewItem::CntPhoneNumberViewItem( QGraphicsItem* aParent ) : |
40 CntDetailViewItem( aParent ), |
40 CntDetailViewItem( aParent ), |
41 mBox(NULL), |
41 mBox(NULL), |
42 mEdit(NULL), |
42 mEdit(NULL), |
43 mFilter(NULL), |
|
44 mLayout(NULL) |
43 mLayout(NULL) |
45 { |
44 { |
46 } |
45 } |
47 |
46 |
48 CntPhoneNumberViewItem::~CntPhoneNumberViewItem() |
47 CntPhoneNumberViewItem::~CntPhoneNumberViewItem() |
49 { |
48 { |
50 delete mFilter; |
|
51 } |
49 } |
52 |
50 |
53 HbAbstractViewItem* CntPhoneNumberViewItem::createItem() |
51 HbAbstractViewItem* CntPhoneNumberViewItem::createItem() |
54 { |
52 { |
55 return new CntPhoneNumberViewItem( *this ); |
53 return new CntPhoneNumberViewItem( *this ); |
116 connect(itemView()->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(changeOrientation(Qt::Orientation))); |
114 connect(itemView()->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(changeOrientation(Qt::Orientation))); |
117 mLayout = new QGraphicsLinearLayout( itemView()->mainWindow()->orientation() ); |
115 mLayout = new QGraphicsLinearLayout( itemView()->mainWindow()->orientation() ); |
118 HbWidget* widget = new HbWidget(); |
116 HbWidget* widget = new HbWidget(); |
119 mBox = new HbComboBox(); |
117 mBox = new HbComboBox(); |
120 mEdit = new HbLineEdit(); |
118 mEdit = new HbLineEdit(); |
121 mFilter = new HbEditorInterface( mEdit ); |
119 |
122 |
|
123 widget->setLayout( mLayout ); |
120 widget->setLayout( mLayout ); |
124 |
121 |
125 mLayout->addItem( mBox ); |
122 mLayout->addItem( mBox ); |
126 mLayout->addItem( mEdit ); |
123 mLayout->addItem( mEdit ); |
127 |
124 |
165 return widget; |
162 return widget; |
166 } |
163 } |
167 |
164 |
168 void CntPhoneNumberViewItem::constructPhoneNumber( CntDetailModelItem* aItem, QString aSubType, QStringList aContext ) |
165 void CntPhoneNumberViewItem::constructPhoneNumber( CntDetailModelItem* aItem, QString aSubType, QStringList aContext ) |
169 { |
166 { |
170 mFilter->setFilter( HbPhoneNumberFilter::instance() ); |
167 mEdit->setInputMethodHints( Qt::ImhDialableCharactersOnly ); |
171 mFilter->setUpAsPhoneNumberEditor(); |
|
172 mEdit->setMaxLength( CNT_PHONENUMBER_EDITOR_MAXLENGTH ); |
168 mEdit->setMaxLength( CNT_PHONENUMBER_EDITOR_MAXLENGTH ); |
173 |
169 |
174 QContactDetail detail = aItem->detail(); |
170 QContactDetail detail = aItem->detail(); |
175 |
171 |
176 // check if the detail type needs to changed |
172 // check if the detail type needs to changed |
177 if ( detail.definitionName() == QContactOnlineAccount::DefinitionName ) |
173 if ( detail.definitionName() == QContactOnlineAccount::DefinitionName ) |
178 { |
174 { |
179 // also we need to remove the old online account and replace it |
175 // also we need to remove the old online account and replace it |
180 // with phonenumber |
176 // with phonenumber |
181 CntDetailEditorModel* model = static_cast<CntDetailEditorModel*>( aItem->model() ); |
177 CntDetailEditorModel* model = static_cast<CntDetailEditorModel*>( itemView()->model() ); |
182 QContact* contact = model->contact(); |
178 QContact* contact = model->contact(); |
183 contact->removeDetail( &detail ); |
179 contact->removeDetail( &detail ); |
184 |
180 |
185 QContactPhoneNumber number; |
181 QContactPhoneNumber number; |
186 number.setSubTypes( aSubType ); |
182 number.setSubTypes( aSubType ); |
197 qDebug() << mEdit->text(); |
193 qDebug() << mEdit->text(); |
198 } |
194 } |
199 |
195 |
200 void CntPhoneNumberViewItem::constructOnlineAccount( CntDetailModelItem* aItem, QString aSubType, QStringList aContext ) |
196 void CntPhoneNumberViewItem::constructOnlineAccount( CntDetailModelItem* aItem, QString aSubType, QStringList aContext ) |
201 { |
197 { |
202 mFilter->setFilter( HbEmailAddressFilter::instance() ); |
|
203 mFilter->setUpAsCompletingEmailField(); |
|
204 mEdit->setMaxLength( CNT_ONLINEACCOUNT_EDITOR_MAXLENGTH ); |
198 mEdit->setMaxLength( CNT_ONLINEACCOUNT_EDITOR_MAXLENGTH ); |
|
199 mEdit->setInputMethodHints( Qt::ImhUrlCharactersOnly ); |
205 |
200 |
206 QContactDetail detail = aItem->detail(); |
201 QContactDetail detail = aItem->detail(); |
207 // check if the detail type needs to changed |
202 // check if the detail type needs to changed |
208 if ( detail.definitionName() == QContactPhoneNumber::DefinitionName ) |
203 if ( detail.definitionName() == QContactPhoneNumber::DefinitionName ) |
209 { |
204 { |
210 // also we need to remove the old phonenumber and replace it |
205 // also we need to remove the old phonenumber and replace it |
211 // with online account |
206 // with online account |
212 CntDetailEditorModel* model = static_cast<CntDetailEditorModel*>( aItem->model() ); |
207 CntDetailEditorModel* model = static_cast<CntDetailEditorModel*>( itemView()->model() ); |
213 QContact* contact = model->contact(); |
208 QContact* contact = model->contact(); |
214 contact->removeDetail( &detail ); |
209 contact->removeDetail( &detail ); |
215 |
210 |
216 QContactOnlineAccount account; |
211 QContactOnlineAccount account; |
217 account.setSubTypes( aSubType ); |
212 account.setSubTypes( aSubType ); |
268 mobilework->setData(contextWork, DetailContext); |
263 mobilework->setData(contextWork, DetailContext); |
269 mobilework->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
264 mobilework->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
270 model->appendRow(mobilework); |
265 model->appendRow(mobilework); |
271 |
266 |
272 QStandardItem *land = new QStandardItem; |
267 QStandardItem *land = new QStandardItem; |
273 land->setText(hbTrId("txt_phob_setlabel_val_phone")); |
268 land->setText(hbTrId("txt_phob_dblist_phone")); |
274 land->setData(subTypeLandline, DetailSubType); |
269 land->setData(subTypeLandline, DetailSubType); |
275 land->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
270 land->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
276 model->appendRow(land); |
271 model->appendRow(land); |
277 |
272 |
278 QStandardItem *landhome = new QStandardItem; |
273 QStandardItem *landhome = new QStandardItem; |
279 landhome->setText(hbTrId("txt_phob_setlabel_val_phone_home")); |
274 landhome->setText(hbTrId("txt_phob_dblist_phone_home")); |
280 landhome->setData(subTypeLandline, DetailSubType); |
275 landhome->setData(subTypeLandline, DetailSubType); |
281 landhome->setData(contextHome, DetailContext); |
276 landhome->setData(contextHome, DetailContext); |
282 landhome->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
277 landhome->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
283 model->appendRow(landhome); |
278 model->appendRow(landhome); |
284 |
279 |
285 QStandardItem *landwork = new QStandardItem; |
280 QStandardItem *landwork = new QStandardItem; |
286 landwork->setText(hbTrId("txt_phob_setlabel_val_phone_work")); |
281 landwork->setText(hbTrId("txt_phob_dblist_phone_work")); |
287 landwork->setData(subTypeLandline, DetailSubType); |
282 landwork->setData(subTypeLandline, DetailSubType); |
288 landwork->setData(contextWork, DetailContext); |
283 landwork->setData(contextWork, DetailContext); |
289 landwork->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
284 landwork->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
290 model->appendRow(landwork); |
285 model->appendRow(landwork); |
291 |
286 |
308 faxwork->setData(contextWork, DetailContext); |
303 faxwork->setData(contextWork, DetailContext); |
309 faxwork->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
304 faxwork->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
310 model->appendRow(faxwork); |
305 model->appendRow(faxwork); |
311 |
306 |
312 QStandardItem *pager = new QStandardItem; |
307 QStandardItem *pager = new QStandardItem; |
313 pager->setText(hbTrId("txt_phob_setlabel_val_pager")); |
308 pager->setText(hbTrId("txt_phob_dblist_pager")); |
314 pager->setData(subTypePager, DetailSubType); |
309 pager->setData(subTypePager, DetailSubType); |
315 pager->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
310 pager->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
316 model->appendRow(pager); |
311 model->appendRow(pager); |
317 |
312 |
318 QStandardItem *assistant = new QStandardItem; |
313 QStandardItem *assistant = new QStandardItem; |
319 assistant->setText(hbTrId("txt_phob_setlabel_val_assistant")); |
314 assistant->setText(hbTrId("txt_phob_dblist_assistant")); |
320 assistant->setData(subTypeAssistant, DetailSubType); |
315 assistant->setData(subTypeAssistant, DetailSubType); |
321 assistant->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
316 assistant->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
322 model->appendRow(assistant); |
317 model->appendRow(assistant); |
323 |
318 |
324 QStandardItem *carPhone = new QStandardItem; |
319 QStandardItem *carPhone = new QStandardItem; |
325 carPhone->setText(hbTrId("txt_phob_setlabel_val_car")); |
320 carPhone->setText(hbTrId("txt_phob_dblist_car")); |
326 carPhone->setData(subTypeCarPhone, DetailSubType); |
321 carPhone->setData(subTypeCarPhone, DetailSubType); |
327 carPhone->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
322 carPhone->setData(CNT_PHONENUMBER_EDITOR_MAXLENGTH, DetailMaxLength); |
328 model->appendRow(carPhone); |
323 model->appendRow(carPhone); |
329 |
324 |
330 // QStandardItem *dtmf = new QStandardItem; |
325 // QStandardItem *dtmf = new QStandardItem; |