3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
6 Minitube 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.
11 Minitube 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.
16 You should have received a copy of the GNU General Public License
17 along with Minitube. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef PLAYLISTMODEL_H
22 #define PLAYLISTMODEL_H
30 ItemTypeRole = Qt::UserRole,
35 DownloadButtonHoveredRole,
36 DownloadButtonPressedRole,
41 enum ItemTypes { ItemTypeVideo = 1, ItemTypeShowMore };
43 class PlaylistModel : public QAbstractListModel {
47 PlaylistModel(QWidget *parent = 0);
49 int rowCount(const QModelIndex &parent = QModelIndex()) const;
50 int columnCount(const QModelIndex &parent = QModelIndex()) const {
54 QVariant data(const QModelIndex &index, int role) const;
55 bool removeRows(int position, int rows, const QModelIndex &parent);
57 Qt::ItemFlags flags(const QModelIndex &index) const;
58 QStringList mimeTypes() const;
59 Qt::DropActions supportedDropActions() const;
60 Qt::DropActions supportedDragActions() const;
61 QMimeData *mimeData(const QModelIndexList &indexes) const;
62 bool dropMimeData(const QMimeData *data,
63 Qt::DropAction action,
66 const QModelIndex &parent);
68 void setActiveRow(int row, bool notify = true);
69 bool rowExists(int row) const { return ((row >= 0) && (row < videos.size())); }
70 int activeRow() const { return m_activeRow; } // returns -1 if there is no active row
72 int previousRow() const;
73 void removeIndexes(QModelIndexList &indexes);
74 int rowForVideo(Video *video);
75 QModelIndex indexForVideo(Video *video);
76 void move(QModelIndexList &indexes, bool up);
78 Video *videoAt(int row) const;
79 Video *activeVideo() const;
80 int rowForCloneVideo(const QString &videoId) const;
82 VideoSource *getVideoSource() { return videoSource; }
83 void setVideoSource(VideoSource *videoSource);
89 void addVideos(const QVector<Video *> &newVideos);
90 void searchFinished(int total);
91 void searchError(const QString &message);
92 void emitDataChanged();
94 void setHoveredRow(int row);
96 void updateHoveredRow();
98 void enterAuthorHover();
99 void exitAuthorHover();
100 void enterAuthorPressed();
101 void exitAuthorPressed();
104 void activeVideoChanged(Video *video, Video *previousVideo);
105 void needSelectionFor(const QVector<Video *> &videos);
106 void haveSuggestions(const QStringList &suggestions);
109 void handleFirstVideo(Video *video);
111 VideoSource *videoSource;
116 QVector<Video *> videos;
117 QVector<Video *> deletedVideos;
122 Video *m_activeVideo;
124 QString errorMessage;