Commit 1cdeaa80 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: variable renaming so they are more explicit

parent 27f5e6a9
...@@ -62,49 +62,49 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -62,49 +62,49 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
model = new PLModel( p_playlist, p_intf, p_root, this ); model = new PLModel( p_playlist, p_intf, p_root, this );
/* Create and configure the QTreeView */ /* Create and configure the QTreeView */
view = new QTreeView; treeView = new QTreeView;
view->setModel( model ); treeView->setModel( model );
view2 = NULL; iconView = NULL;
view->setIconSize( QSize( 20, 20 ) ); treeView->setIconSize( QSize( 20, 20 ) );
view->setAlternatingRowColors( true ); treeView->setAlternatingRowColors( true );
view->setAnimated( true ); treeView->setAnimated( true );
view->setUniformRowHeights( true ); treeView->setUniformRowHeights( true );
view->setSortingEnabled( true ); treeView->setSortingEnabled( true );
view->header()->setSortIndicator( -1 , Qt::AscendingOrder ); treeView->header()->setSortIndicator( -1 , Qt::AscendingOrder );
view->header()->setSortIndicatorShown( true ); treeView->header()->setSortIndicatorShown( true );
view->header()->setClickable( true ); treeView->header()->setClickable( true );
view->header()->setContextMenuPolicy( Qt::CustomContextMenu ); treeView->header()->setContextMenuPolicy( Qt::CustomContextMenu );
view->setSelectionBehavior( QAbstractItemView::SelectRows ); treeView->setSelectionBehavior( QAbstractItemView::SelectRows );
view->setSelectionMode( QAbstractItemView::ExtendedSelection ); treeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
view->setDragEnabled( true ); treeView->setDragEnabled( true );
view->setAcceptDrops( true ); treeView->setAcceptDrops( true );
view->setDropIndicatorShown( true ); treeView->setDropIndicatorShown( true );
installEventFilter( view ); installEventFilter( treeView );
/* Saved Settings */ /* Saved Settings */
getSettings()->beginGroup("Playlist"); getSettings()->beginGroup("Playlist");
if( getSettings()->contains( "headerStateV2" ) ) if( getSettings()->contains( "headerStateV2" ) )
{ {
view->header()->restoreState( treeView->header()->restoreState(
getSettings()->value( "headerStateV2" ).toByteArray() ); getSettings()->value( "headerStateV2" ).toByteArray() );
} }
else else
{ {
for( int m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ ) for( int m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ )
{ {
view->setColumnHidden( c, !( m & COLUMN_DEFAULT ) ); treeView->setColumnHidden( c, !( m & COLUMN_DEFAULT ) );
if( m == COLUMN_TITLE ) view->header()->resizeSection( c, 200 ); if( m == COLUMN_TITLE ) treeView->header()->resizeSection( c, 200 );
else if( m == COLUMN_DURATION ) view->header()->resizeSection( c, 80 ); else if( m == COLUMN_DURATION ) treeView->header()->resizeSection( c, 80 );
} }
} }
getSettings()->endGroup(); getSettings()->endGroup();
/* Connections for the TreeView */ /* Connections for the TreeView */
CONNECT( view, activated( const QModelIndex& ), CONNECT( treeView, activated( const QModelIndex& ),
model,activateItem( const QModelIndex& ) ); model,activateItem( const QModelIndex& ) );
CONNECT( view->header(), customContextMenuRequested( const QPoint & ), CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
this, popupSelectColumn( QPoint ) ); this, popupSelectColumn( QPoint ) );
CONNECT( model, currentChanged( const QModelIndex& ), CONNECT( model, currentChanged( const QModelIndex& ),
this, handleExpansion( const QModelIndex& ) ); this, handleExpansion( const QModelIndex& ) );
...@@ -142,7 +142,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -142,7 +142,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
BUTTONACT( viewButton, toggleView() ); BUTTONACT( viewButton, toggleView() );
/* Finish the layout */ /* Finish the layout */
layout->addWidget( view, 1, 0, 1, -1 ); layout->addWidget( treeView, 1, 0, 1, -1 );
selectColumnsSigMapper = new QSignalMapper( this ); selectColumnsSigMapper = new QSignalMapper( this );
CONNECT( selectColumnsSigMapper, mapped( int ), CONNECT( selectColumnsSigMapper, mapped( int ),
...@@ -152,19 +152,19 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -152,19 +152,19 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
StandardPLPanel::~StandardPLPanel() StandardPLPanel::~StandardPLPanel()
{ {
getSettings()->beginGroup("Playlist"); getSettings()->beginGroup("Playlist");
getSettings()->setValue( "headerStateV2", view->header()->saveState() ); getSettings()->setValue( "headerStateV2", treeView->header()->saveState() );
getSettings()->endGroup(); getSettings()->endGroup();
} }
/* Unused anymore, but might be useful, like in right-click menu */ /* Unused anymore, but might be useful, like in right-click menu */
void StandardPLPanel::gotoPlayingItem() void StandardPLPanel::gotoPlayingItem()
{ {
view->scrollTo( model->currentIndex() ); treeView->scrollTo( model->currentIndex() );
} }
void StandardPLPanel::handleExpansion( const QModelIndex& index ) void StandardPLPanel::handleExpansion( const QModelIndex& index )
{ {
view->scrollTo( index ); treeView->scrollTo( index );
} }
/* PopupAdd Menu for the Add Menu */ /* PopupAdd Menu for the Add Menu */
...@@ -204,7 +204,7 @@ void StandardPLPanel::popupSelectColumn( QPoint pos ) ...@@ -204,7 +204,7 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
QAction* option = menu.addAction( QAction* option = menu.addAction(
qfu( psz_column_title( i ) ) ); qfu( psz_column_title( i ) ) );
option->setCheckable( true ); option->setCheckable( true );
option->setChecked( !view->isColumnHidden( j ) ); option->setChecked( !treeView->isColumnHidden( j ) );
selectColumnsSigMapper->setMapping( option, j ); selectColumnsSigMapper->setMapping( option, j );
CONNECT( option, triggered(), selectColumnsSigMapper, map() ); CONNECT( option, triggered(), selectColumnsSigMapper, map() );
} }
...@@ -213,7 +213,7 @@ void StandardPLPanel::popupSelectColumn( QPoint pos ) ...@@ -213,7 +213,7 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
void StandardPLPanel::toggleColumnShown( int i ) void StandardPLPanel::toggleColumnShown( int i )
{ {
view->setColumnHidden( i, !view->isColumnHidden( i ) ); treeView->setColumnHidden( i, !treeView->isColumnHidden( i ) );
} }
/* Search in the playlist */ /* Search in the playlist */
...@@ -224,7 +224,7 @@ void StandardPLPanel::search( const QString& searchText ) ...@@ -224,7 +224,7 @@ void StandardPLPanel::search( const QString& searchText )
void StandardPLPanel::doPopup( QModelIndex index, QPoint point ) void StandardPLPanel::doPopup( QModelIndex index, QPoint point )
{ {
QItemSelectionModel *selection = view->selectionModel(); QItemSelectionModel *selection = treeView->selectionModel();
QModelIndexList list = selection->selectedIndexes(); QModelIndexList list = selection->selectedIndexes();
model->popup( index, point, list ); model->popup( index, point, list );
} }
...@@ -289,35 +289,35 @@ void StandardPLPanel::keyPressEvent( QKeyEvent *e ) ...@@ -289,35 +289,35 @@ void StandardPLPanel::keyPressEvent( QKeyEvent *e )
void StandardPLPanel::deleteSelection() void StandardPLPanel::deleteSelection()
{ {
QItemSelectionModel *selection = view->selectionModel(); QItemSelectionModel *selection = treeView->selectionModel();
QModelIndexList list = selection->selectedIndexes(); QModelIndexList list = selection->selectedIndexes();
model->doDelete( list ); model->doDelete( list );
} }
void StandardPLPanel::toggleView() void StandardPLPanel::toggleView()
{ {
if( view && view->isVisible() ) if( treeView && treeView->isVisible() )
{ {
if( view2 == NULL ) if( iconView == NULL )
{ {
view2 = new PlIconView( model, this ); iconView = new PlIconView( model, this );
layout->addWidget( view2, 1, 0, 1, -1 ); layout->addWidget( iconView, 1, 0, 1, -1 );
installEventFilter( view2 ); installEventFilter( iconView );
} }
view->hide(); treeView->hide();
view2->show(); iconView->show();
} }
else else
{ {
view2->hide(); iconView->hide();
view->show(); treeView->show();
} }
} }
bool StandardPLPanel::eventFilter( QObject *obj, QEvent *event ) bool StandardPLPanel::eventFilter( QObject *obj, QEvent *event )
{ {
QAbstractItemView *view = qobject_cast<QAbstractItemView *>(obj); QAbstractItemView *aView = qobject_cast<QAbstractItemView *>(obj);
if( !view ) return false; if( !aView ) return false;
switch( event->type() ) switch( event->type() )
{ {
...@@ -326,18 +326,18 @@ bool StandardPLPanel::eventFilter( QObject *obj, QEvent *event ) ...@@ -326,18 +326,18 @@ bool StandardPLPanel::eventFilter( QObject *obj, QEvent *event )
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if( mouseEvent->button() & Qt::RightButton ) if( mouseEvent->button() & Qt::RightButton )
{ {
QModelIndex index = view->indexAt( QModelIndex index = aView->indexAt(
QPoint( mouseEvent->x(), mouseEvent->y() ) ); QPoint( mouseEvent->x(), mouseEvent->y() ) );
doPopup( index, QCursor::pos() ); doPopup( index, QCursor::pos() );
return true; return true;
} }
else if( mouseEvent->button() & Qt::LeftButton ) else if( mouseEvent->button() & Qt::LeftButton )
{ {
if( !view->indexAt( QPoint( mouseEvent->x(), if( !aView->indexAt( QPoint( mouseEvent->x(),
mouseEvent->y() ) ).isValid() ) mouseEvent->y() ) ).isValid() )
view->clearSelection(); aView->clearSelection();
} }
// view->mousePressEvent( mouseEvent ); // aView->mousePressEvent( mouseEvent );
} }
return true; return true;
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
...@@ -345,7 +345,7 @@ bool StandardPLPanel::eventFilter( QObject *obj, QEvent *event ) ...@@ -345,7 +345,7 @@ bool StandardPLPanel::eventFilter( QObject *obj, QEvent *event )
QMouseEvent *mouseEvent2 = static_cast<QMouseEvent *>(event); QMouseEvent *mouseEvent2 = static_cast<QMouseEvent *>(event);
if( mouseEvent2->button() & Qt::RightButton ) if( mouseEvent2->button() & Qt::RightButton )
return false; /* Do NOT forward to QTreeView!! */ return false; /* Do NOT forward to QTreeView!! */
// view->mouseReleaseEvent( mouseEvent ); // aView->mouseReleaseEvent( mouseEvent );
return true; return true;
} }
default: default:
......
...@@ -71,8 +71,8 @@ private: ...@@ -71,8 +71,8 @@ private:
QPushButton *addButton; QPushButton *addButton;
QGridLayout *layout; QGridLayout *layout;
QTreeView *view; QTreeView *treeView;
PlIconView *view2; PlIconView *iconView;
int currentRootId; int currentRootId;
QSignalMapper *selectColumnsSigMapper; QSignalMapper *selectColumnsSigMapper;
......
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