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