]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/playlist_model.hpp
Qt, playlist: Move getMeta helper functions to PLModel
[vlc] / modules / gui / qt4 / components / playlist / playlist_model.hpp
index f6343dfebae8adca8b79c2cc1c161926f3a287c3..2147f227022964b4d7c85eaa6f5c3347430f9996 100644 (file)
 
 #include "playlist_item.hpp"
 
-#include <QModelIndex>
-#include <QObject>
-#include <QEvent>
 #include <QMimeData>
-#include <QSignalMapper>
 #include <QAbstractItemModel>
 #include <QVariant>
-#include <QAction>
+#include <QModelIndex>
 
 class PLItem;
 class PLSelector;
 class PlMimeData;
+class QSignalMapper;
 
 class PLModel : public QAbstractItemModel
 {
     Q_OBJECT
 
-friend class PLItem;
-friend class PLSelector;
-
 public:
     enum {
       IsCurrentRole = Qt::UserRole,
@@ -70,13 +64,13 @@ public:
     /*** QModel subclassing ***/
 
     /* Data structure */
-    QVariant data( const QModelIndex &index, int role ) const;
+    QVariant data( const QModelIndex &index, const int role ) const;
     QVariant headerData( int section, Qt::Orientation orientation,
                          int role = Qt::DisplayRole ) const;
     int rowCount( const QModelIndex &parent = QModelIndex() ) const;
     int columnCount( const QModelIndex &parent = QModelIndex() ) const;
     Qt::ItemFlags flags( const QModelIndex &index ) const;
-    QModelIndex index( int r, int c, const QModelIndex &parent ) const;
+    QModelIndex index( const int r, const int c, const QModelIndex &parent ) const;
     QModelIndex parent( const QModelIndex &index ) const;
 
     /* Drag and Drop */
@@ -90,21 +84,24 @@ public:
 
     /* Lookups */
     QStringList selectedURIs();
-    QModelIndex index( PLItem *, int c ) const;
-    QModelIndex index( int i_id, int c );
-    QModelIndex currentIndex();
+    QModelIndex index( PLItem *, const int c ) const;
+    QModelIndex index( const int i_id, const int c );
+    QModelIndex currentIndex() const;
     bool isParent( const QModelIndex &index, const QModelIndex &current) const;
     bool isCurrent( const QModelIndex &index ) const;
     int itemId( const QModelIndex &index ) const;
     static int columnFromMeta( int meta_column );
     static int columnToMeta( int column );
 
+    static QString getMeta( const QModelIndex & index, int meta );
+    static QPixmap getArtPixmap( const QModelIndex & index, const QSize & size );
+
     /* Actions */
     bool popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list );
     void doDelete( QModelIndexList selected );
     void search( const QString& search_text, const QModelIndex & root, bool b_recursive );
-    void sort( int column, Qt::SortOrder order );
-    void sort( int i_root_id, int column, Qt::SortOrder order );
+    void sort( const int column, Qt::SortOrder order );
+    void sort( const int i_root_id, const int column, Qt::SortOrder order );
     void rebuild();
     void rebuild( playlist_item_t * );
 
@@ -154,9 +151,9 @@ private:
     QSignalMapper *sortingMapper;
 
     /* Lookups */
-    PLItem *findById( PLItem *, int );
-    PLItem *findByInput( PLItem *, int );
-    PLItem *findInner( PLItem *, int , bool );
+    PLItem *findById( PLItem *, int ) const;
+    PLItem *findByInput( PLItem *, int ) const;
+    PLItem *findInner(PLItem *, int , bool ) const;
     bool canEdit() const;
 
     PLItem *p_cached_item;