author | hgs |
Fri, 06 Aug 2010 09:29:48 +0300 | |
changeset 39 | ac7857bd5fdb |
parent 38 | f8c3d4e6102c |
child 47 | 74b7c6e79031 |
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 |
||
39 | 20 |
// User includes |
24 | 21 |
#include "radiofrequencystrip.h" |
22 |
#include "radiouiengine.h" |
|
23 |
#include "radiostation.h" |
|
24 |
#include "radiostationmodel.h" |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
25 |
#include "radioutil.h" |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
26 |
#include "radiouiloader.h" |
24 | 27 |
#include "radiologger.h" |
28 |
||
29 |
RadioFrequencyStrip::RadioFrequencyStrip() : |
|
39 | 30 |
RadioFrequencyStripBase(), |
31 |
mUiEngine( NULL ) |
|
24 | 32 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
33 |
RadioUtil::setFrequencyStrip( this ); |
24 | 34 |
} |
35 |
||
36 |
/*! |
|
37 |
* |
|
38 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
39 |
void RadioFrequencyStrip::init( RadioUiEngine* engine, RadioUiLoader& uiLoader ) |
24 | 40 |
{ |
41 |
mUiEngine = engine; |
|
39 | 42 |
initbase( mUiEngine->minFrequency(), mUiEngine->maxFrequency(), |
43 |
mUiEngine->frequencyStepSize(), RadioUiEngine::lastTunedFrequency() ); |
|
24 | 44 |
|
39 | 45 |
createButtonsFromDocml( uiLoader, DOCML::MV_NAME_PREV_BUTTON, DOCML::MV_NAME_NEXT_BUTTON ); |
24 | 46 |
|
47 |
RadioStationModel* stationModel = &mUiEngine->stationModel(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
48 |
Radio::connect( stationModel, SIGNAL(rowsInserted(QModelIndex,int,int)), |
24 | 49 |
this, SLOT(updateStation(QModelIndex,int,int)) ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
50 |
Radio::connect( stationModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
51 |
this, SLOT(removeStation(QModelIndex,int,int)) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
52 |
Radio::connect( stationModel, SIGNAL(modelReset()), |
24 | 53 |
this, SLOT(initEmptyItems()) ); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
54 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
55 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
56 |
/*! |
24 | 57 |
* |
58 |
*/ |
|
39 | 59 |
void RadioFrequencyStrip::setFrequency( const uint newFrequency, int reason, Scroll::Direction direction ) |
24 | 60 |
{ |
39 | 61 |
Q_UNUSED( reason ); |
62 |
if ( newFrequency != frequency() || reason == TuneReason::Skip ) { |
|
63 |
RadioFrequencyStripBase::setFrequency( newFrequency, reason, direction ); |
|
24 | 64 |
} |
65 |
} |
|
66 |
||
67 |
/*! |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
68 |
* \reimp |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
69 |
*/ |
39 | 70 |
bool RadioFrequencyStrip::isInitialized() const |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
71 |
{ |
39 | 72 |
return mUiEngine != NULL; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
73 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
74 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
75 |
/*! |
39 | 76 |
* \reimp |
24 | 77 |
*/ |
39 | 78 |
QList<FrequencyStrip::StationMarker> RadioFrequencyStrip::stationsInRange( uint minFrequency, uint maxFrequency ) const |
24 | 79 |
{ |
39 | 80 |
QList<RadioStation> stations = mUiEngine->stationsInRange( minFrequency, maxFrequency ); |
81 |
QList<FrequencyStrip::StationMarker> markers; |
|
82 |
foreach ( const RadioStation& station, stations ) { |
|
83 |
markers.append( FrequencyStrip::StationMarker( station.frequency(), station.isFavorite() ) ); |
|
24 | 84 |
} |
39 | 85 |
return markers; |
24 | 86 |
} |
87 |
||
88 |
/*! |
|
39 | 89 |
* \reimp |
24 | 90 |
*/ |
39 | 91 |
void RadioFrequencyStrip::emitFrequencyChanged( uint frequency, int reason, int direction ) |
24 | 92 |
{ |
39 | 93 |
int tuneReason = TuneReason::Unspecified; |
94 |
if ( reason == FrequencyStrip::ManualSeekUpdate ) { |
|
95 |
tuneReason = TuneReason::ManualSeekUpdate; |
|
96 |
} else if ( reason == FrequencyStrip::ManualSeekTune ) { |
|
97 |
tuneReason = TuneReason::ManualSeekTune; |
|
24 | 98 |
} |
39 | 99 |
|
100 |
emit frequencyChanged( frequency, tuneReason, direction ); |
|
24 | 101 |
} |
102 |
||
103 |
/*! |
|
104 |
* |
|
105 |
*/ |
|
39 | 106 |
void RadioFrequencyStrip::skipToPrevious() |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
107 |
{ |
39 | 108 |
emit skipRequested( StationSkip::Previous ); |
24 | 109 |
} |
110 |
||
111 |
/*! |
|
112 |
* |
|
113 |
*/ |
|
39 | 114 |
void RadioFrequencyStrip::skipToPreviousFavorite() |
24 | 115 |
{ |
39 | 116 |
emit skipRequested( StationSkip::PreviousFavorite ); |
117 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
118 |
|
39 | 119 |
/*! |
120 |
* |
|
121 |
*/ |
|
122 |
void RadioFrequencyStrip::skipToNext() |
|
123 |
{ |
|
124 |
emit skipRequested( StationSkip::Next ); |
|
125 |
} |
|
24 | 126 |
|
39 | 127 |
/*! |
128 |
* |
|
129 |
*/ |
|
130 |
void RadioFrequencyStrip::skipToNextFavorite() |
|
131 |
{ |
|
132 |
emit skipRequested( StationSkip::NextFavorite ); |
|
24 | 133 |
} |
134 |
||
135 |
/*! |
|
136 |
* |
|
137 |
*/ |
|
39 | 138 |
void RadioFrequencyStrip::seekDown() |
34 | 139 |
{ |
39 | 140 |
emit seekRequested( Seek::Down ); |
34 | 141 |
} |
142 |
||
24 | 143 |
|
144 |
/*! |
|
145 |
* |
|
146 |
*/ |
|
39 | 147 |
void RadioFrequencyStrip::seekUp() |
24 | 148 |
{ |
39 | 149 |
emit seekRequested( Seek::Up ); |
24 | 150 |
} |
151 |
||
152 |
/*! |
|
39 | 153 |
* \reimp |
24 | 154 |
*/ |
39 | 155 |
bool RadioFrequencyStrip::isScanning() const |
24 | 156 |
{ |
39 | 157 |
return RadioUtil::scanStatus() == Scan::ScanningInMainView; |
24 | 158 |
} |
159 |
||
160 |
/*! |
|
39 | 161 |
* \reimp |
24 | 162 |
*/ |
39 | 163 |
uint RadioFrequencyStrip::frequencyAtIndex( int index ) const |
24 | 164 |
{ |
39 | 165 |
RadioStationModel& model = mUiEngine->stationModel(); |
166 |
return model.data( model.index( index, 0, QModelIndex() ), |
|
167 |
RadioRole::RadioStationRole ).value<RadioStation>().frequency(); |
|
24 | 168 |
} |