Commit 662dc6f8 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: split playlist mode view in a separate function

parent b216ade1
...@@ -255,13 +255,25 @@ bool StandardPLPanel::popup( const QModelIndex & index, const QPoint &point, con ...@@ -255,13 +255,25 @@ bool StandardPLPanel::popup( const QModelIndex & index, const QPoint &point, con
CONNECT( &menu, triggered( QAction * ), model, actionSlot( QAction * ) ); CONNECT( &menu, triggered( QAction * ), model, actionSlot( QAction * ) );
QMenu *viewMenu = new QMenu( qtr( "Playlist View Mode" ) ); menu.addMenu( StandardPLPanel::viewSelectionMenu( this ) );
/* Display and forward the result */
if( !menu.isEmpty() )
{
menu.exec( point ); return true;
}
else return false;
#undef ADD_MENU_ENTRY
}
/* View selection menu */ QMenu* StandardPLPanel::viewSelectionMenu( StandardPLPanel *panel )
QSignalMapper *viewSelectionMapper = new QSignalMapper( this ); {
CONNECT( viewSelectionMapper, mapped( int ), this, showView( int ) ); QMenu *viewMenu = new QMenu( qtr( "Playlist View Mode" ) );
QSignalMapper *viewSelectionMapper = new QSignalMapper( viewMenu );
CONNECT( viewSelectionMapper, mapped( int ), panel, showView( int ) );
QActionGroup *viewGroup = new QActionGroup( this ); QActionGroup *viewGroup = new QActionGroup( viewMenu );
# define MAX_VIEW StandardPLPanel::VIEW_COUNT # define MAX_VIEW StandardPLPanel::VIEW_COUNT
for( int i = 0; i < MAX_VIEW; i++ ) for( int i = 0; i < MAX_VIEW; i++ )
{ {
...@@ -270,19 +282,10 @@ bool StandardPLPanel::popup( const QModelIndex & index, const QPoint &point, con ...@@ -270,19 +282,10 @@ bool StandardPLPanel::popup( const QModelIndex & index, const QPoint &point, con
viewGroup->addAction( action ); viewGroup->addAction( action );
viewSelectionMapper->setMapping( action, i ); viewSelectionMapper->setMapping( action, i );
CONNECT( action, triggered(), viewSelectionMapper, map() ); CONNECT( action, triggered(), viewSelectionMapper, map() );
if( currentViewIndex() == i ) if( panel->currentViewIndex() == i )
action->setChecked( true ); action->setChecked( true );
} }
menu.addMenu( viewMenu ); return viewMenu;
/* Display and forward the result */
if( !menu.isEmpty() )
{
menu.exec( point ); return true;
}
else return false;
#undef ADD_MENU_ENTRY
} }
void StandardPLPanel::popupSelectColumn( QPoint ) void StandardPLPanel::popupSelectColumn( QPoint )
......
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
int currentViewIndex() const; int currentViewIndex() const;
static QMenu *viewSelectionMenu(StandardPLPanel *obj);
protected: protected:
PLModel *model; PLModel *model;
MLModel *mlmodel; MLModel *mlmodel;
...@@ -111,6 +112,7 @@ private: ...@@ -111,6 +112,7 @@ private:
public slots: public slots:
void setRootItem( playlist_item_t *, bool ); void setRootItem( playlist_item_t *, bool );
void browseInto( const QModelIndex& ); void browseInto( const QModelIndex& );
void showView( int );
private slots: private slots:
void deleteSelection(); void deleteSelection();
...@@ -136,7 +138,6 @@ private slots: ...@@ -136,7 +138,6 @@ private slots:
void decreaseZoom() { updateZoom( i_zoom - 1 ); }; void decreaseZoom() { updateZoom( i_zoom - 1 ); };
void toggleColumnShown( int ); void toggleColumnShown( int );
void showView( int );
void cycleViews(); void cycleViews();
signals: signals:
......
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