|
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 //USER |
|
18 #include "logsdetailsview.h" |
|
19 #include "logsdetailsmodel.h" |
|
20 #include "logscall.h" |
|
21 #include "logsmessage.h" |
|
22 #include "logslogger.h" |
|
23 #include "logscomponentrepository.h" |
|
24 #include "logsabstractviewmanager.h" |
|
25 #include "logsdefs.h" |
|
26 #include "logscontact.h" |
|
27 |
|
28 //SYSTEM |
|
29 #include <hblistview.h> |
|
30 #include <hbaction.h> |
|
31 #include <hbgroupbox.h> |
|
32 #include <hbmessagebox.h> |
|
33 #include <hblabel.h> |
|
34 Q_DECLARE_METATYPE(LogsDetailsModel*) |
|
35 |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 LogsDetailsView::LogsDetailsView( |
|
42 LogsComponentRepository& repository, LogsAbstractViewManager& viewManager ) |
|
43 : LogsBaseView(LogsDetailsViewId, repository, viewManager), |
|
44 mViewName(0), |
|
45 mListView(0) |
|
46 { |
|
47 LOGS_QDEBUG( "logs [UI] <-> LogsDetailsView::LogsDetailsView()" ); |
|
48 |
|
49 //TODO: taking away due to toolbar bug. If toolbar visibility changes on view |
|
50 //activation, there will be a crash due to previous view effect is playing |
|
51 //addViewSwitchingEffects(); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 LogsDetailsView::~LogsDetailsView() |
|
59 { |
|
60 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::~LogsDetailsView()" ); |
|
61 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::~LogsDetailsView()" ); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void LogsDetailsView::activated(bool showDialer, QVariant args) |
|
69 { |
|
70 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::activated()" ); |
|
71 //base class handling first |
|
72 LogsBaseView::activated(showDialer, args); |
|
73 |
|
74 LogsDetailsModel* model = qVariantValue<LogsDetailsModel*>(args); |
|
75 if ( !model ){ |
|
76 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::activated(), no model" ); |
|
77 return; |
|
78 } |
|
79 |
|
80 if ( mListView && mDetailsModel && mDetailsModel != model ){ |
|
81 mListView->setModel( 0 ); |
|
82 delete mDetailsModel; |
|
83 } |
|
84 mDetailsModel = model; |
|
85 |
|
86 if (mViewName){ |
|
87 mViewName->setHeading(mDetailsModel->headerData(0, Qt::Vertical).toString()); |
|
88 } |
|
89 |
|
90 if ( mListView ){ |
|
91 mListView->setModel( mDetailsModel );//ownership not transferred |
|
92 } |
|
93 |
|
94 updateMenu(); |
|
95 |
|
96 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::activated()" ); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // LogsDetailsView::deactivated |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void LogsDetailsView::deactivated() |
|
104 { |
|
105 //base class handling first |
|
106 LogsBaseView::deactivated(); |
|
107 if ( mListView ){ |
|
108 mListView->setModel( 0 ); |
|
109 } |
|
110 delete mDetailsModel; |
|
111 mDetailsModel = 0; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void LogsDetailsView::callKeyPressed() |
|
119 { |
|
120 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::callKeyPressed()" ); |
|
121 if ( mCall ){ |
|
122 mCall->initiateCallback(); |
|
123 } |
|
124 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::callKeyPressed()" ); |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // LogsDetailsView::initiateVoiceCall |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void LogsDetailsView::initiateVoiceCall() |
|
132 { |
|
133 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::initiateVoiceCall()" ); |
|
134 if ( mCall ){ |
|
135 mCall->call(LogsCall::TypeLogsVoiceCall); |
|
136 } |
|
137 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::initiateVoiceCall()" ); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void LogsDetailsView::initiateVideoCall() |
|
145 { |
|
146 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::initiateVideoCall()" ); |
|
147 if ( mCall ){ |
|
148 mCall->call(LogsCall::TypeLogsVideoCall); |
|
149 } |
|
150 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::initiateVideoCall()" ); |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void LogsDetailsView::addToContacts() |
|
158 { |
|
159 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::addToContacts()" ); |
|
160 if ( mContact ){ |
|
161 // Use async connection to ensure that model can handle |
|
162 // contact operation completion before view |
|
163 QObject::connect(mContact, SIGNAL(saveCompleted(bool)), |
|
164 this, SLOT(contactActionCompleted(bool)), |
|
165 Qt::QueuedConnection); |
|
166 this->saveContact(); |
|
167 } |
|
168 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::addToContacts()" ); |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void LogsDetailsView::openContact() |
|
176 { |
|
177 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::openContact()" ); |
|
178 if ( mContact ){ |
|
179 // Use async connection to ensure that model can handle |
|
180 // contact operation completion before view |
|
181 QObject::connect(mContact, SIGNAL(openCompleted(bool)), |
|
182 this, SLOT(contactActionCompleted(bool)), |
|
183 Qt::QueuedConnection); |
|
184 mContact->open(); |
|
185 } |
|
186 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::openContact()" ); |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 void LogsDetailsView::contactActionCompleted(bool modified) |
|
194 { |
|
195 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::contactActionCompleted()" ); |
|
196 |
|
197 if (modified){ |
|
198 updateMenu(); |
|
199 if (mViewName){ |
|
200 mViewName->setHeading( |
|
201 mDetailsModel->headerData(0, Qt::Vertical).toString()); |
|
202 } |
|
203 } |
|
204 |
|
205 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::contactActionCompleted()" ); |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void LogsDetailsView::deleteEvent() |
|
213 { |
|
214 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::deleteEvent()" ); |
|
215 if ( mDetailsModel ) { |
|
216 if ( askConfirmation( hbTrId("txt_dialer_ui_title_delete_event"), |
|
217 hbTrId("txt_dialer_info_call_event_will_be_removed_from"))){ |
|
218 mDetailsModel->clearEvent(); |
|
219 handleBackSoftkey(); |
|
220 } |
|
221 } |
|
222 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::deleteEvent()" ); |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // LogsDetailsView::copyNumberToClipboard() |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void LogsDetailsView::copyNumberToClipboard() |
|
230 { |
|
231 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::copyNumberToClipboard()" ); |
|
232 if ( mDetailsModel ) { |
|
233 mDetailsModel->getNumberToClipboard(); |
|
234 handleBackSoftkey(); |
|
235 } |
|
236 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::copyNumberToClipboard()" ); |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // LogsDetailsView::handleBackSoftkey |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 void LogsDetailsView::handleBackSoftkey() |
|
244 { |
|
245 mViewManager.activatePreviousView(); |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void LogsDetailsView::initView() |
|
253 { |
|
254 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::initView()" ); |
|
255 //base class handling first |
|
256 LogsBaseView::initView(); |
|
257 |
|
258 mViewName = qobject_cast<HbGroupBox*>( |
|
259 mRepository.findWidget( logsGroupboxDetailViewNameId ) ); |
|
260 initListWidget(); |
|
261 |
|
262 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::initView()" ); |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 QAbstractItemModel* LogsDetailsView::model() const |
|
270 { |
|
271 return mDetailsModel; |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void LogsDetailsView::initListWidget() |
|
279 { |
|
280 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::initListWidget()" ); |
|
281 mListView = qobject_cast<HbListView*> |
|
282 ( mRepository.findWidget( logsDetailsListWidgetId ) ); |
|
283 Q_ASSERT_X(mListView != 0, "logs [UI] ", "couldn't find list widget !!"); |
|
284 |
|
285 mListView->setItemRecycling(true); |
|
286 |
|
287 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::initListWidget() " ); |
|
288 } |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // LogsDetailsView::updateMenu |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 void LogsDetailsView::updateMenu() |
|
295 { |
|
296 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::updateMenu()" ); |
|
297 if ( !mDetailsModel ) { |
|
298 return; |
|
299 } |
|
300 |
|
301 updateCall( mDetailsModel->index(0) ); |
|
302 updateMessage( mDetailsModel->index(0) ); |
|
303 updateContact( mDetailsModel->index(0) ); |
|
304 |
|
305 HbAction* voiceCallAction = qobject_cast<HbAction*>( |
|
306 mRepository.findObject( logsDetailsViewVoiceCallMenuActionId ) ); |
|
307 HbAction* videoCallAction = qobject_cast<HbAction*>( |
|
308 mRepository.findObject( logsCommonVideoCallMenuActionId ) ); |
|
309 HbAction* internetCallAction = qobject_cast<HbAction*>( |
|
310 mRepository.findObject( logsDetailsViewInternetCallMenuActionId ) ); |
|
311 HbAction* messageAction = qobject_cast<HbAction*>( |
|
312 mRepository.findObject( logsCommonMessageMenuActionId ) ); |
|
313 HbAction* addToContactsAction = qobject_cast<HbAction*>( |
|
314 mRepository.findObject( logsDetailsAddToContactsMenuActionId ) ); |
|
315 HbAction* openContactAction = qobject_cast<HbAction*>( |
|
316 mRepository.findObject( logsDetailsOpenContactMenuActionId ) ); |
|
317 |
|
318 bool voiceCallAvailable(false); |
|
319 bool videoCallAvailable(false); |
|
320 bool internetCallAvailable(false); // Currently always disabled |
|
321 if (mCall) { |
|
322 foreach( LogsCall::CallType callType, mCall->allowedCallTypes() ){ |
|
323 if ( callType == LogsCall::TypeLogsVoiceCall ){ |
|
324 voiceCallAvailable = true; |
|
325 } else if ( callType == LogsCall::TypeLogsVideoCall ) { |
|
326 videoCallAvailable = true; |
|
327 } |
|
328 } |
|
329 } |
|
330 |
|
331 bool contactCanBeAdded(false); |
|
332 bool contactCanBeOpened(false); |
|
333 if (mContact){ |
|
334 if (mContact->allowedRequestType() == LogsContact::TypeLogsContactSave){ |
|
335 contactCanBeAdded = true; |
|
336 } |
|
337 if (mContact->allowedRequestType() == LogsContact::TypeLogsContactOpen){ |
|
338 contactCanBeOpened = true; |
|
339 } |
|
340 } |
|
341 |
|
342 toggleActionAvailability(voiceCallAction, voiceCallAvailable); |
|
343 toggleActionAvailability(videoCallAction, videoCallAvailable); |
|
344 toggleActionAvailability(internetCallAction, internetCallAvailable); |
|
345 toggleActionAvailability(messageAction, mMessage); |
|
346 toggleActionAvailability(addToContactsAction, contactCanBeAdded); |
|
347 toggleActionAvailability(openContactAction, contactCanBeOpened); |
|
348 |
|
349 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::updateMenu()" ); |
|
350 } |
|
351 |
|
352 // ----------------------------------------------------------------------------- |
|
353 // LogsDetailsView::updateWidgetsSizeAndLayout |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 void LogsDetailsView::updateWidgetsSizeAndLayout() |
|
357 { |
|
358 LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::updateWidgetsSizeAndLayout()" ); |
|
359 if ( mListView ) { |
|
360 updateListLayoutName(*mListView, true); |
|
361 updateListSize(); |
|
362 } |
|
363 LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::updateWidgetsSizeAndLayout()" ); |
|
364 } |