notification on playlist save error, small changes
[tomamp] / tomamp / playlistmanager.h
1 #ifndef PLAYLISTMANAGER_H
2 #define PLAYLISTMANAGER_H
3
4 #include <QWidget>
5 #include <phonon/mediaobject.h>
6 #include <phonon/backendcapabilities.h>
7
8
9
10 struct PlaylistItem
11 {
12     Phonon::MediaSource source;
13     QString uri;
14     bool playable;
15     bool localFile;
16     QString title;
17     QString artist;
18     QString album;
19 /*    QString year;
20     QString genre;
21     QString length;*/
22     PlaylistItem (const QString& uri) : source (Phonon::MediaSource (uri)), uri (uri), playable (false), localFile (false) {  }
23     bool operator ==(const Phonon::MediaSource& s) const { return source == s; }
24 };
25
26 class PlaylistManager : public QObject
27 {
28     Q_OBJECT
29 public:
30     PlaylistManager(QWidget* parent);
31     void addStringList (const QStringList&);
32     void parseAndAddFolder (const QString& dir, bool recursive);
33     void removeItem (int i);
34
35     QStringList playlistStrings () const;
36     int size () const { return items.size (); }
37     int indexOf (const Phonon::MediaSource& s) const;
38     const Phonon::MediaSource& at (int i) { return items[i].source; }
39     const PlaylistItem& getItem (int i) const { return items[i]; }
40     bool moveItemUp (int i);
41     bool moveItemDown (int i);
42 public slots:
43     bool savePlaylist(const QString& filename);
44     void loadPlaylist(const QString& filename);
45     void clearPlaylist();
46     void addPlaylist (const QString& filename);
47 signals:
48     void playlistChanged (int from);
49     void itemRemoved (int i);
50     void itemUpdated (int index);
51 private slots:
52     void metaStateChanged(Phonon::State newState, Phonon::State oldState);
53     void appendPlaylist (const QString& filename);
54     void appendPlaylistPLS (const QString& filename);
55 private:
56     bool fileSupported (const QString& fname) const;
57
58     Phonon::MediaObject *metaInformationResolver;
59     QList<PlaylistItem> items;
60     QWidget* parentWidget;
61     int lastMetaRead;
62 };
63
64 #endif // PLAYLISTMANAGER_H