Changeset 26
- Timestamp:
- 12/31/07 17:23:22 (4 years ago)
- Location:
- gui
- Files:
-
- 3 edited
-
main_window.cpp (modified) (2 diffs)
-
main_window.h (modified) (1 diff)
-
main_window.ui (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
gui/main_window.cpp
r25 r26 53 53 connect(removeFromPlaylistPushButton, SIGNAL(clicked(bool)), this, SLOT(removeFromPlaylist())); 54 54 connect(libraryTreeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(libraryItemActivated(const QModelIndex &))); 55 connect(addToPlaylistPushButton, SIGNAL(clicked(bool)), this, SLOT(addToPlaylistButtonActivated())); 55 56 56 57 // Timer … … 253 254 } 254 255 } 256 257 void MainWindow::addToPlaylistButtonActivated() 258 { 259 QStringList files; 260 QModelIndex mappedIndex; 261 MPDStatus::State curState = mpd_status.state; 262 MusicLibraryItem *item; 263 264 // Get selected view indexes 265 QModelIndexList selected = libraryTreeView->selectionModel()->selectedIndexes(); 266 267 if(selected.size() == 0) 268 return; 269 270 for(qint32 i = 0; i < selected.size(); i++) { 271 mappedIndex = libraryProxyModel.mapToSource(selected.at(i)); 272 item = static_cast<MusicLibraryItem *>(mappedIndex.internalPointer()); 273 274 switch(item->type()) { 275 case MusicLibraryItem::Type_Artist: 276 for(qint32 i = 0; i < item->childCount(); i++) { 277 for(qint32 j = 0; j < item->child(i)->childCount(); j++) 278 files.append(item->child(i)->child(j)->file()); 279 } 280 break; 281 case MusicLibraryItem::Type_Album: 282 for(qint32 i = 0; i < item->childCount(); i++) 283 files.append(item->child(i)->file()); 284 break; 285 case MusicLibraryItem::Type_Song: 286 if(item->type() == MusicLibraryItem::Type_Song) 287 files.append(item->file()); 288 break; 289 default: 290 break; 291 } 292 } 293 294 if(!files.isEmpty()) { 295 mpd.add(files); 296 if(curState != MPDStatus::State_Playing) 297 mpd.startPlayingSong(); 298 299 libraryTreeView->selectionModel()->clearSelection(); 300 } 301 } -
gui/main_window.h
r25 r26 43 43 void removeFromPlaylist(); 44 44 void libraryItemActivated(const QModelIndex &); 45 void addToPlaylistButtonActivated(); 45 46 }; 46 47 -
gui/main_window.ui
r21 r26 275 275 <property name="alternatingRowColors" > 276 276 <bool>true</bool> 277 </property> 278 <property name="selectionMode" > 279 <enum>QAbstractItemView::ExtendedSelection</enum> 277 280 </property> 278 281 <property name="sortingEnabled" >
Note: See TracChangeset
for help on using the changeset viewer.
