Sayonara Player
Sorting.h
1 /* Sorting.h */
2 
3 /* Copyright (C) 2011-2016 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef SORTING_H
22 #define SORTING_H
23 
24 #include <QStringList>
25 
26 enum class SortOrder : quint8
27 {
28  NoSorting=0,
29  ArtistNameAsc,
30  ArtistNameDesc,
31  ArtistTrackcountAsc,
32  ArtistTrackcountDesc,
33  AlbumNameAsc,
34  AlbumNameDesc,
35  AlbumYearAsc,
36  AlbumYearDesc,
37  AlbumTracksAsc,
38  AlbumTracksDesc,
39  AlbumDurationAsc,
40  AlbumDurationDesc,
41  AlbumRatingAsc,
42  AlbumRatingDesc,
43  TrackNumAsc,
44  TrackNumDesc,
45  TrackTitleAsc,
46  TrackTitleDesc,
47  TrackAlbumAsc,
48  TrackAlbumDesc,
49  TrackArtistAsc,
50  TrackArtistDesc,
51  TrackYearAsc,
52  TrackYearDesc,
53  TrackLenghtAsc,
54  TrackLengthDesc,
55  TrackBitrateAsc,
56  TrackBitrateDesc,
57  TrackSizeAsc,
58  TrackSizeDesc,
59  TrackDiscnumberAsc,
60  TrackDiscnumberDesc,
61  TrackRatingAsc,
62  TrackRatingDesc
63 };
64 
65 enum class SortOrderPlaylists : quint8{
66  IDAsc=0,
67  IDDesc,
68  NameAsc,
69  NameDesc
70 };
71 
72 
73 
74 // This class has to be inline because of setting registry
75 class LibSortOrder {
76 
77 public:
78  SortOrder so_albums;
79  SortOrder so_artists;
80  SortOrder so_tracks;
81 
82  LibSortOrder(){
83  so_artists = SortOrder::ArtistNameAsc;
84  so_albums = SortOrder::AlbumNameAsc;
85  so_tracks = SortOrder::TrackAlbumAsc;
86  }
87 
88  LibSortOrder(const LibSortOrder& so){
89  so_albums = so.so_albums;
90  so_artists = so.so_artists;
91  so_tracks = so.so_tracks;
92  }
93 
94  bool operator==(LibSortOrder so){
95  return (so.so_albums == so_albums) &&
96  (so.so_artists == so_artists) &&
97  (so.so_tracks == so_tracks);
98  }
99 
100  QString toString() const{
101  return QString::number((int) so_albums) + "," +
102  QString::number((int) so_artists) + "," +
103  QString::number((int) so_tracks);
104  }
105 
106  static LibSortOrder fromString(const QString str){
107 
108  LibSortOrder so;
109  QStringList lst = str.split(",");
110  so.so_albums = (SortOrder) lst[0].toInt();
111  so.so_artists = (SortOrder) lst[1].toInt();
112  so.so_tracks = (SortOrder) lst[2].toInt();
113  return so;
114  }
115 };
116 
117 
118 #endif // SORTING_H
Definition: Sorting.h:75