|
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 #include <HbAbstractViewItem> |
|
22 #include <HbMenu> |
|
23 #include <HbMessageBox> |
|
24 |
|
25 // User includes |
|
26 #include "radiohistoryview.h" |
|
27 #include "radiomainwindow.h" |
|
28 #include "radiologger.h" |
|
29 #include "radioxmluiloader.h" |
|
30 #include "radiouiengine.h" |
|
31 #include "radiostationfiltermodel.h" |
|
32 #include "radiohistorymodel.h" |
|
33 |
|
34 /*! |
|
35 * |
|
36 */ |
|
37 RadioHistoryView::RadioHistoryView() : |
|
38 RadioViewBase(), |
|
39 mHistoryList( 0 ), |
|
40 mAllSongsButton( 0 ), |
|
41 mTaggedSongsButton( 0 ), |
|
42 mFilterModel( 0 ) |
|
43 { |
|
44 } |
|
45 |
|
46 /*! |
|
47 * Private slot |
|
48 * |
|
49 */ |
|
50 void RadioHistoryView::deckButtonPressed() |
|
51 { |
|
52 if ( sender() == mTaggedSongsButton ) { |
|
53 loadSection( DOCML::FILE_HISTORYVIEW, DOCML::HV_SECTION_FAVORITE_MODE ); |
|
54 } else { |
|
55 loadSection( DOCML::FILE_HISTORYVIEW, DOCML::HV_SECTION_HISTORY_MODE ); |
|
56 } |
|
57 |
|
58 const bool showFavorites = mTaggedSongsButton->isChecked(); |
|
59 // mFilterModel->setTypeFilter( showFavorites ? RadioStation::Favorite |
|
60 // : RadioStation::LocalStation ); |
|
61 |
|
62 updateVisibilities(); |
|
63 } |
|
64 |
|
65 /*! |
|
66 * Private slot |
|
67 * |
|
68 */ |
|
69 void RadioHistoryView::clearList() |
|
70 { |
|
71 const bool answer = HbMessageBox::question( hbTrId( "txt_rad_info_clear_recently_played_songs_list" ) ); |
|
72 |
|
73 if ( answer ) { |
|
74 mMainWindow->uiEngine().historyModel().removeAll(); |
|
75 updateVisibilities(); |
|
76 } |
|
77 } |
|
78 |
|
79 /*! |
|
80 * Private slot |
|
81 * |
|
82 */ |
|
83 void RadioHistoryView::updateVisibilities() |
|
84 { |
|
85 const int itemCount = mMainWindow->uiEngine().historyModel().rowCount(); |
|
86 loadSection( DOCML::FILE_HISTORYVIEW, itemCount ? DOCML::HV_SECTION_SHOW_LIST : DOCML::HV_SECTION_HIDE_LIST ); |
|
87 } |
|
88 |
|
89 /*! |
|
90 * Private slot |
|
91 * |
|
92 */ |
|
93 void RadioHistoryView::listItemClicked( const QModelIndex& index ) |
|
94 { |
|
95 showContextMenu( index ); |
|
96 } |
|
97 |
|
98 /*! |
|
99 * Private slot |
|
100 * |
|
101 */ |
|
102 void RadioHistoryView::listItemLongPressed( HbAbstractViewItem* item, const QPointF& coords ) |
|
103 { |
|
104 Q_UNUSED( coords ); |
|
105 showContextMenu( item->modelIndex() ); |
|
106 } |
|
107 |
|
108 /*! |
|
109 * \reimp |
|
110 * |
|
111 */ |
|
112 void RadioHistoryView::init( RadioXmlUiLoader* uiLoader, RadioMainWindow* mainWindow ) |
|
113 { |
|
114 LOG_METHOD; |
|
115 mUiLoader.reset( uiLoader ); |
|
116 mMainWindow = mainWindow; |
|
117 |
|
118 RadioHistoryModel* historyModel = &mMainWindow->uiEngine().historyModel(); |
|
119 historyModel->setShowDetails( mOrientation == Qt::Horizontal ); |
|
120 |
|
121 mHistoryList = mUiLoader->findObject<HbListView>( DOCML::HV_NAME_HISTORY_LIST ); |
|
122 mHistoryList->setScrollingStyle( HbListView::PanOrFlick ); |
|
123 mFilterModel = mMainWindow->uiEngine().createNewFilterModel( this ); |
|
124 mFilterModel->setSourceModel( historyModel ); |
|
125 mHistoryList->setModel( mFilterModel ); |
|
126 mHistoryList->setSelectionMode( HbListView::NoSelection ); |
|
127 mHistoryList->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
|
128 |
|
129 mAllSongsButton = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_ALL_SONGS_BUTTON ); |
|
130 mTaggedSongsButton = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_TAGGED_SONGS_BUTTON ); |
|
131 |
|
132 HbAction* clearListAction = mUiLoader->findObject<HbAction>( DOCML::HV_NAME_CLEAR_LIST_ACTION ); |
|
133 connectAndTest( clearListAction, SIGNAL(triggered()), this, SLOT(clearList()) ); |
|
134 |
|
135 connectAndTest( mTaggedSongsButton, SIGNAL(triggered() ), |
|
136 this, SLOT(deckButtonPressed() ) ); |
|
137 connectAndTest( mAllSongsButton, SIGNAL(triggered() ), |
|
138 this, SLOT(deckButtonPressed() ) ); |
|
139 connectAndTest( historyModel, SIGNAL(itemAdded() ), |
|
140 this, SLOT(updateVisibilities() ) ); |
|
141 updateVisibilities(); |
|
142 |
|
143 initBackAction(); |
|
144 } |
|
145 |
|
146 /*! |
|
147 * \reimp |
|
148 * |
|
149 */ |
|
150 void RadioHistoryView::setOrientation() |
|
151 { |
|
152 RadioHistoryModel& model = mMainWindow->uiEngine().historyModel(); |
|
153 model.setShowDetails( mOrientation == Qt::Horizontal ); |
|
154 } |
|
155 |
|
156 /*! |
|
157 * \reimp |
|
158 * |
|
159 */ |
|
160 void RadioHistoryView::showContextMenu( const QModelIndex& index ) |
|
161 { |
|
162 QModelIndex sourceIndex = mFilterModel->mapToSource( index ); |
|
163 |
|
164 HbMenu* menu = new HbMenu(); |
|
165 HbAction* action = menu->addAction( "Set favorite" ); |
|
166 menu->exec(); |
|
167 |
|
168 // RadioHistoryItem item = mFilterModel->data( index, ) |
|
169 } |