friend class PLItem;
public:
+ enum {
+ IsCurrentRole = Qt::UserRole
+ };
+
PLModel( playlist_t *, intf_thread_t *,
playlist_item_t *, QObject *parent = 0 );
~PLModel();
/* Lookups */
QStringList selectedURIs();
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;
void removeItem( int );
void rebuild(); void rebuild( playlist_item_t *, bool b_first = false );
- static inline PLItem *getItem( QModelIndex index );
+ inline PLItem *getItem( QModelIndex index ) const
+ {
+ if( index.isValid() )
+ return static_cast<PLItem*>( index.internalPointer() );
+ else return rootItem;
+ }
private:
/* General */
PLItem *rootItem;
- PLItem *currentItem;
playlist_t *p_playlist;
intf_thread_t *p_intf;
signals:
void currentChanged( const QModelIndex& );
+ void rootChanged();
public slots:
void activateItem( const QModelIndex &index );