author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:45 +0100 | |
branch | GCC_SURGE |
changeset 37 | 451b2e1545b2 |
parent 19 | afea38384506 |
parent 33 | 11b6825f0862 |
permissions | -rw-r--r-- |
24 | 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <HbMenu> |
|
19 |
#include <HbAction> |
|
20 |
#include <HbEffect> |
|
21 |
#include <QCoreApplication> |
|
22 |
#include <HbMessageBox> |
|
23 |
||
24 |
#include "radioviewbase.h" |
|
25 |
#include "radiowindow.h" |
|
26 |
#include "radiostationmodel.h" |
|
27 |
#include "radiouiloader.h" |
|
28 |
#include "radiouiengine.h" |
|
29 |
#include "radiologger.h" |
|
30 |
||
31 |
/*! |
|
32 |
* |
|
33 |
*/ |
|
34 |
RadioViewBase::RadioViewBase( bool transient ) : |
|
35 |
HbView( 0 ), |
|
36 |
mMainWindow( 0 ), |
|
37 |
mUiLoader( 0 ), |
|
38 |
mTransientView( transient ), |
|
39 |
mUseLoudspeakerAction( 0 ), |
|
40 |
mOrientation( Qt::Vertical ) |
|
41 |
{ |
|
42 |
} |
|
43 |
||
44 |
/*! |
|
45 |
* |
|
46 |
*/ |
|
47 |
RadioViewBase::~RadioViewBase() |
|
48 |
{ |
|
49 |
if ( mUiLoader ) { |
|
50 |
mUiLoader->reset(); |
|
51 |
} |
|
52 |
} |
|
53 |
||
54 |
/*! |
|
55 |
* |
|
56 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
57 |
void RadioViewBase::setMembers( RadioWindow* mainWindow, RadioUiLoader* uiLoader ) |
24 | 58 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
59 |
mMainWindow = mainWindow; |
24 | 60 |
mUiLoader.reset( uiLoader ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
61 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
62 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
63 |
/*! |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
64 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
65 |
*/ |
33
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
66 |
void RadioViewBase::preLazyLoadInit() |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
67 |
{ |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
68 |
// Default implementation does nothing |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
69 |
} |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
70 |
|
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
71 |
/*! |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
72 |
* |
11b6825f0862
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
73 |
*/ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
74 |
void RadioViewBase::initialize( QSharedPointer<RadioUiEngine> uiEngine ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
75 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
76 |
mUiEngine = uiEngine; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
77 |
init(); |
24 | 78 |
} |
79 |
||
80 |
/*! |
|
81 |
* |
|
82 |
*/ |
|
83 |
bool RadioViewBase::isInitialized() const |
|
84 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
85 |
return mUiEngine; |
24 | 86 |
} |
87 |
||
88 |
/*! |
|
89 |
* |
|
90 |
*/ |
|
91 |
bool RadioViewBase::isTransient() const |
|
92 |
{ |
|
93 |
return mTransientView; |
|
94 |
} |
|
95 |
||
96 |
/*! |
|
97 |
* |
|
98 |
*/ |
|
99 |
void RadioViewBase::updateOrientation( Qt::Orientation orientation, bool forceUpdate ) |
|
100 |
{ |
|
101 |
if ( orientation != mOrientation || forceUpdate ) { |
|
102 |
mOrientation = orientation; |
|
103 |
setOrientation(); |
|
104 |
} |
|
105 |
} |
|
106 |
||
107 |
/*! |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
108 |
* |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
109 |
*/ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
110 |
void RadioViewBase::bringToForeground() |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
111 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
112 |
mMainWindow->raise(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
113 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
114 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
115 |
/*! |
24 | 116 |
* Protected slot |
117 |
* |
|
118 |
*/ |
|
119 |
void RadioViewBase::updateAudioRouting( bool loudspeaker ) |
|
120 |
{ |
|
121 |
if ( mUseLoudspeakerAction ) { |
|
122 |
mUseLoudspeakerAction->setText( loudspeaker ? hbTrId( "txt_common_opt_deactivate_loudspeaker" ) |
|
123 |
: hbTrId( "txt_common_opt_activate_loudspeaker" ) ); |
|
124 |
} |
|
125 |
} |
|
126 |
||
127 |
/*! |
|
128 |
* Protected slot |
|
129 |
* |
|
130 |
*/ |
|
131 |
void RadioViewBase::activatePreviousView() |
|
132 |
{ |
|
133 |
mMainWindow->activateMainView(); |
|
134 |
} |
|
135 |
||
136 |
/*! |
|
137 |
* Protected slot |
|
138 |
* |
|
139 |
*/ |
|
140 |
void RadioViewBase::quit() |
|
141 |
{ |
|
142 |
qApp->quit(); |
|
143 |
} |
|
144 |
||
145 |
/*! |
|
146 |
* Private slot |
|
147 |
*/ |
|
148 |
void RadioViewBase::handleUserAnswer( HbAction* answer ) |
|
149 |
{ |
|
150 |
HbMessageBox* dlg = static_cast<HbMessageBox*>( sender() ); |
|
151 |
if( dlg->actions().first() == answer ) { |
|
152 |
userAccepted(); |
|
153 |
} |
|
154 |
} |
|
155 |
||
156 |
/*! |
|
157 |
* |
|
158 |
*/ |
|
159 |
void RadioViewBase::initBackAction() |
|
160 |
{ |
|
161 |
// The default back button activates the tuning view |
|
162 |
HbAction* backAction = new HbAction( Hb::BackNaviAction, this ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
163 |
Radio::connect( backAction, SIGNAL(triggered()), |
24 | 164 |
mMainWindow, SLOT(activateMainView()) ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
165 |
setNavigationAction( backAction ); |
24 | 166 |
} |
167 |
||
168 |
/*! |
|
169 |
* |
|
170 |
*/ |
|
171 |
void RadioViewBase::connectCommonMenuItem( int menuItem ) |
|
172 |
{ |
|
173 |
switch ( menuItem ) { |
|
174 |
case MenuItem::UseLoudspeaker: |
|
175 |
mUseLoudspeakerAction = mUiLoader->findObject<HbAction>( DOCML::NAME_LOUDSPEAKER_ACTION ); |
|
176 |
if ( mUseLoudspeakerAction ) { |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
177 |
Radio::connect( mUseLoudspeakerAction, SIGNAL(triggered()), mUiEngine.data(), SLOT(toggleAudioRoute()) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
178 |
updateAudioRouting( mUiEngine->isUsingLoudspeaker() ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
179 |
Radio::connect( mUiEngine.data(), SIGNAL(audioRouteChanged(bool)), this, SLOT(updateAudioRouting(bool)) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
180 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
181 |
break; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
182 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
183 |
case MenuItem::Exit: |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
184 |
if ( HbAction* exitAction = mUiLoader->findObject<HbAction>( DOCML::NAME_EXIT_ACTION ) ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
185 |
Radio::connect( exitAction, SIGNAL(triggered()), this, SLOT(quit()) ); |
24 | 186 |
} |
187 |
break; |
|
188 |
||
189 |
default: |
|
190 |
break; |
|
191 |
} |
|
192 |
} |
|
193 |
||
194 |
/*! |
|
195 |
* |
|
196 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
197 |
void RadioViewBase::connectXmlElement( const QString& name, const char* signal, QObject* receiver, const char* slot ) |
24 | 198 |
{ |
199 |
if ( QObject* action = mUiLoader->findObject<QObject>( name ) ) { |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
200 |
Radio::connect( action, signal, receiver, slot ); |
24 | 201 |
} |
202 |
} |
|
203 |
||
204 |
/*! |
|
205 |
* |
|
206 |
*/ |
|
207 |
void RadioViewBase::connectViewChangeMenuItem( QString name, const char* slot ) |
|
208 |
{ |
|
209 |
if ( QObject* action = mUiLoader->findObject<QObject>( name ) ) { |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
210 |
Radio::connect( action, SIGNAL(triggered()), mMainWindow, slot ); |
24 | 211 |
} |
212 |
} |
|
213 |
||
214 |
/*! |
|
215 |
* |
|
216 |
*/ |
|
217 |
void RadioViewBase::loadSection( const QString& docml, const QString& section ) |
|
218 |
{ |
|
219 |
LOG_FORMAT( "RadioViewBase::loadSection: Docml: %s, section: %s", GETSTRING( docml ), GETSTRING( section ) ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
220 |
bool ok = false; |
24 | 221 |
mUiLoader->load( docml, section, &ok ); |
222 |
LOG_ASSERT( ok, LOG_FORMAT( "Loading of section %s failed!", GETSTRING( section ) ) ); |
|
223 |
} |
|
224 |
||
225 |
/*! |
|
226 |
* |
|
227 |
*/ |
|
228 |
void RadioViewBase::askQuestion( const QString& question ) |
|
229 |
{ |
|
230 |
HbMessageBox::question( question, this, SLOT(handleUserAnswer(HbAction*)) ); |
|
231 |
} |
|
232 |
||
233 |
/*! |
|
234 |
* |
|
235 |
*/ |
|
236 |
void RadioViewBase::setOrientation() |
|
237 |
{ |
|
238 |
// Default implementation does nothing |
|
239 |
} |
|
240 |
||
241 |
/*! |
|
242 |
* |
|
243 |
*/ |
|
244 |
void RadioViewBase::userAccepted() |
|
245 |
{ |
|
246 |
// Default implementation does nothing |
|
247 |
} |