|
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: Music Player collection container definition - Artists. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtCore> |
|
19 |
|
20 #include <hbdocumentloader.h> |
|
21 #include <hblistview.h> |
|
22 #include <hbgroupbox.h> |
|
23 #include <hbindexfeedback.h> |
|
24 |
|
25 #include "mpcollectioncontainerartists.h" |
|
26 #include "mpmpxcollectiondata.h" |
|
27 #include "mptrace.h" |
|
28 |
|
29 /*! |
|
30 \class MpCollectionContainerArtists |
|
31 \brief Music Player collection container definition - Artists. |
|
32 |
|
33 'Artists' collection container implements the interface specified |
|
34 by MpCollectionContainer. It provides a layout and widgets for the |
|
35 'Artists' view. |
|
36 |
|
37 This container handles the following contexts: |
|
38 \li ECollectionContextArtists |
|
39 \li ECollectionContextArtistAlbums |
|
40 \li ECollectionContextArtistSongs |
|
41 |
|
42 \sa MpCollectionContainer |
|
43 */ |
|
44 |
|
45 /*! |
|
46 Constructs the collection container. |
|
47 */ |
|
48 MpCollectionContainerArtists::MpCollectionContainerArtists( HbDocumentLoader *loader, QGraphicsItem *parent ) |
|
49 : MpCollectionListContainer(loader, parent), |
|
50 mInfoBar(0) |
|
51 { |
|
52 TX_LOG |
|
53 } |
|
54 |
|
55 /*! |
|
56 Destructs the collection container. |
|
57 */ |
|
58 MpCollectionContainerArtists::~MpCollectionContainerArtists() |
|
59 { |
|
60 TX_ENTRY |
|
61 delete mInfoBar; |
|
62 delete mList; |
|
63 TX_EXIT |
|
64 } |
|
65 |
|
66 /*! |
|
67 Slot to be called when an item is selected by the user. |
|
68 */ |
|
69 void MpCollectionContainerArtists::itemActivated( const QModelIndex &index ) |
|
70 { |
|
71 int row = index.row(); |
|
72 TX_ENTRY_ARGS("index=" << row); |
|
73 |
|
74 if ( mCollectionContext == ECollectionContextArtists ) { |
|
75 mArtist = mCollectionData->itemData(row, MpMpxCollectionData::Title); |
|
76 if ( mArtist.isEmpty() ) { |
|
77 mArtist = hbTrId("txt_mus_subtitle_unknown"); |
|
78 } |
|
79 } |
|
80 else if ( mCollectionContext == ECollectionContextArtistAlbums ) { |
|
81 mAlbum = mCollectionData->itemData(row, MpMpxCollectionData::Title); |
|
82 if ( mAlbum.isEmpty() ) { |
|
83 mAlbum = hbTrId("txt_mus_dblist_val_unknown3"); |
|
84 } |
|
85 } |
|
86 MpCollectionListContainer::itemActivated(index); |
|
87 TX_EXIT |
|
88 } |
|
89 |
|
90 /*! |
|
91 Sets up the container by organizing widgets according to its layout. |
|
92 |
|
93 \reimp |
|
94 */ |
|
95 void MpCollectionContainerArtists::setupContainer() |
|
96 { |
|
97 TX_ENTRY_ARGS("mCollectionContext=" << mCollectionContext); |
|
98 if ( mCollectionData->count() ) { |
|
99 bool ok = false; |
|
100 QGraphicsWidget *widget; |
|
101 if ( mCollectionContext == ECollectionContextArtists ) { |
|
102 mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "artists", &ok); |
|
103 if ( !ok ) { |
|
104 TX_LOG_ARGS("Error: invalid xml file."); |
|
105 Q_ASSERT_X(ok, "MpCollectionContainerArtists::setupContainer", "invalid xml file"); |
|
106 } |
|
107 if ( !mList ) { |
|
108 widget = mDocumentLoader->findWidget(QString("artistsList")); |
|
109 mList = qobject_cast<HbListView*>(widget); |
|
110 mIndexFeedback->setItemView(mList); |
|
111 initializeList(); |
|
112 } |
|
113 if ( mInfoBar ) { |
|
114 delete mInfoBar; |
|
115 mInfoBar = 0; |
|
116 } |
|
117 } |
|
118 else if ( mCollectionContext == ECollectionContextArtistAlbums ) { |
|
119 mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "artistSongs", &ok); |
|
120 if ( !ok ) { |
|
121 TX_LOG_ARGS("Error: invalid xml file."); |
|
122 Q_ASSERT_X(ok, "MpCollectionContainerArtists::setupContainer", "invalid xml file"); |
|
123 } |
|
124 |
|
125 widget = mDocumentLoader->findWidget(QString("artistSongsDetail")); |
|
126 mInfoBar = qobject_cast<HbGroupBox*>(widget); |
|
127 |
|
128 QString details; |
|
129 if ( mViewMode == MpCommon::FetchView ) { |
|
130 details = "Select a song"; |
|
131 } |
|
132 else { |
|
133 details = mArtist; |
|
134 } |
|
135 mInfoBar->setHeading(details); |
|
136 } |
|
137 else if ( mCollectionContext == ECollectionContextAlbumSongs ) { |
|
138 mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "artistSongs", &ok); |
|
139 if ( !ok ) { |
|
140 TX_LOG_ARGS("Error: invalid xml file."); |
|
141 Q_ASSERT_X(ok, "MpCollectionContainerArtists::setupContainer", "invalid xml file"); |
|
142 } |
|
143 |
|
144 widget = mDocumentLoader->findWidget(QString("artistSongsDetail")); |
|
145 mInfoBar = qobject_cast<HbGroupBox*>(widget); |
|
146 |
|
147 QString details; |
|
148 if ( mViewMode == MpCommon::FetchView ) { |
|
149 details = "Select a song"; |
|
150 } |
|
151 else { |
|
152 details = mArtist; |
|
153 details.append(" - "); |
|
154 details.append(mAlbum); |
|
155 } |
|
156 mInfoBar->setHeading(details); |
|
157 } |
|
158 else if ( mCollectionContext == ECollectionContextArtistSongs ) { |
|
159 mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "artistSongs", &ok); |
|
160 if ( !ok ) { |
|
161 TX_LOG_ARGS("Error: invalid xml file."); |
|
162 Q_ASSERT_X(ok, "MpCollectionContainerArtists::setupContainer", "invalid xml file"); |
|
163 } |
|
164 |
|
165 widget = mDocumentLoader->findWidget(QString("artistSongsDetail")); |
|
166 mInfoBar = qobject_cast<HbGroupBox*>(widget); |
|
167 |
|
168 QString details; |
|
169 if ( mViewMode == MpCommon::FetchView ) { |
|
170 details = "Select a song"; |
|
171 } |
|
172 else if ( mArtist.isEmpty() ) { |
|
173 details = hbTrId("txt_mus_subtitle_unknown_all"); |
|
174 } |
|
175 else{ |
|
176 details = hbTrId( "txt_mus_subtitle_1_all" ).arg(mArtist); |
|
177 |
|
178 } |
|
179 mInfoBar->setHeading(details); |
|
180 } |
|
181 } |
|
182 else { |
|
183 if ( mInfoBar ) { |
|
184 // When last song in an album is deleted and album list is reloaded |
|
185 delete mInfoBar; |
|
186 mInfoBar = 0; |
|
187 } |
|
188 // Call empty list from base class |
|
189 setupEmptyListContainer(); |
|
190 } |
|
191 TX_EXIT |
|
192 } |
|
193 |