Commit 40969236 authored by Jakob Leben's avatar Jakob Leben

Qt: use QStackedLayout for playlist views

parent bf60a1b3
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <QToolButton> #include <QToolButton>
#include <QFontMetrics> #include <QFontMetrics>
#include <QPainter> #include <QPainter>
#include <QStackedLayout>
#include <assert.h> #include <assert.h>
...@@ -69,6 +70,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -69,6 +70,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
iconView = NULL; iconView = NULL;
treeView = NULL; treeView = NULL;
listView = NULL; listView = NULL;
viewStack = new QStackedLayout();
layout->addLayout( viewStack, 1, 0, 1, -1 );
model = new PLModel( p_playlist, p_intf, p_root, this ); model = new PLModel( p_playlist, p_intf, p_root, this );
currentRootId = -1; currentRootId = -1;
...@@ -271,7 +274,7 @@ void StandardPLPanel::createIconView() ...@@ -271,7 +274,7 @@ void StandardPLPanel::createIconView()
CONNECT( iconView, activated( const QModelIndex & ), CONNECT( iconView, activated( const QModelIndex & ),
this, activate( const QModelIndex & ) ); this, activate( const QModelIndex & ) );
iconView->installEventFilter( this ); iconView->installEventFilter( this );
layout->addWidget( iconView, 1, 0, 1, -1 ); viewStack->addWidget( iconView );
} }
void StandardPLPanel::createListView() void StandardPLPanel::createListView()
...@@ -283,7 +286,7 @@ void StandardPLPanel::createListView() ...@@ -283,7 +286,7 @@ void StandardPLPanel::createListView()
CONNECT( listView, activated( const QModelIndex & ), CONNECT( listView, activated( const QModelIndex & ),
this, activate( const QModelIndex & ) ); this, activate( const QModelIndex & ) );
listView->installEventFilter( this ); listView->installEventFilter( this );
layout->addWidget( listView, 1, 0, 1, -1 ); viewStack->addWidget( listView );
} }
...@@ -346,7 +349,7 @@ void StandardPLPanel::createTreeView() ...@@ -346,7 +349,7 @@ void StandardPLPanel::createTreeView()
this, toggleColumnShown( int ) ); this, toggleColumnShown( int ) );
/* Finish the layout */ /* Finish the layout */
layout->addWidget( treeView, 1, 0, 1, -1 ); viewStack->addWidget( treeView );
} }
void StandardPLPanel::showView( int i_view ) void StandardPLPanel::showView( int i_view )
...@@ -357,40 +360,28 @@ void StandardPLPanel::showView( int i_view ) ...@@ -357,40 +360,28 @@ void StandardPLPanel::showView( int i_view )
{ {
if( treeView == NULL ) if( treeView == NULL )
createTreeView(); createTreeView();
if( iconView ) iconView->hide();
if( listView ) listView->hide();
treeView->show();
currentView = treeView; currentView = treeView;
viewActions[i_view]->setChecked( true );
break; break;
} }
case ICON_VIEW: case ICON_VIEW:
{ {
if( iconView == NULL ) if( iconView == NULL )
createIconView(); createIconView();
if( treeView ) treeView->hide();
if( listView ) listView->hide();
iconView->show();
currentView = iconView; currentView = iconView;
viewActions[i_view]->setChecked( true );
break; break;
} }
case LIST_VIEW: case LIST_VIEW:
{ {
if( listView == NULL ) if( listView == NULL )
createListView(); createListView();
if( treeView ) treeView->hide();
if( iconView ) iconView->hide();
listView->show();
currentView = listView; currentView = listView;
viewActions[i_view]->setChecked( true );
break; break;
} }
default: return; default: return;
} }
viewStack->setCurrentWidget( currentView );
viewActions[i_view]->setChecked( true );
browseInto(); browseInto();
gotoPlayingItem(); gotoPlayingItem();
} }
......
...@@ -45,6 +45,7 @@ class PLModel; ...@@ -45,6 +45,7 @@ class PLModel;
class QPushButton; class QPushButton;
class QKeyEvent; class QKeyEvent;
class QWheelEvent; class QWheelEvent;
class QStackedLayout;
class PlIconView; class PlIconView;
class PlListView; class PlListView;
class LocationBar; class LocationBar;
...@@ -82,6 +83,7 @@ private: ...@@ -82,6 +83,7 @@ private:
PlIconView *iconView; PlIconView *iconView;
PlListView *listView; PlListView *listView;
QAbstractItemView *currentView; QAbstractItemView *currentView;
QStackedLayout *viewStack;
QAction *viewActions[ VIEW_COUNT ]; QAction *viewActions[ VIEW_COUNT ];
QAction *iconViewAction, *treeViewAction; QAction *iconViewAction, *treeViewAction;
......
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