Commit 64119e13 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: MLModel creation and assignation

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 9a68967d
......@@ -30,6 +30,7 @@
#include "components/playlist/standardpanel.hpp" /* MainView */
#include "components/playlist/selector.hpp" /* PLSelector */
#include "components/playlist/playlist_model.hpp" /* PLModel */
#include "components/playlist/ml_model.hpp" /* MLModel */
#include "components/interface_widgets.hpp" /* CoverArtLabel */
#include "util/searchlineedit.hpp"
......@@ -93,7 +94,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
setMinimumWidth( 400 );
PLModel *model = new PLModel( p_playlist, p_intf, p_root, this );
mainView = new StandardPLPanel( this, p_intf, p_root, selector, model );
MLModel *mlmodel = new MLModel( p_intf, this );
mainView = new StandardPLPanel( this, p_intf, p_root, selector, model, mlmodel );
/* Location Bar */
locationBar = new LocationBar( model );
......
......@@ -29,6 +29,7 @@
#include "components/playlist/standardpanel.hpp"
#include "components/playlist/playlist_model.hpp" /* PLModel */
#include "components/playlist/ml_model.hpp" /* MLModel */
#include "components/playlist/views.hpp" /* 3 views */
#include "components/playlist/selector.hpp" /* PLSelector */
#include "menus.hpp" /* Popup */
......@@ -53,9 +54,11 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
intf_thread_t *_p_intf,
playlist_item_t *p_root,
PLSelector *_p_selector,
PLModel *_p_model )
PLModel *_p_model,
MLModel *_p_plmodel)
: QWidget( _parent ), p_intf( _p_intf ),
p_selector( _p_selector ), model( _p_model )
p_selector( _p_selector ), model( _p_model ),
mlmodel( _p_plmodel)
{
viewStack = new QStackedLayout( this );
viewStack->setSpacing( 0 ); viewStack->setMargin( 0 );
......@@ -191,10 +194,18 @@ void StandardPLPanel::searchDelayed( const QString& searchText )
/* This activated by the selector selection */
void StandardPLPanel::setRoot( playlist_item_t *p_item, bool b )
{
if( b ) //SQLML
return;
model->rebuild( p_item );
if( b )
{
msg_Dbg( p_intf, "Setting the SQL ML" );
currentView->setModel( mlmodel );
}
else
{
msg_Dbg( p_intf, "Normal PL/ML or SD" );
if( currentView->model() != model )
currentView->setModel( model );
model->rebuild( p_item );
}
}
void StandardPLPanel::browseInto( const QModelIndex &index )
......@@ -409,20 +420,23 @@ void StandardPLPanel::cycleViews()
void StandardPLPanel::activate( const QModelIndex &index )
{
/* If we are not a leaf node */
if( !index.data( PLModel::IsLeafNodeRole ).toBool() )
if( currentView->model() == model )
{
if( currentView != treeView )
browseInto( index );
}
else
{
playlist_Lock( THEPL );
playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) );
p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
lastActivatedId = p_item->p_input->i_id;
playlist_Unlock( THEPL );
model->activateItem( index );
/* If we are not a leaf node */
if( !index.data( PLModel::IsLeafNodeRole ).toBool() )
{
if( currentView != treeView )
browseInto( index );
}
else
{
playlist_Lock( THEPL );
playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) );
p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
lastActivatedId = p_item->p_input->i_id;
playlist_Unlock( THEPL );
model->activateItem( index );
}
}
}
......
......@@ -37,6 +37,7 @@
class QSignalMapper;
class PLModel;
class MLModel;
class QKeyEvent;
class QWheelEvent;
class QStackedLayout;
......@@ -58,7 +59,7 @@ class StandardPLPanel: public QWidget
public:
StandardPLPanel( PlaylistWidget *, intf_thread_t *,
playlist_item_t *, PLSelector *, PLModel * );
playlist_item_t *, PLSelector *, PLModel *, MLModel * );
virtual ~StandardPLPanel();
enum { ICON_VIEW = 0,
......@@ -72,6 +73,7 @@ public:
protected:
PLModel *model;
MLModel *mlmodel;
virtual void wheelEvent( QWheelEvent *e );
private:
intf_thread_t *p_intf;
......
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