~ci-train-bot/media-hub/media-hub-ubuntu-yakkety-1823

« back to all changes in this revision

Viewing changes to src/com/ubuntu/music/track_list.cpp

  • Committer: Thomas Voß
  • Date: 2013-08-13 14:07:37 UTC
  • Revision ID: thomas.voss@canonical.com-20130813140737-ke081xhuotug54hd
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
 
17
 */
 
18
 
 
19
#include "com/ubuntu/music/track_list.h"
 
20
 
 
21
#include "com/ubuntu/music/track.h"
 
22
 
 
23
#include <functional>
 
24
#include <memory>
 
25
#include <vector>
 
26
 
 
27
namespace music = com::ubuntu::music;
 
28
 
 
29
struct music::TrackList::Private
 
30
{
 
31
    std::vector<music::Track> tracks;
 
32
    bool is_editable = true;
 
33
 
 
34
    bool operator==(const Private& rhs) const
 
35
    {
 
36
        return tracks == rhs.tracks && is_editable == rhs.is_editable;
 
37
    }
 
38
 
 
39
};
 
40
 
 
41
music::TrackList::TrackList() : d(new Private())
 
42
{
 
43
}
 
44
 
 
45
music::TrackList::TrackList(const music::TrackList& rhs) : d(new Private(*rhs.d))
 
46
{
 
47
}
 
48
 
 
49
music::TrackList::~TrackList()
 
50
{
 
51
}
 
52
 
 
53
music::TrackList& music::TrackList::operator=(const music::TrackList& rhs)
 
54
{
 
55
    *d = *rhs.d;
 
56
    return *this;
 
57
}
 
58
 
 
59
bool music::TrackList::operator==(const music::TrackList& rhs) const
 
60
{
 
61
    return *d == *rhs.d;
 
62
}
 
63
 
 
64
bool music::TrackList::is_editable()
 
65
{
 
66
    return d->is_editable;
 
67
}
 
68
 
 
69
void music::TrackList::add_track_with_uri(const music::Track::UriType& uri, const music::Track& after, bool make_current)
 
70
{
 
71
    (void) uri;
 
72
    (void) after;
 
73
    (void) make_current;
 
74
    // ToDo: Talk to service.
 
75
}
 
76
 
 
77
void music::TrackList::remove_track(const Track& track)
 
78
{
 
79
    (void) track;
 
80
 
 
81
    // TODO: Talk to actual service here.
 
82
}
 
83
 
 
84
void music::TrackList::for_each(const std::function<void(const music::Track&)> functor) const
 
85
{
 
86
    for (auto track : d->tracks)
 
87
        functor(track);
 
88
}
 
89
 
 
90
void music::TrackList::go_to(const music::Track& track)
 
91
{
 
92
    (void) track;
 
93
}
 
94
 
 
95
music::Connection music::TrackList::on_track_list_replaced(const std::function<void()>& slot)
 
96
{
 
97
    (void) slot;
 
98
    return Connection(nullptr);
 
99
}
 
100
 
 
101
music::Connection music::TrackList::on_track_added(const std::function<void(const music::Track& t)>& slot)
 
102
{
 
103
    (void) slot;
 
104
    return Connection(nullptr);
 
105
}
 
106
 
 
107
music::Connection music::TrackList::on_track_removed(const std::function<void(const music::Track& t)>& slot)
 
108
{
 
109
    (void) slot;
 
110
    return Connection(nullptr);
 
111
}
 
112
 
 
113
music::Connection music::TrackList::on_current_track_changed(const std::function<void(const music::Track&)>& slot)
 
114
{
 
115
    (void) slot;
 
116
    return Connection(nullptr);
 
117
}