]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/playlist_model.hpp
Qt: clear PL item id cache when sorting
[vlc] / modules / gui / qt4 / components / playlist / playlist_model.hpp
index f48a9ae73a597dd18ce1ec027e84b246c3efbe22..def5ce6e9085a7b5bb96d9eb2833b07c0b2c4706 100644 (file)
 #include <QVariant>
 
 class QSignalMapper;
-
 class PLItem;
 
-#define DEPTH_PL -1
-#define DEPTH_SEL 1
-
-enum {
-    ItemUpdate_Type = QEvent::User + PLEventType + 2,
-    ItemDelete_Type = QEvent::User + PLEventType + 3,
-    ItemAppend_Type = QEvent::User + PLEventType + 4,
-};
-
-class PLEvent : public QEvent
-{
-public:
-    PLEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
-    {
-        i_id = id;
-        add.i_node = -1;
-        add.i_item = -1;
-    };
-
-    PLEvent( const playlist_add_t  *a ) : QEvent( (QEvent::Type)(ItemAppend_Type) )
-    {
-        add = *a;
-    };
-
-    virtual ~PLEvent() { };
-
-    int i_id;
-    playlist_add_t add;
-};
-
-
 class PLModel : public QAbstractItemModel
 {
     Q_OBJECT
@@ -113,7 +81,6 @@ public:
 
     /* Lookups */
     QStringList selectedURIs();
-    bool hasRandom(); bool hasLoop(); bool hasRepeat();
     QModelIndex index( PLItem *, int c ) const;
     QModelIndex currentIndex( ) { return index( currentItem, 0 ); };
     bool isCurrent( const QModelIndex &index ) const;
@@ -128,6 +95,8 @@ public:
     void removeItem( int );
     void rebuild(); void rebuild( playlist_item_t *, bool b_first = false );
 
+    static inline PLItem *getItem( QModelIndex index );
+
 private:
 
     /* General */
@@ -140,23 +109,16 @@ private:
 
     static QIcon icons[ITEM_TYPE_NUMBER];
 
-    /* Callbacks related */
-    void addCallbacks();
-    void delCallbacks();
-    void customEvent( QEvent * );
-    void processItemRemoval( int i_id );
-    void processItemAppend( const playlist_add_t *p_add );
-
     /* Actions */
     void recurseDelete( QList<PLItem*> children, QModelIndexList *fullList );
     void doDeleteItem( PLItem *item, QModelIndexList *fullList );
     void updateTreeItem( PLItem * );
+    void removeItem ( PLItem * );
     void takeItem( PLItem * ); //will not delete item
     void insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos );
     void dropAppendCopy( QByteArray& data, PLItem *target );
     void dropMove( QByteArray& data, PLItem *target, int new_pos );
     /* The following actions will not signal the view! */
-    void removeItem ( PLItem * );
     void updateChildren( PLItem * );
     void updateChildren( playlist_item_t *, PLItem * );
 
@@ -168,9 +130,10 @@ private:
     PLItem *findById( PLItem *, int );
     PLItem *findByInput( PLItem *, int );
     PLItem *findInner( PLItem *, int , bool );
-    static inline PLItem *getItem( QModelIndex index );
+
     int columnFromMeta( int meta_column ) const;
     int columnToMeta( int column ) const;
+    bool canEdit() const;
     PLItem *p_cached_item;
     PLItem *p_cached_item_bi;
     int i_cached_id;
@@ -182,9 +145,6 @@ signals:
 public slots:
     void activateItem( const QModelIndex &index );
     void activateItem( playlist_item_t *p_item );
-    void setRandom( bool );
-    void setLoop( bool );
-    void setRepeat( bool );
 
 private slots:
     void popupPlay();
@@ -198,6 +158,8 @@ private slots:
     void popupSortDesc();
     void processInputItemUpdate( input_item_t *);
     void processInputItemUpdate( input_thread_t* p_input );
+    void processItemRemoval( int i_id );
+    void processItemAppend( int item, int parent );
 };
 
 #endif