void SinglePlaylistView::onBrowseResult(uint browseId, int remainingCount, uint index, QString objectId, GHashTable *metadata) { if (browseId != this->browsePlaylistId) return; if (index != 0 || remainingCount != 0 || !objectId.isNull()) { QStandardItem *item = new QStandardItem(); setItemMetadata(item, objectId, metadata); objectModel->appendRow(item); updateSongCount(); } if (remainingCount == 0) { disconnect(mafwTrackerSource, SIGNAL(browseResult(uint,int,uint,QString,GHashTable*,QString)), this, SLOT(onBrowseResult(uint,int,uint,QString,GHashTable*))); setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false); playlistLoaded = true; switch (pendingActivation) { case Nothing: break; case AddToNowPlaying: addAllToNowPlaying(); break; case AddToPlaylist: addAllToPlaylist(); break; default: onItemActivated(objectProxyModel->mapFromSource(objectModel->index(pendingActivation,0))); break; } }
SinglePlaylistView::SinglePlaylistView(QWidget *parent, MafwRegistryAdapter *mafwRegistry) : BrowserWindow(parent, mafwRegistry), mafwRegistry(mafwRegistry), mafwRenderer(mafwRegistry->renderer()), mafwTrackerSource(mafwRegistry->source(MafwRegistryAdapter::Tracker)), playlist(mafwRegistry->playlist()) { browsePlaylistId = MAFW_SOURCE_INVALID_BROWSE_ID; setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true); permanentDelete = QSettings().value("main/permanentDelete").toBool(); ui->objectList->setItemDelegate(new SongListItemDelegate(ui->objectList)); ui->objectList->setItemDelegateForRow(0, new ShuffleButtonDelegate(ui->objectList)); objectProxyModel->setFilterRole(UserRoleFilterString); ui->objectList->setDragDropMode(QAbstractItemView::InternalMove); ui->objectList->viewport()->setAcceptDrops(true); ui->objectList->setAutoScrollMargin(70); QApplication::setStartDragDistance(20); ui->objectList->setDragEnabled(false); playlistModified = false; pendingActivation = Nothing; clickedIndex = QModelIndex(); clickTimer = new QTimer(this); clickTimer->setInterval(QApplication::doubleClickInterval()); clickTimer->setSingleShot(true); ui->windowMenu->addAction(tr("Add to now playing"), this, SLOT(addAllToNowPlaying())); ui->windowMenu->addAction(tr("Add to a playlist" ), this, SLOT(addAllToPlaylist())); ui->windowMenu->addAction(tr("Delete playlist" ), this, SLOT(deletePlaylist())); connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Enter), this), SIGNAL(activated()), this, SLOT(onContextMenuRequested())); connect(ui->objectList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenuRequested(QPoint))); connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(updateSongCount())); connect(clickTimer, SIGNAL(timeout()), this, SLOT(forgetClick())); }
SingleGenreView::SingleGenreView(QWidget *parent, MafwRegistryAdapter *mafwRegistry) : BrowserWindow(parent, mafwRegistry), mafwRegistry(mafwRegistry), mafwRenderer(mafwRegistry->renderer()), mafwTrackerSource(mafwRegistry->source(MafwRegistryAdapter::Tracker)), playlist(mafwRegistry->playlist()) { ui->objectList->setItemDelegate(new ArtistListItemDelegate(ui->objectList)); ui->objectList->setItemDelegateForRow(0, new ShuffleButtonDelegate(ui->objectList)); ui->windowMenu->addAction(tr("Add to now playing"), this, SLOT(addAllToNowPlaying())); shuffleRequested = false; connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Enter), this), SIGNAL(activated()), this, SLOT(onContextMenuRequested())); connect(ui->objectList, SIGNAL(activated(QModelIndex)), this, SLOT(onItemActivated(QModelIndex))); connect(ui->objectList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenuRequested(QPoint))); }
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(); } } }