Changeset 19 for gui/main_window.cpp


Ignore:
Timestamp:
12/31/07 11:58:35 (4 years ago)
Author:
sander
Message:

Adding songs to playlist works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gui/main_window.cpp

    r18 r19  
    4242    connect(playlistTableView, SIGNAL(activated(const QModelIndex &)), this, SLOT(playlistItemActivated(const QModelIndex &))); 
    4343    connect(removeFromPlaylistPushButton, SIGNAL(clicked(bool)), this, SLOT(removeFromPlaylist())); 
     44    connect(libraryTreeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(libraryItemActivated(const QModelIndex &))); 
    4445 
    4546    // Timer 
     
    202203    mpd.removeSongs(toBeRemoved); 
    203204} 
     205 
     206void MainWindow::libraryItemActivated(const QModelIndex & index) 
     207{ 
     208    QStringList files; 
     209    MusicLibraryItem *item; 
     210    QModelIndex mappedIndex = libraryProxyModel.mapToSource(index); 
     211    item = static_cast<MusicLibraryItem *>(mappedIndex.internalPointer()); 
     212 
     213    switch(item->type()) { 
     214        case MusicLibraryItem::Type_Artist: 
     215            for(qint32 i = 0; i < item->childCount(); i++) { 
     216                for(qint32 j = 0; j < item->child(i)->childCount(); j++) 
     217                    files.append(item->child(i)->child(j)->file()); 
     218            } 
     219            break; 
     220        case MusicLibraryItem::Type_Album: 
     221            for(qint32 i = 0; i < item->childCount(); i++) 
     222                files.append(item->child(i)->file()); 
     223            break; 
     224        case MusicLibraryItem::Type_Song: 
     225            if(item->type() == MusicLibraryItem::Type_Song) 
     226                files.append(item->file()); 
     227            break; 
     228        default: 
     229            break; 
     230    } 
     231 
     232    if(!files.isEmpty()) { 
     233        mpd.add(files); 
     234        mpd.startPlayingSong(); 
     235    } 
     236} 
Note: See TracChangeset for help on using the changeset viewer.