PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 7ms RepoModel.GetById 33ms app.codeStats 0ms

/src/libtomahawk/playlist/TreeModel.h

http://github.com/tomahawk-player/tomahawk
C Header | 93 lines | 51 code | 22 blank | 20 comment | 0 complexity | b0004f49c0bb0de2fad980c1d65e9ded 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-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 TREEMODEL_H
21#define TREEMODEL_H
22
23#include <QAbstractItemModel>
24#include <QPixmap>
25
26#include "Artist.h"
27#include "Album.h"
28#include "Query.h"
29#include "Result.h"
30#include "PlayableModel.h"
31#include "PlaylistInterface.h"
32#include "database/DatabaseCommand_AllArtists.h"
33
34#include "DllMacro.h"
35#include "Typedefs.h"
36
37class QMetaData;
38
39class PlayableItem;
40
41class DLLEXPORT TreeModel : public PlayableModel
42{
43Q_OBJECT
44
45public:
46    explicit TreeModel( QObject* parent = 0 );
47    virtual ~TreeModel();
48
49    virtual Tomahawk::ModelMode mode() const { return m_mode; }
50    virtual void setMode( Tomahawk::ModelMode mode );
51
52    Tomahawk::collection_ptr collection() const;
53
54    void addCollection( const Tomahawk::collection_ptr& collection );
55    //TODO: Unused, but will be useful for supporting filtered queries. - Teo 1/2013
56    //void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllArtists::SortOrder order );
57
58    void addArtists( const Tomahawk::artist_ptr& artist );
59    void fetchAlbums( const Tomahawk::artist_ptr& artist );
60
61    void getCover( const QModelIndex& index );
62
63    virtual PlayableItem* itemFromResult( const Tomahawk::result_ptr& result ) const;
64
65    virtual QModelIndex indexFromArtist( const Tomahawk::artist_ptr& artist ) const;
66    virtual QModelIndex indexFromAlbum( const Tomahawk::album_ptr& album ) const;
67    virtual QModelIndex indexFromResult( const Tomahawk::result_ptr& result ) const;
68    virtual QModelIndex indexFromQuery( const Tomahawk::query_ptr& query ) const;
69
70public slots:
71    void addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr>& albums );
72    void addTracks( const Tomahawk::album_ptr& album, const QModelIndex& parent );
73
74signals:
75    void modeChanged( Tomahawk::ModelMode mode );
76
77protected:
78    bool canFetchMore( const QModelIndex& parent ) const;
79    void fetchMore( const QModelIndex& parent );
80
81private slots:
82    void onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists );
83    void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
84    void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModelIndex& index );
85
86private:
87    Tomahawk::ModelMode m_mode;
88    Tomahawk::collection_ptr m_collection;
89
90    QList<Tomahawk::artist_ptr> m_artistsFilter;
91};
92
93#endif // ALBUMMODEL_H