PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 9ms RepoModel.GetById 31ms app.codeStats 1ms

/src/libtomahawk/SourcePlaylistInterface.h

http://github.com/tomahawk-player/tomahawk
C Header | 89 lines | 50 code | 21 blank | 18 comment | 0 complexity | c294ba38d18e1f35bb29cfb30894ec60 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *   Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
 5 *
 6 *   Tomahawk is free software: you can redistribute it and/or modify
 7 *   it under the terms of the GNU General Public License as published by
 8 *   the Free Software Foundation, either version 3 of the License, or
 9 *   (at your option) any later version.
10 *
11 *   Tomahawk is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef TOMAHAWKSOURCEPLAYLISTINTERFACE_H
21#define TOMAHAWKSOURCEPLAYLISTINTERFACE_H
22
23#include <QObject>
24#include <QPointer>
25
26#include "Typedefs.h"
27#include "PlaylistInterface.h"
28
29#include "DllMacro.h"
30
31namespace Tomahawk
32{
33
34class DLLEXPORT SourcePlaylistInterface : public Tomahawk::PlaylistInterface
35{
36Q_OBJECT
37
38public:
39    SourcePlaylistInterface( Tomahawk::Source* source, Tomahawk::PlaylistModes::LatchMode latchMode = PlaylistModes::StayOnSong );
40    virtual ~SourcePlaylistInterface();
41
42    QList<Tomahawk::query_ptr> tracks() const;
43
44    virtual int trackCount() const { return 1; }
45
46    virtual void setCurrentIndex( qint64 index );
47    virtual Tomahawk::result_ptr resultAt( qint64 index ) const;
48    virtual Tomahawk::query_ptr queryAt( qint64 index ) const;
49    virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const;
50    virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
51
52    virtual qint64 siblingIndex( int itemsAway, qint64 rootIndex = -1 ) const;
53    virtual bool sourceValid() const;
54    virtual bool hasNextResult() const;
55    virtual Tomahawk::result_ptr nextResult() const;
56    virtual Tomahawk::result_ptr currentItem() const;
57
58    virtual PlaylistModes::RepeatMode repeatMode() const { return PlaylistModes::NoRepeat; }
59    virtual PlaylistModes::SeekRestrictions seekRestrictions() const { return PlaylistModes::NoSeek; }
60    virtual PlaylistModes::SkipRestrictions skipRestrictions() const { return PlaylistModes::NoSkipBackwards; }
61    virtual PlaylistModes::RetryMode retryMode() const { return PlaylistModes::Retry; }
62    virtual quint32 retryInterval() const { return 5000; }
63
64    virtual void setLatchMode( PlaylistModes::LatchMode latchMode ) { m_latchMode = latchMode; emit latchModeChanged( latchMode ); }
65
66    virtual bool shuffled() const { return false; }
67
68    virtual QPointer< Tomahawk::Source > source() const;
69
70    virtual void reset();
71
72public slots:
73    virtual void setRepeatMode( PlaylistModes::RepeatMode ) {}
74    virtual void setShuffled( bool ) {}
75    virtual void audioPaused() { setLatchMode( PlaylistModes::StayOnSong ); }
76
77private slots:
78    void onSourcePlaybackStarted( const Tomahawk::track_ptr& track );
79    void resolvingFinished( bool hasResults );
80
81private:
82    QPointer< Tomahawk::Source > m_source;
83    mutable Tomahawk::result_ptr m_currentItem;
84    mutable bool m_gotNextItem;
85};
86
87}; // ns
88
89#endif