]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/playlist/selector.cpp
D&D fixes
[vlc] / modules / gui / qt4 / components / playlist / selector.cpp
1 /*****************************************************************************
2  * selector.cpp : Playlist source selector
3  ****************************************************************************
4  * Copyright (C) 2000-2005 the VideoLAN team
5  * $Id: standardpanel.cpp 16024 2006-07-13 13:51:05Z xtophe $
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include "components/playlist/selector.hpp"
25 #include "qt4.hpp"
26 #include <QVBoxLayout>
27 #include <QHeaderView>
28 #include <QTreeView>
29
30 PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf,
31                         playlist_t *p_playlist ) : QWidget( p ), p_intf(_p_intf)
32 {
33     model = new PLModel( THEPL, THEPL->p_root_category, 1, this );
34     view = new QTreeView( 0 );
35     view->setIconSize( QSize( 24,24 ) );
36     view->setAlternatingRowColors( true );
37     view->setIndentation( 0 );
38     view->header()->hide();
39     view->setModel( model );
40
41     view->setAcceptDrops(true);
42     view->setDropIndicatorShown(true);
43
44     CONNECT( view, activated( const QModelIndex& ),
45              this, setSource( const QModelIndex& ) );
46     CONNECT( view, clicked( const QModelIndex& ),
47              this, setSource( const QModelIndex& ) );
48
49     QVBoxLayout *layout = new QVBoxLayout();
50     layout->setSpacing( 0 ); layout->setMargin( 0 );
51     layout->addWidget( view );
52     setLayout( layout );
53 }
54
55 void PLSelector::setSource( const QModelIndex &index )
56 {
57     if( model )
58         emit activated( model->itemId( index ) );
59 }
60
61 PLSelector::~PLSelector()
62 {
63 }