]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/playlist/playlist.hpp
Qt: Playlist, code simplification and factorisation
[vlc] / modules / gui / qt4 / components / playlist / playlist.hpp
1 /*****************************************************************************
2  * interface_widgets.hpp : Playlist Widgets
3  ****************************************************************************
4  * Copyright (C) 2006-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Rafaël Carré <funman@videolanorg>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifndef _PLAYLISTWIDGET_H_
27 #define _PLAYLISTWIDGET_H_
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include "qt4.hpp"
34
35 //#include <vlc_playlist.h>
36
37 #include <QSplitter>
38 #include <QPushButton>
39
40 class StandardPLPanel;
41 class LocationBar;
42 class QSignalMapper;
43 class SearchLineEdit;
44 class QModelIndex;
45
46 static const QString viewNames[] = { qtr( "Detailed View" ),
47                                      qtr( "Icon View" ),
48                                      qtr( "List View" ) };
49
50 class PlaylistWidget : public QSplitter
51 {
52     Q_OBJECT
53 public:
54     PlaylistWidget( intf_thread_t *_p_i, QWidget * );
55     virtual ~PlaylistWidget();
56
57     void forceHide();
58     void forceShow();
59
60 private:
61     QSplitter            *leftSplitter;
62     StandardPLPanel      *mainView;
63
64     LocationBar          *locationBar;
65     SearchLineEdit       *searchEdit;
66
67     intf_thread_t *p_intf;
68
69 protected:
70     virtual void dropEvent( QDropEvent *);
71     virtual void dragEnterEvent( QDragEnterEvent * );
72     virtual void closeEvent( QCloseEvent * );
73
74 private slots:
75     void changeView( const QModelIndex& index );
76 };
77
78 class LocationButton : public QPushButton
79 {
80 public:
81     LocationButton( const QString &, bool bold, bool arrow, QWidget * parent = NULL );
82     virtual QSize sizeHint() const;
83 protected:
84     virtual void paintEvent ( QPaintEvent * event );
85 private:
86     bool b_arrow;
87 };
88
89 class PLModel;
90 class QHBoxLayout;
91 class LocationBar : public QWidget
92 {
93     Q_OBJECT
94 public:
95     LocationBar( PLModel * );
96     void setIndex( const QModelIndex & );
97     virtual QSize sizeHint() const;
98 protected:
99     virtual void resizeEvent ( QResizeEvent * event );
100
101 private:
102     void layOut( const QSize& size );
103
104     PLModel *model;
105     QSignalMapper *mapper;
106     QList<QWidget*> buttons;
107     QList<QAction*> actions;
108     LocationButton *btnMore;
109     QMenu *menuMore;
110     QList<int> widths;
111
112 public slots:
113     void setRootIndex();
114 private slots:
115     void invoke( int i_item_id );
116
117 signals:
118     void invoked( const QModelIndex & );
119 };
120
121
122 #endif