1 /*****************************************************************************
2 * playlist_model.hpp : Model for a playlist tree
3 ****************************************************************************
4 * Copyright (C) 2000-2005 the VideoLAN team
5 * $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef _PLAYLIST_MODEL_H_
25 #define _PLAYLIST_MODEL_H_
30 #include <vlc/input.h>
31 #include <vlc_playlist.h>
38 PLItem( int, int, PLItem *parent , PLModel *);
39 PLItem( playlist_item_t *, PLItem *parent, PLModel *);
43 void insertChild( PLItem *, int p, bool signal = true );
45 void appendChild( PLItem *item, bool signal = true )
47 insertChild( item, children.count(), signal );
49 PLItem *child( int row ) { return children.value( row ); };
50 int childCount() const { return children.count(); };
51 QString columnString( int col ) { return strings.value( col ); };
52 PLItem *parent() { return parentItem; };
54 void update( playlist_item_t *);
56 QList<PLItem*> children;
61 void init( int, int, PLItem *, PLModel * );
62 QList<QString> strings;
68 static int ItemUpdate_Type = QEvent::User + 2;
69 static int ItemDelete_Type = QEvent::User + 3;
70 static int ItemAppend_Type = QEvent::User + 4;
72 class PLEvent : public QEvent
75 PLEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
76 { i_id = id; p_add = NULL; };
77 PLEvent( playlist_add_t *a ) : QEvent( (QEvent::Type)(ItemAppend_Type) )
79 virtual ~PLEvent() {};
82 playlist_add_t *p_add;
86 #include <QAbstractItemModel>
87 #include <QModelIndex>
90 class PLModel : public QAbstractItemModel
95 PLModel( playlist_t *, playlist_item_t *, int, QObject *parent = 0);
98 void customEvent( QEvent * );
101 QVariant data( const QModelIndex &index, int role) const;
102 Qt::ItemFlags flags( const QModelIndex &index) const;
103 QVariant headerData( int section, Qt::Orientation orientation,
104 int role = Qt::DisplayRole) const;
106 QModelIndex index( int r, int c, const QModelIndex &parent ) const;
107 QModelIndex index( PLItem *, int c ) const;
109 QModelIndex parent( const QModelIndex &index) const;
110 int childrenCount( const QModelIndex &parent = QModelIndex() ) const;
111 int rowCount( const QModelIndex &parent = QModelIndex() ) const;
112 int columnCount( const QModelIndex &parent = QModelIndex() ) const;
115 int i_items_to_append;
122 playlist_t *p_playlist;
124 /* Update processing */
125 void ProcessInputItemUpdate( int i_input_id );
126 void ProcessItemRemoval( int i_id );
127 void ProcessItemAppend( playlist_add_t *p_add );
129 void UpdateTreeItem( PLItem *, bool );
130 void UpdateTreeItem( playlist_item_t *, PLItem *, bool );
131 void UpdateNodeChildren( PLItem * );
132 void UpdateNodeChildren( playlist_item_t *, PLItem * );
135 PLItem *FindById( PLItem *, int );
136 PLItem *FindByInput( PLItem *, int );
137 PLItem *FindInner( PLItem *, int , bool );
138 PLItem *p_cached_item;
139 PLItem *p_cached_item_bi;
141 int i_cached_input_id;