changed: New label formatting that more logically drops separators.
[xbmc:xbmc-antiquated.git] / xbmc / GUIViewStateMusic.cpp
1 /*
2  *      Copyright (C) 2005-2007 Team XboxMediaCenter
3  *      http://www.xboxmediacenter.com
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with GNU Make; see the file COPYING.  If not, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21
22 #include "stdafx.h"
23 #include "GUIViewStateMusic.h"
24 #include "playlistplayer.h"
25 #include "util.h"
26 #include "GUIBaseContainer.h" // for VIEW_TYPE_*
27
28 #include "filesystem/musicdatabasedirectory.h"
29
30 using namespace DIRECTORY;
31 using namespace MUSICDATABASEDIRECTORY;
32
33 int CGUIViewStateWindowMusic::GetPlaylist()
34 {
35   //return PLAYLIST_MUSIC_TEMP;
36   return PLAYLIST_MUSIC;
37 }
38
39 bool CGUIViewStateWindowMusic::UnrollArchives()
40 {
41   return g_guiSettings.GetBool("filelists.unrollarchives");
42 }
43
44 bool CGUIViewStateWindowMusic::AutoPlayNextItem()
45 {
46   return g_guiSettings.GetBool("mymusic.autoplaynextitem");
47 }
48
49 CStdString CGUIViewStateWindowMusic::GetLockType()
50 {
51   return "music";
52 }
53
54 CStdString CGUIViewStateWindowMusic::GetExtensions()
55 {
56   return g_stSettings.m_musicExtensions;
57 }
58
59 CGUIViewStateMusicSearch::CGUIViewStateMusicSearch(const CFileItemList& items) : CGUIViewStateWindowMusic(items)
60 {
61   CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.librarytrackformat");
62   if (strTrackLeft.IsEmpty())
63     strTrackLeft = g_guiSettings.GetString("musicfiles.trackformat");
64   CStdString strTrackRight=g_guiSettings.GetString("musicfiles.librarytrackformatright");
65   if (strTrackRight.IsEmpty())
66     strTrackRight = g_guiSettings.GetString("musicfiles.trackformatright");
67
68   CStdString strAlbumLeft = g_advancedSettings.m_strMusicLibraryAlbumFormat;
69   if (strAlbumLeft.IsEmpty())
70     strAlbumLeft = "%B"; // album
71   CStdString strAlbumRight = g_advancedSettings.m_strMusicLibraryAlbumFormatRight;
72   if (strAlbumRight.IsEmpty())
73     strAlbumRight = "%A"; // artist
74
75   if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
76   {
77     AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A"));  // Title, Artist, Duration| empty, empty
78     SetSortMethod(SORT_METHOD_TITLE_IGNORE_THE);
79   }
80   else
81   {
82     AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A"));  // Title, Artist, Duration| empty, empty
83     SetSortMethod(SORT_METHOD_TITLE);
84   }
85
86   SetViewAsControl(g_stSettings.m_viewStateMusicNavSongs.m_viewMode);
87
88   SetSortOrder(g_stSettings.m_viewStateMusicNavSongs.m_sortOrder);
89
90   LoadViewState(items.m_strPath, WINDOW_MUSIC_NAV);
91 }
92
93 void CGUIViewStateMusicSearch::SaveViewState()
94 {
95   SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_NAV, g_stSettings.m_viewStateMusicNavSongs);
96 }
97
98 CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& items) : CGUIViewStateWindowMusic(items)
99 {
100   CMusicDatabaseDirectory dir;
101   NODE_TYPE NodeType=dir.GetDirectoryChildType(items.m_strPath);
102   NODE_TYPE ParentNodeType=dir.GetDirectoryType(items.m_strPath);
103
104   CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.librarytrackformat");
105   if (strTrackLeft.IsEmpty())
106     strTrackLeft = g_guiSettings.GetString("musicfiles.trackformat");
107   CStdString strTrackRight=g_guiSettings.GetString("musicfiles.librarytrackformatright");
108   if (strTrackRight.IsEmpty())
109     strTrackRight = g_guiSettings.GetString("musicfiles.trackformatright");
110
111   CStdString strAlbumLeft = g_advancedSettings.m_strMusicLibraryAlbumFormat;
112   if (strAlbumLeft.IsEmpty())
113     strAlbumLeft = "%B"; // album
114   CStdString strAlbumRight = g_advancedSettings.m_strMusicLibraryAlbumFormatRight;
115   if (strAlbumRight.IsEmpty())
116     strAlbumRight = "%A"; // artist
117
118   CLog::Log(LOGDEBUG,"Album format left  = [%s]", strAlbumLeft.c_str());
119   CLog::Log(LOGDEBUG,"Album format right = [%s]", strAlbumRight.c_str());
120
121   switch (NodeType)
122   {
123   case NODE_TYPE_OVERVIEW:
124     {
125       AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", "%L", ""));  // Filename, empty | Foldername, empty
126       SetSortMethod(SORT_METHOD_NONE);
127
128       SetViewAsControl(DEFAULT_VIEW_LIST);
129
130       SetSortOrder(SORT_ORDER_NONE);
131     }
132     break;
133   case NODE_TYPE_TOP100:
134     {
135       AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", "%L", ""));  // Filename, empty | Foldername, empty
136       SetSortMethod(SORT_METHOD_NONE);
137
138       SetViewAsControl(DEFAULT_VIEW_LIST);
139
140       SetSortOrder(SORT_ORDER_NONE);
141     }
142     break;
143   case NODE_TYPE_GENRE:
144     {
145       AddSortMethod(SORT_METHOD_GENRE, 551, LABEL_MASKS("%F", "", "%G", ""));  // Filename, empty | Genre, empty
146       SetSortMethod(SORT_METHOD_GENRE);
147
148       SetViewAsControl(DEFAULT_VIEW_LIST);
149
150       SetSortOrder(SORT_ORDER_ASC);
151     }
152     break;
153   case NODE_TYPE_YEAR:
154     {
155       AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%F", "", "%Y", ""));  // Filename, empty | Year, empty
156       SetSortMethod(SORT_METHOD_LABEL);
157
158       SetViewAsControl(DEFAULT_VIEW_LIST);
159
160       SetSortOrder(SORT_ORDER_ASC);
161     }
162     break;
163   case NODE_TYPE_ARTIST:
164     {
165       if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
166       {
167         AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 551, LABEL_MASKS("%F", "", "%A", ""));  // Filename, empty | Artist, empty
168         SetSortMethod(SORT_METHOD_ARTIST_IGNORE_THE);
169       }
170       else
171       {
172         AddSortMethod(SORT_METHOD_ARTIST, 551, LABEL_MASKS("%F", "", "%A", ""));  // Filename, empty | Artist, empty
173         SetSortMethod(SORT_METHOD_ARTIST);
174       }
175
176       SetViewAsControl(g_stSettings.m_viewStateMusicNavArtists.m_viewMode);
177
178       SetSortOrder(g_stSettings.m_viewStateMusicNavArtists.m_sortOrder);
179     }
180     break;
181   case NODE_TYPE_ALBUM_COMPILATIONS:
182   case NODE_TYPE_ALBUM:
183   case NODE_TYPE_YEAR_ALBUM:
184     {
185       // album
186       if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
187         AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));  // Filename, empty | Userdefined, Userdefined
188       else
189         AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));  // Filename, empty | Userdefined, Userdefined
190
191       // artist
192       if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
193         AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));  // Filename, empty | Userdefined, Userdefined
194       else
195         AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));  // Filename, empty | Userdefined, Userdefined
196
197       SetSortMethod(g_stSettings.m_viewStateMusicNavAlbums.m_sortMethod);
198
199       SetViewAsControl(g_stSettings.m_viewStateMusicNavAlbums.m_viewMode);
200
201       SetSortOrder(g_stSettings.m_viewStateMusicNavAlbums.m_sortOrder);
202     }
203     break;
204   case NODE_TYPE_ALBUM_RECENTLY_ADDED:
205     {
206       AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));  // Filename, empty | Userdefined, Userdefined
207       SetSortMethod(SORT_METHOD_NONE);
208
209       SetViewAsControl(g_stSettings.m_viewStateMusicNavAlbums.m_viewMode);
210
211       SetSortOrder(SORT_ORDER_NONE);
212     }
213     break;
214   case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS:
215     {
216       AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS(strTrackLeft, strTrackRight));  // Userdefined, Userdefined | empty, empty
217       SetSortMethod(SORT_METHOD_NONE);
218
219       SetViewAsControl(g_stSettings.m_viewStateMusicNavSongs.m_viewMode);
220
221       SetSortOrder(SORT_ORDER_NONE);
222     }
223     break;
224   case NODE_TYPE_ALBUM_RECENTLY_PLAYED:
225     {
226       AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));  // Filename, empty | Userdefined, Userdefined
227       SetSortMethod(SORT_METHOD_NONE);
228
229       SetViewAsControl(g_stSettings.m_viewStateMusicNavAlbums.m_viewMode);
230
231       SetSortOrder(SORT_ORDER_NONE);
232     }
233     break;
234   case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS:
235     {
236       AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS(strTrackLeft, strTrackRight));  // Userdefined, Userdefined | empty, empty
237       SetSortMethod(SORT_METHOD_NONE);
238
239       SetViewAsControl(g_stSettings.m_viewStateMusicNavAlbums.m_viewMode);
240
241       SetSortOrder(SORT_ORDER_NONE);
242     }
243     break;
244   case NODE_TYPE_ALBUM_TOP100:
245     {
246       AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));  // Filename, empty | Userdefined, Userdefined
247       SetSortMethod(SORT_METHOD_NONE);
248
249       SetViewAsControl(DEFAULT_VIEW_LIST);
250
251       SetSortOrder(SORT_ORDER_NONE);
252     }
253     break;
254   case NODE_TYPE_ALBUM_COMPILATIONS_SONGS:
255   case NODE_TYPE_ALBUM_TOP100_SONGS:
256   case NODE_TYPE_YEAR_SONG:
257   case NODE_TYPE_SONG:
258     {
259       AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight));  // Userdefined, Userdefined| empty, empty
260       if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
261       {
262         AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D"));  // Title, Artist, Duration| empty, empty
263         AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T - %A", "%D"));  // Album, Title, Artist, Duration| empty, empty
264         AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%D"));  // Artist, Title, Duration| empty, empty
265         AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
266       }
267       else
268       {
269         AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D"));  // Title, Artist, Duration| empty, empty
270         AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T - %A", "%D"));  // Album, Title, Artist, Duration| empty, empty
271         AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%D"));  // Artist, Title, Duration| empty, empty
272         AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
273       }
274       AddSortMethod(SORT_METHOD_DURATION, 555, LABEL_MASKS("%T - %A", "%D"));  // Titel, Artist, Duration| empty, empty
275       AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R"));  // Title - Artist, Rating
276
277       // the "All Albums" entries always default to SORT_METHOD_ALBUM as this is most logical - user can always
278       // change it and the change will be saved for this particular path
279       if (dir.IsAllItem(items.m_strPath))
280         SetSortMethod(g_guiSettings.GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_ALBUM_IGNORE_THE : SORT_METHOD_ALBUM);
281       else
282         SetSortMethod(g_stSettings.m_viewStateMusicNavSongs.m_sortMethod);
283
284       SetViewAsControl(g_stSettings.m_viewStateMusicNavSongs.m_viewMode);
285
286       SetSortOrder(g_stSettings.m_viewStateMusicNavSongs.m_sortOrder);
287     }
288     break;
289   case NODE_TYPE_SONG_TOP100:
290     {
291       AddSortMethod(SORT_METHOD_NONE, 554, LABEL_MASKS(strTrackLeft, strTrackRight));  // Userdefined, Userdefined | empty, empty
292       SetSortMethod(SORT_METHOD_NONE);
293
294       SetViewAsControl(g_stSettings.m_viewStateMusicNavSongs.m_viewMode);
295
296       SetSortOrder(SORT_ORDER_NONE);
297     }
298     break;
299   }
300
301   LoadViewState(items.m_strPath, WINDOW_MUSIC_NAV);
302 }
303
304 void CGUIViewStateMusicDatabase::SaveViewState()
305 {
306   CMusicDatabaseDirectory dir;
307   NODE_TYPE NodeType=dir.GetDirectoryChildType(m_items.m_strPath);
308
309   switch (NodeType)
310   {
311     case NODE_TYPE_ARTIST:
312       SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_NAV, g_stSettings.m_viewStateMusicNavArtists);
313       break;
314     case NODE_TYPE_ALBUM_COMPILATIONS:
315     case NODE_TYPE_ALBUM:
316     case NODE_TYPE_YEAR_ALBUM:
317       SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_NAV, g_stSettings.m_viewStateMusicNavAlbums);
318       break;
319     case NODE_TYPE_ALBUM_RECENTLY_ADDED:
320     case NODE_TYPE_ALBUM_TOP100:
321     case NODE_TYPE_ALBUM_RECENTLY_PLAYED:
322       SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_NAV);
323       break;
324     case NODE_TYPE_ALBUM_COMPILATIONS_SONGS:
325     case NODE_TYPE_SONG:
326     case NODE_TYPE_YEAR_SONG:
327       SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_NAV, g_stSettings.m_viewStateMusicNavSongs);
328       break;
329     case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS:
330     case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS:
331     case NODE_TYPE_SONG_TOP100:
332       SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_NAV);
333       break;
334     default:
335       SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_NAV);
336       break;
337         }
338 }
339
340
341 CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items)
342 {
343   CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat");
344   CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright");
345
346   AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS(strTrackLeft, strTrackRight));
347   AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight));  // Userdefined, Userdefined| empty, empty
348   if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
349   {
350     AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D"));  // Title, Artist, Duration| empty, empty
351     AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T - %A", "%D"));  // Album, Titel, Artist, Duration| empty, empty
352     AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%D"));  // Artist, Titel, Duration| empty, empty
353     AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
354   }
355   else
356   {
357     AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D"));  // Title, Artist, Duration| empty, empty
358     AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T - %A", "%D"));  // Album, Titel, Artist, Duration| empty, empty
359     AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%D"));  // Artist, Titel, Duration| empty, empty
360     AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
361   }
362   AddSortMethod(SORT_METHOD_DURATION, 555, LABEL_MASKS("%T - %A", "%D"));  // Titel, Artist, Duration| empty, empty
363   AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R"));  // Titel, Artist, Rating| empty, empty
364   SetSortMethod(g_stSettings.m_viewStateMusicNavSongs.m_sortMethod);
365
366   SetViewAsControl(g_stSettings.m_viewStateMusicNavSongs.m_viewMode);
367
368   SetSortOrder(g_stSettings.m_viewStateMusicNavSongs.m_sortOrder);
369   LoadViewState(items.m_strPath, WINDOW_MUSIC_NAV);
370 }
371
372 void CGUIViewStateMusicSmartPlaylist::SaveViewState()
373 {
374   SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_NAV, g_stSettings.m_viewStateMusicNavSongs);
375 }
376
377 CGUIViewStateMusicPlaylist::CGUIViewStateMusicPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items)
378 {
379   CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat");
380   CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright");
381
382   AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS(strTrackLeft, strTrackRight));
383   AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight));  // Userdefined, Userdefined| empty, empty
384   if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
385   {
386     AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D"));  // Title, Artist, Duration| empty, empty
387     AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T - %A", "%D"));  // Album, Titel, Artist, Duration| empty, empty
388     AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%D"));  // Artist, Titel, Duration| empty, empty
389     AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
390   }
391   else
392   {
393     AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D"));  // Title, Artist, Duration| empty, empty
394     AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T - %A", "%D"));  // Album, Titel, Artist, Duration| empty, empty
395     AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%D"));  // Artist, Titel, Duration| empty, empty
396     AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
397   }
398   AddSortMethod(SORT_METHOD_DURATION, 555, LABEL_MASKS("%T - %A", "%D"));  // Titel, Artist, Duration| empty, empty
399   AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R"));  // Titel, Artist, Rating| empty, empty
400
401   SetSortMethod((SORT_METHOD)g_guiSettings.GetInt("musicfiles.sortmethod"));
402   SetViewAsControl(g_guiSettings.GetInt("musicfiles.viewmode"));
403   SetSortOrder((SORT_ORDER)g_guiSettings.GetInt("musicfiles.sortorder"));
404
405   LoadViewState(items.m_strPath, WINDOW_MUSIC_FILES);
406 }
407
408 void CGUIViewStateMusicPlaylist::SaveViewState()
409 {
410   SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_FILES);
411 }
412
413
414 CGUIViewStateWindowMusicNav::CGUIViewStateWindowMusicNav(const CFileItemList& items) : CGUIViewStateWindowMusic(items)
415 {
416   if (items.IsVirtualDirectoryRoot())
417   {
418     AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "%I", "%L", ""));  // Filename, Size | Foldername, empty
419     SetSortMethod(SORT_METHOD_NONE);
420
421     SetViewAsControl(DEFAULT_VIEW_LIST);
422
423     SetSortOrder(SORT_ORDER_NONE);
424   }
425   else
426   {
427     AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%F", "%D", "%L", ""));  // Filename, Duration | Foldername, empty
428     SetSortMethod(SORT_METHOD_LABEL);
429
430     SetViewAsControl(DEFAULT_VIEW_LIST);
431
432     SetSortOrder(SORT_ORDER_ASC);
433   }
434   LoadViewState(items.m_strPath, WINDOW_MUSIC_NAV);
435 }
436
437 void CGUIViewStateWindowMusicNav::SaveViewState()
438 {
439   SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_NAV);
440 }
441
442 VECSHARES& CGUIViewStateWindowMusicNav::GetShares()
443 {
444   //  Setup shares we want to have
445   m_shares.clear();
446   //  Musicdb shares
447   CFileItemList items;
448   CDirectory::GetDirectory("musicdb://", items);
449   for (int i=0; i<items.Size(); ++i)
450   {
451     CFileItem* item=items[i];
452     CShare share;
453     share.strName=item->GetLabel();
454     share.strPath = item->m_strPath;
455     share.m_strThumbnailImage="defaultFolderBig.png";
456     share.m_iDriveType = SHARE_TYPE_LOCAL;
457     m_shares.push_back(share);
458   }
459
460   //  Playlists share
461   CShare share;
462   share.strName=g_localizeStrings.Get(136); // Playlists
463   share.strPath = "special://musicplaylists/";
464   share.m_strThumbnailImage="defaultFolderBig.png";
465   share.m_iDriveType = SHARE_TYPE_LOCAL;
466   m_shares.push_back(share);
467
468   // Search share
469   share.strName=g_localizeStrings.Get(137); // Search
470   share.strPath = "musicsearch://";
471   share.m_strThumbnailImage="defaultFolderBig.png";
472   share.m_iDriveType = SHARE_TYPE_LOCAL;
473   m_shares.push_back(share);
474
475   return CGUIViewStateWindowMusic::GetShares();
476 }
477
478 CGUIViewStateWindowMusicSongs::CGUIViewStateWindowMusicSongs(const CFileItemList& items) : CGUIViewStateWindowMusic(items)
479 {
480   if (items.IsVirtualDirectoryRoot())
481   {
482     AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS()); // Preformated
483     AddSortMethod(SORT_METHOD_DRIVE_TYPE, 564, LABEL_MASKS()); // Preformated
484     SetSortMethod(SORT_METHOD_LABEL);
485
486     SetViewAsControl(g_guiSettings.GetInt("musicfiles.viewmode"));
487
488     SetSortOrder(SORT_ORDER_ASC);
489   }
490   else
491   {
492     CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat");
493     CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright");
494
495     AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", ""));  // Userdefined, Userdefined | FolderName, empty
496     AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS(strTrackLeft, "%I", "%L", "%I"));  // Userdefined, Size | FolderName, Size
497     AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS(strTrackLeft, "%J", "%L", "%J"));  // Userdefined, Date | FolderName, Date
498     AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", ""));  // Userdefined, Userdefined | FolderName, empty
499     SetSortMethod((SORT_METHOD)g_guiSettings.GetInt("musicfiles.sortmethod"));
500     SetViewAsControl(g_guiSettings.GetInt("musicfiles.viewmode"));
501     SetSortOrder((SORT_ORDER)g_guiSettings.GetInt("musicfiles.sortorder"));
502   }
503   LoadViewState(items.m_strPath, WINDOW_MUSIC_FILES);
504 }
505
506 void CGUIViewStateWindowMusicSongs::SaveViewState()
507 {
508   SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_FILES);
509 }
510
511 VECSHARES& CGUIViewStateWindowMusicSongs::GetShares()
512 {
513   return g_settings.m_vecMyMusicShares;
514 }
515
516 CGUIViewStateWindowMusicPlaylist::CGUIViewStateWindowMusicPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items)
517 {
518   CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.nowplayingtrackformat");
519   if (strTrackLeft.IsEmpty())
520     strTrackLeft = g_guiSettings.GetString("musicfiles.trackformat");
521   CStdString strTrackRight=g_guiSettings.GetString("musicfiles.nowplayingtrackformatright");
522   if (strTrackRight.IsEmpty())
523     strTrackRight = g_guiSettings.GetString("musicfiles.trackformatright");
524
525   AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", ""));  // Userdefined, Userdefined | FolderName, empty
526   SetSortMethod(SORT_METHOD_NONE);
527
528   SetViewAsControl(DEFAULT_VIEW_LIST);
529
530   SetSortOrder(SORT_ORDER_NONE);
531
532   LoadViewState(items.m_strPath, WINDOW_MUSIC_PLAYLIST);
533 }
534
535 void CGUIViewStateWindowMusicPlaylist::SaveViewState()
536 {
537   SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_PLAYLIST);
538 }
539
540 int CGUIViewStateWindowMusicPlaylist::GetPlaylist()
541 {
542   return PLAYLIST_MUSIC;
543 }
544
545 bool CGUIViewStateWindowMusicPlaylist::AutoPlayNextItem()
546 {
547   return false;
548 }
549
550 bool CGUIViewStateWindowMusicPlaylist::HideParentDirItems()
551 {
552   return true;
553 }
554
555 VECSHARES& CGUIViewStateWindowMusicPlaylist::GetShares()
556 {
557   m_shares.clear();
558   //  Playlist share
559   CShare share;
560   share.strName;
561   share.strPath = "playlistmusic://";
562   share.m_strThumbnailImage="defaultFolderBig.png";
563   share.m_iDriveType = SHARE_TYPE_LOCAL;
564   m_shares.push_back(share);
565
566   return CGUIViewStateWindowMusic::GetShares();
567 }
568
569 CGUIViewStateMusicShoutcast::CGUIViewStateMusicShoutcast(const CFileItemList& items) : CGUIViewStateWindowMusic(items)
570 {
571   /* sadly m_idepth isn't remembered when a directory is retrieved from cache */
572   /* and thus this check hardly ever works, so let's just disable it for now */
573   if( true || m_items.m_idepth > 1 )
574   { /* station list */
575     AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%K", "%B kbps", "%K", ""));  // Title, Bitrate | Title, nothing
576     AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%K", "%A listeners", "%K", ""));  // Titel, Listeners | Titel, nothing
577     AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%K", "%B kbps", "%K", ""));  // Title, Bitrate | Title, nothing
578
579     SetSortMethod(g_stSettings.m_viewStateMusicShoutcast.m_sortMethod);
580     SetSortOrder(g_stSettings.m_viewStateMusicShoutcast.m_sortOrder);
581   }
582   else
583   { /* genre list */
584     AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%K", "", "%K", ""));  // Title, nothing | Title, nothing
585     SetSortMethod(SORT_METHOD_LABEL);
586     SetSortOrder(SORT_ORDER_ASC); /* maybe we should have this stored somewhere */
587   }
588
589   SetViewAsControl(DEFAULT_VIEW_LIST);
590   LoadViewState(items.m_strPath, WINDOW_MUSIC_FILES);
591 }
592
593 bool CGUIViewStateMusicShoutcast::AutoPlayNextItem()
594 {
595   return false;
596 }
597
598 void CGUIViewStateMusicShoutcast::SaveViewState()
599 {
600   SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_FILES, g_stSettings.m_viewStateMusicShoutcast);
601 }
602
603 CGUIViewStateMusicLastFM::CGUIViewStateMusicLastFM(const CFileItemList& items) : CGUIViewStateWindowMusic(items)
604 {
605   CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat");
606   CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright");
607
608   AddSortMethod(SORT_METHOD_UNSORTED, 571, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", ""));  // Userdefined, Userdefined | FolderName, empty
609   AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", ""));  // Userdefined, Userdefined | FolderName, empty
610   AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS(strTrackLeft, "%I", "%L", "%I"));  // Userdefined, Size | FolderName, Size
611
612   SetSortMethod(g_stSettings.m_viewStateMusicLastFM.m_sortMethod);
613   SetSortOrder(g_stSettings.m_viewStateMusicLastFM.m_sortOrder);
614
615   SetViewAsControl(DEFAULT_VIEW_LIST);
616   LoadViewState(items.m_strPath, WINDOW_MUSIC_FILES);
617 }
618
619 bool CGUIViewStateMusicLastFM::AutoPlayNextItem()
620 {
621   return false;
622 }
623
624 void CGUIViewStateMusicLastFM::SaveViewState()
625 {
626   SaveViewToDb(m_items.m_strPath, WINDOW_MUSIC_FILES, g_stSettings.m_viewStateMusicLastFM);
627 }