X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fplaylist_model.hpp;h=ede272e042b8b31881c41cff9293517617af3f70;hb=6ee1e193fd896ab9a4729fde14f009d9ce629815;hp=796a67bca4905e2d8431e2cf19bb02cb0f7f992b;hpb=596ccd7682678e4416d193eef9ddc80fa6cf2f7e;p=vlc diff --git a/modules/gui/qt4/playlist_model.hpp b/modules/gui/qt4/playlist_model.hpp index 796a67bca4..ede272e042 100644 --- a/modules/gui/qt4/playlist_model.hpp +++ b/modules/gui/qt4/playlist_model.hpp @@ -1,8 +1,8 @@ /***************************************************************************** * playlist_model.hpp : Model for a playlist tree **************************************************************************** - * Copyright (C) 2000-2005 the VideoLAN team - * $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $ + * Copyright (C) 2006 the VideoLAN team + * $Id$ * * Authors: Clément Stenac * @@ -24,13 +24,18 @@ #ifndef _PLAYLIST_MODEL_H_ #define _PLAYLIST_MODEL_H_ -#include -#include #include -#include +#include #include +#include +#include +#include +#include +#include + class PLModel; +class QSignalMapper; class PLItem { @@ -42,32 +47,38 @@ public: int row() const; void insertChild( PLItem *, int p, bool signal = true ); - void appendChild( PLItem *item, bool signal = true ) + void appendChild( PLItem *item, bool signal = true ) { insertChild( item, children.count(), signal ); }; + void remove( PLItem *removed ); PLItem *child( int row ) { return children.value( row ); }; int childCount() const { return children.count(); }; QString columnString( int col ) { return strings.value( col ); }; PLItem *parent() { return parentItem; }; - void update( playlist_item_t *); + void update( playlist_item_t *, bool); protected: QList children; + QList strings; + bool current; + int type; int i_id; int i_input_id; + int i_showflags; + + void updateview( void ); friend class PLModel; private: void init( int, int, PLItem *, PLModel * ); - QList strings; PLItem *parentItem; - PLModel *model; }; static int ItemUpdate_Type = QEvent::User + 2; static int ItemDelete_Type = QEvent::User + 3; static int ItemAppend_Type = QEvent::User + 4; +static int PLUpdate_Type = QEvent::User + 5; class PLEvent : public QEvent { @@ -77,14 +88,12 @@ public: PLEvent( playlist_add_t *a ) : QEvent( (QEvent::Type)(ItemAppend_Type) ) { p_add = a; }; virtual ~PLEvent() {}; - + int i_id; playlist_add_t *p_add; -}; - +}; #include -#include #include class PLModel : public QAbstractItemModel @@ -92,20 +101,19 @@ class PLModel : public QAbstractItemModel Q_OBJECT public: - PLModel( playlist_t *, playlist_item_t *, int, QObject *parent = 0); + PLModel( playlist_t *, intf_thread_t *, + playlist_item_t *, int, QObject *parent = 0); ~PLModel(); - void customEvent( QEvent * ); - - /* QModel stuff */ + /* All types of lookups / QModel stuff */ QVariant data( const QModelIndex &index, int role) const; Qt::ItemFlags flags( const QModelIndex &index) const; QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - QModelIndex index( int r, int c, const QModelIndex &parent ) const; QModelIndex index( PLItem *, int c ) const; - + int itemId( const QModelIndex &index ) const; + bool isCurrent( const QModelIndex &index ); QModelIndex parent( const QModelIndex &index) const; int childrenCount( const QModelIndex &parent = QModelIndex() ) const; int rowCount( const QModelIndex &parent = QModelIndex() ) const; @@ -113,24 +121,60 @@ public: bool b_need_update; int i_items_to_append; - void Rebuild(); + + void rebuild(); void rebuild( playlist_item_t *); + bool hasRandom(); bool hasLoop(); bool hasRepeat(); + + /* Actions made by the views */ + void popup( QModelIndex & index, QPoint &point, QModelIndexList list ); + void doDelete( QModelIndexList selected ); + void search( QString search ); + void sort( int column, Qt::SortOrder order ); + void removeItem( int ); + + /* DnD handling */ + Qt::DropActions supportedDropActions() const; + QMimeData* mimeData(const QModelIndexList &indexes) const; + bool dropMimeData(const QMimeData *data, Qt::DropAction action, + int row, int column, const QModelIndex &target); + QStringList mimeTypes() const; + + void sendArt( QString url ); + void removeArt( ); + + int shownFlags() { return rootItem->i_showflags; } private: void addCallbacks(); void delCallbacks(); + void customEvent( QEvent * ); + PLItem *rootItem; playlist_t *p_playlist; + intf_thread_t *p_intf; + int i_depth; + + static QIcon icons[ITEM_TYPE_NUMBER]; /* Update processing */ void ProcessInputItemUpdate( int i_input_id ); void ProcessItemRemoval( int i_id ); void ProcessItemAppend( playlist_add_t *p_add ); - - void UpdateTreeItem( PLItem *, bool ); - void UpdateTreeItem( playlist_item_t *, PLItem *, bool ); + + void UpdateTreeItem( PLItem *, bool, bool force = false ); + void UpdateTreeItem( playlist_item_t *, PLItem *, bool, bool forc = false ); void UpdateNodeChildren( PLItem * ); void UpdateNodeChildren( playlist_item_t *, PLItem * ); - + + /* Actions */ + void recurseDelete( QList children, QModelIndexList *fullList); + void doDeleteItem( PLItem *item, QModelIndexList *fullList ); + + /* Popup */ + int i_popup_item, i_popup_parent; + QModelIndexList current_selection; + QSignalMapper *ContextUpdateMapper; + /* Lookups */ PLItem *FindById( PLItem *, int ); PLItem *FindByInput( PLItem *, int ); @@ -139,7 +183,25 @@ private: PLItem *p_cached_item_bi; int i_cached_id; int i_cached_input_id; - +signals: + void artSet( QString ); + void shouldRemove( int ); +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(); + void popupDel(); + void popupInfo(); + void popupStream(); + void popupSave(); +#ifdef WIN32 + void popupExplore(); +#endif + void viewchanged( int ); friend class PLItem; };