|
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 #include "cntaddressviewitem.h" |
|
18 #include "cntdetailmodelitem.h" |
|
19 #include "cntdetailconst.h" |
|
20 |
|
21 #include <qcontactdetail.h> |
|
22 #include <qcontactaddress.h> |
|
23 #include <hbdataform.h> |
|
24 #include <hbdataformmodel.h> |
|
25 #include <hbdataformmodelitem.h> |
|
26 #include <hbstyleloader.h> |
|
27 #include <hbpushbutton.h> |
|
28 #include <qgraphicslinearlayout.h> |
|
29 #include <hbwidget.h> |
|
30 #include <hbtextitem.h> |
|
31 |
|
32 //#include "qlocationpickeritem_temp.h" |
|
33 #include <xqaiwrequest.h> |
|
34 #include <xqservicerequest.h> |
|
35 #include <xqappmgr.h> |
|
36 CntAddressViewItem::CntAddressViewItem(QGraphicsItem* aParent) : |
|
37 /*CntDetailViewItem(aParent),*/ |
|
38 HbDataFormViewItem(aParent), |
|
39 mRequest(0), |
|
40 mAppManager(0), |
|
41 mSenderButton(0) |
|
42 { |
|
43 } |
|
44 |
|
45 CntAddressViewItem::~CntAddressViewItem() |
|
46 { |
|
47 delete mRequest; |
|
48 delete mAppManager; |
|
49 } |
|
50 |
|
51 HbAbstractViewItem* CntAddressViewItem::createItem() |
|
52 { |
|
53 return new CntAddressViewItem(*this); |
|
54 } |
|
55 |
|
56 HbWidget* CntAddressViewItem::createCustomWidget() |
|
57 { |
|
58 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Horizontal); |
|
59 |
|
60 HbWidget* widget = new HbWidget(); |
|
61 widget->setLayout(layout); |
|
62 |
|
63 HbStyleLoader::registerFilePath(":/style/cntlocationbutton.css"); |
|
64 HbStyleLoader::registerFilePath(":/style/cntlocationbutton.hbpushbutton.widgetml"); |
|
65 HbDataForm* form = static_cast<HbDataForm*> (itemView()); |
|
66 HbDataFormModel* model = static_cast<HbDataFormModel*> (form->model()); |
|
67 HbDataFormModelItem* item = model->itemFromIndex(modelIndex()); |
|
68 |
|
69 HbPushButton* mLocationButton = new HbPushButton(this); |
|
70 mLocationButton->setObjectName("cntlocationbutton"); |
|
71 mLocationButton->setIcon(HbIcon(":/icons/pickerIcon.jpg")); |
|
72 mLocationButton->setText(qtTrId("Select location from map")); |
|
73 mLocationButton->setOrientation(Qt::Horizontal); |
|
74 |
|
75 connect(mLocationButton, SIGNAL(clicked()), this, SLOT(launchLocationPicker())); |
|
76 |
|
77 layout->addItem(mLocationButton); |
|
78 return widget; |
|
79 } |
|
80 |
|
81 void CntAddressViewItem::launchLocationPicker() |
|
82 { |
|
83 mAppManager = new XQApplicationManager(); |
|
84 if (mRequest) { |
|
85 delete mRequest; |
|
86 mRequest = 0; |
|
87 } |
|
88 |
|
89 mSenderButton = sender(); |
|
90 mRequest = mAppManager->create("com.nokia.symbian", "ILocationPick", "pick()", false); |
|
91 if (mRequest) { |
|
92 connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, |
|
93 SLOT(handleLocationChange(const QVariant&))); |
|
94 mRequest->send(); |
|
95 } |
|
96 } |
|
97 |
|
98 void CntAddressViewItem::handleLocationChange(const QVariant& aValue) |
|
99 { |
|
100 Q_UNUSED( aValue ); |
|
101 } |
|
102 |
|
103 //Q_IMPLEMENT_USER_METATYPE(QLocationPickerItem) |
|
104 |
|
105 // End of File |