Ability to sort cur.playlist by long tap on it
[someplayer] / src / trackmetainformation.cpp
1 /*
2  * SomePlayer - An alternate music player for Maemo 5
3  * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) 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 this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include "trackmetainformation.h"
21
22 using namespace SomePlayer::DataObjects;
23
24 TrackMetadata::TrackMetadata() {
25 }
26
27 TrackMetadata::TrackMetadata(QString title = "", QString artist = "", QString album = "", int length = 0) {
28         _metadata["TITLE"] = title == "" ? _UNKNOWN_TRACK_ : title.trimmed();
29         _metadata["ARTIST"] = artist == "" ? _UNKNOWN_ARTIST_ : artist.trimmed();
30         _metadata["ALBUM"] = album == "" ? _UNKNOWN_ALBUM_ : album.trimmed();
31         _length = length;
32         _year = 0;
33 }
34
35 TrackMetadata::TrackMetadata(const TrackMetadata &metadata) {
36         this->_metadata = metadata._metadata;
37         this->_length = metadata._length;
38         this->_year = metadata._year;
39 }
40
41 QString TrackMetadata::title() {
42         if (_metadata.contains("TITLE")) {
43                 return _metadata["TITLE"];
44         } else {
45                 return _UNKNOWN_TRACK_;
46         }
47 }
48
49 QString TrackMetadata::artist() {
50         if (_metadata.contains("ARTIST")) {
51                 return _metadata["ARTIST"];
52         } else {
53                 return _UNKNOWN_ARTIST_;
54         }
55 }
56
57 QString TrackMetadata::album() {
58         if (_metadata.contains("ALBUM")) {
59                 return _metadata["ALBUM"];
60         } else {
61                 return _UNKNOWN_ALBUM_;
62         }
63 }
64
65 int TrackMetadata::length() {
66         return _length;
67 }
68
69 int TrackMetadata::year() {
70         return _year;
71 }
72
73 void TrackMetadata::setTitle(QString title) {
74         _metadata["TITLE"] = title;
75 }
76
77 void TrackMetadata::setArtist(QString artist) {
78         _metadata["ARTIST"] = artist;
79 }
80
81 void TrackMetadata::setAlbum(QString album) {
82         _metadata["ALBUM"] = album;
83 }
84
85 void TrackMetadata::setLength(int length) {
86         _length = length;
87 }
88
89 void TrackMetadata::setYear(int year) {
90         _year = year;
91 }