void SingleGenreView::onItemActivated(QModelIndex index) { if (index.row() == 0) { this->setEnabled(false); playlist->assignAudioPlaylist(); playlist->clear(); playlist->setShuffled(true); shuffleRequested = true; addAllToNowPlaying(); } else { int songCount = index.data(UserRoleAlbumCount).toInt(); if (songCount == 0 || songCount == 1) { this->setEnabled(false); SingleAlbumView *albumView = new SingleAlbumView(this, mafwRegistry); albumView->browseAlbumByObjectId(index.data(UserRoleObjectID).toString()); albumView->setWindowTitle(index.data(Qt::DisplayRole).toString()); albumView->show(); connect(albumView, SIGNAL(destroyed()), this, SLOT(onChildClosed())); ui->indicator->inhibit(); } else if (songCount > 1) { this->setEnabled(false); SingleArtistView *artistView = new SingleArtistView(this, mafwRegistry); artistView->browseArtist(index.data(UserRoleObjectID).toString()); artistView->setWindowTitle(index.data(Qt::DisplayRole).toString()); artistView->show(); connect(artistView, SIGNAL(destroyed()), this, SLOT(onChildClosed())); ui->indicator->inhibit(); } } }
void VideosWindow::onVideoSelected(QModelIndex index) { if (index.data(UserRoleHeader).toBool()) return; this->setEnabled(false); VideoNowPlayingWindow *window = new VideoNowPlayingWindow(this, mafwRegistry); window->showFullScreen(); connect(window, SIGNAL(destroyed()), this, SLOT(onChildClosed())); ui->indicator->inhibit(); playlist->assignVideoPlaylist(); playlist->clear(); int selectedRow; int indexOffset = 0; int videoCount = 0; gchar** videoAddBuffer = new gchar*[objectModel->rowCount()+1]; bool filter = QSettings().value("main/playlistFilter", false).toBool(); if (filter) { selectedRow = index.row(); for (int i = 0; i < objectProxyModel->rowCount(); i++) if (!objectProxyModel->index(i,0).data(UserRoleHeader).toBool()) videoAddBuffer[videoCount++] = qstrdup(objectProxyModel->index(i,0).data(UserRoleObjectID).toString().toUtf8()); else if (i < selectedRow) ++indexOffset; } else { selectedRow = objectProxyModel->mapToSource(index).row(); for (int i = 0; i < objectModel->rowCount(); i++) if (!objectModel->item(i)->data(UserRoleHeader).toBool()) videoAddBuffer[videoCount++] = qstrdup(objectModel->item(i)->data(UserRoleObjectID).toString().toUtf8()); else if (i < selectedRow) ++indexOffset; } videoAddBuffer[videoCount] = NULL; playlist->appendItems((const gchar**) videoAddBuffer); for (int i = 0; i < videoCount; i++) delete[] videoAddBuffer[i]; delete[] videoAddBuffer; mafwRenderer->gotoIndex(selectedRow-indexOffset); window->play(); }