author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 23 Jun 2010 18:12:57 +0300 | |
changeset 32 | 189d20c34778 |
parent 28 | 075425b8d9a4 |
child 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 |
// System includes |
|
19 |
#include <HbListView> |
|
20 |
#include <HbAbstractViewItem> |
|
21 |
#include <HbPushButton> |
|
22 |
#include <HbEffect> |
|
23 |
#include <HbAction> |
|
24 |
#include <HbInputDialog> |
|
25 |
#include <HbMenu> |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
26 |
#include <QSortFilterProxyModel> |
24 | 27 |
|
28 |
// User includes |
|
29 |
#include "radiostationsview.h" |
|
30 |
#include "radiologger.h" |
|
31 |
#include "radiowindow.h" |
|
32 |
#include "radiouiengine.h" |
|
33 |
#include "radiofrequencyscanner.h" |
|
34 |
#include "radiouiloader.h" |
|
35 |
#include "radiostationmodel.h" |
|
36 |
#include "radiostation.h" |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
37 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
38 |
// Constants |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
39 |
const char* REGEX_SHOW_FAVORITES = "true"; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
40 |
const char* REGEX_SHOW_ALL = ".+"; |
24 | 41 |
|
42 |
/*! |
|
43 |
* |
|
44 |
*/ |
|
45 |
RadioStationsView::RadioStationsView() : |
|
46 |
RadioViewBase( false ), |
|
47 |
mModel( 0 ), |
|
48 |
mScanStationsAction( 0 ), |
|
49 |
mClearListAction( 0 ), |
|
50 |
mStationsList( 0 ), |
|
51 |
mFavoritesButton( 0 ), |
|
52 |
mLocalStationsButton( 0 ), |
|
53 |
mSelectedStation( new RadioStation ), |
|
54 |
mCurrentQuestion( NoQuestion ) |
|
55 |
{ |
|
56 |
} |
|
57 |
||
58 |
/*! |
|
59 |
* |
|
60 |
*/ |
|
61 |
RadioStationsView::~RadioStationsView() |
|
62 |
{ |
|
63 |
} |
|
64 |
||
65 |
/*! |
|
66 |
* |
|
67 |
*/ |
|
68 |
void RadioStationsView::setNowPlayingIcon( const HbIcon& nowPlayingIcon ) |
|
69 |
{ |
|
70 |
mNowPlayingIcon = nowPlayingIcon; |
|
71 |
} |
|
72 |
||
73 |
/*! |
|
74 |
* |
|
75 |
*/ |
|
76 |
HbIcon RadioStationsView::nowPlayingIcon() const |
|
77 |
{ |
|
78 |
return mNowPlayingIcon; |
|
79 |
} |
|
80 |
||
81 |
/*! |
|
82 |
* |
|
83 |
*/ |
|
84 |
void RadioStationsView::setFavoriteIcon( const HbIcon& favoriteIcon ) |
|
85 |
{ |
|
86 |
mFavoriteIcon = favoriteIcon; |
|
87 |
} |
|
88 |
||
89 |
/*! |
|
90 |
* |
|
91 |
*/ |
|
92 |
HbIcon RadioStationsView::favoriteIcon() const |
|
93 |
{ |
|
94 |
return mFavoriteIcon; |
|
95 |
} |
|
96 |
||
97 |
/*! |
|
98 |
* Private slot |
|
99 |
* |
|
100 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
101 |
void RadioStationsView::handleClick( const QModelIndex& index ) |
24 | 102 |
{ |
103 |
LOG_TIMESTAMP( "Channel change started" ); |
|
104 |
QModelIndex sourceIndex = mFilterModel->mapToSource( index ); |
|
105 |
*mSelectedStation = mModel->stationAt( sourceIndex.row() ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
106 |
mUiEngine->setFrequency( mSelectedStation->frequency(), TuneReason::StationsList ); |
24 | 107 |
} |
108 |
||
109 |
/*! |
|
110 |
* Private slot |
|
111 |
* |
|
112 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
113 |
void RadioStationsView::handleLongPress( HbAbstractViewItem* item, const QPointF& coords ) |
24 | 114 |
{ |
115 |
Q_UNUSED( item ); |
|
116 |
||
117 |
HbMenu* menu = mUiLoader->findObject<HbMenu>( DOCML::NAME_CONTEXT_MENU ); |
|
118 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
119 |
*mSelectedStation = mFilterModel->data( item->modelIndex(), RadioRole::RadioStationRole ).value<RadioStation>(); |
24 | 120 |
|
121 |
HbAction* favoriteAction = mUiLoader->findObject<HbAction>( DOCML::NAME_CONTEXT_FAVORITE ); |
|
122 |
if ( mSelectedStation->isFavorite() ) { |
|
123 |
favoriteAction->setText( hbTrId( "txt_rad_menu_remove_favourite" ) ); |
|
124 |
} else { |
|
125 |
favoriteAction->setText( hbTrId( "txt_rad_menu_add_to_favourites" ) ); |
|
126 |
} |
|
127 |
||
128 |
menu->setPreferredPos( QPointF( size().width() / 2 - menu->size().width() / 2, coords.y() - menu->size().height() / 2 ) ); |
|
129 |
menu->show(); |
|
130 |
} |
|
131 |
||
132 |
/*! |
|
133 |
* Private slot |
|
134 |
* |
|
135 |
*/ |
|
136 |
void RadioStationsView::updateAntennaStatus( bool connected ) |
|
137 |
{ |
|
138 |
Q_UNUSED( connected ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
139 |
updateVisibilities(); |
24 | 140 |
} |
141 |
||
142 |
/*! |
|
143 |
* Private slot |
|
144 |
* |
|
145 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
146 |
void RadioStationsView::updateViewMode() |
24 | 147 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
148 |
QString section = DOCML::SV_SECTION_SHOW_ALL_STATIONS; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
149 |
QString filter = REGEX_SHOW_ALL; |
24 | 150 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
151 |
if ( sender() == mFavoritesButton ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
152 |
section = DOCML::SV_SECTION_SHOW_FAVORITES; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
153 |
filter = REGEX_SHOW_FAVORITES; |
24 | 154 |
} |
155 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
156 |
loadSection( DOCML::FILE_STATIONSVIEW, section ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
157 |
mFilterModel->setFilterRegExp( filter ); |
24 | 158 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
159 |
updateVisibilities(); |
24 | 160 |
} |
161 |
||
162 |
/*! |
|
163 |
* Private slot |
|
164 |
* |
|
165 |
*/ |
|
166 |
void RadioStationsView::startScanning() |
|
167 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
168 |
const int rowCount = mUiEngine->stationModel().rowCount(); |
24 | 169 |
mCurrentQuestion = StartScanning; |
170 |
if ( rowCount > 0 ) { |
|
171 |
askQuestion( hbTrId( "txt_rad_info_all_stations_in_stations_list_will_be" ) ); |
|
172 |
} else { |
|
173 |
userAccepted(); |
|
174 |
} |
|
175 |
} |
|
176 |
||
177 |
/*! |
|
178 |
* Private slot |
|
179 |
* |
|
180 |
*/ |
|
181 |
void RadioStationsView::finishScanning() |
|
182 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
183 |
updateVisibilities(); |
24 | 184 |
mFrequencyScanner.take(); |
185 |
} |
|
186 |
||
187 |
/*! |
|
188 |
* Private slot |
|
189 |
* |
|
190 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
191 |
void RadioStationsView::updateVisibilities() |
24 | 192 |
{ |
193 |
LOG_SLOT_CALLER; |
|
194 |
bool listEmpty = mModel->rowCount() == 0; |
|
195 |
const bool localStationsMode = !mFavoritesButton->isChecked(); |
|
196 |
||
197 |
if ( !localStationsMode ) { |
|
198 |
listEmpty = mModel->favoriteCount() == 0; |
|
199 |
} |
|
200 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
201 |
mClearListAction->setEnabled( !listEmpty ); |
24 | 202 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
203 |
const bool scanAvailable = mUiEngine->isAntennaAttached() && localStationsMode; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
204 |
mScanStationsAction->setEnabled( scanAvailable ); |
24 | 205 |
HbPushButton* scanButton = mUiLoader->findWidget<HbPushButton>( DOCML::SV_NAME_SCAN_BUTTON ); |
206 |
scanButton->setEnabled( scanAvailable ); |
|
207 |
||
208 |
loadSection( DOCML::FILE_STATIONSVIEW, listEmpty ? DOCML::SV_SECTION_SHOW_SCAN_TEXT : DOCML::SV_SECTION_HIDE_SCAN_TEXT ); |
|
209 |
} |
|
210 |
||
211 |
/*! |
|
212 |
* Private slot |
|
213 |
* |
|
214 |
*/ |
|
215 |
void RadioStationsView::clearList() |
|
216 |
{ |
|
217 |
const bool favoriteMode = mFavoritesButton->isChecked(); |
|
218 |
mCurrentQuestion = ClearList; |
|
219 |
askQuestion( hbTrId( favoriteMode ? "txt_rad_info_clear_favourite_stations_list" |
|
220 |
: "txt_rad_info_clear_all_stations_list" ) ); |
|
221 |
} |
|
222 |
||
223 |
/*! |
|
224 |
* Private slot |
|
225 |
* |
|
226 |
*/ |
|
227 |
void RadioStationsView::rename() |
|
228 |
{ |
|
229 |
HbInputDialog* nameQuery = new HbInputDialog(); |
|
230 |
nameQuery->setAttribute( Qt::WA_DeleteOnClose, true ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
231 |
nameQuery->setDismissPolicy( HbDialog::TapOutside ); |
24 | 232 |
nameQuery->setPromptText( hbTrId( "txt_rad_dialog_new_name" ) ); |
233 |
nameQuery->setInputMode( HbInputDialog::TextInput ); |
|
234 |
nameQuery->setValue( mSelectedStation->name() ); |
|
235 |
nameQuery->setObjectName( DOCML::NAME_INPUT_QUERY ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
236 |
nameQuery->open( this, SLOT(renameDone(HbAction*)) ); |
24 | 237 |
} |
238 |
||
239 |
/*! |
|
240 |
* Private slot |
|
241 |
* |
|
242 |
*/ |
|
243 |
void RadioStationsView::toggleFavorite() |
|
244 |
{ |
|
245 |
mModel->setFavoriteByPreset( mSelectedStation->presetIndex(), !mSelectedStation->isFavorite() ); |
|
246 |
} |
|
247 |
||
248 |
/*! |
|
249 |
* Private slot |
|
250 |
* |
|
251 |
*/ |
|
252 |
void RadioStationsView::deleteStation() |
|
253 |
{ |
|
254 |
mCurrentQuestion = DeleteStation; |
|
255 |
askQuestion( hbTrId( "txt_rad_menu_delete_station" ) ); |
|
256 |
} |
|
257 |
||
258 |
/*! |
|
259 |
* Private slot |
|
260 |
* |
|
261 |
*/ |
|
262 |
void RadioStationsView::renameDone( HbAction* action ) |
|
263 |
{ |
|
264 |
HbInputDialog* dlg = static_cast<HbInputDialog*>( sender() ); |
|
265 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
266 |
if( action ) { |
24 | 267 |
mModel->renameStation( mSelectedStation->presetIndex(), dlg->value().toString() ); |
268 |
} |
|
269 |
} |
|
270 |
||
271 |
/*! |
|
272 |
* From RadioViewBase |
|
273 |
* |
|
274 |
*/ |
|
275 |
void RadioStationsView::init() |
|
276 |
{ |
|
277 |
LOG_METHOD; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
278 |
mModel = &mUiEngine->stationModel(); |
24 | 279 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
280 |
mFilterModel = new QSortFilterProxyModel( this ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
281 |
mFilterModel->setDynamicSortFilter( true ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
282 |
mFilterModel->setFilterRole( RadioRole::IsFavoriteRole ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
283 |
mFilterModel->setSourceModel( &mUiEngine->stationModel() ); |
24 | 284 |
|
285 |
loadSection( DOCML::FILE_STATIONSVIEW, DOCML::SV_SECTION_SHOW_ALL_STATIONS ); |
|
286 |
||
287 |
if ( !mFavoriteIcon.isNull() && !mNowPlayingIcon.isNull() ) { |
|
288 |
mModel->setIcons( mFavoriteIcon.qicon(), mNowPlayingIcon.qicon() ); |
|
289 |
} |
|
290 |
mModel->setDetail( RadioStationModel::ShowIcons | RadioStationModel::ShowGenre ); |
|
291 |
||
292 |
mStationsList = mUiLoader->findObject<HbListView>( DOCML::SV_NAME_STATIONS_LIST ); |
|
293 |
mFavoritesButton = mUiLoader->findObject<HbAction>( DOCML::SV_NAME_FAVORITES_BUTTON ); |
|
294 |
mLocalStationsButton = mUiLoader->findObject<HbAction>( DOCML::SV_NAME_LOCALS_BUTTON ); |
|
295 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
296 |
Radio::connect( mUiEngine.data(), SIGNAL(antennaStatusChanged(bool)), |
24 | 297 |
this, SLOT(updateAntennaStatus(bool)) ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
298 |
Radio::connect( mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
299 |
this, SLOT(updateVisibilities()) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
300 |
Radio::connect( mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
301 |
this, SLOT(updateVisibilities()) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
302 |
Radio::connect( mModel, SIGNAL(modelReset()), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
303 |
this, SLOT(updateVisibilities()) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
304 |
Radio::connect( mFavoritesButton, SIGNAL(triggered()), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
305 |
this, SLOT(updateViewMode()) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
306 |
Radio::connect( mLocalStationsButton, SIGNAL(triggered() ), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
307 |
this, SLOT(updateViewMode()) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
308 |
Radio::connect( mStationsList, SIGNAL(activated(QModelIndex)), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
309 |
this, SLOT(handleClick(QModelIndex)) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
310 |
Radio::connect( mStationsList, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
311 |
this, SLOT(handleLongPress(HbAbstractViewItem*,QPointF)) ); |
24 | 312 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
313 |
connectCommonMenuItem( MenuItem::Exit ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
314 |
connectXmlElement( DOCML::SV_NAME_SCAN_BUTTON, SIGNAL(clicked()), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
315 |
this, SLOT(startScanning()) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
316 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
317 |
// Context menu actions |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
318 |
connectXmlElement( DOCML::SV_NAME_RENAME_ACTION, SIGNAL(triggered()), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
319 |
this, SLOT(rename()) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
320 |
connectXmlElement( DOCML::SV_NAME_FAVORITE_ACTION, SIGNAL(triggered()), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
321 |
this, SLOT(toggleFavorite()) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
322 |
connectXmlElement( DOCML::SV_NAME_DELETE_ACTION, SIGNAL(triggered()), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
323 |
this, SLOT(deleteStation()) ); |
24 | 324 |
|
325 |
// "Scan local stations" menu item |
|
326 |
mScanStationsAction = mUiLoader->findObject<HbAction>( DOCML::SV_NAME_SCAN_ACTION ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
327 |
Radio::connect( mScanStationsAction, SIGNAL(triggered() ), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
328 |
this, SLOT(startScanning() ) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
329 |
|
24 | 330 |
// "Remove all presets" menu item |
331 |
mClearListAction = mUiLoader->findObject<HbAction>( DOCML::SV_NAME_CLEAR_LIST_ACTION ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
332 |
Radio::connect( mClearListAction, SIGNAL(triggered() ), |
24 | 333 |
this, SLOT(clearList() ) ); |
334 |
||
335 |
connectCommonMenuItem( MenuItem::UseLoudspeaker ); |
|
336 |
||
337 |
initListView(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
338 |
|
24 | 339 |
initBackAction(); |
340 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
341 |
updateViewMode(); |
24 | 342 |
} |
343 |
||
344 |
/*! |
|
345 |
* \reimp |
|
346 |
*/ |
|
347 |
void RadioStationsView::userAccepted() |
|
348 |
{ |
|
349 |
if ( mCurrentQuestion == StartScanning ) { |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
350 |
mFrequencyScanner.reset( new RadioFrequencyScanner( *mUiEngine, this ) ); |
24 | 351 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
352 |
Radio::connect( mFrequencyScanner.data(), SIGNAL(frequencyScannerFinished()), |
24 | 353 |
this, SLOT(finishScanning()) ); |
354 |
||
355 |
mFrequencyScanner->startScanning(); |
|
356 |
} else if ( mCurrentQuestion == ClearList ){ |
|
357 |
const bool favoriteMode = mFavoritesButton->isChecked(); |
|
358 |
mModel->removeAll( favoriteMode ? RadioStationModel::RemoveFavorites : RadioStationModel::RemoveAll ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
359 |
updateVisibilities(); |
24 | 360 |
} else if ( mCurrentQuestion == DeleteStation ) { |
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
361 |
mModel->removeStation( *mSelectedStation ); |
24 | 362 |
} |
363 |
||
364 |
mCurrentQuestion = NoQuestion; |
|
365 |
} |
|
366 |
||
367 |
/*! |
|
368 |
* |
|
369 |
*/ |
|
370 |
void RadioStationsView::initListView() |
|
371 |
{ |
|
372 |
mStationsList->setScrollingStyle( HbListView::PanOrFlick ); |
|
373 |
mStationsList->setModel( mFilterModel ); |
|
374 |
mStationsList->setSelectionMode( HbListView::NoSelection ); |
|
375 |
mStationsList->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
|
376 |
} |