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: Conference call bubble handler. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
18 |
#include <QTimer> |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
19 |
|
37 | 20 |
#include <hbaction.h> |
21 |
#include <hbtextitem.h> |
|
22 |
#include <hblabel.h> |
|
23 |
#include <hblistview.h> |
|
24 |
||
25 |
#include "bubblemanager2.h" |
|
26 |
#include "bubbleconferencehandler.h" |
|
27 |
#include "bubbleconferenceheader.h" |
|
28 |
#include "bubbleutils.h" |
|
29 |
#include "bubbleparticipantlistitem.h" |
|
30 |
#include "bubbleparticipantlistmodel.h" |
|
31 |
#include "bubblebutton.h" |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
32 |
#include "bubbleheadingwidget.h" |
37 | 33 |
|
34 |
static const int BUBBLE_SELECTION_TIMEOUT = 3000; |
|
35 |
||
36 |
BubbleConferenceHandler::BubbleConferenceHandler( |
|
37 |
BubbleWidgetManager& widgetManager, |
|
38 |
BubbleWidgetManager::View view, |
|
39 |
BubbleWidgetManager::Container container, |
|
40 |
QObject* parent ) |
|
41 |
: BubbleHandler(widgetManager,view,container,parent) |
|
42 |
{ |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
43 |
mHeading = |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
44 |
qobject_cast<BubbleHeadingWidget*>(widget(BubbleWidgetManager::Heading)); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
45 |
Q_ASSERT(mHeading); |
37 | 46 |
|
47 |
mButtonCenter = |
|
48 |
qobject_cast<BubbleButton*>(widget(BubbleWidgetManager::CenterButton)); |
|
49 |
Q_ASSERT(mButtonCenter); |
|
50 |
mButtonLeft = |
|
51 |
qobject_cast<BubbleButton*>(widget(BubbleWidgetManager::LeftButton)); |
|
52 |
Q_ASSERT(mButtonLeft); |
|
53 |
mButtonRight = |
|
54 |
qobject_cast<BubbleButton*>(widget(BubbleWidgetManager::RightButton)); |
|
55 |
Q_ASSERT(mButtonRight); |
|
56 |
||
57 |
mList = |
|
58 |
qobject_cast<HbListView*>(widget(BubbleWidgetManager::ParticipantList)); |
|
59 |
Q_ASSERT(mList); |
|
60 |
mModel = new BubbleParticipantListModel(); |
|
61 |
mList->setModel(mModel); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
62 |
|
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
63 |
HbAbstractItemView::ItemAnimations noCreationAndRemovalAnimations = HbAbstractItemView::All; |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
64 |
noCreationAndRemovalAnimations ^= HbAbstractItemView::Appear; |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
65 |
noCreationAndRemovalAnimations ^= HbAbstractItemView::Disappear; |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
66 |
mList->setEnabledAnimations(noCreationAndRemovalAnimations); |
37 | 67 |
|
68 |
mPrototype = |
|
69 |
qobject_cast<BubbleParticipantListItem*>( |
|
70 |
widgetManager.createParticipantListItem()); |
|
71 |
Q_ASSERT(mPrototype); |
|
72 |
mList->setItemPrototype(mPrototype); |
|
73 |
connect(mList->selectionModel(), |
|
74 |
SIGNAL(currentChanged(QModelIndex,QModelIndex)), |
|
75 |
this, |
|
76 |
SLOT(handleItemSelected(QModelIndex,QModelIndex))); |
|
77 |
||
78 |
mSelectionTimer = new QTimer(this); |
|
79 |
connect(mSelectionTimer,SIGNAL(timeout()),SLOT(clearSelection())); |
|
80 |
mSelectionTimer->setSingleShot(true); |
|
81 |
||
82 |
reset(); |
|
83 |
} |
|
84 |
||
85 |
BubbleConferenceHandler::~BubbleConferenceHandler() |
|
86 |
{ |
|
87 |
} |
|
88 |
||
89 |
void BubbleConferenceHandler::reset() |
|
90 |
{ |
|
91 |
mHeader = 0; |
|
92 |
||
93 |
mSelectionTimer->stop(); |
|
94 |
mPrototype->clearActions(); |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
95 |
mHeading->reset(); |
37 | 96 |
mButtonCenter->hide(); |
97 |
mButtonCenter->setDown(false); |
|
98 |
mButtonCenter->disconnect(); |
|
99 |
mButtonLeft->hide(); |
|
100 |
mButtonLeft->setDown(false); |
|
101 |
mButtonLeft->disconnect(); |
|
102 |
mButtonRight->hide(); |
|
103 |
mButtonRight->setDown(false); |
|
104 |
mButtonRight->disconnect(); |
|
105 |
} |
|
106 |
||
107 |
void BubbleConferenceHandler::readBubbleHeader( const BubbleHeader& header ) |
|
108 |
{ |
|
109 |
Q_ASSERT(header.isConference()); |
|
110 |
mHeader = static_cast<const BubbleConferenceHeader*>(&header); |
|
111 |
||
112 |
// set actions to item prototype |
|
113 |
QList<HbAbstractViewItem*> prototypes = mList->itemPrototypes(); |
|
114 |
QList<HbAction*> actions = mHeader->participantListActions(); |
|
115 |
foreach (HbAction* action, actions ) { |
|
116 |
mPrototype->addAction(action); |
|
117 |
} |
|
118 |
||
119 |
// populate participant list model |
|
120 |
QList<BubbleHeader*> participants = mHeader->headers(); |
|
121 |
foreach(BubbleHeader* participant, participants) { |
|
122 |
mModel->addParticipant( |
|
123 |
participant->bubbleId(), |
|
124 |
participant->cli(), |
|
125 |
(int)participant->callState(), |
|
126 |
!(mHeader->callFlags()&BubbleManagerIF::NoCiphering)); |
|
127 |
} |
|
128 |
||
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
129 |
mHeading->readBubbleHeader(header); |
37 | 130 |
|
131 |
setButtons(mHeader->actions()); |
|
132 |
||
133 |
clearSelection(); |
|
134 |
} |
|
135 |
||
136 |
void BubbleConferenceHandler::setButtons(const QList<HbAction*>& actions) |
|
137 |
{ |
|
138 |
if ( actions.count()==1 && mButtonCenter ) { |
|
139 |
HbAction* action = actions.at(0); |
|
140 |
mButtonCenter->setIcon( action->icon() ); |
|
141 |
BubbleUtils::setButtonStyleForAction(*mButtonCenter,*action); |
|
142 |
connect(mButtonCenter, SIGNAL( clicked() ), |
|
143 |
action, SLOT( trigger() ) ); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
144 |
connect(mButtonCenter, SIGNAL( longPress(QPointF)), |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
145 |
action, SLOT( trigger() ) ); |
37 | 146 |
mButtonCenter->show(); |
147 |
} else if (actions.count()==2 && mButtonLeft && mButtonRight ) { |
|
148 |
// Left button |
|
149 |
HbAction* action1 = actions.at(0); |
|
150 |
mButtonLeft->setIcon( action1->icon() ); |
|
151 |
BubbleUtils::setButtonStyleForAction(*mButtonLeft,*action1); |
|
152 |
connect( mButtonLeft, SIGNAL( clicked() ), |
|
153 |
action1, SLOT( trigger() ) ); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
154 |
connect(mButtonLeft, SIGNAL( longPress(QPointF)), |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
155 |
action1, SLOT( trigger() ) ); |
37 | 156 |
mButtonLeft->show(); |
157 |
// Right button |
|
158 |
HbAction* action2 = actions.at(1); |
|
159 |
mButtonRight->setIcon( action2->icon() ); |
|
160 |
BubbleUtils::setButtonStyleForAction(*mButtonRight,*action2); |
|
161 |
connect( mButtonRight, SIGNAL( clicked() ), |
|
162 |
action2, SLOT( trigger() ) ); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
163 |
connect(mButtonRight, SIGNAL( longPress(QPointF)), |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
164 |
action2, SLOT( trigger() ) ); |
37 | 165 |
mButtonRight->show(); |
166 |
} |
|
167 |
} |
|
168 |
||
169 |
QGraphicsWidget* BubbleConferenceHandler::graphicsWidgetForAction( |
|
170 |
HbAction* action ) const |
|
171 |
{ |
|
172 |
if ( mButtonLeft->text() == action->text() ) { |
|
173 |
return mButtonLeft; |
|
174 |
} else if ( mButtonRight->text() == action->text() ) { |
|
175 |
return mButtonRight; |
|
176 |
} else if ( mButtonCenter->text() == action->text() ) { |
|
177 |
return mButtonCenter; |
|
178 |
} else { |
|
179 |
return 0; |
|
180 |
} |
|
181 |
} |
|
182 |
||
183 |
void BubbleConferenceHandler::updateTimerDisplayNow() |
|
184 |
{ |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
185 |
mHeading->updateTimerDisplayNow(); |
37 | 186 |
} |
187 |
||
188 |
void BubbleConferenceHandler::handleItemSelected( |
|
189 |
const QModelIndex & current, |
|
190 |
const QModelIndex & previous ) |
|
191 |
{ |
|
192 |
Q_UNUSED(previous); |
|
193 |
||
194 |
if (current.isValid()) { |
|
195 |
Q_ASSERT( mHeader != 0 ); |
|
196 |
// need to cast constness away |
|
197 |
BubbleConferenceHeader& mutableHeader = |
|
198 |
const_cast<BubbleConferenceHeader&>(*mHeader); |
|
199 |
mutableHeader.setSelectedHeader(mModel->bubbleId(current.row())); |
|
200 |
mSelectionTimer->stop(); |
|
201 |
mSelectionTimer->start(BUBBLE_SELECTION_TIMEOUT); |
|
202 |
} |
|
203 |
} |
|
204 |
||
205 |
void BubbleConferenceHandler::clearSelection() |
|
206 |
{ |
|
207 |
mList->selectionModel()->clear(); |
|
208 |
} |
|
209 |
||
210 |
void BubbleConferenceHandler::conferenceMemberRemoved(int bubbleId) |
|
211 |
{ |
|
212 |
mModel->removeParticipant(bubbleId); |
|
213 |
} |
|
214 |
||
215 |
void BubbleConferenceHandler::conferenceRemoved() |
|
216 |
{ |
|
217 |
mModel->reset(); |
|
218 |
mList->reset(); |
|
219 |
} |