selector.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * selector.hpp : Playlist source selector
00003  ****************************************************************************
00004  * Copyright (C) 2000-2009 the VideoLAN team
00005  * $Id: 976e60725655da44a9c1e94947fcf78117364639 $
00006  *
00007  * Authors: Clément Stenac <zorglub@videolan.org>
00008  *          Jean-Baptiste Kempf
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef _PLSEL_H_
00026 #define _PLSEL_H_
00027 
00028 #ifdef HAVE_CONFIG_H
00029 # include "config.h"
00030 #endif
00031 
00032 #include <QTreeWidget>
00033 #include <QTreeWidgetItem>
00034 #include <QStyledItemDelegate>
00035 #include <QPainter>
00036 #include <QPushButton>
00037 #include <QLabel>
00038 #include <QHBoxLayout>
00039 #include "util/customwidgets.hpp"
00040 
00041 #include <vlc_playlist.h>
00042 
00043 #include "qt4.hpp"
00044 
00045 class PlaylistWidget;
00046 
00047 enum SelectorItemType {
00048     CATEGORY_TYPE,
00049     SD_TYPE,
00050     PL_ITEM_TYPE
00051 };
00052 
00053 enum SpecialData {
00054     IS_PODCAST = 1,
00055     IS_PL,
00056     IS_ML
00057 };
00058 
00059 enum {
00060     TYPE_ROLE = Qt::UserRole,
00061     NAME_ROLE, //QString
00062     LONGNAME_ROLE, //QString
00063     PL_ITEM_ROLE, //playlist_item_t*
00064     PL_ITEM_ID_ROLE, //playlist_item_t->i_id
00065     IN_ITEM_ROLE, //input_item_t->i_id
00066     SPECIAL_ROLE //SpecialData
00067 };
00068 
00069 enum ItemAction {
00070     ADD_ACTION,
00071     RM_ACTION
00072 };
00073 
00074 
00075 class SelectorActionButton : public QVLCFramelessButton
00076 {
00077 public:
00078     SelectorActionButton( QWidget *parent = NULL )
00079         : QVLCFramelessButton( parent ) {}
00080 private:
00081     void paintEvent( QPaintEvent * );
00082 };
00083 
00084 class PLSelItem : public QWidget
00085 {
00086     Q_OBJECT
00087 public:
00088     PLSelItem( QTreeWidgetItem*, const QString& );
00089     void setText( const QString& );
00090     void addAction( ItemAction, const QString& toolTip = 0 );
00091     QTreeWidgetItem *treeItem() { return qitem; }
00092     QString text() { return lbl->text(); }
00093 public slots:
00094     void showAction();
00095     void hideAction();
00096 private slots:
00097     void triggerAction() { emit action( this ); }
00098 signals:
00099     void action( PLSelItem* );
00100 private:
00101     void enterEvent( QEvent* );
00102     void leaveEvent( QEvent* );
00103     QTreeWidgetItem* qitem;
00104     QVLCFramelessButton *lblAction;
00105     QLabel *lbl;
00106     QHBoxLayout *layout;
00107 };
00108 
00109 Q_DECLARE_METATYPE( playlist_item_t *);
00110 Q_DECLARE_METATYPE( input_item_t *);
00111 class PLSelector: public QTreeWidget
00112 {
00113     Q_OBJECT
00114 public:
00115     PLSelector( QWidget *p, intf_thread_t *_p_intf );
00116     virtual ~PLSelector();
00117 protected:
00118     friend class PlaylistWidget;
00119 private:
00120     QStringList mimeTypes () const;
00121     bool dropMimeData ( QTreeWidgetItem *, int, const QMimeData *, Qt::DropAction );
00122     void dragMoveEvent ( QDragMoveEvent * event );
00123     void createItems();
00124     void drawBranches ( QPainter *, const QRect &, const QModelIndex & ) const;
00125     PLSelItem * addItem (
00126         SelectorItemType type, const char* str, bool drop,
00127         QTreeWidgetItem* parentItem = 0 );
00128     PLSelItem * addPodcastItem( playlist_item_t *p_item );
00129     inline PLSelItem * itemWidget( QTreeWidgetItem * );
00130     intf_thread_t *p_intf;
00131     QTreeWidgetItem *podcastsParent;
00132     int podcastsParentId;
00133 private slots:
00134     void setSource( QTreeWidgetItem *item );
00135     void plItemAdded( int, int );
00136     void plItemRemoved( int );
00137     void inputItemUpdate( input_item_t * );
00138     void podcastAdd( PLSelItem* );
00139     void podcastRemove( PLSelItem* );
00140 
00141 signals:
00142     void activated( playlist_item_t * );
00143 };
00144 
00145 #endif

Generated on Tue May 25 08:04:57 2010 for VLC by  doxygen 1.5.6