Commit 5b6e15db authored by Clément Stenac's avatar Clément Stenac

Qt4 playlist dialog base stuff

parent f8663297
......@@ -28,6 +28,13 @@
#include <QWidget>
#include <QString>
class QTreeView;
class PLModel;
/**
* \todo Share a single model between views using a filterproxy
*/
class PLPanel: public QWidget
{
Q_OBJECT;
......@@ -37,8 +44,10 @@ public:
p_intf = _p_intf;
}
virtual ~PLPanel() {};
private:
protected:
intf_thread_t *p_intf;
public slots:
virtual void setRoot( int ) = 0;
};
......@@ -46,8 +55,14 @@ class StandardPLPanel: public PLPanel
{
Q_OBJECT;
public:
StandardPLPanel( QWidget *, intf_thread_t *, playlist_t *,playlist_item_t * );
StandardPLPanel( QWidget *, intf_thread_t *,
playlist_t *,playlist_item_t * );
virtual ~StandardPLPanel();
private:
PLModel *model;
QTreeView *view;
public slots:
virtual void setRoot( int );
};
#endif
......@@ -22,13 +22,38 @@
*****************************************************************************/
#include "components/playlist/selector.hpp"
#include "qt4.hpp"
#include <QVBoxLayout>
#include <QHeaderView>
#include <QTreeView>
PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p )
PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf,
playlist_t *p_playlist ) : QWidget( p ), p_intf(_p_intf)
{
p_intf = _p_intf;
model = new PLModel( THEPL, THEPL->p_root_category, 1, this );
model->Rebuild();
view = new QTreeView( 0 );
view->setIndentation( 0 );
view->header()->hide();
view->setModel( model );
connect( view, SIGNAL( activated( const QModelIndex& ) ),
this, SLOT( setSource( const QModelIndex& ) ) );
connect( view, SIGNAL( clicked( const QModelIndex& ) ),
this, SLOT( setSource( const QModelIndex& ) ) );
QVBoxLayout *layout = new QVBoxLayout();
layout->setSpacing( 0 ); layout->setMargin( 0 );
layout->addWidget( view );
setLayout( layout );
}
void PLSelector::setSource( const QModelIndex &index )
{
if( model )
emit activated( model->itemId( index ) );
}
PLSelector::~PLSelector()
{
}
......@@ -27,15 +27,24 @@
#include <vlc/vlc.h>
#include <QWidget>
#include <QString>
#include <playlist_model.hpp>
class QTreeView;
class PLSelector: public QWidget
{
Q_OBJECT;
public:
PLSelector( QWidget *p, intf_thread_t *_p_intf );
PLSelector( QWidget *p, intf_thread_t *_p_intf, playlist_t * );
virtual ~PLSelector();
private:
intf_thread_t *p_intf;
PLModel *model;
QTreeView *view;
private slots:
void setSource( const QModelIndex& );
signals:
void activated( int );
};
#endif
......@@ -24,15 +24,36 @@
#include "playlist_model.hpp"
#include "components/playlist/panels.hpp"
#include <QTreeView>
#include <QVBoxLayout>
#include <QHeaderView>
#include "qt4.hpp"
#include <assert.h>
StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
playlist_t *p_playlist,
playlist_item_t *p_root ):
PLPanel( _parent, _p_intf )
{
PLModel *model = new PLModel( p_playlist, p_root, -1, this );
QTreeView *view = new QTreeView( this );
model = new PLModel( p_playlist, p_root, -1, this );
model->Rebuild();
view = new QTreeView( 0 );
view->setModel(model);
view->header()->resizeSection( 0, 300 );
connect( view, SIGNAL( activated( const QModelIndex& ) ), model,
SLOT( activateItem( const QModelIndex& ) ) );
QVBoxLayout *layout = new QVBoxLayout();
layout->setSpacing( 0 ); layout->setMargin( 0 );
layout->addWidget( view );
setLayout( layout );
}
void StandardPLPanel::setRoot( int i_root_id )
{
playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id );
assert( p_item );
model->rebuildRoot( p_item );
model->Rebuild();
}
......
......@@ -18,7 +18,8 @@
*
* 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. *****************************************************************************/
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
******************************************************************************/
#include "dialogs/playlist.hpp"
#include "util/qvlcframe.hpp"
......@@ -32,17 +33,17 @@ PlaylistDialog *PlaylistDialog::instance = NULL;
PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{
setWindowTitle( qtr( "Playlist" ) );
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
selector = new PLSelector( this, p_intf, THEPL );
selector->setMaximumWidth( 150 );
QHBoxLayout *layout = new QHBoxLayout();
selector = new PLSelector( this, p_intf );
layout->addWidget( selector, 1 );
rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this, p_intf,
p_playlist, p_playlist->p_root_category ) );
layout->addWidget( rightPanel, 3 );
readSettings( "playlist", QSize( 500,500 ) );
THEPL, THEPL->p_local_category ) );
connect( selector, SIGNAL( activated( int ) ), rightPanel, SLOT( setRoot( int ) ) );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( selector, 0 );
layout->addWidget( rightPanel, 10 );
readSettings( "playlist", QSize( 600,300 ) );
setLayout( layout );
}
......
......@@ -23,6 +23,7 @@
#ifndef _PLAYLIST_DIALOG_H_
#define _PLAYLIST_DIALOG_H_
#include <QModelIndex>
#include "util/qvlcframe.hpp"
class PLSelector;
......@@ -44,7 +45,6 @@ private:
PLSelector *selector;
PLPanel *rightPanel;
public slots:
};
......
......@@ -82,6 +82,7 @@ void DialogsProvider::customEvent( QEvent *event )
doInteraction( de->p_arg ); break;
case INTF_DIALOG_VLM:
case INTF_DIALOG_BOOKMARKS:
bookmarksDialog(); break;
case INTF_DIALOG_WIZARD:
default:
msg_Warn( p_intf, "unimplemented dialog\n" );
......
This diff is collapsed.
......@@ -42,7 +42,7 @@ public:
int row() const;
void insertChild( PLItem *, int p, bool signal = true );
void appendChild( PLItem *item, bool signal = true )
void appendChild( PLItem *item, bool signal = true )
{
insertChild( item, children.count(), signal );
};
......@@ -54,14 +54,13 @@ public:
void update( playlist_item_t *);
protected:
QList<PLItem*> children;
QList<QString> strings;
int i_id;
int i_input_id;
friend class PLModel;
private:
void init( int, int, PLItem *, PLModel * );
QList<QString> strings;
PLItem *parentItem;
PLModel *model;
};
......@@ -77,11 +76,10 @@ public:
PLEvent( playlist_add_t *a ) : QEvent( (QEvent::Type)(ItemAppend_Type) )
{ p_add = a; };
virtual ~PLEvent() {};
int i_id;
playlist_add_t *p_add;
};
};
#include <QAbstractItemModel>
#include <QModelIndex>
......@@ -102,10 +100,11 @@ public:
Qt::ItemFlags flags( const QModelIndex &index) const;
QVariant headerData( int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QModelIndex index( int r, int c, const QModelIndex &parent ) const;
QModelIndex index( PLItem *, int c ) const;
int itemId( const QModelIndex &index ) const;
QModelIndex parent( const QModelIndex &index) const;
int childrenCount( const QModelIndex &parent = QModelIndex() ) const;
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
......@@ -114,23 +113,25 @@ public:
bool b_need_update;
int i_items_to_append;
void Rebuild();
void rebuildRoot( playlist_item_t * );
private:
void addCallbacks();
void delCallbacks();
PLItem *rootItem;
playlist_t *p_playlist;
int i_depth;
/* Update processing */
void ProcessInputItemUpdate( int i_input_id );
void ProcessItemRemoval( int i_id );
void ProcessItemAppend( playlist_add_t *p_add );
void UpdateTreeItem( PLItem *, bool );
void UpdateTreeItem( playlist_item_t *, PLItem *, bool );
void UpdateTreeItem( PLItem *, bool, bool force = false );
void UpdateTreeItem( playlist_item_t *, PLItem *, bool, bool forc = false );
void UpdateNodeChildren( PLItem * );
void UpdateNodeChildren( playlist_item_t *, PLItem * );
/* Lookups */
PLItem *FindById( PLItem *, int );
PLItem *FindByInput( PLItem *, int );
......@@ -139,7 +140,8 @@ private:
PLItem *p_cached_item_bi;
int i_cached_id;
int i_cached_input_id;
public slots:
void activateItem( const QModelIndex &index );
friend class PLItem;
};
......
......@@ -71,7 +71,7 @@ static int Open( vlc_object_t *p_this )
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_intf->p_sys->p_playlist )
return VLC_EGENERIC;
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
return VLC_SUCCESS;
......
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