1 /*****************************************************************************
2 * selector.cpp : Playlist source selector
3 ****************************************************************************
4 * Copyright (C) 2000-2005 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 *****************************************************************************/
30 #include "components/playlist/selector.hpp"
33 #include <QVBoxLayout>
34 #include <QHeaderView>
35 #include <QTreeWidget>
37 #include <vlc_playlist.h>
39 PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p ), p_intf(_p_intf)
41 // model = new PLModel( THEPL, p_intf, THEPL->p_root_category, 1, this );
42 view = new QTreeWidget;
43 view->setIconSize( QSize( 24,24 ) );
44 // view->setAlternatingRowColors( true );
45 view->setIndentation( 0 );
46 view->header()->hide();
47 // view->setModel( model );
49 view->setAcceptDrops(true);
50 view->setDropIndicatorShown(true);
54 CONNECT( view, itemActivated( QTreeWidgetItem *, int ),
55 this, setSource( QTreeWidgetItem *) );
56 CONNECT( view, itemClicked( QTreeWidgetItem *, int ),
57 this, setSource( QTreeWidgetItem *) );
59 QVBoxLayout *layout = new QVBoxLayout();
60 layout->setSpacing( 0 ); layout->setMargin( 0 );
61 layout->addWidget( view );
64 /* select the first item */
65 // view->setCurrentIndex( model->index( 0, 0, QModelIndex() ) );
68 void PLSelector::setSource( QTreeWidgetItem *item )
72 playlist_item_t *pl_item =
73 item->data( 0, Qt::UserRole ).value<playlist_item_t *>();
74 emit activated( pl_item );
78 void PLSelector::createItems()
81 QTreeWidgetItem *pl = new QTreeWidgetItem( view );
82 pl->setText( 0, qtr( "Playlist" ) );
83 pl->setData( 0, Qt::UserRole, QVariant::fromValue( THEPL->p_local_category ) );
84 /* QTreeWidgetItem *empty = new QTreeWidgetItem( view );
85 empty->setFlags(Qt::NoItemFlags);
87 QTreeWidgetItem *lib = new QTreeWidgetItem( view );
88 lib->setText( 0, qtr( "Library" ) );
89 lib->setData( 0, Qt::UserRole, QVariant::fromValue( THEPL->p_ml_category ) );
91 QTreeWidgetItem *empty2 = new QTreeWidgetItem( view );
92 empty2->setFlags(Qt::NoItemFlags);*/
97 PLSelector::~PLSelector()