PageRenderTime 142ms CodeModel.GetById 60ms app.highlight 7ms RepoModel.GetById 74ms app.codeStats 0ms

/src/libtomahawk/playlist/dynamic/DynamicModel.h

http://github.com/tomahawk-player/tomahawk
C Header | 107 lines | 56 code | 27 blank | 24 comment | 0 complexity | 381ec1081542293b26af8bbb3a0a6e1f MD5 | raw file
  1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2 *
  3 *   Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  4 *   Copyright 2010-2011, 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 DYNAMIC_MODEL_H
 21#define DYNAMIC_MODEL_H
 22
 23#include "playlist/PlaylistModel.h"
 24#include "Query.h"
 25
 26namespace Tomahawk
 27{
 28
 29class StationModelItem;
 30
 31/**
 32 * Extends PlaylistModel with support for handling stations
 33 */
 34class DynamicModel : public PlaylistModel
 35{
 36    Q_OBJECT
 37public:
 38    DynamicModel( QObject* parent = 0 );
 39    virtual ~DynamicModel();
 40
 41    void startOnDemand();
 42    void stopOnDemand( bool stopPlaying = true );
 43    void changeStation();
 44
 45    virtual QString description() const;
 46
 47    void loadPlaylist( const dynplaylist_ptr& playlist, bool loadEntries = true );
 48
 49    virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
 50
 51    bool searchingForNext() const { return m_searchingForNext; }
 52
 53    void setFilterUnresolvable( bool filter ) { m_filterUnresolvable = filter; }
 54    bool filterUnresolvable() const { return m_filterUnresolvable; }
 55
 56    // a batchof static tracks wre generated
 57    void tracksGenerated( const QList< query_ptr > entries, int limitResolvedTo = -1 );
 58
 59    using PlaylistModel::loadPlaylist;
 60
 61    bool ignoreRevision( const QString& revisionguid ) const { return waitForRevision( revisionguid ); }
 62    void removeRevisionFromIgnore( const QString& revisionguid ) { removeFromWaitList( revisionguid ); }
 63
 64signals:
 65    void collapseFromTo( int startRow, int num );
 66    void checkForOverflow();
 67
 68    void trackGenerationFailure( const QString& msg );
 69
 70    void tracksAdded();
 71
 72private slots:
 73    void newTrackGenerated( const Tomahawk::query_ptr& query );
 74
 75    void trackResolveFinished( bool );
 76    void newTrackLoading();
 77
 78    void filteringTrackResolved( bool successful );
 79
 80private:
 81    void filterUnresolved( const QList< query_ptr >& entries );
 82    void addToPlaylist( const QList< query_ptr >& entries, bool clearFirst );
 83
 84    dynplaylist_ptr m_playlist;
 85
 86    // for filtering unresolvable
 87    int m_limitResolvedTo;
 88    QList< query_ptr > m_toResolveList;
 89    QList< query_ptr > m_resolvedList;
 90
 91    // for managing upcoming queue
 92    QList< Query* > m_waitingFor;
 93    QList< QPair< QString, QString > > m_deduper;
 94
 95    bool m_onDemandRunning;
 96    bool m_changeOnNext;
 97    bool m_searchingForNext;
 98    bool m_firstTrackGenerated;
 99    bool m_filterUnresolvable;
100    bool m_startingAfterFailed;
101    int m_currentAttempts;
102    int m_lastResolvedRow;
103};
104
105};
106
107#endif