]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/playlist_model.cpp
Qt: rename a signal to be more self-documenting
[vlc] / modules / gui / qt4 / components / playlist / playlist_model.cpp
index 113f214ec5e493c3606162030d8928bfe924a3f1..183038cf7e2b15d4de2829883025354b06bc750f 100644 (file)
@@ -380,7 +380,10 @@ QVariant PLModel::data( const QModelIndex &index, const int role ) const
     {
         return QVariant( QBrush( Qt::gray ) );
     }
-    else if( role == IsCurrentRole ) return QVariant( isCurrent( index ) );
+    else if( role == IsCurrentRole )
+    {
+        return QVariant( isCurrent( index ) );
+    }
     else if( role == IsLeafNodeRole )
     {
         QVariant isLeaf;
@@ -596,7 +599,7 @@ void PLModel::processInputItemUpdate( input_thread_t *p_input )
     if( p_input && !( p_input->b_dead || !vlc_object_alive( p_input ) ) )
     {
         PLItem *item = findByInput( rootItem, input_GetItem( p_input )->i_id );
-        if( item ) emit currentChanged( index( item, 0 ) );
+        if( item ) emit currentIndexChanged( index( item, 0 ) );
     }
     processInputItemUpdate( input_GetItem( p_input ) );
 }
@@ -649,7 +652,7 @@ void PLModel::processItemAppend( int i_item, int i_parent )
     endInsertRows();
 
     if( newItem->inputItem() == THEMIM->currentInputItem() )
-        emit currentChanged( index( newItem, 0 ) );
+        emit currentIndexChanged( index( newItem, 0 ) );
 }
 
 void PLModel::rebuild( playlist_item_t *p_root )
@@ -843,11 +846,11 @@ void PLModel::sort( const int i_root_id, const int column, Qt::SortOrder order )
     if( i_popup_item > -1 )
     {
         PLItem *popupitem = findById( rootItem, i_popup_item );
-        if( popupitem ) emit currentChanged( index( popupitem, 0 ) );
+        if( popupitem ) emit currentIndexChanged( index( popupitem, 0 ) );
         /* reset i_popup_item as we don't show it as selected anymore anyway */
         i_popup_item = -1;
     }
-    else if( currentIndex().isValid() ) emit currentChanged( currentIndex() );
+    else if( currentIndex().isValid() ) emit currentIndexChanged( currentIndex() );
 }
 
 void PLModel::search( const QString& search_text, const QModelIndex & idx, bool b_recursive )
@@ -953,21 +956,23 @@ bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode
             menu.addAction( qtr( "Add to playlist"), this, SLOT( popupAddToPlaylist() ) );
         menu.addAction( QIcon( ":/buttons/playlist/playlist_remove" ),
                         qtr(I_POP_DEL), this, SLOT( popupDel() ) );
-        menu.addSeparator();
     }
 
+    menu.addSeparator();
     /* Playlist sorting */
     if( !sortingMenu )
     {
         sortingMenu = new QMenu( qtr( "Sort by" ) );
         sortingMapper = new QSignalMapper( this );
-        for( int i = 1, j = 1; i < COLUMN_ALBUM; i <<= 1, j++ )
+        /* Choose what columns to show in sorting menu, not sure if this should be configurable*/
+        QList<int> sortingColumns;
+        sortingColumns << COLUMN_TITLE << COLUMN_ARTIST << COLUMN_ALBUM << COLUMN_TRACK_NUMBER << COLUMN_URI;
+        foreach( int Column, sortingColumns )
         {
-            if( i == COLUMN_NUMBER ) continue;
-            QAction *asc  = sortingMenu->addAction( qfu( psz_column_title( i ) ) + " " + qtr("Ascending") );
-            QAction *desc = sortingMenu->addAction( qfu( psz_column_title( i ) ) + " " + qtr("Descending") );
-            sortingMapper->setMapping( asc, j );
-            sortingMapper->setMapping( desc, -j );
+            QAction *asc  = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Ascending") );
+            QAction *desc = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Descending") );
+            sortingMapper->setMapping( asc, columnFromMeta(Column) + 1 );
+            sortingMapper->setMapping( desc, -1 * (columnFromMeta(Column)+1) );
             CONNECT( asc, triggered(), sortingMapper, map() );
             CONNECT( desc, triggered(), sortingMapper, map() );
         }
@@ -975,6 +980,12 @@ bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode
     }
     menu.addMenu( sortingMenu );
 
+    /* Zoom */
+    QMenu *zoomMenu = new QMenu( qtr( "Display size" ) );
+    zoomMenu->addAction( qtr( "Increase" ), this, SLOT( increaseZoom() ) );
+    zoomMenu->addAction( qtr( "Decrease" ), this, SLOT( decreaseZoom() ) );
+    menu.addMenu( zoomMenu );
+
     /* Store the current selected item for popup*() methods */
     current_selection = list;
 
@@ -1101,6 +1112,19 @@ void PLModel::popupSort( int column )
           column > 0 ? Qt::AscendingOrder : Qt::DescendingOrder );
 }
 
+/* */
+void PLModel::increaseZoom()
+{
+    i_zoom++;
+    emit layoutChanged();
+}
+
+void PLModel::decreaseZoom()
+{
+    i_zoom--;
+    emit layoutChanged();
+}
+
 /******************* Drag and Drop helper class ******************/
 PlMimeData::~PlMimeData()
 {