~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libtomahawk/MetaPlaylistInterface.cpp

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 
2
 *
 
3
 *   Copyright 2012, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 
4
 *
 
5
 *   Tomahawk is free software: you can redistribute it and/or modify
 
6
 *   it under the terms of the GNU General Public License as published by
 
7
 *   the Free Software Foundation, either version 3 of the License, or
 
8
 *   (at your option) any later version.
 
9
 *
 
10
 *   Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#include "MetaPlaylistInterface.h"
 
20
#include "Result.h"
 
21
#include "Pipeline.h"
 
22
#include "Source.h"
 
23
#include "utils/Logger.h"
 
24
 
 
25
using namespace Tomahawk;
 
26
 
 
27
 
 
28
MetaPlaylistInterface::MetaPlaylistInterface()
 
29
    : Tomahawk::PlaylistInterface()
 
30
{
 
31
}
 
32
 
 
33
 
 
34
MetaPlaylistInterface::~MetaPlaylistInterface()
 
35
{
 
36
}
 
37
 
 
38
 
 
39
void
 
40
MetaPlaylistInterface::addChildInterface( const Tomahawk::playlistinterface_ptr& interface )
 
41
{
 
42
    m_childInterfaces << interface;
 
43
 
 
44
    if ( m_childInterfaces.count() == 1 )
 
45
    {
 
46
        connect( interface.data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ),
 
47
                                   SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) );
 
48
 
 
49
        connect( interface.data(), SIGNAL( shuffleModeChanged( bool ) ),
 
50
                                   SIGNAL( shuffleModeChanged( bool ) ) );
 
51
    }
 
52
}
 
53
 
 
54
 
 
55
QList< Tomahawk::query_ptr >
 
56
MetaPlaylistInterface::tracks() const
 
57
{
 
58
    if ( m_childInterfaces.count() )
 
59
        return m_childInterfaces.first()->tracks();
 
60
    else
 
61
        return QList< Tomahawk::query_ptr >();
 
62
}
 
63
 
 
64
 
 
65
int
 
66
MetaPlaylistInterface::trackCount() const
 
67
{
 
68
    if ( m_childInterfaces.count() )
 
69
        return m_childInterfaces.first()->trackCount();
 
70
    else
 
71
        return 0;
 
72
}
 
73
 
 
74
 
 
75
result_ptr
 
76
MetaPlaylistInterface::currentItem() const
 
77
{
 
78
    if ( m_childInterfaces.count() )
 
79
        return m_childInterfaces.first()->currentItem();
 
80
    else
 
81
        return Tomahawk::result_ptr();
 
82
}
 
83
 
 
84
 
 
85
qint64
 
86
MetaPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
 
87
{
 
88
    if ( m_childInterfaces.count() )
 
89
        return m_childInterfaces.first()->siblingIndex( itemsAway, rootIndex );
 
90
    else
 
91
        return -1;
 
92
}
 
93
 
 
94
 
 
95
Tomahawk::query_ptr
 
96
MetaPlaylistInterface::queryAt( qint64 index ) const
 
97
{
 
98
    if ( m_childInterfaces.count() )
 
99
        return m_childInterfaces.first()->queryAt( index );
 
100
    else
 
101
        return Tomahawk::query_ptr();
 
102
}
 
103
 
 
104
 
 
105
Tomahawk::result_ptr
 
106
MetaPlaylistInterface::resultAt( qint64 index ) const
 
107
{
 
108
    if ( m_childInterfaces.count() )
 
109
        return m_childInterfaces.first()->resultAt( index );
 
110
    else
 
111
        return Tomahawk::result_ptr();
 
112
}
 
113
 
 
114
 
 
115
qint64
 
116
MetaPlaylistInterface::indexOfResult( const Tomahawk::result_ptr& result ) const
 
117
{
 
118
    if ( m_childInterfaces.count() )
 
119
        return m_childInterfaces.first()->indexOfResult( result );
 
120
    else
 
121
        return -1;
 
122
}
 
123
 
 
124
 
 
125
qint64
 
126
MetaPlaylistInterface::indexOfQuery( const Tomahawk::query_ptr& query ) const
 
127
{
 
128
    if ( m_childInterfaces.count() )
 
129
        return m_childInterfaces.first()->indexOfQuery( query );
 
130
    else
 
131
        return -1;
 
132
}
 
133
 
 
134
 
 
135
PlaylistModes::RepeatMode
 
136
MetaPlaylistInterface::repeatMode() const
 
137
{
 
138
    if ( m_childInterfaces.count() )
 
139
        return m_childInterfaces.first()->repeatMode();
 
140
    else
 
141
        return PlaylistModes::NoRepeat;
 
142
}
 
143
 
 
144
 
 
145
bool
 
146
MetaPlaylistInterface::shuffled() const
 
147
{
 
148
    if ( m_childInterfaces.count() )
 
149
        return m_childInterfaces.first()->shuffled();
 
150
    else
 
151
        return false;
 
152
}
 
153
 
 
154
 
 
155
bool
 
156
MetaPlaylistInterface::hasChildInterface( const Tomahawk::playlistinterface_ptr& interface )
 
157
{
 
158
    foreach ( const Tomahawk::playlistinterface_ptr& iface, m_childInterfaces )
 
159
    {
 
160
        if ( iface == interface || iface->hasChildInterface( interface ) )
 
161
            return true;
 
162
    }
 
163
 
 
164
    return false;
 
165
}
 
166
 
 
167
 
 
168
void
 
169
MetaPlaylistInterface::setRepeatMode( PlaylistModes::RepeatMode mode )
 
170
{
 
171
    if ( m_childInterfaces.count() )
 
172
        return m_childInterfaces.first()->setRepeatMode( mode );
 
173
}
 
174
 
 
175
 
 
176
void
 
177
MetaPlaylistInterface::setShuffled( bool enabled )
 
178
{
 
179
    if ( m_childInterfaces.count() )
 
180
        return m_childInterfaces.first()->setShuffled( enabled );
 
181
}