]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/playlist/playlist.hpp
Qt4: switch PLModel to use PlaylistEventManager
[vlc] / modules / gui / qt4 / components / playlist / playlist.hpp
1 /*****************************************************************************
2  * interface_widgets.hpp : Playlist Widgets
3  ****************************************************************************
4  * Copyright (C) 2006 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
23  * Foundation, Inc., 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 "dialogs_provider.hpp" /* Media Info from ArtLabel */
36 #include "components/interface_widgets.hpp"
37 //#include <vlc_playlist.h>
38
39 #include <QSplitter>
40 #include <QLabel>
41
42 class PLSelector;
43 class PLPanel;
44 class QPushButton;
45 class CoverArtLabel;
46 class ArtLabel;
47
48 class PlaylistWidget : public QSplitter
49 {
50     Q_OBJECT;
51 public:
52     PlaylistWidget( intf_thread_t *_p_i );
53     virtual ~PlaylistWidget();
54 private:
55     PLSelector *selector;
56     PLPanel *rightPanel;
57     QPushButton *addButton;
58     ArtLabel *art;
59 protected:
60     intf_thread_t *p_intf;
61     virtual void dropEvent( QDropEvent *);
62     virtual void dragEnterEvent( QDragEnterEvent * );
63     virtual void closeEvent( QCloseEvent * );
64 };
65
66 class ArtLabel : public CoverArtLabel
67 {
68     Q_OBJECT
69 public:
70     ArtLabel( QWidget *parent, intf_thread_t *intf )
71             : CoverArtLabel( parent, intf ) {};
72     virtual void mouseDoubleClickEvent( QMouseEvent *event )
73     {
74         THEDP->mediaInfoDialog();
75         event->accept();
76     }
77 };
78
79 enum PLEventType {
80     ItemAddedEv = QEvent::User,
81     ItemRemovedEv
82 };
83
84 class PLEMEvent : public QEvent
85 {
86 public:
87     PLEMEvent( int t, int i, int p )
88         : QEvent( (QEvent::Type)t ), item(i), parent(p) {}
89     int item;
90     int parent;
91 };
92
93 class PlaylistEventManager : public QObject
94 {
95     Q_OBJECT;
96
97 public:
98     PlaylistEventManager( playlist_t* );
99     ~PlaylistEventManager();
100
101 signals:
102     void itemAdded( int i_item, int i_parent );
103     void itemRemoved( int i_id );
104
105 private:
106     static int itemAddedCb ( vlc_object_t *, const char *,
107                               vlc_value_t, vlc_value_t, void * );
108     static int itemRemovedCb ( vlc_object_t *, const char *,
109                                 vlc_value_t, vlc_value_t, void * );
110     void trigger( vlc_value_t, int );
111     void customEvent( QEvent* );
112     playlist_t *pl;
113 };
114 #endif