1 /*****************************************************************************
2 * playlist_item.hpp : Item for a playlist tree
3 ****************************************************************************
4 * Copyright (C) 2006-2011 the VideoLAN team
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_ITEM_H_
25 #define _PLAYLIST_ITEM_H_
35 friend class PLItem; /* super ugly glue stuff */
41 virtual int id() const = 0;
42 int childCount() const { return children.count(); }
43 int indexOf( AbstractPLItem *item ) const { return children.indexOf( item ); };
44 int lastIndexOf( AbstractPLItem *item ) const { return children.lastIndexOf( item ); };
45 AbstractPLItem *parent() { return parentItem; }
46 virtual input_item_t *inputItem() = 0;
47 void insertChild( AbstractPLItem *item, int pos = -1 ) { children.insert( pos, item ); }
48 void appendChild( AbstractPLItem *item ) { insertChild( item, children.count() ); } ;
49 virtual AbstractPLItem *child( int id ) const = 0;
52 QList<AbstractPLItem *> children;
53 AbstractPLItem *parentItem;
56 class PLItem : public AbstractPLItem
62 bool hasSameParent( PLItem *other ) { return parent() == other->parent(); }
63 bool operator< ( PLItem& );
67 int id() const { return i_id; };
68 input_item_t *inputItem() { return p_input; }
69 AbstractPLItem *child( int id ) const { return children.value( id ); };
72 PLItem( playlist_item_t *, PLItem *parent );
74 void removeChild( PLItem * );
75 void takeChildAt( int );
77 PLItem( playlist_item_t * );
78 void init( playlist_item_t *, PLItem * );
80 input_item_t *p_input;