TOMOC = main_interface \
dialogs_provider \
input_manager \
- playlist_model
+ playlist_model \
dialogs/playlist \
dialogs/prefs_dialog \
dialogs/streaminfo \
components/preferences_widgets \
components/preferences \
components/open \
+ components/playlist/panels \
util/input_slider
MOCCPP = $(TOMOC:%=%.moc.cpp)
main_interface.moc.cpp \
dialogs_provider.moc.cpp \
input_manager.moc.cpp \
- playlist_model.moc.cpp \
+ playlist_model.moc.cpp \
dialogs/playlist.moc.cpp \
dialogs/streaminfo.moc.cpp \
dialogs/prefs_dialog.moc.cpp \
components/preferences_widgets.moc.cpp \
components/preferences.moc.cpp \
components/open.moc.cpp \
+ components/playlist/panels.moc.cpp \
util/input_slider.moc.cpp
if ENABLE_QT4
main_interface.cpp \
dialogs_provider.cpp \
input_manager.cpp \
- playlist_model.cpp \
+ playlist_model.cpp \
dialogs/playlist.cpp \
dialogs/prefs_dialog.cpp \
dialogs/streaminfo.cpp \
components/preferences_widgets.cpp \
components/preferences.cpp \
components/open.cpp \
+ components/playlist/standardpanel.cpp \
util/input_slider.cpp
$(NULL)
main_interface.hpp \
dialogs_provider.hpp \
input_manager.hpp \
- playlist_model.hpp \
+ playlist_model.hpp \
dialogs/playlist.hpp \
dialogs/streaminfo.hpp \
dialogs/prefs_dialog.hpp \
components/preferences_widgets.hpp \
components/preferences.hpp \
components/open.hpp \
+ components/playlist/panels.hpp \
util/input_slider.hpp \
ui/input_stats.ui \
pixmaps/advanced.xpm \
{
p_intf = _p_intf;
}
- virtual ~PLPanel();
+ virtual ~PLPanel() {};
private:
intf_thread_t *p_intf;
};
{
Q_OBJECT;
public:
- StandardPLPanel( QWidget *, intf_thread_t * );
+ StandardPLPanel( QWidget *, intf_thread_t *, playlist_item_t * );
virtual ~StandardPLPanel();
};
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#include "playlist_model.hpp"
#include "components/playlist/panels.hpp"
+#include <QTreeView>
-StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf ):
+StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
+ playlist_item_t *p_root ):
PLPanel( _parent, _p_intf )
{
+
+ PLModel *model = new PLModel( p_root, -1, this );
+ QTreeView *view = new QTreeView( this );
+ view->setModel(model);
}
StandardPLPanel::~StandardPLPanel()
{}
-
-#endif
#include "dialogs/playlist.hpp"
#include "util/qvlcframe.hpp"
#include "qt4.hpp"
-
+#include "components/playlist/panels.hpp"
PlaylistDialog *PlaylistDialog::instance = NULL;
-PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCFrame( p_intf )
+PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{
+ playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
+ VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+ new StandardPLPanel( this, p_intf, p_playlist->p_root_category );
}
PlaylistDialog::~PlaylistDialog()
#include "main_interface.hpp"
#include "input_manager.hpp"
#include "util/input_slider.hpp"
-#include "util/qvlcframe.hpp">
+#include "util/qvlcframe.hpp"
#include "dialogs_provider.hpp"
#include <QCloseEvent>
#include <assert.h>
connect( ui.stopButton, SLOT( clicked() ), this, SLOT( stop() ) );
connect( ui.nextButton, SLOT( clicked() ), this, SLOT( next() ) );
connect( ui.prevButton, SLOT( clicked() ), this, SLOT( prev() ) );
+
+ connect( ui.playlistButton, SLOT(clicked() ),
+ DialogsProvider::getInstance( p_intf ), SLOT( playlistDialog() ) );
}
MainInterface::~MainInterface()
qDeleteAll(children);
}
-void PLItem::insertChild( PLItem *item, int i_pos )
+void PLItem::insertChild( PLItem *item, int i_pos, bool signal )
{
assert( model );
- model->beginInsertRows( model->index( this , 0 ), i_pos, i_pos );
+ if( signal )
+ model->beginInsertRows( model->index( this , 0 ), i_pos, i_pos );
children.append( item );
- model->endInsertRows();
+ if( signal )
+ model->endInsertRows();
}
int PLItem::row() const
i_cached_id = -1;
i_cached_input_id = -1;
+ addCallbacks();
+}
+
+PLModel::~PLModel()
+{
+ delCallbacks();
+ delete rootItem;
+}
+
+void PLModel::addCallbacks()
+{
/* Some global changes happened -> Rebuild all */
var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
/* We went to the next item */
var_AddCallback( p_playlist, "item-deleted", ItemDeleted, this );
}
-PLModel::~PLModel()
+void PLModel::delCallbacks()
{
var_DelCallback( p_playlist, "item-change", ItemChanged, this );
var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );
var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
var_DelCallback( p_playlist, "item-append", ItemAppended, this );
var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this );
- delete rootItem;
}
/****************** Base model mandatory implementations *****************/
+
QVariant PLModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return createIndex(parentItem->row(), 0, parentItem);
}
+int PLModel::columnCount( const QModelIndex &i) const
+{
+ return 1;
+}
+
int PLModel::childrenCount(const QModelIndex &parent) const
+{
+ return rowCount( parent );
+}
+
+int PLModel::rowCount(const QModelIndex &parent) const
{
PLItem *parentItem;
ProcessItemRemoval( ple->i_id );
}
+/**** Events processing ****/
void PLModel::ProcessInputItemUpdate( int i_input_id )
{
assert( i_input_id >= 0 );
- /// \todo
+ UpdateTreeItem( FindByInput( rootItem, i_input_id ), true );
}
void PLModel::ProcessItemRemoval( int i_id )
nodeItem->appendChild( new PLItem( p_item, nodeItem, this ) );
-
end:
return;
}
+
+void PLModel::Rebuild()
+{
+ /* Remove callbacks before locking to avoid deadlocks */
+ delCallbacks();
+ PL_LOCK;
+
+ /* Invalidate cache */
+ i_cached_id = i_cached_input_id = -1;
+
+ /* Clear the tree */
+ qDeleteAll( rootItem->children );
+
+ /* Recreate from root */
+ UpdateNodeChildren( rootItem );
+
+ /* And signal the view */
+ emit layoutChanged();
+
+ addCallbacks();
+ PL_UNLOCK;
+}
+
+void PLModel::UpdateNodeChildren( PLItem *root )
+{
+ playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
+ UpdateNodeChildren( p_node, root );
+}
+
+void PLModel::UpdateNodeChildren( playlist_item_t *p_node, PLItem *root )
+{
+ for( int i = 0; i < p_node->i_children ; i++ )
+ {
+ PLItem *newItem = new PLItem( p_node->pp_children[i], root, this );
+ root->appendChild( newItem, false );
+ UpdateTreeItem( newItem, false );
+ if( p_node->pp_children[i]->i_children != -1 )
+ UpdateNodeChildren( p_node->pp_children[i], newItem );
+ }
+}
+
+void PLModel::UpdateTreeItem( PLItem *item, bool signal )
+{
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, rootItem->i_id );
+ UpdateTreeItem( p_item, item, signal );
+}
+
+void PLModel::UpdateTreeItem( playlist_item_t *p_item, PLItem *item, bool signal )
+{
+ /// \todo
+ if( signal )
+ { // emit
+ }
+}
/**********************************************************************
* Playlist callbacks
~PLItem();
int row() const;
- void insertChild( PLItem *, int );
+ void insertChild( PLItem *, int p, bool signal = true );
- void appendChild( PLItem *item ) { insertChild( item, children.count() ); };
+ void appendChild( PLItem *item, bool signal = true )
+ {
+ insertChild( item, children.count(), signal );
+ };
PLItem *child( int row ) { return children.value( row ); };
int childCount() const { return children.count(); };
QString columnString( int col ) { return strings.value( col ); };
QModelIndex parent( const QModelIndex &index) const;
int childrenCount( const QModelIndex &parent = QModelIndex() ) const;
+ int rowCount( const QModelIndex &parent = QModelIndex() ) const;
+ int columnCount( const QModelIndex &parent = QModelIndex() ) const;
bool b_need_update;
int i_items_to_append;
private:
+ void addCallbacks();
+ void delCallbacks();
PLItem *rootItem;
playlist_t *p_playlist;
/* Update processing */
+ void Rebuild();
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 UpdateNodeChildren( PLItem * );
+ void UpdateNodeChildren( playlist_item_t *, PLItem * );
+
/* Lookups */
PLItem *FindById( PLItem *, int );
PLItem *FindByInput( PLItem *, int );