Commit 83717d05 authored by Jakob Leben's avatar Jakob Leben

Qt: unify item activation among PL views, change title when browsing in iconView

Also delay view creation in constructor after the title label has been created
parent 4fdd32fa
...@@ -121,18 +121,4 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent ) ...@@ -121,18 +121,4 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
PlListViewItemDelegate *pl = new PlListViewItemDelegate(); PlListViewItemDelegate *pl = new PlListViewItemDelegate();
setItemDelegate( pl ); setItemDelegate( pl );
CONNECT( this, activated( const QModelIndex & ), this, activate( const QModelIndex & ) );
}
void PlIconView::activate( const QModelIndex & index )
{
if( model()->hasChildren( index ) )
setRootIndex( index );
else
{
PLModel *plModel = qobject_cast<PLModel*>( model() );
if( !plModel ) return;
plModel->activateItem( index );
}
} }
...@@ -47,8 +47,6 @@ class PlIconView : public QListView ...@@ -47,8 +47,6 @@ class PlIconView : public QListView
public: public:
PlIconView( PLModel *model, QWidget *parent = 0 ); PlIconView( PLModel *model, QWidget *parent = 0 );
public slots:
void activate( const QModelIndex & index );
}; };
#endif #endif
......
...@@ -65,23 +65,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -65,23 +65,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
iconView = NULL; iconView = NULL;
treeView = NULL; treeView = NULL;
/* Saved Settings */
getSettings()->beginGroup("Playlist");
int i_viewMode = getSettings()->value( "view-mode", TREE_VIEW ).toInt();
if( i_viewMode == ICON_VIEW )
{
createIconView();
currentView = iconView;
}
else
{
createTreeView();
currentView = treeView;
}
getSettings()->endGroup();
currentRootId = -1; currentRootId = -1;
/* Title label */ /* Title label */
...@@ -113,6 +96,23 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -113,6 +96,23 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
viewButton->setIcon( QIcon( ":/buttons/playlist/playlist_add" ) ); viewButton->setIcon( QIcon( ":/buttons/playlist/playlist_add" ) );
layout->addWidget( viewButton, 0, 2 ); layout->addWidget( viewButton, 0, 2 );
BUTTONACT( viewButton, toggleView() ); BUTTONACT( viewButton, toggleView() );
/* Saved Settings */
getSettings()->beginGroup("Playlist");
int i_viewMode = getSettings()->value( "view-mode", TREE_VIEW ).toInt();
if( i_viewMode == ICON_VIEW )
{
createIconView();
currentView = iconView;
}
else
{
createTreeView();
currentView = treeView;
}
getSettings()->endGroup();
} }
StandardPLPanel::~StandardPLPanel() StandardPLPanel::~StandardPLPanel()
...@@ -272,6 +272,8 @@ void StandardPLPanel::createIconView() ...@@ -272,6 +272,8 @@ void StandardPLPanel::createIconView()
iconView->setContextMenuPolicy( Qt::CustomContextMenu ); iconView->setContextMenuPolicy( Qt::CustomContextMenu );
CONNECT( iconView, customContextMenuRequested( const QPoint & ), CONNECT( iconView, customContextMenuRequested( const QPoint & ),
this, popupPlView( const QPoint & ) ); this, popupPlView( const QPoint & ) );
CONNECT( iconView, activated( const QModelIndex & ),
this, activate( const QModelIndex & ) );
layout->addWidget( iconView, 1, 0, 1, -1 ); layout->addWidget( iconView, 1, 0, 1, -1 );
} }
...@@ -316,7 +318,7 @@ void StandardPLPanel::createTreeView() ...@@ -316,7 +318,7 @@ void StandardPLPanel::createTreeView()
/* Connections for the TreeView */ /* Connections for the TreeView */
CONNECT( treeView, activated( const QModelIndex& ), CONNECT( treeView, activated( const QModelIndex& ),
model,activateItem( const QModelIndex& ) ); this, activate( const QModelIndex& ) );
CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ), CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
this, popupSelectColumn( QPoint ) ); this, popupSelectColumn( QPoint ) );
CONNECT( treeView, customContextMenuRequested( const QPoint & ), CONNECT( treeView, customContextMenuRequested( const QPoint & ),
...@@ -358,3 +360,16 @@ void StandardPLPanel::wheelEvent( QWheelEvent *e ) ...@@ -358,3 +360,16 @@ void StandardPLPanel::wheelEvent( QWheelEvent *e )
// Accept this event in order to prevent unwanted volume up/down changes // Accept this event in order to prevent unwanted volume up/down changes
e->accept(); e->accept();
} }
void StandardPLPanel::activate( const QModelIndex &index )
{
if( model->hasChildren( index ) && currentView == iconView )
{
iconView->setRootIndex( index );
title->setText( index.data().toString() );
}
else
{
model->activateItem( index );
}
}
...@@ -98,6 +98,7 @@ private slots: ...@@ -98,6 +98,7 @@ private slots:
void popupPlView( const QPoint & ); void popupPlView( const QPoint & );
void toggleColumnShown( int ); void toggleColumnShown( int );
void toggleView(); void toggleView();
void activate( const QModelIndex & );
}; };
#endif #endif
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