PageRenderTime 102ms CodeModel.GetById 60ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/src/libtomahawk/playlist/collectionflatmodel.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 73 lines | 39 code | 16 blank | 18 comment | 0 complexity | 3268a391d0a80ae51498bc03f6341f45 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 *
 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#ifndef COLLECTIONFLATMODEL_H
20#define COLLECTIONFLATMODEL_H
21
22#include <QAbstractItemModel>
23#include <QList>
24#include <QHash>
25
26#include "typedefs.h"
27#include "trackmodel.h"
28#include "query.h"
29#include "source.h"
30#include "playlistinterface.h"
31
32#include "database/databasecommand_alltracks.h"
33
34#include "dllmacro.h"
35
36class QMetaData;
37
38class DLLEXPORT CollectionFlatModel : public TrackModel
39{
40Q_OBJECT
41
42public:
43    explicit CollectionFlatModel( QObject* parent = 0 );
44    ~CollectionFlatModel();
45
46    virtual int trackCount() const { return rowCount( QModelIndex() ) + m_tracksToAdd.count(); }
47
48    void addCollections( const QList< Tomahawk::collection_ptr >& collections );
49    void addCollection( const Tomahawk::collection_ptr& collection, bool sendNotifications = true );
50    void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllTracks::SortOrder order );
51
52signals:
53    void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
54    void shuffleModeChanged( bool enabled );
55
56    void loadingStarted();
57    void loadingFinished();
58    void trackCountChanged( unsigned int tracks );
59
60private slots:
61    void onDataChanged();
62
63    void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
64    void onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks );
65
66private:
67    QMap< Tomahawk::collection_ptr, QPair< int, int > > m_collectionRows;
68    QList<Tomahawk::query_ptr> m_tracksToAdd;
69    // just to keep track of what we are waiting to be loaded
70    QList<Tomahawk::Collection*> m_loadingCollections;
71};
72
73#endif // COLLECTIONFLATMODEL_H