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