Added application config. Moved application data from /tmp to ~/.someplayer
[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 title" : title.trimmed();
29         _metadata["ARTIST"] = artist == "" ? "Unknown artist" : artist.trimmed();
30         _metadata["ALBUM"] = album == "" ? "Unknown album" : album.trimmed();
31         _length = length;
32 }
33
34 TrackMetadata::TrackMetadata(const TrackMetadata &metadata) {
35         this->_metadata = metadata._metadata;
36         this->_length = metadata._length;
37 }
38
39 QString TrackMetadata::title() {
40         if (_metadata.contains("TITLE")) {
41                 return _metadata["TITLE"];
42         } else {
43                 return "Unknown title";
44         }
45 }
46
47 QString TrackMetadata::artist() {
48         if (_metadata.contains("ARTIST")) {
49                 return _metadata["ARTIST"];
50         } else {
51                 return "Unknown artist";
52         }
53 }
54
55 QString TrackMetadata::album() {
56         if (_metadata.contains("ALBUM")) {
57                 return _metadata["ALBUM"];
58         } else {
59                 return "Unknown album";
60         }
61 }
62
63 int TrackMetadata::length() {
64         return _length;
65 }
66
67 void TrackMetadata::setTitle(QString title) {
68         _metadata["TITLE"] = title;
69 }
70
71 void TrackMetadata::setArtist(QString artist) {
72         _metadata["ARTIST"] = artist;
73 }
74
75 void TrackMetadata::setAlbum(QString album) {
76         _metadata["ALBUM"] = album;
77 }
78
79 void TrackMetadata::setLength(int length) {
80         _length = length;
81 }