]> git.sur5r.net Git - minitube/blobdiff - src/playlistmodel.h
Upload 3.9.3-2 to unstable
[minitube] / src / playlistmodel.h
index 88d6dcfea7601e24bfa3bb6a17449e9774485f21..bd0fd2df6fc007f020aebbb8185ba688294b24ec 100644 (file)
@@ -21,10 +21,7 @@ $END_LICENSE */
 #ifndef PLAYLISTMODEL_H
 #define PLAYLISTMODEL_H
 
-#include <QtGui>
-#if QT_VERSION >= 0x050000
 #include <QtWidgets>
-#endif
 
 class Video;
 class VideoSource;
@@ -41,20 +38,19 @@ enum DataRoles {
     AuthorPressedRole
 };
 
-enum ItemTypes {
-    ItemTypeVideo = 1,
-    ItemTypeShowMore
-};
+enum ItemTypes { ItemTypeVideo = 1, ItemTypeShowMore };
 
 class PlaylistModel : public QAbstractListModel {
-
     Q_OBJECT
 
 public:
     PlaylistModel(QWidget *parent = 0);
 
     int rowCount(const QModelIndex &parent = QModelIndex()) const;
-    int columnCount( const QModelIndex& parent = QModelIndex() ) const { Q_UNUSED( parent ); return 4; }
+    int columnCount(const QModelIndex &parent = QModelIndex()) const {
+        Q_UNUSED(parent);
+        return 4;
+    }
     QVariant data(const QModelIndex &index, int role) const;
     bool removeRows(int position, int rows, const QModelIndex &parent);
 
@@ -62,61 +58,64 @@ public:
     QStringList mimeTypes() const;
     Qt::DropActions supportedDropActions() const;
     Qt::DropActions supportedDragActions() const;
-    QMimeData* mimeData( const QModelIndexList &indexes ) const;
+    QMimeData *mimeData(const QModelIndexList &indexes) const;
     bool dropMimeData(const QMimeData *data,
-                      Qt::DropAction action, int row, int column,
+                      Qt::DropAction action,
+                      int row,
+                      int column,
                       const QModelIndex &parent);
 
-    void setActiveRow(int row , bool notify = true);
-    bool rowExists( int row ) const { return (( row >= 0 ) && ( row < videos.size() ) ); }
+    void setActiveRow(int row, bool notify = true);
+    bool rowExists(int row) const { return ((row >= 0) && (row < videos.size())); }
     int activeRow() const { return m_activeRow; } // returns -1 if there is no active row
     int nextRow() const;
     int previousRow() const;
     void removeIndexes(QModelIndexList &indexes);
-    int rowForVideo(Videovideo);
-    QModelIndex indexForVideo(Videovideo);
+    int rowForVideo(Video *video);
+    QModelIndex indexForVideo(Video *video);
     void move(QModelIndexList &indexes, bool up);
 
-    Video* videoAt( int row ) const;
-    VideoactiveVideo() const;
+    Video *videoAt(int row) const;
+    Video *activeVideo() const;
     int rowForCloneVideo(const QString &videoId) const;
 
-    VideoSourcegetVideoSource() { return videoSource; }
+    VideoSource *getVideoSource() { return videoSource; }
     void setVideoSource(VideoSource *videoSource);
     void abortSearch();
 
 public slots:
     void searchMore();
     void searchNeeded();
-    void addVideos(QList<Video*> newVideos);
+    void addVideos(const QVector<Video *> &newVideos);
     void searchFinished(int total);
-    void searchError(QString message);
-    void updateThumbnail();
+    void searchError(const QString &message);
+    void emitDataChanged();
 
     void setHoveredRow(int row);
     void clearHover();
+    void updateHoveredRow();
+
     void enterAuthorHover();
     void exitAuthorHover();
     void enterAuthorPressed();
     void exitAuthorPressed();
-    void updateAuthor();
 
 signals:
-    void activeRowChanged(int);
-    void needSelectionFor(QList<Video*>);
+    void activeVideoChanged(Video *video, Video *previousVideo);
+    void needSelectionFor(const QVector<Video *> &videos);
     void haveSuggestions(const QStringList &suggestions);
 
 private:
-    void handleFirstVideo(Video* video);
-    void searchMore(int max);
+    void handleFirstVideo(Video *video);
 
     VideoSource *videoSource;
     bool searching;
     bool canSearchMore;
     bool firstSearch;
 
-    QList<Video*> videos;
-    int skip;
+    QVector<Video *> videos;
+    QVector<Video *> deletedVideos;
+    int startIndex;
     int max;
 
     int m_activeRow;
@@ -127,6 +126,8 @@ private:
     int hoveredRow;
     bool authorHovered;
     bool authorPressed;
+
+    QMutex mutex;
 };
 
 #endif