Now 'Artist name' and 'ArTist Name' is the same for library
[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 #include <QFileInfo>
23
24 using namespace SomePlayer::DataObjects;
25
26 Track::Track() : QObject() {
27 }
28
29 Track::Track(int id, TrackMetadata metadata, QString source) : QObject() {
30         _id = id;
31         _metadata = metadata;
32         if (_metadata.title() == _UNKNOWN_TRACK_) {
33                 QFileInfo info(source);
34                 _metadata.setTitle(info.baseName());
35         }
36         _source = source;
37         _count = 0;
38 }
39
40 Track::Track(const Track &track) : QObject() {
41         this->_metadata = track.metadata();
42         this->_source = track.source();
43         this->_id = track._id;
44         this->_count = track._count;
45 }
46
47 /// deprecated
48 Track::Track(QString source) :QObject() {
49         _resolver = new TagResolver(this);
50         connect(_resolver, SIGNAL(decoded(Track)), this, SLOT(decoded(Track)));
51         QStringList foo;
52         foo << source;
53         _resolver->decode(foo);
54         _count = 0;
55         _id = -1;
56 }
57
58 TrackMetadata Track::metadata() const {
59         return _metadata;
60 }
61
62 QString Track::source() const {
63         return _source;
64 }
65
66 int Track::id() const {
67         return _id;
68 }
69
70 void Track::setSource(QString source) {
71         _source = source;
72 }
73
74 int Track::count() const{
75         return _count;
76 }
77
78 void Track::setCount(int count) {
79         _count = count;
80 }
81
82 void Track::decoded(Track track) {
83         _id = track.id();
84         _source = track.source();
85         _metadata = track.metadata();
86         delete _resolver;
87 }
88
89 Track &Track::operator =(const Track &track) {
90         _id = track.id();
91         _source = track.source();
92         _metadata = track.metadata();
93         _count = track._count;
94         return *this;
95 }
96
97 Track::~Track() {}
98
99 bool Track::operator ==(const Track &track) {
100         return _source == track._source;
101 }