X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Fplaylist%2Fselector.hpp;h=b5e86c576606ae91ca7fbfd19126164d517a7e3f;hb=b2e1a820e1e7aa041f2d52bf75d9363c10e0c7ac;hp=7a5931b4c5cd67ebe4de229b8251899d12486efe;hpb=64e68cb4564b29b615fcdcbb60ee98cfa76083ac;p=vlc diff --git a/modules/gui/qt4/components/playlist/selector.hpp b/modules/gui/qt4/components/playlist/selector.hpp index 7a5931b4c5..b5e86c5766 100644 --- a/modules/gui/qt4/components/playlist/selector.hpp +++ b/modules/gui/qt4/components/playlist/selector.hpp @@ -1,10 +1,11 @@ /***************************************************************************** * selector.hpp : Playlist source selector **************************************************************************** - * Copyright (C) 2000-2005 the VideoLAN team + * Copyright (C) 2000-2009 the VideoLAN team * $Id$ * * Authors: Clément Stenac + * Jean-Baptiste Kempf * * 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 @@ -24,18 +25,125 @@ #ifndef _PLSEL_H_ #define _PLSEL_H_ -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "qt4.hpp" +#include "util/customwidgets.hpp" /* QVLCFramelessButton */ + +#include + +class QHBoxLayout; +class QPainter; +class QTreeWidgetItem; +class PlaylistWidget; +class QLabel; + +enum SelectorItemType { + CATEGORY_TYPE, + SD_TYPE, + PL_ITEM_TYPE +}; + +enum SpecialData { + IS_PODCAST = 1, + IS_PL, + IS_ML +}; + +enum { + TYPE_ROLE = Qt::UserRole + 1, + NAME_ROLE, //QString + LONGNAME_ROLE, //QString + PL_ITEM_ROLE, //playlist_item_t* + PL_ITEM_ID_ROLE, //playlist_item_t->i_id + IN_ITEM_ROLE, //input_item_t->i_id + SPECIAL_ROLE //SpecialData +}; + +enum ItemAction { + ADD_ACTION, + RM_ACTION +}; + + +class SelectorActionButton : public QVLCFramelessButton +{ +protected: + virtual void paintEvent( QPaintEvent * ); +}; + +class PLSelItem : public QWidget +{ + Q_OBJECT +public: + PLSelItem( QTreeWidgetItem*, const QString& ); + + void setText( const QString& text ) { lbl->setText( text ); } + const QString text() { return lbl->text(); } + + void addAction( ItemAction, const QString& toolTip = 0 ); + QTreeWidgetItem *treeItem() { return qitem; } + +public slots: + void showAction() { if( lblAction ) lblAction->show(); } + void hideAction() { if( lblAction ) lblAction->hide(); } + +private slots: + void triggerAction() { emit action( this ); } + +signals: + void action( PLSelItem* ); + +private: + inline void enterEvent( QEvent* ){ showAction(); } + inline void leaveEvent( QEvent* ){ hideAction(); } -class PLSelector: public QWidget + QTreeWidgetItem* qitem; + QVLCFramelessButton *lblAction; + QLabel *lbl; + QHBoxLayout *layout; +}; + +Q_DECLARE_METATYPE( playlist_item_t *); +Q_DECLARE_METATYPE( input_item_t *); +class PLSelector: public QTreeWidget { - Q_OBJECT; + Q_OBJECT public: PLSelector( QWidget *p, intf_thread_t *_p_intf ); virtual ~PLSelector(); +protected: + friend class PlaylistWidget; + private: - intf_thread_t *p_intf; + void createItems(); + PLSelItem * addItem ( SelectorItemType type, const char* str, + bool drop = false, QTreeWidgetItem* parentItem = 0 ); + PLSelItem * addPodcastItem( playlist_item_t *p_item ); + + inline PLSelItem * itemWidget( QTreeWidgetItem * ); + void drawBranches ( QPainter *, const QRect &, const QModelIndex & ) const; + + QStringList mimeTypes () const; + bool dropMimeData ( QTreeWidgetItem *, int, const QMimeData *, Qt::DropAction ); + void dragMoveEvent ( QDragMoveEvent * event ); + + intf_thread_t *p_intf; + QTreeWidgetItem *podcastsParent; + int podcastsParentId; + +private slots: + void setSource( QTreeWidgetItem *item ); + void plItemAdded( int, int ); + void plItemRemoved( int ); + void inputItemUpdate( input_item_t * ); + void podcastAdd( PLSelItem* ); + void podcastRemove( PLSelItem* ); + +signals: + void activated( playlist_item_t * ); }; #endif