]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/plugins.hpp
d1737b1d7534d7043b966de3c032b48b4b4e4a1d
[vlc] / modules / gui / qt4 / dialogs / plugins.hpp
1 /*****************************************************************************
2  * plugins.hpp : Plug-ins and extensions listing
3  ****************************************************************************
4  * Copyright (C) 2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jean-Baptiste Kempf <jb (at) 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 #ifndef QVLC_PLUGIN_DIALOG_H_
25 #define QVLC_PLUGIN_DIALOG_H_ 1
26
27 #include "util/qvlcframe.hpp"
28 #include "util/singleton.hpp"
29
30 #include <vlc_extensions.h>
31
32 #include <QStringList>
33 #include <QTreeWidgetItem>
34 #include <QAbstractListModel>
35 #include <QStyledItemDelegate>
36
37 class QLabel;
38 class QTabWidget;
39 class QComboBox;
40 class QTreeWidget;
41 class QLineEdit;
42 class QTextBrowser;
43 class QListView;
44 class QStyleOptionViewItem;
45 class QPainter;
46 class QKeyEvent;
47 class PluginTab;
48 class ExtensionTab;
49 class ExtensionListItem;
50 class SearchLineEdit;
51 class ExtensionCopy;
52
53
54 class PluginDialog : public QVLCFrame, public Singleton<PluginDialog>
55 {
56     Q_OBJECT
57
58 private:
59     PluginDialog( intf_thread_t * );
60     virtual ~PluginDialog();
61
62     QTabWidget *tabs;
63     PluginTab *pluginTab;
64     ExtensionTab *extensionTab;
65
66     friend class Singleton<PluginDialog>;
67 };
68
69 class PluginTab : public QVLCFrame
70 {
71     Q_OBJECT
72 public:
73     enum
74     {
75         NAME = 0,
76         CAPABILITY,
77         SCORE
78     };
79
80 protected:
81     virtual void keyPressEvent( QKeyEvent *keyEvent );
82
83 private:
84     PluginTab( intf_thread_t *p_intf );
85     virtual ~PluginTab();
86
87     void FillTree();
88     QTreeWidget *treePlugins;
89     SearchLineEdit *edit;
90
91 private slots:
92     void search( const QString& );
93
94     friend class PluginDialog;
95 };
96
97 class ExtensionTab : public QVLCFrame
98 {
99     Q_OBJECT
100
101 protected:
102     virtual void keyPressEvent( QKeyEvent *keyEvent );
103
104 private:
105     ExtensionTab( intf_thread_t *p_intf );
106     virtual ~ExtensionTab();
107
108 private slots:
109     void moreInformation();
110     void updateButtons();
111
112 private:
113     QListView *extList;
114     QPushButton *butMoreInfo;
115
116     friend class PluginDialog;
117 };
118
119 class PluginTreeItem : public QTreeWidgetItem
120 {
121 public:
122     PluginTreeItem(QStringList &qs_item, int Type = QTreeWidgetItem::Type)
123             : QTreeWidgetItem (qs_item, Type) {}
124     virtual ~PluginTreeItem() {}
125
126     virtual bool operator< ( const QTreeWidgetItem & other ) const;
127 };
128
129 class ExtensionListModel : public QAbstractListModel
130 {
131
132     Q_OBJECT
133
134 public:
135     ExtensionListModel( QListView *view, intf_thread_t *p_intf );
136     virtual ~ExtensionListModel();
137
138     static const Qt::ItemDataRole DescriptionRole = Qt::UserRole;
139     virtual QVariant data( const QModelIndex& index, int role ) const;
140     virtual QModelIndex index( int row, int column = 0,
141                                const QModelIndex& = QModelIndex() ) const;
142     virtual int rowCount( const QModelIndex& = QModelIndex() ) const;
143
144 private slots:
145     void updateList();
146
147 private:
148     intf_thread_t *p_intf;
149     QList<ExtensionCopy*> extensions;
150 };
151
152 class ExtensionItemDelegate : public QStyledItemDelegate
153 {
154 public:
155     ExtensionItemDelegate( intf_thread_t *p_intf, QListView *view );
156     virtual ~ExtensionItemDelegate();
157
158     virtual void paint( QPainter *painter,
159                         const QStyleOptionViewItem &option,
160                         const QModelIndex &index ) const;
161     virtual QSize sizeHint( const QStyleOptionViewItem &option,
162                             const QModelIndex &index ) const;
163
164 private:
165     QListView *view;
166     intf_thread_t *p_intf;
167 };
168
169 class ExtensionInfoDialog : public QVLCDialog
170 {
171 public:
172     ExtensionInfoDialog( const ExtensionCopy& extension,
173                          intf_thread_t *p_intf, QWidget *parent );
174 };
175
176 #endif
177