72
|
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 "cntimportsview.h"
|
|
18 |
#include "cntsimengine.h"
|
|
19 |
|
81
|
20 |
#include "cntglobal.h"
|
|
21 |
#include <cntdebug.h>
|
|
22 |
|
72
|
23 |
#include <hbaction.h>
|
|
24 |
#include <hbview.h>
|
|
25 |
#include <hbframebackground.h>
|
|
26 |
#include <hblistview.h>
|
|
27 |
#include <hbextendedlocale.h>
|
|
28 |
#include <hbparameterlengthlimiter.h>
|
|
29 |
#include <hblistviewitem.h>
|
81
|
30 |
#include <hbdevicenotificationdialog.h>
|
|
31 |
#include <hbprogressdialog.h>
|
|
32 |
|
|
33 |
#include <QTimer>
|
|
34 |
#include <QStandardItemModel>
|
72
|
35 |
#include <QCoreApplication>
|
|
36 |
|
|
37 |
const char *CNT_IMPORT_UI_XML = ":/xml/contacts_sim.docml";
|
|
38 |
|
81
|
39 |
/*!
|
|
40 |
Constructor
|
|
41 |
*/
|
|
42 |
CntImportsView::CntImportsView() :
|
|
43 |
mViewManager(NULL),
|
|
44 |
mSimEngine(NULL),
|
|
45 |
mListView(NULL),
|
|
46 |
mView(NULL),
|
|
47 |
mSoftkey(NULL),
|
|
48 |
mModel(NULL),
|
|
49 |
mImportSimPopup(NULL),
|
|
50 |
mEngine(NULL)
|
72
|
51 |
{
|
|
52 |
CNT_ENTRY
|
81
|
53 |
|
72
|
54 |
bool ok = false;
|
|
55 |
mDocumentLoader.load(CNT_IMPORT_UI_XML, &ok);
|
|
56 |
|
|
57 |
if (ok)
|
|
58 |
{
|
|
59 |
mView = static_cast<HbView*>(mDocumentLoader.findWidget(QString("view")));
|
|
60 |
}
|
|
61 |
else
|
|
62 |
{
|
|
63 |
qFatal("Unable to read :/xml/contacts_sim.docml");
|
|
64 |
}
|
|
65 |
|
|
66 |
mSimEngine = new CntSimEngine(*this, *mView);
|
81
|
67 |
connect(mSimEngine, SIGNAL(showNamesView()), this, SLOT(showPreviousView()));
|
|
68 |
connect(mSimEngine, SIGNAL(closePopup()), this, SLOT(closeImportPopup()));
|
72
|
69 |
|
|
70 |
//back button
|
|
71 |
mSoftkey = new HbAction(Hb::BackNaviAction, mView);
|
|
72 |
connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView()));
|
|
73 |
|
|
74 |
CNT_EXIT
|
|
75 |
}
|
|
76 |
|
|
77 |
/*!
|
81
|
78 |
Destructor
|
72
|
79 |
*/
|
81
|
80 |
CntImportsView::~CntImportsView()
|
72
|
81 |
{
|
|
82 |
CNT_ENTRY
|
81
|
83 |
|
|
84 |
mView->deleteLater();
|
|
85 |
delete mModel;
|
|
86 |
delete mSimEngine;
|
|
87 |
|
72
|
88 |
CNT_EXIT
|
|
89 |
}
|
|
90 |
|
|
91 |
/*
|
|
92 |
Activates a default view
|
|
93 |
*/
|
|
94 |
void CntImportsView::activate(const CntViewParameters aArgs)
|
|
95 |
{
|
|
96 |
CNT_ENTRY
|
|
97 |
Q_UNUSED(aArgs);
|
|
98 |
//back button
|
|
99 |
|
|
100 |
if (mView->navigationAction() != mSoftkey)
|
|
101 |
{
|
|
102 |
mView->setNavigationAction(mSoftkey);
|
|
103 |
}
|
|
104 |
|
|
105 |
mViewManager = &mEngine->viewManager();
|
|
106 |
QContactManager *ContactSymbianManager = &mEngine->contactManager(SYMBIAN_BACKEND);
|
|
107 |
|
|
108 |
mModel = new QStandardItemModel();
|
|
109 |
|
|
110 |
mSimEngine->init(*mEngine);
|
|
111 |
|
|
112 |
mListView = static_cast<HbListView*>(mDocumentLoader.findWidget(QString("listView")));
|
|
113 |
|
|
114 |
HbFrameBackground frame;
|
|
115 |
frame.setFrameGraphicsName("qtg_fr_list_normal");
|
|
116 |
frame.setFrameType(HbFrameDrawer::NinePieces);
|
|
117 |
mListView->itemPrototypes().first()->setDefaultFrame(frame);
|
|
118 |
mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape);
|
|
119 |
mListView->setUniformItemSizes(true);
|
|
120 |
|
|
121 |
connect(mListView, SIGNAL(activated (const QModelIndex&)),
|
|
122 |
this, SLOT(onListViewActivated(const QModelIndex&)));
|
|
123 |
|
|
124 |
|
|
125 |
QStandardItem *importItem = new QStandardItem();
|
|
126 |
QStringList simList;
|
|
127 |
|
|
128 |
mSimEngine->checkEntries(simList, *importItem);
|
|
129 |
|
|
130 |
importItem->setData(simList, Qt::DisplayRole);
|
|
131 |
importItem->setData(HbIcon("qtg_large_sim"), Qt::DecorationRole);
|
|
132 |
|
|
133 |
mModel->insertRow(0,importItem);
|
|
134 |
|
|
135 |
mListView->setModel(mModel);
|
|
136 |
mListView->setSelectionMode(HbAbstractItemView::NoSelection);
|
|
137 |
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(userCancelsImport()));
|
|
138 |
CNT_EXIT
|
|
139 |
}
|
|
140 |
|
81
|
141 |
void CntImportsView::deactivate()
|
|
142 |
{
|
|
143 |
|
|
144 |
}
|
72
|
145 |
|
81
|
146 |
/*!
|
|
147 |
Returns the contact manager
|
|
148 |
*/
|
|
149 |
QContactManager *CntImportsView::contactSymbianManager()
|
|
150 |
{
|
|
151 |
if (mSimEngine)
|
|
152 |
{
|
|
153 |
return mSimEngine->contactSymbianManager();
|
|
154 |
}
|
|
155 |
|
|
156 |
return NULL;
|
|
157 |
}
|
|
158 |
|
|
159 |
/*!
|
|
160 |
Activates a previous view
|
|
161 |
*/
|
|
162 |
void CntImportsView::showPreviousView()
|
|
163 |
{
|
|
164 |
CNT_ENTRY
|
|
165 |
|
|
166 |
CntViewParameters args;
|
|
167 |
mViewManager->back(args);
|
|
168 |
|
|
169 |
CNT_EXIT
|
|
170 |
}
|
|
171 |
|
|
172 |
/*!
|
|
173 |
Close the import popup
|
|
174 |
*/
|
|
175 |
void CntImportsView::closeImportPopup()
|
|
176 |
{
|
|
177 |
CNT_ENTRY
|
|
178 |
|
|
179 |
if (mImportSimPopup != NULL)
|
|
180 |
{
|
|
181 |
mImportSimPopup->close();
|
|
182 |
mImportSimPopup = NULL;
|
|
183 |
}
|
|
184 |
|
|
185 |
CNT_EXIT
|
|
186 |
}
|
|
187 |
|
|
188 |
/*!
|
|
189 |
Called when list item is activated
|
|
190 |
*/
|
72
|
191 |
void CntImportsView::onListViewActivated(const QModelIndex &index)
|
|
192 |
{
|
|
193 |
CNT_ENTRY
|
81
|
194 |
|
72
|
195 |
int row = index.row();
|
|
196 |
if ( row == 0 ) // row 0 has "Imports from SIM"
|
|
197 |
{
|
81
|
198 |
if (!mSimEngine->startSimImport())
|
|
199 |
{
|
|
200 |
//show error note
|
|
201 |
mSimEngine->simInfoErrorMessage(KErrAccessDenied);
|
|
202 |
}
|
|
203 |
else
|
|
204 |
{
|
|
205 |
//start popup and progress
|
|
206 |
showWaitNote();
|
|
207 |
}
|
|
208 |
}
|
72
|
209 |
|
|
210 |
CNT_EXIT
|
|
211 |
}
|
|
212 |
|
81
|
213 |
/*!
|
|
214 |
Called when importing is cancelled
|
|
215 |
*/
|
72
|
216 |
void CntImportsView::userCancelsImport()
|
|
217 |
{
|
|
218 |
CNT_ENTRY
|
81
|
219 |
|
72
|
220 |
QString results;
|
|
221 |
|
|
222 |
if(mSimEngine->userCancelsImport(results))
|
|
223 |
{
|
|
224 |
HbDeviceNotificationDialog::notification(QString(),results);
|
|
225 |
}
|
81
|
226 |
|
72
|
227 |
CNT_EXIT
|
|
228 |
}
|
|
229 |
|
81
|
230 |
/*!
|
|
231 |
Display the wait note
|
|
232 |
*/
|
|
233 |
void CntImportsView::showWaitNote()
|
|
234 |
{
|
|
235 |
CNT_ENTRY
|
|
236 |
|
|
237 |
mImportSimPopup = new HbProgressDialog(HbProgressDialog::WaitDialog);
|
|
238 |
mImportSimPopup->setDismissPolicy(HbPopup::NoDismiss);
|
|
239 |
mImportSimPopup->setTimeout(HbPopup::NoTimeout);
|
|
240 |
mImportSimPopup->setBackgroundFaded(true);
|
|
241 |
mImportSimPopup->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
242 |
|
|
243 |
mImportSimPopup->setHeadingText(hbTrId("txt_phob_title_import_contacts"));
|
|
244 |
mImportSimPopup->setIcon(HbIcon("qtg_large_sim"));
|
|
245 |
mImportSimPopup->setText(hbTrId("txt_phob_info_importing_contacts_from_sim"));
|
|
246 |
|
|
247 |
connect(mImportSimPopup, SIGNAL(cancelled()), mSimEngine, SLOT(stopSimImport()));
|
|
248 |
|
|
249 |
mImportSimPopup->show();
|
|
250 |
|
|
251 |
CNT_EXIT
|
|
252 |
}
|
|
253 |
|
|
254 |
/*!
|
|
255 |
Set preferred details for the given contact
|
|
256 |
*/
|
|
257 |
void CntImportsView::setPreferredDetails( QContact *aContact )
|
|
258 |
{
|
|
259 |
CNT_ENTRY
|
|
260 |
|
|
261 |
mSimEngine->setPreferredDetails(*aContact);
|
|
262 |
|
|
263 |
CNT_EXIT
|
|
264 |
}
|
72
|
265 |
|
|
266 |
void CntImportsView::setListBoxItemText(QString& aPrimary, QString& aSecondary)
|
|
267 |
{
|
|
268 |
CNT_ENTRY
|
81
|
269 |
|
72
|
270 |
QList<QStandardItem*> importItems = mModel->takeRow(0);
|
|
271 |
QStandardItem* importItem = NULL;
|
81
|
272 |
|
|
273 |
if (importItems.count() > 0)
|
|
274 |
{
|
72
|
275 |
importItem = importItems.at(0);
|
|
276 |
}
|
|
277 |
|
|
278 |
if (importItem != NULL)
|
|
279 |
{
|
|
280 |
QStringList simList;
|
|
281 |
|
|
282 |
simList << aPrimary;
|
|
283 |
simList << aSecondary;
|
|
284 |
|
|
285 |
importItem->setData(simList, Qt::DisplayRole);
|
|
286 |
importItem->setData(HbIcon("qtg_large_sim"), Qt::DecorationRole);
|
|
287 |
mModel->insertRow(0, importItem);
|
|
288 |
mListView->reset();
|
|
289 |
}
|
81
|
290 |
|
72
|
291 |
CNT_EXIT
|
|
292 |
}
|
|
293 |
|
|
294 |
void CntImportsView::setListBoxItemEnabled(bool aEnabled)
|
|
295 |
{
|
|
296 |
CNT_ENTRY
|
81
|
297 |
|
72
|
298 |
QList<QStandardItem*> importItems = mModel->takeRow(0);
|
|
299 |
QStandardItem* importItem = NULL;
|
81
|
300 |
|
72
|
301 |
if ( !importItems.isEmpty() )
|
|
302 |
{
|
|
303 |
importItem = importItems.first();
|
|
304 |
}
|
|
305 |
|
|
306 |
if (importItem != NULL)
|
|
307 |
{
|
|
308 |
importItem->setEnabled(aEnabled);
|
|
309 |
}
|
81
|
310 |
|
72
|
311 |
CNT_EXIT
|
|
312 |
}
|
|
313 |
|
|
314 |
// EOF
|