author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:21 +0100 | |
branch | GCC_SURGE |
changeset 51 | f39ed5e045e0 |
parent 30 | ebdbd102c78a |
parent 46 | bc5a64e5bc3c |
permissions | -rw-r--r-- |
37 | 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: BubbleManager widget. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <QtGui> |
|
19 |
#include <QtAlgorithms> |
|
20 |
||
21 |
#include <hblabel.h> |
|
22 |
#include <hbstyle.h> |
|
23 |
#include <hbiconitem.h> |
|
24 |
#include <hbaction.h> |
|
25 |
#include <hbstackedlayout.h> |
|
26 |
#include <hbmainwindow.h> |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
27 |
#include <hbstyleloader.h> |
37 | 28 |
|
29 |
#include "bubblemanager2.h" |
|
30 |
#include "bubbleheader.h" |
|
31 |
#include "bubbleconferenceheader.h" |
|
32 |
#include "bubbleutils.h" |
|
33 |
#include "bubblewidgetmanager.h" |
|
34 |
#include "bubbleimagemanager.h" |
|
35 |
#include "bubblehandler.h" |
|
36 |
#include "bubbleeffecthandler.h" |
|
37 |
||
38 |
||
39 |
BubbleManager::BubbleManager( QGraphicsItem *parent ) : |
|
40 |
HbWidget( parent ), |
|
41 |
mIsReadyToDraw(0), |
|
42 |
mMuted(0), |
|
43 |
mMutedIcon(0), |
|
44 |
mSortHeaders(false), |
|
45 |
mInitialized(false), |
|
46 |
mBubbleSelectionDisabled(0) |
|
47 |
{ |
|
48 |
// allocate headers |
|
49 |
BubbleHeader* header; |
|
50 |
for ( int i = 0 ; i < BUBBLE_MAX_CALL_COUNT ; i++ ) { |
|
51 |
header = new BubbleHeader; |
|
52 |
header->setBubbleId( i ); |
|
53 |
mCallHeaders.append( header ); |
|
54 |
} |
|
55 |
||
56 |
mConferenceHeader = new BubbleConferenceHeader(); |
|
57 |
mConferenceHeader->setBubbleId(BUBBLE_CONF_CALL_ID); |
|
58 |
||
59 |
mBubbleImageManager = new BubbleImageManager(this); |
|
60 |
||
61 |
mEffectHandler = new BubbleEffectHandler(this); |
|
62 |
||
63 |
mWidgetManager = new BubbleWidgetManager( |
|
64 |
*mBubbleImageManager, this); |
|
65 |
||
66 |
mMainLayout = new HbStackedLayout(this); |
|
67 |
mMainLayout->setContentsMargins(0.0,0.0,0.0,0.0); |
|
68 |
setLayout(mMainLayout); |
|
69 |
||
70 |
// preload views on boot |
|
71 |
mWidgetManager->view(BubbleWidgetManager::SingleCallView); |
|
72 |
} |
|
73 |
||
74 |
BubbleManager::~BubbleManager() |
|
75 |
{ |
|
76 |
qDeleteAll(mCallHeaders); |
|
77 |
mCallHeaders.clear(); |
|
78 |
delete mConferenceHeader; |
|
79 |
} |
|
80 |
||
81 |
/** |
|
82 |
* Before making any changes to bubble headers, call this function so |
|
83 |
* manager can prapare for them properly. |
|
84 |
*/ |
|
85 |
void BubbleManager::startChanges() |
|
86 |
{ |
|
87 |
mIsReadyToDraw++; |
|
88 |
if ( mIsReadyToDraw > 1 ) { |
|
89 |
return; |
|
90 |
} |
|
91 |
||
92 |
if (parentItem()) { |
|
93 |
// reset/hide on outlooks may result clearFocus() call, |
|
94 |
// which means that there is no focused item. move focus |
|
95 |
// to parent item, before reset/hide calls. |
|
96 |
parentItem()->setFocus(); |
|
97 |
} |
|
98 |
||
99 |
// invalidate current widgets |
|
100 |
for (int i=0; i<mMainLayout->count(); i++) { |
|
101 |
mMainLayout->itemAt(i)->graphicsItem()->hide(); |
|
102 |
} |
|
103 |
||
104 |
// reset active handlers |
|
105 |
foreach (BubbleHandler* handler, mActiveHandlers) { |
|
106 |
handler->reset(); |
|
107 |
} |
|
108 |
mActiveHandlers.clear(); |
|
109 |
} |
|
110 |
||
111 |
/** |
|
112 |
* After the changes to bubble headers call this function so manager |
|
113 |
* can prepare bubbles to right places and check the drawing order. |
|
114 |
* Memory for arrays has been allocated beforehand. |
|
115 |
*/ |
|
116 |
void BubbleManager::endChanges() |
|
117 |
{ |
|
118 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
119 |
||
120 |
mIsReadyToDraw--; |
|
121 |
if ( mIsReadyToDraw != 0 ) { |
|
122 |
return; |
|
123 |
} |
|
124 |
||
125 |
if (!mInitialized) { |
|
126 |
if (mainWindow()) { |
|
127 |
mWidgetManager->handleOrientationChange(mainWindow()->orientation()); |
|
128 |
mInitialized=true; |
|
129 |
} |
|
130 |
} |
|
131 |
||
132 |
// sort active headers |
|
133 |
if ( mActiveHeaders.count() && mSortHeaders) { |
|
134 |
qStableSort(mActiveHeaders.begin(), |
|
135 |
mActiveHeaders.end(), |
|
136 |
BubbleUtils::compareHeaders ); |
|
137 |
mSortHeaders = false; |
|
138 |
} |
|
139 |
||
140 |
// select view |
|
141 |
QGraphicsWidget* view = selectView(); |
|
142 |
||
143 |
if (view) { |
|
144 |
setViewData(view); |
|
145 |
view->show(); |
|
146 |
} |
|
147 |
||
148 |
if (!mActiveHeaders.count()) { |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
149 |
// all calls ended |
37 | 150 |
mBubbleImageManager->releasePixmaps(); |
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
151 |
releaseNonCachedViews(); |
37 | 152 |
} |
153 |
||
154 |
// restore mute state |
|
155 |
setPhoneMuted(mMuted); |
|
156 |
||
157 |
update(); |
|
158 |
} |
|
159 |
||
160 |
QGraphicsWidget* BubbleManager::selectView() |
|
161 |
{ |
|
162 |
QGraphicsWidget* view=0; |
|
163 |
int bubbleCount = shownHeaderCount(); |
|
164 |
||
165 |
if (bubbleCount && isConferenceExpanded()) { |
|
166 |
view = mWidgetManager->view(BubbleWidgetManager::ConferenceView); |
|
167 |
} else { |
|
168 |
switch(bubbleCount) { |
|
169 |
case 1: |
|
170 |
view = mWidgetManager->view(BubbleWidgetManager::SingleCallView); |
|
171 |
break; |
|
172 |
case 2: |
|
173 |
view = mWidgetManager->view(BubbleWidgetManager::TwoCallsView); |
|
174 |
break; |
|
175 |
case 3: |
|
176 |
view = mWidgetManager->view(BubbleWidgetManager::ThreeCallsView); |
|
177 |
break; |
|
178 |
default: |
|
179 |
break; |
|
180 |
} |
|
181 |
} |
|
182 |
||
183 |
if (view) { |
|
184 |
if (addToLayout(view)) { |
|
185 |
// connect signals |
|
186 |
connectSignals(view); |
|
187 |
} |
|
188 |
} |
|
189 |
||
190 |
return view; |
|
191 |
} |
|
192 |
||
193 |
bool BubbleManager::addToLayout(QGraphicsWidget* widget) |
|
194 |
{ |
|
195 |
Q_ASSERT(widget); |
|
196 |
||
197 |
bool added=false; |
|
198 |
int index = mMainLayout->indexOf(widget); |
|
199 |
if (index == -1) { |
|
200 |
mMainLayout->addItem(widget); |
|
201 |
added=true; |
|
202 |
} |
|
203 |
||
204 |
return added; |
|
205 |
} |
|
206 |
||
207 |
void BubbleManager::removeFromLayout(QGraphicsWidget* widget) |
|
208 |
{ |
|
209 |
mMainLayout->removeItem(widget); |
|
210 |
} |
|
211 |
||
212 |
void BubbleManager::connectSignals(QGraphicsWidget* widget) |
|
213 |
{ |
|
214 |
QList<BubbleHandler*>* handlers = mWidgetManager->handlers(widget); |
|
215 |
if (handlers) { |
|
216 |
foreach (BubbleHandler* handler, *handlers) { |
|
217 |
connect(handler,SIGNAL(headerSelected(int)), |
|
218 |
SLOT(showExpanded(int))); |
|
219 |
} |
|
220 |
} |
|
221 |
} |
|
222 |
||
223 |
void BubbleManager::setViewData(QGraphicsWidget* view) |
|
224 |
{ |
|
225 |
Q_ASSERT(view); |
|
226 |
||
227 |
QList<BubbleHandler*>* handlers = |
|
228 |
mWidgetManager->handlers(view); |
|
229 |
||
230 |
if (handlers) { |
|
231 |
if (isConferenceExpanded()) { |
|
232 |
// only conference call is displayed |
|
233 |
Q_ASSERT(handlers->count()==1); |
|
234 |
BubbleHandler* handler = handlers->at(0); |
|
235 |
handler->readBubbleHeader(*mConferenceHeader); |
|
236 |
mActiveHandlers.append(handler); |
|
237 |
} else { |
|
238 |
int i=0; |
|
239 |
foreach (BubbleHandler* handler, *handlers) { |
|
240 |
findNextDrawableHeader(i); |
|
241 |
handler->readBubbleHeader(*mActiveHeaders.at(i)); |
|
242 |
mActiveHandlers.append(handler); |
|
243 |
i++; |
|
244 |
if (i==mActiveHeaders.count()) { |
|
245 |
break; |
|
246 |
} |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
} |
|
251 |
||
252 |
/** |
|
253 |
* Takes a new call header in use. |
|
254 |
* Returns bubble idenfication number. |
|
255 |
*/ |
|
256 |
int BubbleManager::createCallHeader() |
|
257 |
{ |
|
258 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
259 |
||
260 |
quint8 index = 0; |
|
261 |
while ( mCallHeaders[index]->isUsed( ) ) { |
|
262 |
index++; |
|
263 |
Q_ASSERT( index < mCallHeaders.size() ); |
|
264 |
} |
|
265 |
||
266 |
BubbleHeader* header = mCallHeaders[index]; |
|
267 |
||
268 |
header->setIsUsed( true ); |
|
269 |
||
270 |
mActiveHeaders.insert( 0, header ); // in priority order |
|
271 |
||
272 |
return header->bubbleId(); |
|
273 |
} |
|
274 |
||
275 |
/** |
|
276 |
* Removes call header from use |
|
277 |
*/ |
|
278 |
void BubbleManager::removeCallHeader( int bubbleId ) |
|
279 |
{ |
|
280 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
281 |
||
282 |
for ( int i=0; i < mActiveHeaders.size(); i++ ) { |
|
283 |
if ( mActiveHeaders[i]->bubbleId() == bubbleId ) { |
|
284 |
QString image = mActiveHeaders[i]->callImage(); |
|
285 |
mActiveHeaders[i]->reset(); |
|
286 |
mActiveHeaders.remove( i ); |
|
287 |
releaseImageIfNotUsed(image); |
|
288 |
break; |
|
289 |
} |
|
290 |
} |
|
291 |
} |
|
292 |
||
293 |
/** |
|
294 |
* Finds header by bubble id. |
|
295 |
*/ |
|
296 |
bool BubbleManager::findActiveHeader( int bubbleId, BubbleHeader*& header ) |
|
297 |
{ |
|
298 |
header = 0; |
|
299 |
for ( int i=0; i < mActiveHeaders.size(); i++ ) { |
|
300 |
if ( mActiveHeaders[i]->bubbleId() == bubbleId ) { |
|
301 |
header = mActiveHeaders[i]; |
|
302 |
break; |
|
303 |
} |
|
304 |
} |
|
305 |
||
306 |
return header ? true : false; |
|
307 |
} |
|
308 |
||
309 |
void BubbleManager::findNextDrawableHeader(int& index) const |
|
310 |
{ |
|
311 |
while (mActiveHeaders.at(index)->isInConference()) { |
|
312 |
index++; |
|
313 |
} |
|
314 |
} |
|
315 |
||
316 |
/** |
|
317 |
* Sets call state to header. |
|
318 |
*/ |
|
319 |
void BubbleManager::setState( |
|
320 |
int bubbleId, |
|
321 |
PhoneCallState state ) |
|
322 |
{ |
|
323 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
324 |
||
325 |
BubbleHeader* header = 0; |
|
326 |
findActiveHeader( bubbleId, header ); |
|
327 |
Q_ASSERT( header ); |
|
328 |
||
329 |
BubbleManager::PhoneCallState oldState = |
|
330 |
header->callState(); |
|
331 |
||
332 |
if ( shownHeaderCount()<3 && |
|
333 |
!header->isInConference() && |
|
334 |
(expandedBubble() != bubbleId) && |
|
335 |
(oldState==OnHold && state==Active) ) { |
|
336 |
// send key swap -> make active call expanded |
|
337 |
int i = mActiveHeaders.indexOf(header); |
|
338 |
mActiveHeaders.remove(i); |
|
339 |
mActiveHeaders.insert(0, header); |
|
340 |
} |
|
341 |
||
342 |
header->setCallState( state ); |
|
343 |
} |
|
344 |
||
345 |
/** |
|
346 |
* Sets text label to header. For conf also. |
|
347 |
* Text to be seen in bubble ( e.g. 'on hold' ) |
|
348 |
*/ |
|
349 |
void BubbleManager::setLabel( |
|
350 |
int bubbleId, |
|
351 |
const QString& text, |
|
352 |
Qt::TextElideMode clipDirection ) |
|
353 |
{ |
|
354 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
355 |
||
356 |
BubbleHeader* header = 0; |
|
357 |
findActiveHeader( bubbleId, header ); |
|
358 |
Q_ASSERT( header ); |
|
359 |
||
360 |
header->setText( text, clipDirection ); |
|
361 |
} |
|
362 |
||
363 |
/** |
|
364 |
* Sets caller's line identification ( name or number) to header. |
|
365 |
* For conf also. Caller's CLI ( e.g. 'Mother' ) |
|
366 |
*/ |
|
367 |
void BubbleManager::setCli( |
|
368 |
int bubbleId, |
|
369 |
const QString& cliText, |
|
370 |
Qt::TextElideMode clipDirection ) |
|
371 |
{ |
|
372 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
373 |
||
374 |
BubbleHeader* header = 0; |
|
375 |
findActiveHeader( bubbleId, header ); |
|
376 |
Q_ASSERT( header ); |
|
377 |
||
378 |
header->setCli( cliText, clipDirection ); |
|
379 |
} |
|
380 |
||
381 |
/** |
|
382 |
* Updates caller's line identification ( name or number) to header. |
|
383 |
* Caller's CLI ( e.g. 'Daddy' )- |
|
384 |
*/ |
|
385 |
void BubbleManager::updateCLI( |
|
386 |
int bubbleId, |
|
387 |
const QString& cliText, |
|
388 |
Qt::TextElideMode clipDirection ) |
|
389 |
{ |
|
390 |
BubbleHeader* header = 0; |
|
391 |
findActiveHeader( bubbleId, header ); |
|
392 |
Q_ASSERT( header ); |
|
393 |
||
394 |
header->setCli( cliText, clipDirection ); |
|
395 |
||
396 |
// ToDo: take care of redrawing |
|
397 |
} |
|
398 |
||
399 |
/** |
|
400 |
* Number or voip adress, when phonebook name takes Cli. |
|
401 |
*/ |
|
402 |
void BubbleManager::setSecondaryCli( |
|
403 |
int bubbleId, |
|
404 |
const QString& cliText, |
|
405 |
Qt::TextElideMode clipDirection ) |
|
406 |
{ |
|
407 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
408 |
||
409 |
BubbleHeader* header = 0; |
|
410 |
findActiveHeader( bubbleId, header ); |
|
411 |
Q_ASSERT( header ); |
|
412 |
||
413 |
header->setSecondaryCli( cliText, clipDirection ); |
|
414 |
} |
|
415 |
||
416 |
/** |
|
417 |
* Sets call time or cost text to header. For conf also. |
|
418 |
*/ |
|
419 |
void BubbleManager::setCallTime( |
|
420 |
int bubbleId, |
|
421 |
const QString& callTime ) |
|
422 |
{ |
|
423 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
424 |
||
425 |
BubbleHeader* header = 0; |
|
426 |
findActiveHeader( bubbleId, header ); |
|
427 |
Q_ASSERT( header ); |
|
428 |
||
429 |
header->setTimerCost( callTime ); |
|
430 |
} |
|
431 |
||
432 |
/** |
|
433 |
* Updates call time or cost text to header. For conf also. |
|
434 |
* Timer or cost text ( e.g. '00:12:34' or '£01.23' ). |
|
435 |
*/ |
|
436 |
void BubbleManager::updateCallTime( |
|
437 |
int bubbleId, |
|
438 |
const QString& callTime ) |
|
439 |
{ |
|
440 |
BubbleHeader* header = 0; |
|
441 |
findActiveHeader( bubbleId, header ); |
|
442 |
Q_ASSERT( header ); |
|
443 |
||
444 |
header->setTimerCost( callTime ); |
|
445 |
||
446 |
foreach (BubbleHandler* handler,mActiveHandlers) { |
|
447 |
handler->updateTimerDisplayNow(); |
|
448 |
} |
|
449 |
} |
|
450 |
||
451 |
/** |
|
452 |
* Attach a call image to header. |
|
453 |
*/ |
|
454 |
void BubbleManager::setCallObjectImage( |
|
455 |
int bubbleId, |
|
456 |
const QString& fileName ) |
|
457 |
{ |
|
458 |
BubbleHeader* header = 0; |
|
459 |
findActiveHeader( bubbleId, header ); |
|
460 |
Q_ASSERT( header ); |
|
461 |
||
462 |
header->setCallImage(fileName); |
|
463 |
} |
|
464 |
||
465 |
/** |
|
466 |
* Attach the theme call image to header. |
|
467 |
*/ |
|
468 |
void BubbleManager::setCallObjectFromTheme( |
|
469 |
int bubbleId ) |
|
470 |
{ |
|
471 |
BubbleHeader* header = 0; |
|
472 |
findActiveHeader( bubbleId, header ); |
|
473 |
Q_ASSERT( header ); |
|
474 |
||
475 |
header->setShowDefaultAvatar(true); |
|
476 |
} |
|
477 |
||
478 |
/** |
|
479 |
* Sets call flags to header. |
|
480 |
*/ |
|
481 |
void BubbleManager::setCallFlags( |
|
482 |
int bubbleId, |
|
483 |
int flags ) |
|
484 |
{ |
|
485 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
486 |
||
487 |
BubbleHeader* header = 0; |
|
488 |
findActiveHeader( bubbleId, header ); |
|
489 |
Q_ASSERT( header ); |
|
490 |
||
491 |
header->setCallFlags( flags ); |
|
492 |
} |
|
493 |
||
494 |
/** |
|
495 |
* Sets call flags to header. |
|
496 |
*/ |
|
497 |
void BubbleManager::setCallFlag( |
|
498 |
int bubbleId, |
|
499 |
PhoneCallFlags flag, |
|
500 |
bool set ) |
|
501 |
{ |
|
502 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
503 |
||
504 |
BubbleHeader* header = 0; |
|
505 |
findActiveHeader( bubbleId, header ); |
|
506 |
Q_ASSERT( header ); |
|
507 |
||
508 |
if ( set ) { |
|
509 |
header->setCallFlag( flag ); |
|
510 |
} |
|
511 |
else { |
|
512 |
header->removeCallFlag( flag ); |
|
513 |
} |
|
514 |
} |
|
515 |
||
516 |
/** |
|
517 |
* Sets number type. |
|
518 |
*/ |
|
519 |
void BubbleManager::setNumberType( |
|
520 |
int bubbleId, |
|
521 |
PhoneNumberType type ) |
|
522 |
{ |
|
523 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
524 |
||
525 |
BubbleHeader* header = 0; |
|
526 |
findActiveHeader( bubbleId, header ); |
|
527 |
Q_ASSERT( header ); |
|
528 |
||
529 |
header->setNumberType( type ); |
|
530 |
} |
|
531 |
||
532 |
/** |
|
533 |
* Sets phone muted/unmuted. |
|
534 |
* @param aIsMuted ETrue if phone is muted. |
|
535 |
*/ |
|
536 |
void BubbleManager::setPhoneMuted( |
|
537 |
bool muted ) |
|
538 |
{ |
|
539 |
if (!mMutedIcon && muted) { |
|
540 |
mMutedIcon = mWidgetManager->view(BubbleWidgetManager::MutedOverlay); |
|
541 |
Q_ASSERT(mMutedIcon); |
|
542 |
addToLayout(mMutedIcon); |
|
543 |
mMutedIcon->setZValue(10.0); |
|
544 |
mEffectHandler->addEffect(mMutedIcon,BubbleMutedAppear); |
|
545 |
mEffectHandler->addEffect(mMutedIcon,BubbleMutedDisappear); |
|
546 |
} |
|
547 |
||
548 |
if (mMutedIcon) { |
|
549 |
// run effect when mute status changes |
|
550 |
if (muted && !mMuted) { |
|
551 |
mEffectHandler->startEffect(BubbleMutedAppear); |
|
552 |
} else if (!muted && mMuted) { |
|
553 |
mEffectHandler->startEffect(BubbleMutedDisappear); |
|
554 |
} else { |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
555 |
mEffectHandler->cancelAllEffects(mMutedIcon); |
37 | 556 |
mMutedIcon->setVisible(muted); |
557 |
} |
|
558 |
} |
|
559 |
||
560 |
mMuted = muted; |
|
561 |
} |
|
562 |
||
563 |
/** |
|
564 |
* Creates a conference call based upon two calls. Bubbles must be |
|
565 |
* created first. |
|
566 |
*/ |
|
567 |
int BubbleManager::createConference( |
|
568 |
int bubble1, |
|
569 |
int bubble2 ) |
|
570 |
{ |
|
571 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
572 |
||
573 |
mConferenceHeader->setIsUsed(true); |
|
574 |
mActiveHeaders.append(mConferenceHeader); |
|
575 |
addRowToConference(bubble1); |
|
576 |
addRowToConference(bubble2); |
|
577 |
return mConferenceHeader->bubbleId(); |
|
578 |
} |
|
579 |
||
580 |
/** |
|
581 |
* Splits conference call into invidual two calls. Call headers stays |
|
582 |
* in use. Headers' state will not be changed. |
|
583 |
*/ |
|
584 |
void BubbleManager::removeConference() |
|
585 |
{ |
|
586 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
587 |
||
588 |
mConferenceHeader->reset(); |
|
589 |
mSortHeaders = true; |
|
590 |
||
591 |
for ( int i=0; i < mActiveHeaders.size(); i++ ) { |
|
592 |
if ( mActiveHeaders[i]->bubbleId() == BUBBLE_CONF_CALL_ID ) { |
|
593 |
mActiveHeaders.remove( i ); |
|
594 |
break; |
|
595 |
} |
|
596 |
} |
|
597 |
||
598 |
QGraphicsWidget* view = |
|
599 |
mWidgetManager->view(BubbleWidgetManager::ConferenceView); |
|
600 |
if (view) { |
|
601 |
QList<BubbleHandler*>* handlers = mWidgetManager->handlers(view); |
|
602 |
if (handlers) { |
|
603 |
foreach (BubbleHandler* handler, *handlers) { |
|
604 |
handler->conferenceRemoved(); |
|
605 |
} |
|
606 |
} |
|
607 |
} |
|
608 |
} |
|
609 |
||
610 |
/** |
|
611 |
* Adds new call to conference call. |
|
612 |
*/ |
|
613 |
void BubbleManager::addRowToConference( int bubbleId ) |
|
614 |
{ |
|
615 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
616 |
||
617 |
BubbleHeader* header = 0; |
|
618 |
findActiveHeader( bubbleId, header ); |
|
619 |
Q_ASSERT( header ); |
|
620 |
||
621 |
Q_ASSERT( !header->isInConference() ); |
|
622 |
Q_ASSERT( !header->isConference() ); |
|
623 |
||
624 |
mConferenceHeader->addHeader(header); |
|
625 |
||
626 |
// release image while in conference |
|
627 |
releaseImageIfNotUsed(header->callImage()); |
|
628 |
} |
|
629 |
||
630 |
/** |
|
631 |
* Takes specified call out of conference. Use RemoveConference if |
|
632 |
* conference has only two calls in it. Header's state is same as |
|
633 |
* before adding it to conference (if not changed inside the conf). |
|
634 |
*/ |
|
635 |
void BubbleManager::removeRowFromConference( int bubbleId ) |
|
636 |
{ |
|
637 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
638 |
mConferenceHeader->removeHeader(bubbleId); |
|
639 |
mSortHeaders = true; |
|
640 |
||
641 |
QGraphicsWidget* view = |
|
642 |
mWidgetManager->view(BubbleWidgetManager::ConferenceView); |
|
643 |
||
644 |
if (view) { |
|
645 |
QList<BubbleHandler*>* handlers = mWidgetManager->handlers(view); |
|
646 |
if (handlers) { |
|
647 |
foreach (BubbleHandler* handler, *handlers) { |
|
648 |
handler->conferenceMemberRemoved(bubbleId); |
|
649 |
} |
|
650 |
} |
|
651 |
} |
|
652 |
} |
|
653 |
||
654 |
/** |
|
655 |
* Counts calls in conference call. |
|
656 |
*/ |
|
657 |
int BubbleManager::conferenceRowCount() const |
|
658 |
{ |
|
659 |
return mConferenceHeader->headers().count(); |
|
660 |
} |
|
661 |
||
662 |
||
663 |
/** |
|
664 |
* Sets highlight to specified line in conference. |
|
665 |
*/ |
|
666 |
void BubbleManager::setSelectionInConference( int rowNumber ) |
|
667 |
{ |
|
668 |
Q_UNUSED(rowNumber) |
|
669 |
} |
|
670 |
||
671 |
/** |
|
672 |
* Sets highlight to specified bubble id in conference. |
|
673 |
*/ |
|
674 |
void BubbleManager::setSelectionIdInConference( int bubbleId ) |
|
675 |
{ |
|
676 |
Q_UNUSED(bubbleId) |
|
677 |
} |
|
678 |
||
679 |
/** |
|
680 |
* Gets highlighted item in conference. |
|
681 |
*/ |
|
682 |
int BubbleManager::selectionInConference() const |
|
683 |
{ |
|
684 |
return -1; |
|
685 |
} |
|
686 |
||
687 |
/** |
|
688 |
* Gets highlighted item in conference. |
|
689 |
*/ |
|
690 |
int BubbleManager::selectionIdInConference() const |
|
691 |
{ |
|
692 |
return mConferenceHeader->selectedHeader(); |
|
693 |
} |
|
694 |
||
695 |
/** |
|
696 |
* Moves highligh one up if possible |
|
697 |
*/ |
|
698 |
void BubbleManager::moveHighlightOneUpInConference() |
|
699 |
{ |
|
700 |
// may be needed in non-touch |
|
701 |
} |
|
702 |
||
703 |
/** |
|
704 |
* Moves highligh one down if possible |
|
705 |
*/ |
|
706 |
void BubbleManager::moveHighlightOneDownInConference() |
|
707 |
{ |
|
708 |
// may be needed in non-touch |
|
709 |
} |
|
710 |
||
711 |
/** |
|
712 |
* Use this function to expand or shrink conference bubble. |
|
713 |
*/ |
|
714 |
void BubbleManager::setExpandedConferenceCallHeader( |
|
715 |
bool expanded ) |
|
716 |
{ |
|
717 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
718 |
if ( mConferenceHeader->isUsed() ) { |
|
719 |
mConferenceHeader->setExpanded(expanded); |
|
720 |
mSortHeaders = true; |
|
721 |
} |
|
722 |
} |
|
723 |
||
724 |
/** |
|
725 |
* Query: is conference expanded? |
|
726 |
*/ |
|
727 |
bool BubbleManager::isConferenceExpanded( ) const |
|
728 |
{ |
|
729 |
return mConferenceHeader->isExpanded(); |
|
730 |
} |
|
731 |
||
732 |
||
733 |
/** |
|
734 |
* Number of headers shown on the screen. |
|
735 |
*/ |
|
736 |
int BubbleManager::shownHeaderCount() const |
|
737 |
{ |
|
738 |
QVectorIterator<BubbleHeader*> i(mActiveHeaders); |
|
739 |
int count = 0; |
|
740 |
while (i.hasNext()) { |
|
741 |
if ( !i.next()->isInConference() ) { |
|
742 |
count++; |
|
743 |
} |
|
744 |
} |
|
745 |
return count; |
|
746 |
} |
|
747 |
||
748 |
/** |
|
749 |
* Set CLI used in participant list (text or phonenumber). |
|
750 |
*/ |
|
751 |
void BubbleManager::setParticipantListCli( |
|
752 |
int bubbleId, |
|
753 |
ParticipantListCli aParticipantCli ) |
|
754 |
{ |
|
755 |
Q_UNUSED(bubbleId) |
|
756 |
Q_UNUSED(aParticipantCli) |
|
757 |
} |
|
758 |
||
759 |
void BubbleManager::addAction( int bubbleId, HbAction* action ) |
|
760 |
{ |
|
761 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
762 |
||
763 |
BubbleHeader* header = 0; |
|
764 |
findActiveHeader( bubbleId, header ); |
|
765 |
Q_ASSERT( header ); |
|
766 |
||
767 |
header->addAction(action); |
|
768 |
} |
|
769 |
||
770 |
void BubbleManager::clearActions( int bubbleId ) |
|
771 |
{ |
|
772 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
773 |
||
774 |
BubbleHeader* header = 0; |
|
775 |
findActiveHeader( bubbleId, header ); |
|
776 |
Q_ASSERT( header ); |
|
777 |
||
778 |
header->clearActions(); |
|
779 |
} |
|
780 |
||
781 |
QGraphicsWidget* BubbleManager::graphicsWidgetForAction( |
|
782 |
HbAction* action ) const |
|
783 |
{ |
|
784 |
QGraphicsWidget* widget = 0; |
|
785 |
||
786 |
foreach (BubbleHandler* handler,mActiveHandlers) { |
|
787 |
widget = handler->graphicsWidgetForAction(action); |
|
788 |
if (widget) { |
|
789 |
break; |
|
790 |
} |
|
791 |
} |
|
792 |
||
793 |
if (!widget) { |
|
794 |
// check if it's expand action |
|
795 |
QVectorIterator<BubbleHeader*> i(mActiveHeaders); |
|
796 |
bool bubbleWidget=false; |
|
797 |
while (i.hasNext()) { |
|
798 |
BubbleHeader* h = i.next(); |
|
799 |
if ( h->expandAction() && |
|
800 |
(h->expandAction()->text()==action->text()) ) { |
|
801 |
bubbleWidget=true; |
|
802 |
break; |
|
803 |
} |
|
804 |
} |
|
805 |
||
806 |
if (bubbleWidget) { |
|
807 |
if ( mActiveHandlers.count()==2 ) { |
|
808 |
widget = mWidgetManager->container( |
|
809 |
BubbleWidgetManager::TwoCallsView, |
|
810 |
BubbleWidgetManager::CollapsedBubble ); |
|
811 |
} else if ( mActiveHandlers.count()==3 ) { |
|
812 |
// return top most bubble |
|
813 |
widget = mWidgetManager->container( |
|
814 |
BubbleWidgetManager::ThreeCallsView, |
|
815 |
BubbleWidgetManager::CollapsedBubble2 ); |
|
816 |
} |
|
817 |
} |
|
818 |
} |
|
819 |
||
820 |
return widget; |
|
821 |
} |
|
822 |
||
823 |
void BubbleManager::addParticipantListAction(HbAction *action) |
|
824 |
{ |
|
825 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
826 |
mConferenceHeader->addParticipantListAction(action); |
|
827 |
} |
|
828 |
||
829 |
void BubbleManager::clearParticipantListActions() |
|
830 |
{ |
|
831 |
Q_ASSERT( mIsReadyToDraw > 0 ); |
|
832 |
mConferenceHeader->clearParticipantListActions(); |
|
833 |
} |
|
834 |
||
835 |
int BubbleManager::expandedBubble() const |
|
836 |
{ |
|
837 |
// shall not be called without creating call headers first |
|
838 |
Q_ASSERT(mActiveHeaders.count()); |
|
839 |
||
840 |
if (isConferenceExpanded()) { |
|
841 |
return mConferenceHeader->bubbleId(); |
|
842 |
} else { |
|
843 |
int i=0; |
|
844 |
findNextDrawableHeader(i); |
|
845 |
return mActiveHeaders.at(i)->bubbleId(); |
|
846 |
} |
|
847 |
} |
|
848 |
||
849 |
void BubbleManager::setExpandAction(int bubbleId, HbAction* action) |
|
850 |
{ |
|
851 |
BubbleHeader* header = 0; |
|
852 |
findActiveHeader( bubbleId, header ); |
|
853 |
Q_ASSERT( header ); |
|
854 |
header->setExpandAction(action); |
|
855 |
} |
|
856 |
||
857 |
void BubbleManager::setBubbleSelectionDisabled(bool disabled) |
|
858 |
{ |
|
859 |
mBubbleSelectionDisabled = disabled; |
|
860 |
} |
|
861 |
||
862 |
void BubbleManager::handleOrientationChange( |
|
863 |
Qt::Orientation orientation) |
|
864 |
{ |
|
865 |
mWidgetManager->handleOrientationChange(orientation); |
|
866 |
} |
|
867 |
||
868 |
void BubbleManager::polishEvent() |
|
869 |
{ |
|
870 |
// for debugging - remove |
|
871 |
HbWidget::polishEvent(); |
|
872 |
} |
|
873 |
||
874 |
void BubbleManager::showExpanded( int bubbleId ) |
|
875 |
{ |
|
876 |
if ( !mBubbleSelectionDisabled && (mActiveHeaders.count() > 1) ) { |
|
877 |
int expanded = mActiveHeaders[0]->bubbleId(); |
|
878 |
if ( bubbleId != expanded ) { |
|
879 |
startChanges(); |
|
880 |
||
881 |
BubbleHeader* header = 0; |
|
882 |
||
883 |
if (bubbleId == BUBBLE_CONF_CALL_ID) { |
|
884 |
header = mConferenceHeader; |
|
885 |
} else { |
|
886 |
// find header |
|
887 |
for ( int i=0; i < mActiveHeaders.size(); i++ ) { |
|
888 |
if ( mActiveHeaders[i]->bubbleId() == bubbleId ) { |
|
889 |
header = mActiveHeaders[i]; |
|
890 |
mActiveHeaders.remove(i); |
|
891 |
break; |
|
892 |
} |
|
893 |
} |
|
894 |
||
895 |
Q_ASSERT(header); |
|
896 |
||
897 |
// set it first |
|
898 |
mActiveHeaders.insert(0,header); |
|
899 |
} |
|
900 |
||
901 |
endChanges(); |
|
902 |
||
903 |
// trigger the expand action |
|
904 |
HbAction* action = header->expandAction(); |
|
905 |
if (action) { |
|
906 |
action->trigger(); |
|
907 |
} |
|
908 |
} |
|
909 |
} |
|
910 |
} |
|
911 |
||
912 |
void BubbleManager::releaseImageIfNotUsed( |
|
913 |
const QString& imageFileName) |
|
914 |
{ |
|
915 |
bool used = false; |
|
916 |
||
917 |
if (!imageFileName.isEmpty()) { |
|
918 |
foreach(BubbleHeader* header, mActiveHeaders) { |
|
919 |
if (!header->isInConference() && |
|
920 |
header->callImage()==imageFileName) { |
|
921 |
used = true; |
|
922 |
break; |
|
923 |
} |
|
924 |
} |
|
925 |
||
926 |
if (!used) { |
|
927 |
mBubbleImageManager->unloadImage(imageFileName); |
|
928 |
} |
|
929 |
} |
|
930 |
} |
|
931 |
||
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
932 |
void BubbleManager::releaseNonCachedViews() |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
933 |
{ |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
934 |
static const int viewCount = 3; |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
935 |
static const int views[viewCount] = { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
936 |
BubbleWidgetManager::TwoCallsView, |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
937 |
BubbleWidgetManager::ThreeCallsView, |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
938 |
BubbleWidgetManager::ConferenceView |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
939 |
}; |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
940 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
941 |
for (int i=0; i < viewCount; i++ ) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
942 |
BubbleWidgetManager::View viewid = |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
943 |
(BubbleWidgetManager::View)views[i]; |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
944 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
945 |
if (mWidgetManager->isLoaded(viewid)) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
946 |
QGraphicsWidget* view = mWidgetManager->view(viewid); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
947 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
948 |
if (view) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
949 |
removeFromLayout(view); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
950 |
mWidgetManager->releaseView(viewid); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
951 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
952 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
953 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
954 |
} |