1 /****************************************************************************************
2  * Copyright (c) 2008 - 2009 Nikolaj Hald Nielsen <nhn@kde.org>                         *
3  * Copyright (c) 2009 Téo Mrnjavac <teo@kde.org>                                        *
4  * Copyright (c) 2012 Ralf Engels <ralf-engels@gmx.de>                                  *
5  *                                                                                      *
6  * This program is free software; you can redistribute it and/or modify it under        *
7  * the terms of the GNU General Public License as published by the Free Software        *
8  * Foundation; either version 2 of the License, or (at your option) any later           *
9  * version.                                                                             *
10  *                                                                                      *
11  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
13  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
14  *                                                                                      *
15  * You should have received a copy of the GNU General Public License along with         *
16  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
17  ****************************************************************************************/
18 
19 #ifndef AMAROK_PLAYLISTDEFINES_H
20 #define AMAROK_PLAYLISTDEFINES_H
21 
22 #include <QString>
23 #include <QStringList>
24 
25 namespace Playlist
26 {
27 
28 /** A enum used by playlist and layouts to identify a token.
29     We should have used the varTitle numbers for that.
30 */
31 enum Column
32 {
33     PlaceHolder = 0,
34     Album,
35     AlbumArtist,
36     Artist,
37     Bitrate,
38     Bpm,
39     Comment,
40     Composer,
41     CoverImage,
42     Directory,
43     DiscNumber,
44     Divider,
45     Filename,
46     Filesize,
47     Genre,
48     GroupLength,
49     GroupTracks,
50     Labels,
51     LastPlayed,
52     Length,
53     LengthInSeconds,
54     Mood,
55     Moodbar,
56     PlayCount,
57     Rating,
58     SampleRate,
59     Score,
60     Source,
61     SourceEmblem,
62     Title,
63     TitleWithTrackNum,
64     TrackNumber,
65     Type,
66     Year,
67     NUM_COLUMNS
68 };
69 //when sorting, Random is -1
70 
71 enum SearchFields
72 {
73     MatchTrack = 1,
74     MatchArtist = 2,
75     MatchAlbum = 4,
76     MatchGenre = 8,
77     MatchComposer = 16,
78     MatchYear = 32,
79     MatchRating = 64
80 };
81 
82 enum DataRoles
83 {
84     TrackRole = Qt::UserRole,
85     StateRole,
86     UniqueIdRole,
87     ActiveTrackRole,
88     QueuePositionRole,
89     InCollectionRole,
90     MultiSourceRole,
91     StopAfterTrackRole
92 };
93 
94 /**
95  * A singleton class used to store translated names of playlist columns.
96  * Use the global function columnNames to access them.
97  *
98  * @author Alexander Potashev <aspotashev@gmail.com>
99  */
100 class PlaylistColumnInfos
101 {
102     public:
103         static const QStringList &internalNames();
104         static const QStringList &names();
105         static const QStringList &icons();
106         static const QList<Column> &groups();
107 
108     private:
109         PlaylistColumnInfos();
110 
111         static QStringList *s_internalNames;
112         static QStringList *s_names;
113         static QStringList *s_icons;
114         static QList<Column> *s_groups;
115 };
116 
columnForName(const QString & internalName)117 inline Column columnForName( const QString &internalName )
118 {
119     return static_cast<Column>(Playlist::PlaylistColumnInfos::internalNames().
120                                indexOf( internalName ));
121 }
122 
internalColumnName(Column c)123 inline const QString &internalColumnName( Column c )
124 {
125     return Playlist::PlaylistColumnInfos::internalNames().at( static_cast<int>(c) );
126 }
127 
columnName(Column c)128 inline const QString &columnName( Column c )
129 {
130     return Playlist::PlaylistColumnInfos::names().at( static_cast<int>(c) );
131 }
132 
iconName(Column c)133 inline const QString &iconName( Column c )
134 {
135     return Playlist::PlaylistColumnInfos::icons().at( static_cast<int>(c) );
136 }
137 
groupableCategories()138 inline const QList<Playlist::Column> &groupableCategories()
139 {
140     return Playlist::PlaylistColumnInfos::groups();
141 }
142 
143 /** these are the columns that can be directly edited by the user. */
144 bool isEditableColumn( Column c );
145 
146 //FIXME: disabled sorting by File size, Group length, Group tracks, Length because
147 //       it doesn't work.
148 bool isSortableColumn( Column c );
149 
150 
151 }
152 
153 // Q_DECLARE_METATYPE(Playlist::Column)
154 
155 
156 #endif
157