]> git.sur5r.net Git - minitube/blob - src/playlistmodel.h
Imported Upstream version 2.0
[minitube] / src / playlistmodel.h
1 #ifndef PLAYLISTMODEL_H
2 #define PLAYLISTMODEL_H
3
4 #include <QtGui>
5
6 class Video;
7 class VideoSource;
8
9 enum DataRoles {
10     ItemTypeRole = Qt::UserRole,
11     VideoRole,
12     ActiveTrackRole,
13     DownloadItemRole,
14     HoveredItemRole,
15     DownloadButtonHoveredRole,
16     DownloadButtonPressedRole,
17     AuthorHoveredRole,
18     AuthorPressedRole
19 };
20
21 enum ItemTypes {
22     ItemTypeVideo = 1,
23     ItemTypeShowMore
24 };
25
26 class PlaylistModel : public QAbstractListModel {
27
28     Q_OBJECT
29
30 public:
31     PlaylistModel(QWidget *parent = 0);
32
33     int rowCount(const QModelIndex &parent = QModelIndex()) const;
34     int columnCount( const QModelIndex& parent = QModelIndex() ) const { Q_UNUSED( parent ); return 4; }
35     QVariant data(const QModelIndex &index, int role) const;
36     bool removeRows(int position, int rows, const QModelIndex &parent);
37
38     Qt::ItemFlags flags(const QModelIndex &index) const;
39     QStringList mimeTypes() const;
40     Qt::DropActions supportedDropActions() const;
41     Qt::DropActions supportedDragActions() const;
42     QMimeData* mimeData( const QModelIndexList &indexes ) const;
43     bool dropMimeData(const QMimeData *data,
44                       Qt::DropAction action, int row, int column,
45                       const QModelIndex &parent);
46
47     void setActiveRow(int row , bool notify = true);
48     bool rowExists( int row ) const { return (( row >= 0 ) && ( row < videos.size() ) ); }
49     int activeRow() const { return m_activeRow; } // returns -1 if there is no active row
50     int nextRow() const;
51     int previousRow() const;
52     void removeIndexes(QModelIndexList &indexes);
53     int rowForVideo(Video* video);
54     QModelIndex indexForVideo(Video* video);
55     void move(QModelIndexList &indexes, bool up);
56
57     Video* videoAt( int row ) const;
58     Video* activeVideo() const;
59     int rowForCloneVideo(Video *video) const;
60
61     VideoSource* getVideoSource() { return videoSource; }
62     void setVideoSource(VideoSource *videoSource);
63     void abortSearch();
64
65 public slots:
66     void searchMore();
67     void searchNeeded();
68     void addVideos(QList<Video*> newVideos);
69     void searchFinished(int total);
70     void searchError(QString message);
71     void updateThumbnail();
72
73     void setHoveredRow(int row);
74     void clearHover();
75     void enterAuthorHover();
76     void exitAuthorHover();
77     void enterAuthorPressed();
78     void exitAuthorPressed();
79     void updateAuthor();
80
81 signals:
82     void activeRowChanged(int);
83     void needSelectionFor(QList<Video*>);
84     void haveSuggestions(const QStringList &suggestions);
85
86 private:
87     void handleFirstVideo(Video* video);
88     void searchMore(int max);
89
90     VideoSource *videoSource;
91     bool searching;
92     bool canSearchMore;
93     bool firstSearch;
94
95     QList<Video*> videos;
96     int skip;
97     int max;
98
99     int m_activeRow;
100     Video *m_activeVideo;
101
102     QString errorMessage;
103
104     int hoveredRow;
105     bool authorHovered;
106     bool authorPressed;
107 };
108
109 #endif