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