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