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 *****************************************************************************/
28 #include "components/playlist/selector.hpp"
31 #include <QVBoxLayout>
32 #include <QHeaderView>
35 PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p ), p_intf(_p_intf)
37 model = new PLModel( THEPL, p_intf, THEPL->p_root_category, 1, this );
38 view = new QTreeView( 0 );
39 view->setIconSize( QSize( 24,24 ) );
40 view->setAlternatingRowColors( true );
41 view->setIndentation( 0 );
42 view->header()->hide();
43 view->setModel( model );
45 view->setAcceptDrops(true);
46 view->setDropIndicatorShown(true);
48 CONNECT( view, activated( const QModelIndex& ),
49 this, setSource( const QModelIndex& ) );
50 CONNECT( view, clicked( const QModelIndex& ),
51 this, setSource( const QModelIndex& ) );
53 QVBoxLayout *layout = new QVBoxLayout();
54 layout->setSpacing( 0 ); layout->setMargin( 0 );
55 layout->addWidget( view );
58 /* select the first item */
59 view->setCurrentIndex( model->index( 0, 0, QModelIndex() ) );
62 void PLSelector::setSource( const QModelIndex &index )
65 emit activated( model->itemId( index ) );
68 PLSelector::~PLSelector()