1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2012, Christian Muehlhaeuser <muesli@tomahawk-player.org>
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.
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.
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/>.
19
#include "MetaPlaylistInterface.h"
23
#include "utils/Logger.h"
25
using namespace Tomahawk;
28
MetaPlaylistInterface::MetaPlaylistInterface()
29
: Tomahawk::PlaylistInterface()
34
MetaPlaylistInterface::~MetaPlaylistInterface()
40
MetaPlaylistInterface::addChildInterface( const Tomahawk::playlistinterface_ptr& interface )
42
m_childInterfaces << interface;
44
if ( m_childInterfaces.count() == 1 )
46
connect( interface.data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ),
47
SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) );
49
connect( interface.data(), SIGNAL( shuffleModeChanged( bool ) ),
50
SIGNAL( shuffleModeChanged( bool ) ) );
55
QList< Tomahawk::query_ptr >
56
MetaPlaylistInterface::tracks() const
58
if ( m_childInterfaces.count() )
59
return m_childInterfaces.first()->tracks();
61
return QList< Tomahawk::query_ptr >();
66
MetaPlaylistInterface::trackCount() const
68
if ( m_childInterfaces.count() )
69
return m_childInterfaces.first()->trackCount();
76
MetaPlaylistInterface::currentItem() const
78
if ( m_childInterfaces.count() )
79
return m_childInterfaces.first()->currentItem();
81
return Tomahawk::result_ptr();
86
MetaPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const
88
if ( m_childInterfaces.count() )
89
return m_childInterfaces.first()->siblingIndex( itemsAway, rootIndex );
96
MetaPlaylistInterface::queryAt( qint64 index ) const
98
if ( m_childInterfaces.count() )
99
return m_childInterfaces.first()->queryAt( index );
101
return Tomahawk::query_ptr();
106
MetaPlaylistInterface::resultAt( qint64 index ) const
108
if ( m_childInterfaces.count() )
109
return m_childInterfaces.first()->resultAt( index );
111
return Tomahawk::result_ptr();
116
MetaPlaylistInterface::indexOfResult( const Tomahawk::result_ptr& result ) const
118
if ( m_childInterfaces.count() )
119
return m_childInterfaces.first()->indexOfResult( result );
126
MetaPlaylistInterface::indexOfQuery( const Tomahawk::query_ptr& query ) const
128
if ( m_childInterfaces.count() )
129
return m_childInterfaces.first()->indexOfQuery( query );
135
PlaylistModes::RepeatMode
136
MetaPlaylistInterface::repeatMode() const
138
if ( m_childInterfaces.count() )
139
return m_childInterfaces.first()->repeatMode();
141
return PlaylistModes::NoRepeat;
146
MetaPlaylistInterface::shuffled() const
148
if ( m_childInterfaces.count() )
149
return m_childInterfaces.first()->shuffled();
156
MetaPlaylistInterface::hasChildInterface( const Tomahawk::playlistinterface_ptr& interface )
158
foreach ( const Tomahawk::playlistinterface_ptr& iface, m_childInterfaces )
160
if ( iface == interface || iface->hasChildInterface( interface ) )
169
MetaPlaylistInterface::setRepeatMode( PlaylistModes::RepeatMode mode )
171
if ( m_childInterfaces.count() )
172
return m_childInterfaces.first()->setRepeatMode( mode );
177
MetaPlaylistInterface::setShuffled( bool enabled )
179
if ( m_childInterfaces.count() )
180
return m_childInterfaces.first()->setShuffled( enabled );