1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
|
/*****************************************************************************
* plugins.hpp : Plug-ins and extensions listing
****************************************************************************
* Copyright (C) 2008 the VideoLAN team
* $Id: 26ee90ad15d3798c07d0fe06f15a580f3d3b2212 $
*
* Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef QVLC_PLUGIN_DIALOG_H_
#define QVLC_PLUGIN_DIALOG_H_ 1
#include "util/qvlcframe.hpp"
#include "util/singleton.hpp"
#include <vlc_extensions.h>
#include <vlc_addons.h>
#include <QStringList>
#include <QTreeWidgetItem>
#include <QPushButton>
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include <QStyledItemDelegate>
class QLabel;
class QTabWidget;
class QComboBox;
class QTreeWidget;
class QLineEdit;
//class QTextBrowser;
class QListView;
class QStyleOptionViewItem;
class QPainter;
class QKeyEvent;
class PluginTab;
class ExtensionTab;
class AddonsTab;
class ExtensionListItem;
class SearchLineEdit;
class ExtensionCopy;
class ExtensionsManager;
class AddonsManager;
class PixmapAnimator;
class DelegateAnimationHelper;
class AddonsSortFilterProxyModel;
class PluginDialog : public QVLCFrame, public Singleton<PluginDialog>
{
Q_OBJECT
private:
PluginDialog( intf_thread_t * );
virtual ~PluginDialog();
QTabWidget *tabs;
PluginTab *pluginTab;
ExtensionTab *extensionTab;
AddonsTab *addonsTab;
friend class Singleton<PluginDialog>;
};
class PluginTab : public QVLCFrame
{
Q_OBJECT
public:
enum
{
NAME = 0,
CAPABILITY,
SCORE
};
protected:
virtual void keyPressEvent( QKeyEvent *keyEvent );
private:
PluginTab( intf_thread_t *p_intf );
virtual ~PluginTab();
void FillTree();
QTreeWidget *treePlugins;
SearchLineEdit *edit;
private slots:
void search( const QString& );
friend class PluginDialog;
};
class ExtensionTab : public QVLCFrame
{
Q_OBJECT
protected:
virtual void keyPressEvent( QKeyEvent *keyEvent );
private:
ExtensionTab( intf_thread_t *p_intf );
virtual ~ExtensionTab();
private slots:
void moreInformation();
void updateButtons();
private:
QListView *extList;
QPushButton *butMoreInfo;
friend class PluginDialog;
};
class AddonsTab : public QVLCFrame
{
Q_OBJECT
friend class PluginDialog;
protected:
void keyPressEvent( QKeyEvent *keyEvent );
private slots:
void moreInformation();
void installChecked( int );
void reposync();
private:
AddonsTab( intf_thread_t *p_intf );
virtual ~AddonsTab();
bool eventFilter ( QObject * watched, QEvent * event );
enum
{
ONLYLOCALADDONS = 0,
WITHONLINEADDONS
};
QListView *addonsView;
AddonsSortFilterProxyModel *addonsModel;
/* Wait spinner */
PixmapAnimator *spinnerAnimation;
bool b_localdone;
};
class PluginTreeItem : public QTreeWidgetItem
{
public:
PluginTreeItem(QStringList &qs_item, int Type = QTreeWidgetItem::Type)
: QTreeWidgetItem (qs_item, Type) {}
virtual ~PluginTreeItem() {}
virtual bool operator< ( const QTreeWidgetItem & other ) const;
};
class ExtensionListModel : public QAbstractListModel
{
Q_OBJECT
public:
/* Safe copy of the extension_t struct */
class ExtensionCopy
{
public:
ExtensionCopy( extension_t * );
~ExtensionCopy();
QVariant data( int role ) const;
private:
QString name, title, description, shortdesc, author, version, url;
QPixmap *icon;
};
ExtensionListModel( QObject *parent, ExtensionsManager *EM );
ExtensionListModel( QObject *parent = 0 );
virtual ~ExtensionListModel();
enum
{
SummaryRole = Qt::UserRole,
VersionRole,
AuthorRole,
LinkRole,
FilenameRole
};
virtual QVariant data( const QModelIndex& index, int role ) const;
virtual QModelIndex index( int row, int column = 0,
const QModelIndex& = QModelIndex() ) const;
virtual int rowCount( const QModelIndex& = QModelIndex() ) const;
protected slots:
void updateList();
private:
ExtensionsManager *EM;
QList<ExtensionCopy*> extensions;
};
class AddonsListModel: public ExtensionListModel
{
Q_OBJECT
public:
AddonsListModel( AddonsManager *AM, QObject *parent = 0 );
virtual QVariant data( const QModelIndex& index, int role ) const;
virtual QModelIndex index( int row, int column = 0,
const QModelIndex& = QModelIndex() ) const;
virtual int rowCount( const QModelIndex& = QModelIndex() ) const;
virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
virtual bool setData( const QModelIndex &index, const QVariant &value, int role );
enum
{
TypeRole = FilenameRole + 1,
DescriptionRole,
UUIDRole,
FlagsRole,
StateRole,
DownloadsCountRole,
ScoreRole
};
static QColor getColorByAddonType( int );
protected slots:
void addonAdded( addon_entry_t * );
void addonChanged( const addon_entry_t * );
protected:
class Addon
{
public:
Addon( addon_entry_t * );
~Addon();
bool operator==( const Addon & other ) const;
bool operator==( const addon_entry_t * p_other ) const;
QVariant data( int ) const;
private:
addon_entry_t * p_entry;
};
QList<Addon*> addons;
AddonsManager *AM;
};
class AddonsSortFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
AddonsSortFilterProxyModel( QObject *parent = 0 );
public slots:
virtual void setTypeFilter( int );
virtual void setStatusFilter( int );
protected:
virtual bool filterAcceptsRow( int, const QModelIndex & ) const;
private:
int i_type_filter;
int i_status_filter;
};
class ExtensionItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
ExtensionItemDelegate( QObject *parent );
virtual ~ExtensionItemDelegate();
virtual void paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index ) const;
virtual QSize sizeHint( const QStyleOptionViewItem &option,
const QModelIndex &index ) const;
virtual void initStyleOption( QStyleOptionViewItem *option,
const QModelIndex &index ) const;
protected:
QMargins margins;
};
class AddonItemDelegate : public ExtensionItemDelegate
{
Q_OBJECT
public:
AddonItemDelegate( QObject *parent );
~AddonItemDelegate();
virtual void paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index ) const;
virtual QSize sizeHint( const QStyleOptionViewItem &option,
const QModelIndex &index ) const;
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setAnimator( DelegateAnimationHelper *animator );
public slots:
void editButtonClicked();
signals:
void showInfo();
protected:
DelegateAnimationHelper *animator;
QWidget *progressbar;
};
class ExtensionInfoDialog : public QVLCDialog
{
public:
ExtensionInfoDialog( const QModelIndex &index,
intf_thread_t *p_intf, QWidget *parent );
};
class AddonInfoDialog : public QVLCDialog
{
public:
AddonInfoDialog( const QModelIndex &index,
intf_thread_t *p_intf, QWidget *parent );
};
#endif
|