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
25 #if QT_VERSION >= 0x050000
33 ItemTypeRole = Qt::UserRole,
38 DownloadButtonHoveredRole,
39 DownloadButtonPressedRole,
49 class PlaylistModel : public QAbstractListModel {
54 PlaylistModel(QWidget *parent = 0);
56 int rowCount(const QModelIndex &parent = QModelIndex()) const;
57 int columnCount( const QModelIndex& parent = QModelIndex() ) const { Q_UNUSED( parent ); return 4; }
58 QVariant data(const QModelIndex &index, int role) const;
59 bool removeRows(int position, int rows, const QModelIndex &parent);
61 Qt::ItemFlags flags(const QModelIndex &index) const;
62 QStringList mimeTypes() const;
63 Qt::DropActions supportedDropActions() const;
64 Qt::DropActions supportedDragActions() const;
65 QMimeData* mimeData( const QModelIndexList &indexes ) const;
66 bool dropMimeData(const QMimeData *data,
67 Qt::DropAction action, int row, int column,
68 const QModelIndex &parent);
70 void setActiveRow(int row , bool notify = true);
71 bool rowExists( int row ) const { return (( row >= 0 ) && ( row < videos.size() ) ); }
72 int activeRow() const { return m_activeRow; } // returns -1 if there is no active row
74 int previousRow() const;
75 void removeIndexes(QModelIndexList &indexes);
76 int rowForVideo(Video* video);
77 QModelIndex indexForVideo(Video* video);
78 void move(QModelIndexList &indexes, bool up);
80 Video* videoAt( int row ) const;
81 Video* activeVideo() const;
82 int rowForCloneVideo(const QString &videoId) const;
84 VideoSource* getVideoSource() { return videoSource; }
85 void setVideoSource(VideoSource *videoSource);
91 void addVideos(QList<Video*> newVideos);
92 void searchFinished(int total);
93 void searchError(QString message);
94 void updateThumbnail();
96 void setHoveredRow(int row);
98 void enterAuthorHover();
99 void exitAuthorHover();
100 void enterAuthorPressed();
101 void exitAuthorPressed();
105 void activeRowChanged(int);
106 void needSelectionFor(QList<Video*>);
107 void haveSuggestions(const QStringList &suggestions);
110 void handleFirstVideo(Video* video);
111 void searchMore(int max);
113 VideoSource *videoSource;
118 QList<Video*> videos;
123 Video *m_activeVideo;
125 QString errorMessage;