X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Fplaylist%2Fplaylist_model.hpp;h=cb5e68c3e04766c9ee682acc8f9eeaa6b6c192c5;hb=790811343ae90c501aabd1a40ec375659fd415f2;hp=620ea81db8bc0f0d5e15234e33f6bc4abf14097d;hpb=ee145e3acff6449afb3a27a9e505213518873d40;p=vlc diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp index 620ea81db8..cb5e68c3e0 100644 --- a/modules/gui/qt4/components/playlist/playlist_model.hpp +++ b/modules/gui/qt4/components/playlist/playlist_model.hpp @@ -45,40 +45,8 @@ #include 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 @@ -86,6 +54,10 @@ class PLModel : public QAbstractItemModel friend class PLItem; public: + enum { + IsCurrentRole = Qt::UserRole + }; + PLModel( playlist_t *, intf_thread_t *, playlist_item_t *, QObject *parent = 0 ); ~PLModel(); @@ -113,14 +85,14 @@ public: /* Lookups */ QStringList selectedURIs(); - bool hasRandom(); bool hasLoop(); bool hasRepeat(); QModelIndex index( PLItem *, int c ) const; - QModelIndex currentIndex( ) { return index( currentItem, 0 ); }; + QModelIndex index( int i_id, int c ); + QModelIndex currentIndex(); bool isCurrent( const QModelIndex &index ) const; int itemId( const QModelIndex &index ) const; /* Actions */ - void popup( QModelIndex & index, QPoint &point, QModelIndexList list ); + void popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list ); void doDelete( QModelIndexList selected ); void search( const QString& search_text ); void sort( int column, Qt::SortOrder order ); @@ -128,11 +100,17 @@ public: void removeItem( int ); void rebuild(); void rebuild( playlist_item_t *, bool b_first = false ); + inline PLItem *getItem( QModelIndex index ) const + { + if( index.isValid() ) + return static_cast( index.internalPointer() ); + else return rootItem; + } + private: /* General */ PLItem *rootItem; - PLItem *currentItem; playlist_t *p_playlist; intf_thread_t *p_intf; @@ -140,13 +118,6 @@ 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 children, QModelIndexList *fullList ); void doDeleteItem( PLItem *item, QModelIndexList *fullList ); @@ -168,7 +139,7 @@ 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; @@ -179,13 +150,11 @@ private: signals: void currentChanged( const QModelIndex& ); + void rootChanged(); 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(); @@ -199,6 +168,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