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,
36 playlist_t *p_playlist ) : QWidget( p ), p_intf(_p_intf)
38 model = new PLModel( THEPL, p_intf, THEPL->p_root_category, 1, this );
39 view = new QTreeView( 0 );
40 view->setIconSize( QSize( 24,24 ) );
41 view->setAlternatingRowColors( true );
42 view->setIndentation( 0 );
43 view->header()->hide();
44 view->setModel( model );
46 view->setAcceptDrops(true);
47 view->setDropIndicatorShown(true);
49 CONNECT( view, activated( const QModelIndex& ),
50 this, setSource( const QModelIndex& ) );
51 CONNECT( view, clicked( const QModelIndex& ),
52 this, setSource( const QModelIndex& ) );
54 QVBoxLayout *layout = new QVBoxLayout();
55 layout->setSpacing( 0 ); layout->setMargin( 0 );
56 layout->addWidget( view );
59 /* select the first item */
60 view->setCurrentIndex( model->index( 0, 0, QModelIndex() ) );
63 void PLSelector::setSource( const QModelIndex &index )
66 emit activated( model->itemId( index ) );
69 PLSelector::~PLSelector()