1 /******************************************************************************
2     QtAV Player Demo:  this file is part of QtAV examples
3     Copyright (C) 2012-2014 Wang Bin <wbsecg1@gmail.com>
4 
5 *   This file is part of QtAV
6 
7     This program is free software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 ******************************************************************************/
20 
21 
22 #ifndef PLAYLIST_H
23 #define PLAYLIST_H
24 
25 #include <QWidget>
26 #include <QtCore/QModelIndex>
27 #include "PlayListItem.h"
28 
29 QT_BEGIN_NAMESPACE
30 class QListView;
31 class QToolButton;
32 QT_END_NAMESPACE
33 class PlayListDelegate;
34 
35 class PlayListModel;
36 class PlayList : public QWidget
37 {
38     Q_OBJECT
39 public:
40     explicit PlayList(QWidget *parent = 0);
41     ~PlayList();
42 
43     void setSaveFile(const QString& file);
44     QString saveFile() const;
45     void load();
46     void save();
47 
48     PlayListItem itemAt(int row);
49     void insertItemAt(const PlayListItem& item, int row = 0);
50     void setItemAt(const PlayListItem& item, int row = 0);
51     void remove(const QString& url);
52     void insert(const QString& url, int row = 0);
53     void setMaxRows(int r);
54     int maxRows() const;
55 
56 signals:
57     void aboutToPlay(const QString& url);
58 
59 private slots:
60     void removeSelectedItems();
61     void clearItems();
62     //
63     void addItems();
64 
65     void onAboutToPlay(const QModelIndex& index);
66     //void highlight(const QModelIndex& index);
67 private:
68     QListView *mpListView;
69     QToolButton *mpClear, *mpRemove, *mpAdd;
70     PlayListDelegate *mpDelegate;
71     PlayListModel *mpModel;
72     int mMaxRows;
73     QString mFile;
74     bool mFirstShow;
75 };
76 
77 #endif // PLAYLIST_H
78