Fixes in desktop file
[someplayer] / src / track.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 "track.h"
21 #include "tagresolver.h"
22
23 using namespace SomePlayer::DataObjects;
24
25 Track::Track() : QObject() {
26 }
27
28 Track::Track(int id, TrackMetadata metadata, QString source) : QObject() {
29         _id = id;
30         _metadata = metadata;
31         _source = source;
32         _count = 0;
33 }
34
35 Track::Track(const Track &track) : QObject() {
36         this->_metadata = track.metadata();
37         this->_source = track.source();
38         this->_id = track._id;
39         this->_count = track._count;
40 }
41
42 Track::Track(QString source) :QObject() {
43         _resolver = new TagResolver(this);
44         connect(_resolver, SIGNAL(decoded(Track)), this, SLOT(decoded(Track)));
45         QStringList foo;
46         foo << source;
47         _resolver->decode(foo);
48         _count = 0;
49         _id = -1;
50 }
51
52 TrackMetadata Track::metadata() const {
53         return _metadata;
54 }
55
56 QString Track::source() const {
57         return _source;
58 }
59
60 int Track::id() const {
61         return _id;
62 }
63
64 void Track::setSource(QString source) {
65         _source = source;
66 }
67
68 int Track::count() const{
69         return _count;
70 }
71
72 void Track::setCount(int count) {
73         _count = count;
74 }
75
76 void Track::decoded(Track track) {
77         _id = track.id();
78         _source = track.source();
79         _metadata = track.metadata();
80         delete _resolver;
81 }
82
83 Track &Track::operator =(const Track &track) {
84         _id = track.id();
85         _source = track.source();
86         _metadata = track.metadata();
87         _count = track._count;
88         return *this;
89 }
90
91 Track::~Track() {}
92
93 bool Track::operator ==(const Track &track) {
94         return _source == track._source;
95 }