|
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: Utility methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <hbiconitem.h> |
|
19 #include "bubblemanager2.h" |
|
20 #include "bubbleutils.h" |
|
21 #include "bubbleheader.h" |
|
22 #include "bubblestyleoption.h" |
|
23 #include "bubblebuttonstyle.h" |
|
24 #include "hbpushbutton.h" |
|
25 #include "hbaction.h" |
|
26 |
|
27 void BubbleUtils::setCallHeaderTexts3Lines( |
|
28 const BubbleHeader& header, |
|
29 BubbleStyleOption& option ) |
|
30 { |
|
31 switch( header.callState() ) { |
|
32 case BubbleManager::Incoming: |
|
33 case BubbleManager::Waiting: |
|
34 case BubbleManager::AlertToDisconnected: |
|
35 { |
|
36 if ( header.secondaryCli().length() ) { |
|
37 option.mText1.append( header.cli() ); |
|
38 option.mText1Clip = header.cliClipDirection(); |
|
39 option.mText2.append( header.secondaryCli() ); |
|
40 option.mText2Clip = header.secondaryCliClipDirection(); |
|
41 option.mText3.append( header.text() ); |
|
42 option.mText3Clip = header.textClipDirection(); |
|
43 option.mCliLineNumber = 1; |
|
44 } else { |
|
45 option.mText1.append( header.cli() ); |
|
46 option.mText1Clip = header.cliClipDirection(); |
|
47 option.mText2.append( header.text() ); |
|
48 option.mText2Clip = header.textClipDirection(); |
|
49 option.mCliLineNumber = 1; |
|
50 } |
|
51 break; |
|
52 } |
|
53 |
|
54 case BubbleManager::Outgoing: |
|
55 { |
|
56 if ( header.secondaryCli().length() ) { |
|
57 option.mText1.append( header.text() ); |
|
58 option.mText1Clip = header.textClipDirection(); |
|
59 option.mText2.append( header.cli() ); |
|
60 option.mText2Clip = header.cliClipDirection(); |
|
61 option.mText3.append( header.secondaryCli() ); |
|
62 option.mText3Clip = header.secondaryCliClipDirection(); |
|
63 option.mCliLineNumber = 2; |
|
64 } else { |
|
65 option.mText1.append( header.text() ); |
|
66 option.mText1Clip = header.textClipDirection(); |
|
67 option.mText2.append( header.cli() ); |
|
68 option.mText2Clip = header.cliClipDirection(); |
|
69 option.mCliLineNumber = 2; |
|
70 } |
|
71 break; |
|
72 } |
|
73 |
|
74 case BubbleManager::Active: |
|
75 case BubbleManager::Alerting: |
|
76 { |
|
77 if ( header.secondaryCli().length() ) { |
|
78 option.mText1.append( header.cli() ); |
|
79 option.mText1Clip = header.cliClipDirection(); |
|
80 option.mText2.append( header.secondaryCli() ); |
|
81 option.mText2Clip = header.secondaryCliClipDirection(); |
|
82 option.mText3.append( header.timerCost() ); |
|
83 option.mText3Clip = Qt::ElideRight; |
|
84 option.mCliLineNumber = 1; |
|
85 option.mTimerLineNumber = 3; |
|
86 } else { |
|
87 option.mText1.append( header.cli() ); |
|
88 option.mText1Clip = header.cliClipDirection(); |
|
89 option.mText2.append( header.timerCost() ); |
|
90 option.mText2Clip = Qt::ElideRight; |
|
91 option.mCliLineNumber = 1; |
|
92 option.mTimerLineNumber = 2; |
|
93 } |
|
94 break; |
|
95 } |
|
96 |
|
97 case BubbleManager::OnHold: |
|
98 case BubbleManager::Disconnected: |
|
99 { |
|
100 if ( header.secondaryCli().length() ) { |
|
101 option.mText1.append( header.cli() ); |
|
102 option.mText1Clip = header.cliClipDirection(); |
|
103 option.mText2.append( header.secondaryCli() ); |
|
104 option.mText2Clip = header.secondaryCliClipDirection(); |
|
105 option.mText3.append( header.text() ); |
|
106 option.mText3Clip = header.textClipDirection(); |
|
107 option.mCliLineNumber = 1; |
|
108 } else { |
|
109 option.mText1.append( header.cli() ); |
|
110 option.mText1Clip = header.cliClipDirection(); |
|
111 option.mText2.append( header.text() ); |
|
112 option.mText2Clip = header.textClipDirection(); |
|
113 option.mCliLineNumber = 1; |
|
114 } |
|
115 break; |
|
116 } |
|
117 |
|
118 default: |
|
119 // do nothing |
|
120 break; |
|
121 } // switch |
|
122 } |
|
123 |
|
124 void BubbleUtils::setCallHeaderTexts2Lines( |
|
125 const BubbleHeader& header, |
|
126 BubbleStyleOption& option ) |
|
127 { |
|
128 switch( header.callState() ) { |
|
129 case BubbleManager::Active: |
|
130 option.mText1.append( header.cli() ); |
|
131 option.mText1Clip = header.cliClipDirection(); |
|
132 option.mText2.append( header.timerCost() ); |
|
133 option.mText2Clip = Qt::ElideRight; |
|
134 option.mCliLineNumber = 1; |
|
135 option.mTimerLineNumber = 2; |
|
136 break; |
|
137 |
|
138 |
|
139 case BubbleManager::OnHold: |
|
140 case BubbleManager::Disconnected: |
|
141 option.mText1.append( header.cli() ); |
|
142 option.mText1Clip = header.cliClipDirection(); |
|
143 option.mText2.append( header.text() ); |
|
144 option.mText2Clip = header.textClipDirection(); |
|
145 option.mCliLineNumber = 1; |
|
146 break; |
|
147 |
|
148 case BubbleManager::Waiting: |
|
149 case BubbleManager::AlertToDisconnected: |
|
150 option.mText1.append( header.cli() ); |
|
151 option.mText1Clip = header.cliClipDirection(); |
|
152 option.mText2.append( header.text() ); |
|
153 option.mText2Clip = header.textClipDirection(); |
|
154 option.mCliLineNumber = 1; |
|
155 break; |
|
156 |
|
157 default: |
|
158 // do nothing |
|
159 break; |
|
160 } // switch |
|
161 } |
|
162 |
|
163 bool BubbleUtils::compareHeaders( |
|
164 const BubbleHeader* header1, |
|
165 const BubbleHeader* header2 ) |
|
166 { |
|
167 if ( header1->callState() < header2->callState() ) { |
|
168 return false; |
|
169 } else { |
|
170 return true; |
|
171 } |
|
172 } |
|
173 |
|
174 QString BubbleUtils::stylePluginNameWithPath(const QString& pluginName) |
|
175 { |
|
176 QString nameWithPath; |
|
177 |
|
178 #if defined(Q_OS_SYMBIAN) |
|
179 nameWithPath.append("z:/resource/qt/plugins/phone/"); |
|
180 nameWithPath.append(pluginName); |
|
181 #elif defined(Q_OS_WIN) |
|
182 nameWithPath.append("c:/hb/bin/"); |
|
183 nameWithPath.append(pluginName); |
|
184 #else // Q_OS_UNIX |
|
185 nameWithPath.append("/home/lib/"); |
|
186 nameWithPath.append(pluginName); |
|
187 #endif |
|
188 |
|
189 return nameWithPath; |
|
190 } |
|
191 |
|
192 void BubbleUtils::setButtonStyleForAction( |
|
193 HbPushButton& button, |
|
194 const HbAction& action) |
|
195 { |
|
196 BubbleButtonStyle* style = |
|
197 static_cast<BubbleButtonStyle*>(button.style()); |
|
198 |
|
199 if (action.softKeyRole()==QAction::PositiveSoftKey) { |
|
200 style->setButtonColor(BubbleButtonStyle::Green); |
|
201 } else if (action.softKeyRole()==QAction::NegativeSoftKey) { |
|
202 style->setButtonColor(BubbleButtonStyle::Red); |
|
203 } else { |
|
204 style->setButtonColor(BubbleButtonStyle::Default); |
|
205 } |
|
206 |
|
207 } |
|
208 |