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,
46 class PlaylistModel : public QAbstractListModel {
51 PlaylistModel(QWidget *parent = 0);
53 int rowCount(const QModelIndex &parent = QModelIndex()) const;
54 int columnCount( const QModelIndex& parent = QModelIndex() ) const { Q_UNUSED( parent ); return 4; }
55 QVariant data(const QModelIndex &index, int role) const;
56 bool removeRows(int position, int rows, const QModelIndex &parent);
58 Qt::ItemFlags flags(const QModelIndex &index) const;
59 QStringList mimeTypes() const;
60 Qt::DropActions supportedDropActions() const;
61 Qt::DropActions supportedDragActions() const;
62 QMimeData* mimeData( const QModelIndexList &indexes ) const;
63 bool dropMimeData(const QMimeData *data,
64 Qt::DropAction action, int row, int column,
65 const QModelIndex &parent);
67 void setActiveRow(int row , bool notify = true);
68 bool rowExists( int row ) const { return (( row >= 0 ) && ( row < videos.size() ) ); }
69 int activeRow() const { return m_activeRow; } // returns -1 if there is no active row
71 int previousRow() const;
72 void removeIndexes(QModelIndexList &indexes);
73 int rowForVideo(Video* video);
74 QModelIndex indexForVideo(Video* video);
75 void move(QModelIndexList &indexes, bool up);
77 Video* videoAt( int row ) const;
78 Video* activeVideo() const;
79 int rowForCloneVideo(const QString &videoId) const;
81 VideoSource* getVideoSource() { return videoSource; }
82 void setVideoSource(VideoSource *videoSource);
88 void addVideos(QList<Video*> newVideos);
89 void searchFinished(int total);
90 void searchError(QString message);
91 void updateThumbnail();
93 void setHoveredRow(int row);
95 void enterAuthorHover();
96 void exitAuthorHover();
97 void enterAuthorPressed();
98 void exitAuthorPressed();
102 void activeRowChanged(int);
103 void needSelectionFor(QList<Video*>);
104 void haveSuggestions(const QStringList &suggestions);
107 void handleFirstVideo(Video* video);
108 void searchMore(int max);
110 VideoSource *videoSource;
115 QList<Video*> videos;
120 Video *m_activeVideo;
122 QString errorMessage;