summaryrefslogtreecommitdiffstats
path: root/src/library/banshee/bansheeplaylistmodel.h
blob: 95ba244342b3152d4529eaa9305a8e9775dedc6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef BANSHEEPLAYLISTMODEL_H
#define BANSHEEPLAYLISTMODEL_H

#include <QHash>
#include <QtSql>

#include "library/trackmodel.h"
#include "library/trackcollection.h"
#include "library/dao/trackdao.h"
#include "library/banshee/bansheedbconnection.h"
#include "library/stardelegate.h"
#include "library/basesqltablemodel.h"

class BansheePlaylistModel : public BaseSqlTableModel {
    Q_OBJECT
  public:
    BansheePlaylistModel(QObject* pParent, TrackCollection* pTrackCollection, BansheeDbConnection* pConnection);
    virtual ~BansheePlaylistModel();

    void setTableModel(int playlistId);

    virtual TrackPointer getTrack(const QModelIndex& index) const;
    virtual QString getTrackLocation(const QModelIndex& index) const;
    virtual bool isColumnInternal(int column);

    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
    TrackModel::CapabilitiesFlags getCapabilities() const;

    virtual bool setData(const QModelIndex& index, const QVariant& value, int role=Qt::EditRole);


  protected:
    // Use this if you want a model that is read-only.
    virtual Qt::ItemFlags readOnlyFlags(const QModelIndex &index) const;
    // Use this if you want a model that can be changed
    virtual Qt::ItemFlags readWriteFlags(const QModelIndex &index) const;

  private slots:
    virtual void tracksChanged(QSet<TrackId> trackIds);
    virtual void trackLoaded(QString group, TrackPointer pTrack);

  private:
    QString getFieldString(const QModelIndex& index, const QString& fieldName) const;
    QVariant getFieldVariant(const QModelIndex& index, const QString& fieldName) const;

    TrackCollection* m_pTrackCollection;
    BansheeDbConnection* m_pConnection;
    int m_playlistId;
};

#endif // BANSHEEPLAYLISTMODEL_H