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 <HbAction> |
|
21 |
|
22 // User includes |
|
23 #include "radiowizardview.h" |
|
24 #include "radiobannerlabel.h" |
|
25 #include "radiomainwindow.h" |
|
26 #include "radiouiengine.h" |
|
27 #include "radiolocalization.h" |
|
28 #include "radiologger.h" |
|
29 #include "radiostationmodel.h" |
|
30 #include "radiofrequencyscanner.h" |
|
31 #include "radioxmluiloader.h" |
|
32 |
|
33 /*! |
|
34 * |
|
35 */ |
|
36 RadioWizardView::RadioWizardView( RadioXmlUiLoader* uiLoader ) : |
|
37 RadioViewBase( uiLoader ), |
|
38 mBannerLabel( 0 ), |
|
39 mStartScanningRequested( false ) |
|
40 { |
|
41 } |
|
42 |
|
43 /*! |
|
44 * Private slot |
|
45 * |
|
46 */ |
|
47 void RadioWizardView::engineStatusChanged( bool radioIsOn ) |
|
48 { |
|
49 if ( radioIsOn ) |
|
50 { |
|
51 LOG("Starting scanning after engine started up"); |
|
52 disconnect( &mMainWindow->uiEngine(), SIGNAL(radioStatusChanged(bool)), this, SLOT(engineStatusChanged(bool)) ); |
|
53 startScanning(); |
|
54 } |
|
55 } |
|
56 |
|
57 /*! |
|
58 * Private slot |
|
59 * |
|
60 */ |
|
61 void RadioWizardView::saveSelectedAsFavorites() |
|
62 { |
|
63 mModel->setFavorites( mList->selectionModel()->selectedIndexes() ); |
|
64 mMainWindow->activateTuningView(); |
|
65 } |
|
66 |
|
67 /*! |
|
68 * Private slot |
|
69 * |
|
70 */ |
|
71 void RadioWizardView::listItemClicked( const QModelIndex& index ) |
|
72 { |
|
73 RadioStation station = mModel->stationAt( index.row() ); |
|
74 RADIO_ASSERT( station.isValid() , "FMRadio", "invalid RadioStation"); |
|
75 |
|
76 LOG_FORMAT( "RadioWizardView::setFrequency, selectedRow: %d", station.presetIndex() ); |
|
77 |
|
78 mMainWindow->uiEngine().tunePreset( station.presetIndex() ); |
|
79 } |
|
80 |
|
81 /*! |
|
82 * From RadioViewBase |
|
83 * |
|
84 */ |
|
85 void RadioWizardView::init( RadioMainWindow* aMainWindow, RadioStationModel* aModel ) |
|
86 { |
|
87 LOG_METHOD; |
|
88 mMainWindow = aMainWindow; |
|
89 mModel = aModel; |
|
90 mModel->setDetail( RadioStationModel::ShowGenre ); |
|
91 |
|
92 mBannerLabel = mUiLoader->findObject<RadioBannerLabel>( DOCML_NAME_WV_HEADINGBANNER ); |
|
93 mList = mUiLoader->findWidget<HbListView>( DOCML_NAME_WV_STATIONSLIST ); |
|
94 |
|
95 mList->setSelectionMode( HbListView::MultiSelection ); |
|
96 mList->setModel( mModel ); |
|
97 mList->setScrollingStyle( HbListView::PanOrFlick ); |
|
98 |
|
99 // "Go to stations view" menu item |
|
100 connectViewChangeMenuItem( DOCML_NAME_WV_STATIONSVIEWACTION, SLOT(activateStationsView()) ); |
|
101 |
|
102 setDoneAction(); |
|
103 } |
|
104 |
|
105 /*! |
|
106 * From QGraphicsWidget |
|
107 * |
|
108 */ |
|
109 void RadioWizardView::showEvent( QShowEvent* event ) |
|
110 { |
|
111 RadioViewBase::showEvent( event ); |
|
112 |
|
113 RadioUiEngine* engine = &mMainWindow->uiEngine(); |
|
114 if ( engine->isRadioOn() && !mStartScanningRequested ) |
|
115 { |
|
116 LOG("Engine was already running. Starting scanning immediately"); |
|
117 startScanning(); |
|
118 } |
|
119 else |
|
120 { |
|
121 connectAndTest( engine, SIGNAL(radioStatusChanged(bool)), this, SLOT(engineStatusChanged(bool)) ); |
|
122 } |
|
123 } |
|
124 |
|
125 /*! |
|
126 * |
|
127 */ |
|
128 void RadioWizardView::setDoneAction() |
|
129 { |
|
130 // The default back button activates the tuning view |
|
131 HbAction* doneAction = new HbAction( Hb::DoneNaviAction, this ); |
|
132 connectAndTest( doneAction, SIGNAL(triggered()), |
|
133 this, SLOT(saveSelectedAsFavorites()) ); |
|
134 setNavigationAction( doneAction ); |
|
135 } |
|
136 |
|
137 /*! |
|
138 * |
|
139 */ |
|
140 void RadioWizardView::startScanning() |
|
141 { |
|
142 if ( !mStartScanningRequested ) { |
|
143 mStartScanningRequested = true; |
|
144 RadioFrequencyScanner* scanner = new RadioFrequencyScanner( mMainWindow->uiEngine(), this ); |
|
145 scanner->startScanning(); |
|
146 } |
|
147 } |
|