Changeset 19
- Timestamp:
- 12/31/07 11:58:35 (4 years ago)
- Files:
-
- 7 edited
-
gui/main_window.cpp (modified) (2 diffs)
-
gui/main_window.h (modified) (1 diff)
-
gui/musiclibraryitem.cpp (modified) (1 diff)
-
gui/musiclibraryitem.h (modified) (2 diffs)
-
lib/mpdconnection.cpp (modified) (11 diffs)
-
lib/mpdconnection.h (modified) (1 diff)
-
lib/mpdparseutils.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
gui/main_window.cpp
r18 r19 42 42 connect(playlistTableView, SIGNAL(activated(const QModelIndex &)), this, SLOT(playlistItemActivated(const QModelIndex &))); 43 43 connect(removeFromPlaylistPushButton, SIGNAL(clicked(bool)), this, SLOT(removeFromPlaylist())); 44 connect(libraryTreeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(libraryItemActivated(const QModelIndex &))); 44 45 45 46 // Timer … … 202 203 mpd.removeSongs(toBeRemoved); 203 204 } 205 206 void 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 } -
gui/main_window.h
r18 r19 41 41 void playlistItemActivated(const QModelIndex &); 42 42 void removeFromPlaylist(); 43 void libraryItemActivated(const QModelIndex &); 43 44 }; 44 45 -
gui/musiclibraryitem.cpp
r17 r19 64 64 } 65 65 66 QString & MusicLibraryItem::file() const 67 { 68 return *_file; 69 } 70 66 71 void MusicLibraryItem::setFile(const QString &filename) 67 72 { 68 file = new QString(filename);73 _file = new QString(filename); 69 74 } 70 75 -
gui/musiclibraryitem.h
r17 r19 27 27 void setParent(MusicLibraryItem *parent); 28 28 MusicLibraryItem::Type type() const; 29 QString & file() const; 29 30 void setFile(const QString &filename); 30 31 void clearChildren(); … … 34 35 QList<MusicLibraryItem *> childItems; 35 36 QString itemData; 36 QString * file;37 QString *_file; 37 38 MusicLibraryItem *parentItem; 38 39 }; -
lib/mpdconnection.cpp
r17 r19 185 185 */ 186 186 187 void MPDConnection::add(const QStringList &files) 188 { 189 QByteArray send = "command_list_begin\n"; 190 191 for(qint32 i = 0; i < files.size(); i++) { 192 send += "add \""; 193 send += files.at(i); 194 send += "\"\n"; 195 } 196 197 send += "command_list_end"; 198 199 sendCommand(send); 200 201 if(!commandOk()) 202 qDebug("Couldn't add song(s) to playlist"); 203 } 204 187 205 void MPDConnection::removeSongs(const QList<qint32> &items) 188 206 { … … 199 217 sendCommand(send); 200 218 201 if(!commandOk()) {219 if(!commandOk()) 202 220 qDebug("Couldn't remove songs from playlist"); 203 }204 221 } 205 222 … … 243 260 sendCommand("next"); 244 261 245 if(!commandOk()) {262 if(!commandOk()) 246 263 qDebug("Couldn't go to next track"); 247 }248 264 } 249 265 … … 258 274 sendCommand(data); 259 275 260 if(!commandOk()) {276 if(!commandOk()) 261 277 qDebug("Couldn't set pause"); 262 }263 278 } 264 279 … … 269 284 sendCommand(data); 270 285 271 if(!commandOk()) {286 if(!commandOk()) 272 287 qDebug("Couldn't start playing song"); 273 }274 288 } 275 289 … … 280 294 sendCommand(data); 281 295 282 if(!commandOk()) {296 if(!commandOk()) 283 297 qDebug("Couldn't start playing song id"); 284 }285 298 } 286 299 … … 289 302 sendCommand("previous"); 290 303 291 if(!commandOk()) {304 if(!commandOk()) 292 305 qDebug("Couldn't go to previous track"); 293 }294 306 } 295 307 … … 304 316 sendCommand(data); 305 317 306 if(!commandOk()) {318 if(!commandOk()) 307 319 qDebug("Couldn't toggle random"); 308 }309 320 } 310 321 … … 319 330 sendCommand(data); 320 331 321 if(!commandOk()) {332 if(!commandOk()) 322 333 qDebug("Couldn't toggle repeat"); 323 }324 334 } 325 335 … … 348 358 sendCommand(data); 349 359 350 if(!commandOk()) {360 if(!commandOk()) 351 361 qDebug("Couldn't set volume"); 352 }353 362 } 354 363 … … 357 366 sendCommand("stop"); 358 367 359 if(!commandOk()) {368 if(!commandOk()) 360 369 qDebug("Couldn't stop playing"); 361 }362 370 } 363 371 -
lib/mpdconnection.h
r17 r19 32 32 33 33 // Playlist 34 void add(const QStringList &files); 34 35 void currentSong(); 35 36 void playListInfo(); -
lib/mpdparseutils.cpp
r17 r19 72 72 if(tokens.at(0) == "file") { 73 73 song->file = tokens.at(1); 74 song->file = song->file.trimmed(); 74 75 } else if(tokens.at(0) == "Time") { 75 76 song->time = tokens.at(1).toUInt();
Note: See TracChangeset
for help on using the changeset viewer.
