Commit b2e1a820 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf Committed by Jean-Baptiste Kempf

Qt, selector: cleanup

Code cleanup, forward declaration and cosmetics
parent 9eb0513a
...@@ -29,20 +29,16 @@ ...@@ -29,20 +29,16 @@
# include "config.h" # include "config.h"
#endif #endif
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QStyledItemDelegate>
#include <QPainter>
#include <QPushButton>
#include <QLabel>
#include <QHBoxLayout>
#include "util/customwidgets.hpp"
#include <vlc_playlist.h>
#include "qt4.hpp" #include "qt4.hpp"
#include "util/customwidgets.hpp" /* QVLCFramelessButton */
#include <QTreeWidget>
class QHBoxLayout;
class QPainter;
class QTreeWidgetItem;
class PlaylistWidget; class PlaylistWidget;
class QLabel;
enum SelectorItemType { enum SelectorItemType {
CATEGORY_TYPE, CATEGORY_TYPE,
...@@ -57,7 +53,7 @@ enum SpecialData { ...@@ -57,7 +53,7 @@ enum SpecialData {
}; };
enum { enum {
TYPE_ROLE = Qt::UserRole, TYPE_ROLE = Qt::UserRole + 1,
NAME_ROLE, //QString NAME_ROLE, //QString
LONGNAME_ROLE, //QString LONGNAME_ROLE, //QString
PL_ITEM_ROLE, //playlist_item_t* PL_ITEM_ROLE, //playlist_item_t*
...@@ -74,11 +70,8 @@ enum ItemAction { ...@@ -74,11 +70,8 @@ enum ItemAction {
class SelectorActionButton : public QVLCFramelessButton class SelectorActionButton : public QVLCFramelessButton
{ {
public: protected:
SelectorActionButton( QWidget *parent = NULL ) virtual void paintEvent( QPaintEvent * );
: QVLCFramelessButton( parent ) {}
private:
void paintEvent( QPaintEvent * );
}; };
class PLSelItem : public QWidget class PLSelItem : public QWidget
...@@ -86,20 +79,27 @@ class PLSelItem : public QWidget ...@@ -86,20 +79,27 @@ class PLSelItem : public QWidget
Q_OBJECT Q_OBJECT
public: public:
PLSelItem( QTreeWidgetItem*, const QString& ); PLSelItem( QTreeWidgetItem*, const QString& );
void setText( const QString& );
void setText( const QString& text ) { lbl->setText( text ); }
const QString text() { return lbl->text(); }
void addAction( ItemAction, const QString& toolTip = 0 ); void addAction( ItemAction, const QString& toolTip = 0 );
QTreeWidgetItem *treeItem() { return qitem; } QTreeWidgetItem *treeItem() { return qitem; }
QString text() { return lbl->text(); }
public slots: public slots:
void showAction(); void showAction() { if( lblAction ) lblAction->show(); }
void hideAction(); void hideAction() { if( lblAction ) lblAction->hide(); }
private slots: private slots:
void triggerAction() { emit action( this ); } void triggerAction() { emit action( this ); }
signals: signals:
void action( PLSelItem* ); void action( PLSelItem* );
private: private:
void enterEvent( QEvent* ); inline void enterEvent( QEvent* ){ showAction(); }
void leaveEvent( QEvent* ); inline void leaveEvent( QEvent* ){ hideAction(); }
QTreeWidgetItem* qitem; QTreeWidgetItem* qitem;
QVLCFramelessButton *lblAction; QVLCFramelessButton *lblAction;
QLabel *lbl; QLabel *lbl;
...@@ -116,20 +116,24 @@ public: ...@@ -116,20 +116,24 @@ public:
virtual ~PLSelector(); virtual ~PLSelector();
protected: protected:
friend class PlaylistWidget; friend class PlaylistWidget;
private: private:
QStringList mimeTypes () const;
bool dropMimeData ( QTreeWidgetItem *, int, const QMimeData *, Qt::DropAction );
void dragMoveEvent ( QDragMoveEvent * event );
void createItems(); void createItems();
void drawBranches ( QPainter *, const QRect &, const QModelIndex & ) const; PLSelItem * addItem ( SelectorItemType type, const char* str,
PLSelItem * addItem ( bool drop = false, QTreeWidgetItem* parentItem = 0 );
SelectorItemType type, const char* str, bool drop,
QTreeWidgetItem* parentItem = 0 );
PLSelItem * addPodcastItem( playlist_item_t *p_item ); PLSelItem * addPodcastItem( playlist_item_t *p_item );
inline PLSelItem * itemWidget( QTreeWidgetItem * ); 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; intf_thread_t *p_intf;
QTreeWidgetItem *podcastsParent; QTreeWidgetItem *podcastsParent;
int podcastsParentId; int podcastsParentId;
private slots: private slots:
void setSource( QTreeWidgetItem *item ); void setSource( QTreeWidgetItem *item );
void plItemAdded( int, int ); void plItemAdded( int, int );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment