22 #include <HbMenu> |
22 #include <HbMenu> |
23 #include <HbMessageBox> |
23 #include <HbMessageBox> |
24 |
24 |
25 // User includes |
25 // User includes |
26 #include "radiohistoryview.h" |
26 #include "radiohistoryview.h" |
27 #include "radiomainwindow.h" |
27 #include "radiowindow.h" |
28 #include "radiologger.h" |
28 #include "radiologger.h" |
29 #include "radioxmluiloader.h" |
29 #include "radiouiloader.h" |
30 #include "radiouiengine.h" |
30 #include "radiouiengine.h" |
31 #include "radiostationfiltermodel.h" |
|
32 #include "radiohistorymodel.h" |
31 #include "radiohistorymodel.h" |
|
32 #include "radiohistoryitem.h" |
|
33 |
|
34 // BEGIN TEMPORARY TEST CODE CODE |
|
35 #include <QTimer> |
|
36 #include "radiostationmodel.h" |
|
37 |
|
38 struct Song |
|
39 { |
|
40 const char* mArtist; |
|
41 const char* mTitle; |
|
42 }; |
|
43 const Song KRecognizedSongs[] = { |
|
44 { "Red Hot Chili Peppers", "Under The Bridge" }, |
|
45 { "Queens Of The Stone Age", "No One Knows" }, |
|
46 { "The Presidents of the United States of America", "Dune Buggy" }, |
|
47 { "System of a Down", "Aerials" }, |
|
48 { "The White Stripes", "Seven Nation Army" }, |
|
49 { "Alice In Chains", "When The Sun Rose Again" }, |
|
50 { "Bullet For My Valentine", "Tears Don't Fall" } |
|
51 }; |
|
52 const int KSongsCount = sizeof( KRecognizedSongs ) / sizeof( KRecognizedSongs[0] ); |
|
53 // END TEMPORARY TEST CODE CODE |
33 |
54 |
34 /*! |
55 /*! |
35 * |
56 * |
36 */ |
57 */ |
37 RadioHistoryView::RadioHistoryView() : |
58 RadioHistoryView::RadioHistoryView() : |
38 RadioViewBase(), |
59 RadioViewBase( false ), |
39 mHistoryList( 0 ), |
60 mHistoryList( 0 ), |
40 mAllSongsButton( 0 ), |
61 mAllSongsButton( 0 ), |
41 mTaggedSongsButton( 0 ), |
62 mTaggedSongsButton( 0 ), |
42 mFilterModel( 0 ) |
63 mSelectedItem( new RadioHistoryItem() ), |
43 { |
64 mCurrentRow( -1 ), |
|
65 mSongIndex( 0 ) |
|
66 { |
|
67 } |
|
68 |
|
69 /*! |
|
70 * |
|
71 */ |
|
72 RadioHistoryView::~RadioHistoryView() |
|
73 { |
|
74 } |
|
75 |
|
76 /*! |
|
77 * |
|
78 */ |
|
79 void RadioHistoryView::setNonTaggedIcon( const HbIcon& nonTaggedIcon ) |
|
80 { |
|
81 mNonTaggedIcon = nonTaggedIcon; |
|
82 mNonTaggedIcon.setColor( Qt::white ); |
|
83 } |
|
84 |
|
85 /*! |
|
86 * |
|
87 */ |
|
88 HbIcon RadioHistoryView::nonTaggedIcon() const |
|
89 { |
|
90 return mNonTaggedIcon; |
|
91 } |
|
92 |
|
93 /*! |
|
94 * |
|
95 */ |
|
96 void RadioHistoryView::setTaggedIcon( const HbIcon& taggedIcon ) |
|
97 { |
|
98 mTaggedIcon = taggedIcon; |
|
99 } |
|
100 |
|
101 /*! |
|
102 * |
|
103 */ |
|
104 HbIcon RadioHistoryView::taggedIcon() const |
|
105 { |
|
106 return mTaggedIcon; |
44 } |
107 } |
45 |
108 |
46 /*! |
109 /*! |
47 * Private slot |
110 * Private slot |
48 * |
111 * |
88 |
147 |
89 /*! |
148 /*! |
90 * Private slot |
149 * Private slot |
91 * |
150 * |
92 */ |
151 */ |
93 void RadioHistoryView::listItemClicked( const QModelIndex& index ) |
152 void RadioHistoryView::showContextMenu( const QModelIndex& index ) |
94 { |
153 { |
95 showContextMenu( index ); |
154 *mSelectedItem = historyModel().itemAtIndex( index ); |
96 } |
155 mCurrentRow = index.row(); |
97 |
156 |
98 /*! |
157 HbMenu* menu = mUiLoader->findObject<HbMenu>( DOCML::HV_NAME_CONTEXT_MENU ); |
99 * Private slot |
158 |
100 * |
159 if ( HbAction* tagAction = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_CONTEXT_TAG ) ) { |
101 */ |
160 if ( mSelectedItem->isTagged() ) { |
102 void RadioHistoryView::listItemLongPressed( HbAbstractViewItem* item, const QPointF& coords ) |
161 tagAction->setText( hbTrId( "txt_rad_menu_remove_tag" ) ); |
103 { |
162 } else { |
104 Q_UNUSED( coords ); |
163 tagAction->setText( hbTrId( "txt_rad_menu_tag_song" ) ); |
105 showContextMenu( item->modelIndex() ); |
164 } |
|
165 } |
|
166 |
|
167 if ( HbAction* searchAction = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_CONTEXT_SEARCH ) ) { |
|
168 //TODO: Check if "search from other store" should be available |
|
169 searchAction->setVisible( false ); |
|
170 } |
|
171 |
|
172 HbAbstractViewItem* item = mHistoryList->itemByIndex( index ); |
|
173 QPointF coords = item->pos(); |
|
174 coords.setY( mHistoryList->contentWidget()->pos().y() + coords.y() ); |
|
175 menu->setPreferredPos( QPointF( size().width() / 2 - menu->size().width() / 2, coords.y() + menu->size().height() / 2 ) ); |
|
176 |
|
177 menu->show(); |
|
178 } |
|
179 |
|
180 /*! |
|
181 * Private slot |
|
182 * |
|
183 */ |
|
184 void RadioHistoryView::toggleTagging() |
|
185 { |
|
186 historyModel().toggleTagging( *mSelectedItem, mCurrentRow ); |
|
187 mSelectedItem->reset(); |
|
188 mCurrentRow = -1; |
|
189 } |
|
190 |
|
191 /*! |
|
192 * Private slot |
|
193 * |
|
194 */ |
|
195 void RadioHistoryView::openOviStore() |
|
196 { |
|
197 QString msg = "To be implemented: Open ovi store. Artist: %1, Title: %2"; |
|
198 HbMessageBox::information( msg.arg( mSelectedItem->artist() ).arg( mSelectedItem->title() ) ); |
|
199 mMainWindow->uiEngine().openMusicStore( *mSelectedItem ); |
|
200 } |
|
201 |
|
202 /*! |
|
203 * Private slot |
|
204 * |
|
205 */ |
|
206 void RadioHistoryView::openOtherStore() |
|
207 { |
|
208 QString msg = "To be implemented: Open other store. Artist: %1, Title: %2"; |
|
209 HbMessageBox::information( msg.arg( mSelectedItem->artist() ).arg( mSelectedItem->title() ) ); |
|
210 mMainWindow->uiEngine().openMusicStore( *mSelectedItem, RadioUiEngine::OtherStore ); |
|
211 } |
|
212 |
|
213 /*! |
|
214 * Private slot |
|
215 * TEMPORARY TEST CODE |
|
216 */ |
|
217 void RadioHistoryView::addSongs() |
|
218 { |
|
219 for ( int i = 0; i < KSongsCount; ++i ) { |
|
220 QTimer::singleShot( 1000 + i * 1500, this, SLOT(addOneSong()) ); |
|
221 } |
|
222 } |
|
223 |
|
224 /*! |
|
225 * Private slot |
|
226 * TEMPORARY TEST CODE |
|
227 */ |
|
228 void RadioHistoryView::addOneSong() |
|
229 { |
|
230 Song song = KRecognizedSongs[mSongIndex++]; |
|
231 mSongIndex %= KSongsCount; |
|
232 |
|
233 RadioStation station = mMainWindow->uiEngine().stationModel().currentStation(); |
|
234 mMainWindow->uiEngine().historyModel().addItem( song.mArtist, song.mTitle, station ); |
106 } |
235 } |
107 |
236 |
108 /*! |
237 /*! |
109 * \reimp |
238 * \reimp |
110 * |
239 * |
111 */ |
240 */ |
112 void RadioHistoryView::init( RadioXmlUiLoader* uiLoader, RadioMainWindow* mainWindow ) |
241 void RadioHistoryView::init() |
113 { |
242 { |
114 LOG_METHOD; |
243 LOG_METHOD; |
115 mUiLoader.reset( uiLoader ); |
244 mInitialized = true; |
116 mMainWindow = mainWindow; |
|
117 |
245 |
118 RadioHistoryModel* historyModel = &mMainWindow->uiEngine().historyModel(); |
246 RadioHistoryModel* historyModel = &mMainWindow->uiEngine().historyModel(); |
119 historyModel->setShowDetails( mOrientation == Qt::Horizontal ); |
247 historyModel->setShowDetails( mOrientation == Qt::Horizontal ); |
120 |
248 |
|
249 if ( !mNonTaggedIcon.isNull() && !mTaggedIcon.isNull() ) { |
|
250 historyModel->setIcons( mNonTaggedIcon.qicon(), mTaggedIcon.qicon() ); |
|
251 } |
|
252 |
121 mHistoryList = mUiLoader->findObject<HbListView>( DOCML::HV_NAME_HISTORY_LIST ); |
253 mHistoryList = mUiLoader->findObject<HbListView>( DOCML::HV_NAME_HISTORY_LIST ); |
122 mHistoryList->setScrollingStyle( HbListView::PanOrFlick ); |
254 mHistoryList->setScrollingStyle( HbListView::PanOrFlick ); |
123 mFilterModel = mMainWindow->uiEngine().createNewFilterModel( this ); |
255 mHistoryList->setModel( historyModel ); |
124 mFilterModel->setSourceModel( historyModel ); |
|
125 mHistoryList->setModel( mFilterModel ); |
|
126 mHistoryList->setSelectionMode( HbListView::NoSelection ); |
256 mHistoryList->setSelectionMode( HbListView::NoSelection ); |
127 mHistoryList->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
257 mHistoryList->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
128 |
258 |
129 mAllSongsButton = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_ALL_SONGS_BUTTON ); |
259 mAllSongsButton = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_ALL_SONGS_BUTTON ); |
130 mTaggedSongsButton = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_TAGGED_SONGS_BUTTON ); |
260 mTaggedSongsButton = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_TAGGED_SONGS_BUTTON ); |
131 |
261 |
132 HbAction* clearListAction = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_CLEAR_LIST_ACTION ); |
262 if ( HbAction* clearListAction = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_CLEAR_LIST_ACTION ) ) { |
133 connectAndTest( clearListAction, SIGNAL(triggered()), this, SLOT(clearList()) ); |
263 connectAndTest( clearListAction, SIGNAL(triggered()), |
|
264 this, SLOT(clearList()) ); |
|
265 } |
134 |
266 |
135 connectAndTest( mTaggedSongsButton, SIGNAL(triggered() ), |
267 connectAndTest( mTaggedSongsButton, SIGNAL(triggered() ), |
136 this, SLOT(deckButtonPressed() ) ); |
268 this, SLOT(deckButtonPressed() ) ); |
137 connectAndTest( mAllSongsButton, SIGNAL(triggered() ), |
269 connectAndTest( mAllSongsButton, SIGNAL(triggered() ), |
138 this, SLOT(deckButtonPressed() ) ); |
270 this, SLOT(deckButtonPressed() ) ); |
139 connectAndTest( historyModel, SIGNAL(itemAdded() ), |
271 connectAndTest( historyModel, SIGNAL(itemAdded() ), |
140 this, SLOT(updateVisibilities() ) ); |
272 this, SLOT(updateVisibilities() ) ); |
|
273 |
|
274 loadSection( DOCML::FILE_HISTORYVIEW, DOCML::HV_SECTION_HISTORY_MODE ); |
141 updateVisibilities(); |
275 updateVisibilities(); |
142 |
276 |
|
277 connectCommonMenuItem( MenuItem::UseLoudspeaker ); |
|
278 |
143 initBackAction(); |
279 initBackAction(); |
|
280 |
|
281 // BEGIN TEMPORARY TEST CODE |
|
282 if ( HbAction* addSongsAction = mUiLoader->findObject<HbAction>( "hv:add_songs_action" ) ) { |
|
283 connectAndTest( addSongsAction, SIGNAL(triggered()), |
|
284 this, SLOT(addSongs()) ); |
|
285 } |
|
286 // END TEMPORARY TEST CODE |
144 } |
287 } |
145 |
288 |
146 /*! |
289 /*! |
147 * \reimp |
290 * \reimp |
148 * |
291 * |