|
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 "logsrecentcallsview.h" |
|
19 #include "logscomponentrepository.h" |
|
20 #include "logsabstractviewmanager.h" |
|
21 #include "logsmodel.h" |
|
22 #include "logsdefs.h" |
|
23 #include "logslogger.h" |
|
24 #include "logscall.h" |
|
25 #include "logsmessage.h" |
|
26 #include "logscontact.h" |
|
27 #include "logseffecthandler.h" |
|
28 #include "logsmatchesmodel.h" |
|
29 #include "logspageindicator.h" |
|
30 |
|
31 //SYSTEM |
|
32 #include <hbview.h> |
|
33 #include <hblistview.h> |
|
34 #include <hbabstractviewitem.h> |
|
35 #include <hblabel.h> |
|
36 #include <hbmenu.h> |
|
37 #include <hbaction.h> |
|
38 #include <hbtoolbar.h> |
|
39 #include <dialpad.h> |
|
40 #include <hblineedit.h> |
|
41 #include <hbgroupbox.h> |
|
42 #include <hbmessagebox.h> |
|
43 #include <hbmainwindow.h> |
|
44 #include <QTimer> |
|
45 |
|
46 Q_DECLARE_METATYPE(LogsMatchesModel*) |
|
47 |
|
48 const int logsMissedCallsMarkingDelayMs = 1000; |
|
49 const int logsSwipeAngleDelta = 30; // angle is from 0 to 360 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // LogsRecentCallsView::LogsRecentCallsView |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 LogsRecentCallsView::LogsRecentCallsView( |
|
56 LogsComponentRepository& repository, LogsAbstractViewManager& viewManager ) |
|
57 : LogsBaseView(LogsRecentViewId, repository, viewManager), |
|
58 mViewName(0), |
|
59 mListView(0), |
|
60 mFilter(0), |
|
61 mCurrentView(LogsServices::ViewAll), |
|
62 mAppearingView(LogsServices::ViewAll), |
|
63 mMoveLeftInList(false), |
|
64 mEffectHandler(0), |
|
65 mListViewX(0), |
|
66 mMatchesModel(0), |
|
67 mMarkingMissedAsSeen(false), |
|
68 mPageIndicator(0), |
|
69 mResetted(false) |
|
70 { |
|
71 LOGS_QDEBUG( "logs [UI] <-> LogsRecentCallsView::LogsRecentCallsView()" ); |
|
72 mModel = mRepository.model(); |
|
73 |
|
74 //TODO: taking away due to toolbar bug. If toolbar visibility changes on view |
|
75 //activation, there will be a crash due to previous view effect is playing |
|
76 //addViewSwitchingEffects(); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // LogsRecentCallsView::~LogsRecentCallsView |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 LogsRecentCallsView::~LogsRecentCallsView() |
|
84 { |
|
85 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::~LogsRecentCallsView()" ); |
|
86 |
|
87 delete mMatchesModel; |
|
88 mModel = 0; |
|
89 |
|
90 delete mEffectHandler; |
|
91 delete mFilter; |
|
92 |
|
93 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::~LogsRecentCallsView()" ); |
|
94 } |
|
95 |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // LogsRecentCallsView::activated |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void LogsRecentCallsView::activated(bool showDialer, QVariant args) |
|
102 { |
|
103 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::activated()" ); |
|
104 // base class handling first |
|
105 LogsBaseView::activated(showDialer, args); |
|
106 |
|
107 LogsServices::LogsView view = static_cast<LogsServices::LogsView>( args.toInt() ); |
|
108 |
|
109 // View update is needed when we activate view for the first time (!mFilter) |
|
110 // or if view has to be changed |
|
111 if ( !mFilter || ( !args.isNull() && (mCurrentView != view) ) ) { |
|
112 updateView( view ); |
|
113 } |
|
114 activateEmptyListIndicator(mFilter); |
|
115 |
|
116 mDialpad->editor().setText(QString()); |
|
117 |
|
118 mPageIndicator->setActiveItemIndex(mConversionMap.value(mCurrentView)); |
|
119 |
|
120 if ( mResetted ){ |
|
121 // After reset, first data addition should cause scrolling to topitem |
|
122 connect( mFilter, SIGNAL(rowsInserted(const QModelIndex&,int,int)), |
|
123 this, SLOT(scrollToTopItem()) ); |
|
124 mResetted = false; |
|
125 } |
|
126 |
|
127 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::activated()" ); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // LogsRecentCallsView::deactivated |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void LogsRecentCallsView::deactivated() |
|
135 { |
|
136 //base class handling first |
|
137 LogsBaseView::deactivated(); |
|
138 |
|
139 deactivateEmptyListIndicator(mFilter); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void LogsRecentCallsView::handleExit() |
|
147 { |
|
148 markMissedCallsSeen(); |
|
149 LogsBaseView::handleExit(); |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // LogsRecentCallsView::isExitAllowed |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 bool LogsRecentCallsView::isExitAllowed() |
|
157 { |
|
158 return !mMarkingMissedAsSeen; |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void LogsRecentCallsView::resetView() |
|
166 { |
|
167 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::resetView()" ); |
|
168 LogsBaseView::resetView(); |
|
169 mResetted = true; |
|
170 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::resetView()" ); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // LogsRecentCallsView::initView |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void LogsRecentCallsView::initView() |
|
178 { |
|
179 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::initView()" ); |
|
180 //base class handling first |
|
181 LogsBaseView::initView(); |
|
182 |
|
183 mViewName = |
|
184 qobject_cast<HbGroupBox*>(mRepository.findWidget(logsGroupboxViewNameId)); |
|
185 |
|
186 addStringsToMap(); |
|
187 initListWidget(); |
|
188 |
|
189 mEffectHandler = new LogsEffectHandler; |
|
190 connect(mEffectHandler, SIGNAL(dissappearByMovingComplete()), |
|
191 this, SLOT(dissappearByMovingComplete())); |
|
192 connect(mEffectHandler, SIGNAL(dissappearByFadingComplete()), |
|
193 this, SLOT(dissappearByFadingComplete())); |
|
194 |
|
195 mPageIndicator = qobject_cast<LogsPageIndicator*> |
|
196 (mRepository.findWidget(logsPageIndicatorId)); |
|
197 |
|
198 mPageIndicator->initialize(mTitleMap.count(), mConversionMap.value(mCurrentView)); |
|
199 |
|
200 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::initView()" ); |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // LogsRecentCallsView::model |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 QAbstractItemModel* LogsRecentCallsView::model() const |
|
208 { |
|
209 return mFilter; |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // LogsRecentCallsView::callKeyPressed |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void LogsRecentCallsView::callKeyPressed() |
|
217 { |
|
218 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::callKeyPressed()" ); |
|
219 // Call to topmost item in current list |
|
220 if ( mListView && mFilter && mFilter->hasIndex(0,0) ) { |
|
221 QModelIndex topIndex = mFilter->index(0,0); |
|
222 mListView->scrollTo( topIndex ); |
|
223 mListView->setCurrentIndex( topIndex, QItemSelectionModel::Select ); |
|
224 initiateCallback(topIndex); |
|
225 } |
|
226 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::callKeyPressed()" ); |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // LogsRecentCallsView::markingCompleted |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 void LogsRecentCallsView::markingCompleted(int err) |
|
234 { |
|
235 LOGS_QDEBUG_2( "logs [UI] -> LogsRecentCallsView::markingCompleted(), err", err ); |
|
236 Q_UNUSED(err); |
|
237 mMarkingMissedAsSeen = false; |
|
238 emit exitAllowed(); |
|
239 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::markingCompleted()" ); |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // LogsRecentCallsView::openDialpad |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 void LogsRecentCallsView::openDialpad() |
|
247 { |
|
248 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::openDialpad()" ); |
|
249 LogsBaseView::openDialpad(); |
|
250 |
|
251 // Create matches model already before any input to optimize |
|
252 // first search |
|
253 if ( !mMatchesModel ){ |
|
254 mMatchesModel = mModel->logsMatchesModel(); |
|
255 } |
|
256 |
|
257 updateCallButton(); |
|
258 |
|
259 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::openDialpad()" ); |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // LogsRecentCallsView::dialpadEditorTextChanged |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 void LogsRecentCallsView::dialpadEditorTextChanged() |
|
267 { |
|
268 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::dialpadEditorTextChanged()" ); |
|
269 if ( mDialpad->editor().text().length() > 0 ) { |
|
270 QVariant arg = qVariantFromValue( mMatchesModel ); |
|
271 if ( mViewManager.activateView( LogsMatchesViewId, true, arg ) ){ |
|
272 mMatchesModel = 0; // Ownership was given to matches view |
|
273 } |
|
274 } else { |
|
275 updateCallButton(); |
|
276 } |
|
277 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::dialpadEditorTextChanged()" ); |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // LogsRecentCallsView::clearList |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void LogsRecentCallsView::clearList() |
|
285 { |
|
286 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::clearList()->" ); |
|
287 if ( mFilter ) { |
|
288 if ( askConfirmation( hbTrId("txt_dialer_ui_title_clear_list"), |
|
289 hbTrId("txt_dialer_ui_info_all_call_events_will_be_remo"))){ |
|
290 mModel->clearList( mFilter->clearType() ); |
|
291 } |
|
292 } |
|
293 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::clearList()<-" ); |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // LogsRecentCallsView::updateView |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 void LogsRecentCallsView::updateView(LogsServices::LogsView view) |
|
301 { |
|
302 LOGS_QDEBUG_2( "logs [UI] -> LogsRecentCallsView::updateView(), view:", view ); |
|
303 mCurrentView = view; |
|
304 LogsFilter::FilterType filter = getFilter( view ); |
|
305 updateFilter(filter); |
|
306 updateViewName(); |
|
307 updateContextMenuItems(mCurrentView); |
|
308 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateView()" ); |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // LogsRecentCallsView::changeFilter |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 void LogsRecentCallsView::changeFilter(HbAction* action) |
|
316 { |
|
317 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::changeFilter()" ); |
|
318 LogsServices::LogsView view = mActionMap.key( action->objectName(), |
|
319 LogsServices::ViewAll ); |
|
320 updateContextMenuItems(view); |
|
321 changeView(view); |
|
322 |
|
323 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::changeFilter()" ); |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // LogsRecentCallsView::handleBackSoftkey |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void LogsRecentCallsView::handleBackSoftkey() |
|
331 { |
|
332 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::handleBackSoftkey()" ); |
|
333 handleExit(); |
|
334 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::handleBackSoftkey()" ); |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // LogsRecentCallsView::addStringsToMap |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 void LogsRecentCallsView::addStringsToMap() |
|
342 { |
|
343 mTitleMap.insert(LogsBaseView::ViewAll, hbTrId("txt_dialer_subhead_recent_calls")); |
|
344 mTitleMap.insert(LogsBaseView::ViewCalled, hbTrId("txt_dialer_subhead_dialled_calls")); |
|
345 mTitleMap.insert(LogsBaseView::ViewReceived, hbTrId("txt_dial_subhead_received_calls")); |
|
346 mTitleMap.insert(LogsBaseView::ViewMissed, hbTrId("txt_dialer_subhead_missed_calls")); |
|
347 |
|
348 mConversionMap.insert(LogsServices::ViewAll, LogsBaseView::ViewAll); |
|
349 mConversionMap.insert(LogsServices::ViewCalled, LogsBaseView::ViewCalled); |
|
350 mConversionMap.insert(LogsServices::ViewReceived, LogsBaseView::ViewReceived); |
|
351 mConversionMap.insert(LogsServices::ViewMissed, LogsBaseView::ViewMissed); |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // LogsRecentCallsView::initListWidget |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 void LogsRecentCallsView::initListWidget() |
|
359 { |
|
360 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::initListWidget()" ); |
|
361 mListView = qobject_cast<HbListView*> |
|
362 ( mRepository.findWidget( logsListWidgetId ) ); |
|
363 Q_ASSERT_X(mListView != 0, "logs [UI] ", "couldn't find list widget !!"); |
|
364 |
|
365 |
|
366 // Optimize memory usage, list reserves only memory for visible items |
|
367 mListView->setItemRecycling(true); |
|
368 |
|
369 connect(mListView, SIGNAL(activated(const QModelIndex)), |
|
370 this, SLOT(initiateCallback(const QModelIndex))); |
|
371 connect(mListView, |
|
372 SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), |
|
373 this, |
|
374 SLOT(showListItemMenu(HbAbstractViewItem*, const QPointF&))); |
|
375 |
|
376 mListView->setScrollingStyle(HbScrollArea::PanOrFlick); |
|
377 mListView->setFrictionEnabled(true); |
|
378 |
|
379 mListViewX = mListView->pos().x(); |
|
380 |
|
381 grabGesture(Qt::SwipeGesture); |
|
382 |
|
383 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::initListWidget() " ); |
|
384 } |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // LogsRecentCallsView::updateFilter |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 void LogsRecentCallsView::updateFilter(LogsFilter::FilterType type) |
|
391 { |
|
392 if ( mListView ) { |
|
393 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::updateFilter()" ); |
|
394 |
|
395 deactivateEmptyListIndicator(mFilter); |
|
396 |
|
397 handleMissedCallsMarking(); |
|
398 |
|
399 delete mFilter; |
|
400 mFilter = 0; |
|
401 mFilter = new LogsFilter( type ); |
|
402 mFilter->setSourceModel( mModel ); |
|
403 |
|
404 mListView->setModel( mFilter );//ownership not transferred |
|
405 |
|
406 scrollToTopItem(); |
|
407 |
|
408 activateEmptyListIndicator(mFilter); |
|
409 |
|
410 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateFilter() " ); |
|
411 } else { |
|
412 LOGS_QWARNING( "logs [UI] LogsRecentCallsView::updateFilter(), !no list widget!" ); |
|
413 } |
|
414 } |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // LogsRecentCallsView::updateViewName |
|
418 // ----------------------------------------------------------------------------- |
|
419 // |
|
420 void LogsRecentCallsView::updateViewName() |
|
421 { |
|
422 if ( mViewName ) { |
|
423 mViewName->setHeading( mTitleMap.value(mConversionMap.value(mCurrentView))); |
|
424 } |
|
425 } |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // LogsRecentCallsView::updateContextMenuItems |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 void LogsRecentCallsView::updateContextMenuItems(LogsServices::LogsView view) |
|
432 { |
|
433 LOGS_QDEBUG_2( |
|
434 "logs [UI] -> LogsRecentCallsView::updateContextMenuItems(), view:", view ); |
|
435 if ( mShowFilterMenu ) { |
|
436 QString activeActionName = mActionMap.value(view); |
|
437 foreach (QAction* action, mShowFilterMenu->actions() ) { |
|
438 action->setChecked( action->objectName() == activeActionName ); |
|
439 } |
|
440 } |
|
441 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateContextMenuItems()" ); |
|
442 } |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // LogsRecentCallsView::getFilter |
|
446 // ----------------------------------------------------------------------------- |
|
447 // |
|
448 LogsFilter::FilterType LogsRecentCallsView::getFilter(LogsServices::LogsView view) |
|
449 { |
|
450 LogsFilter::FilterType filter = LogsFilter::All; |
|
451 switch (view){ |
|
452 case LogsServices::ViewAll: |
|
453 filter = LogsFilter::All; |
|
454 break; |
|
455 case LogsServices::ViewReceived: |
|
456 filter = LogsFilter::Received; |
|
457 break; |
|
458 case LogsServices::ViewCalled: |
|
459 filter = LogsFilter::Called; |
|
460 break; |
|
461 case LogsServices::ViewMissed: |
|
462 filter = LogsFilter::Missed; |
|
463 break; |
|
464 default: |
|
465 break; |
|
466 } |
|
467 return filter; |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // LogsRecentCallsView::gestureEvent |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void LogsRecentCallsView::gestureEvent(QGestureEvent *event) |
|
475 { |
|
476 QGesture* gesture = event->gesture(Qt::SwipeGesture); |
|
477 if (gesture) { |
|
478 QSwipeGesture* swipe = static_cast<QSwipeGesture *>(gesture); |
|
479 if (swipe->state() == Qt::GestureFinished) { |
|
480 QSwipeGesture::SwipeDirection direction = swipeAngleToDirection( |
|
481 swipe->swipeAngle(), logsSwipeAngleDelta); |
|
482 if (mViewManager.mainWindow().orientation() == Qt::Vertical) { |
|
483 if (direction == QSwipeGesture::Left) { |
|
484 leftFlick(); |
|
485 event->accept(Qt::SwipeGesture); |
|
486 } else if (direction == QSwipeGesture::Right) { |
|
487 rightFlick(); |
|
488 event->accept(Qt::SwipeGesture); |
|
489 } |
|
490 } else { |
|
491 if (direction == QSwipeGesture::Down) { |
|
492 rightFlick(); |
|
493 event->accept(Qt::SwipeGesture); |
|
494 } else if (direction == QSwipeGesture::Up) { |
|
495 leftFlick(); |
|
496 event->accept(Qt::SwipeGesture); |
|
497 } |
|
498 } |
|
499 } |
|
500 } |
|
501 } |
|
502 |
|
503 // ----------------------------------------------------------------------------- |
|
504 // LogsRecentCallsView::swipeAngleToDirection |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 QSwipeGesture::SwipeDirection LogsRecentCallsView::swipeAngleToDirection( |
|
508 int angle, int delta) |
|
509 { |
|
510 QSwipeGesture::SwipeDirection direction(QSwipeGesture::NoDirection); |
|
511 if ((angle > 90-delta) && (angle < 90+delta)) { |
|
512 direction = QSwipeGesture::Up; |
|
513 } else if ((angle > 270-delta) && (angle < 270+delta)) { |
|
514 direction = QSwipeGesture::Down; |
|
515 } else if (((angle >= 0) && (angle < delta)) |
|
516 || ((angle > 360-delta) && (angle <= 360))) { |
|
517 direction = QSwipeGesture::Right; |
|
518 } else if ((angle > 180-delta) && (angle < 180+delta)) { |
|
519 direction = QSwipeGesture::Left; |
|
520 } |
|
521 LOGS_QDEBUG_4( "logs [UI] LogsRecentCallsView::swipeAngleToDirection() angle: ", |
|
522 angle, " direction: ", direction ); |
|
523 return direction; |
|
524 } |
|
525 |
|
526 // ----------------------------------------------------------------------------- |
|
527 // LogsRecentCallsView::leftFlick |
|
528 // ----------------------------------------------------------------------------- |
|
529 // |
|
530 void LogsRecentCallsView::leftFlick() |
|
531 { |
|
532 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::leftFlick()" ); |
|
533 if ( mConversionMap.value(mCurrentView) + 1 < mTitleMap.count() ){ |
|
534 LogsBaseView::LogsViewMap viewmap = |
|
535 static_cast<LogsBaseView::LogsViewMap>(mConversionMap.value(mCurrentView) +1); |
|
536 changeView( mConversionMap.key(viewmap) ); |
|
537 } else { |
|
538 if (model() && model()->rowCount() > 0) { |
|
539 mEffectHandler->startMoveNotPossibleEffect(*mListView, false, mListViewX); |
|
540 } else { |
|
541 mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, false, mListViewX); |
|
542 } |
|
543 } |
|
544 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::leftFlick()" ); |
|
545 } |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // LogsRecentCallsView::rightFlick |
|
549 // ----------------------------------------------------------------------------- |
|
550 // |
|
551 void LogsRecentCallsView::rightFlick() |
|
552 { |
|
553 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::rightFlick()" ); |
|
554 if ( mConversionMap.value(mCurrentView) > 0 ){ |
|
555 LogsBaseView::LogsViewMap viewmap = |
|
556 static_cast<LogsBaseView::LogsViewMap>(mConversionMap.value(mCurrentView) - 1); |
|
557 changeView( mConversionMap.key(viewmap) ); |
|
558 } else { |
|
559 if (model() && model()->rowCount() > 0) { |
|
560 mEffectHandler->startMoveNotPossibleEffect(*mListView, true, mListViewX); |
|
561 } else { |
|
562 mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, true, mListViewX); |
|
563 } |
|
564 } |
|
565 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::rightFlick()" ); |
|
566 } |
|
567 |
|
568 // ----------------------------------------------------------------------------- |
|
569 // LogsRecentCallsView::changeView |
|
570 // ----------------------------------------------------------------------------- |
|
571 // |
|
572 void LogsRecentCallsView::changeView(LogsServices::LogsView view) |
|
573 { |
|
574 LOGS_QDEBUG_2( "logs [UI] -> LogsRecentCallsView::changeView(), view:", view ); |
|
575 |
|
576 if ( view == mCurrentView ){ |
|
577 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::changeView(), view already correct" ); |
|
578 // Already correct view, running animation can continue but make sure that |
|
579 // appearing view is then correct. |
|
580 mAppearingView = view; |
|
581 return; |
|
582 } |
|
583 |
|
584 mMoveLeftInList = mConversionMap.value(view) < mConversionMap.value(mCurrentView); |
|
585 |
|
586 mAppearingView = view; |
|
587 mEffectHandler->startDissappearAppearByFadingEffect(*mViewName); |
|
588 mEffectHandler->startDissappearAppearByMovingEffect( |
|
589 *mListView, *mEmptyListLabel, !mMoveLeftInList, mListViewX); |
|
590 |
|
591 mPageIndicator->setActiveItemIndex(mConversionMap.value(mAppearingView)); |
|
592 |
|
593 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::changeView()" ); |
|
594 } |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 void LogsRecentCallsView::dissappearByFadingComplete() |
|
601 { |
|
602 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::dissappearByFadingComplete()" ) |
|
603 |
|
604 // Previous view name has dissappeared by fading, set new view name |
|
605 // as it is brought visible by effect |
|
606 mViewName->setHeading( mTitleMap.value(mConversionMap.value(mAppearingView)) ); |
|
607 |
|
608 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::dissappearByFadingComplete()" ) |
|
609 } |
|
610 |
|
611 // ----------------------------------------------------------------------------- |
|
612 // |
|
613 // ----------------------------------------------------------------------------- |
|
614 // |
|
615 void LogsRecentCallsView::dissappearByMovingComplete() |
|
616 { |
|
617 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::dissappearByMovingComplete()" ) |
|
618 |
|
619 updateView( mAppearingView ); |
|
620 |
|
621 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::dissappearByMovingComplete()" ) |
|
622 } |
|
623 |
|
624 // ----------------------------------------------------------------------------- |
|
625 // LogsRecentCallsView::updateMenu |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 void LogsRecentCallsView::updateMenu() |
|
629 { |
|
630 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::updateMenu()" ); |
|
631 HbAction* action = qobject_cast<HbAction*>( |
|
632 mRepository.findObject( logsRecentViewClearListMenuActionId ) ); |
|
633 if ( action && model() ) { |
|
634 bool visible( model()->rowCount() > 0 ); |
|
635 action->setVisible( visible ); |
|
636 } |
|
637 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateMenu()" ); |
|
638 } |
|
639 |
|
640 // ----------------------------------------------------------------------------- |
|
641 // LogsRecentCallsView::updateEmptyListWidgetsVisibility |
|
642 // ----------------------------------------------------------------------------- |
|
643 // |
|
644 void LogsRecentCallsView::updateEmptyListWidgetsVisibility() |
|
645 { |
|
646 updateMenu(); |
|
647 updateEmptyListLabelVisibility(); |
|
648 updateCallButton(); |
|
649 } |
|
650 |
|
651 // ----------------------------------------------------------------------------- |
|
652 // LogsRecentCallsView::updateWidgetsSizeAndLayout |
|
653 // ----------------------------------------------------------------------------- |
|
654 // |
|
655 void LogsRecentCallsView::updateWidgetsSizeAndLayout() |
|
656 { |
|
657 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::updateWidgetsSizeAndLayout()" ); |
|
658 if ( mListView ) { |
|
659 updateListLayoutName(*mListView); |
|
660 updateListSize(); |
|
661 } |
|
662 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateWidgetsSizeAndLayout()" ); |
|
663 } |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // LogsRecentCallsView::updateCallButton |
|
667 // If dialpad contains text or there is items in list, call button is enabled |
|
668 // ----------------------------------------------------------------------------- |
|
669 // |
|
670 void LogsRecentCallsView::updateCallButton() |
|
671 { |
|
672 bool isVisible = !mDialpad->editor().text().isEmpty(); |
|
673 if ( !isVisible && mFilter ) { |
|
674 isVisible = ( mFilter->rowCount() > 0 ); |
|
675 } |
|
676 mDialpad->setCallButtonEnabled( isVisible ); |
|
677 } |
|
678 |
|
679 // ----------------------------------------------------------------------------- |
|
680 // LogsRecentCallsView::handleMissedCallsMarking |
|
681 // ----------------------------------------------------------------------------- |
|
682 // |
|
683 void LogsRecentCallsView::handleMissedCallsMarking() |
|
684 { |
|
685 if ( mFilter && !mMarkingMissedAsSeen && !mResetted && |
|
686 ( mFilter->filterType() == LogsFilter::Missed || |
|
687 mFilter->filterType() == LogsFilter::All ) ){ |
|
688 // Don't care if timer would be already running, slot's implementation |
|
689 // takes care that marking is done only once |
|
690 LOGS_QDEBUG( "logs [UI] <-> LogsRecentCallsView::handleMissedCallsMarking()" ); |
|
691 QTimer::singleShot( |
|
692 logsMissedCallsMarkingDelayMs, this, SLOT(markMissedCallsSeen()) ); |
|
693 } |
|
694 } |
|
695 |
|
696 // ----------------------------------------------------------------------------- |
|
697 // LogsRecentCallsView::markMissedCallsSeen |
|
698 // ----------------------------------------------------------------------------- |
|
699 // |
|
700 bool LogsRecentCallsView::markMissedCallsSeen() |
|
701 { |
|
702 if ( !mMarkingMissedAsSeen ){ |
|
703 connect( mModel, SIGNAL(markingCompleted(int)), |
|
704 this, SLOT(markingCompleted(int)) ); |
|
705 mMarkingMissedAsSeen = |
|
706 mModel->markEventsSeen(LogsModel::TypeLogsClearMissed); |
|
707 } |
|
708 return mMarkingMissedAsSeen; |
|
709 } |
|
710 |
|
711 // ----------------------------------------------------------------------------- |
|
712 // LogsRecentCallsView::scrollToTopItem |
|
713 // ----------------------------------------------------------------------------- |
|
714 // |
|
715 void LogsRecentCallsView::scrollToTopItem() |
|
716 { |
|
717 LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::scrollToTopItem()" ); |
|
718 disconnect( mFilter, SIGNAL(rowsInserted(const QModelIndex&,int,int)), |
|
719 this, SLOT(scrollToTopItem())); |
|
720 if ( mFilter && mFilter->hasIndex(0,0) ) { |
|
721 mListView->scrollTo( mFilter->index(0,0) ); |
|
722 } |
|
723 LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::scrollToTopItem()" ); |
|
724 } |