]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/plugins.hpp
Extensions/Qt: Use a custom QListView in Plugins & Extensions panel
[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
73 private:
74     PluginTab( intf_thread_t *p_intf );
75     virtual ~PluginTab();
76
77     void FillTree();
78     QTreeWidget *treePlugins;
79     SearchLineEdit *edit;
80
81 private slots:
82     void search( const QString& );
83
84     friend class PluginDialog;
85 };
86
87 class ExtensionTab : public QVLCFrame
88 {
89     Q_OBJECT;
90
91 protected:
92     virtual void keyPressEvent( QKeyEvent *keyEvent );
93
94 private:
95     ExtensionTab( intf_thread_t *p_intf );
96     virtual ~ExtensionTab();
97
98     QListView *extList;
99     QPushButton *butMoreInfo;
100
101     friend class PluginDialog;
102 };
103
104 class PluginTreeItem : public QTreeWidgetItem
105 {
106 public:
107     PluginTreeItem(QStringList &qs_item, int Type = QTreeWidgetItem::Type)
108             : QTreeWidgetItem (qs_item, Type) {}
109     virtual ~PluginTreeItem() {}
110
111     virtual bool operator< ( const QTreeWidgetItem & other ) const;
112 };
113
114 class ExtensionListModel : public QAbstractListModel
115 {
116
117     Q_OBJECT
118
119 public:
120     ExtensionListModel( QListView *view, intf_thread_t *p_intf );
121     virtual ~ExtensionListModel();
122
123     virtual QVariant data( const QModelIndex& index, int role ) const;
124     virtual QModelIndex index( int row, int column = 0,
125                                const QModelIndex& = QModelIndex() ) const;
126     virtual int rowCount( const QModelIndex& = QModelIndex() ) const;
127
128 private slots:
129     void updateList();
130
131 private:
132     intf_thread_t *p_intf;
133     QList<ExtensionCopy*> extensions;
134 };
135
136 class ExtensionItemDelegate : public QStyledItemDelegate
137 {
138 public:
139     ExtensionItemDelegate( intf_thread_t *p_intf, QListView *view );
140     virtual ~ExtensionItemDelegate();
141
142     virtual void paint( QPainter *painter,
143                         const QStyleOptionViewItem &option,
144                         const QModelIndex &index ) const;
145     virtual QSize sizeHint( const QStyleOptionViewItem &option,
146                             const QModelIndex &index ) const;
147
148 private:
149     QListView *view;
150     intf_thread_t *p_intf;
151 };
152
153 #endif
154