diff options
-rw-r--r-- | collectionalbumsview.cpp | 1 | ||||
-rw-r--r-- | playerwidget.cpp | 29 | ||||
-rw-r--r-- | playerwidget.h | 3 |
3 files changed, 28 insertions, 5 deletions
diff --git a/collectionalbumsview.cpp b/collectionalbumsview.cpp index 1f44c10..673a837 100644 --- a/collectionalbumsview.cpp +++ b/collectionalbumsview.cpp @@ -26,6 +26,7 @@ void CollectionAlbumsView::populate(){ curAlbum->setIcon(albumIcon); curAlbum->setData(Album, TypeRole); curAlbum->setData(albumQ.value(0), IdRole); + curAlbum->setData(albumQ.value(1), AlbumRole); root->appendRow(curAlbum); QSqlQuery songQ = QSqlQuery(db); songQ.prepare("SELECT sipos, ttitle, tfullpath, igenres_id, artists.tartists_name, albums.talbum_name, ilength FROM songs, artists, albums WHERE albums.ialbums_id = :id AND songs.iartists_id = artists.iartists_id and songs.ialbums_id = albums.ialbums_id ORDER BY sipos"); diff --git a/playerwidget.cpp b/playerwidget.cpp index f589f4d..cc6af7c 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -48,6 +48,7 @@ #include "collectionfavoritesview.h" #include "collectionfoldersview.h" #include "collectionwebradioview.h" +#include "collectionwidgetproxy.h" PlayerWidget::PlayerWidget(QSplashScreen *splash, QWidget *parent) : QWidget(parent), mDurSecs(0), mPlayListLength(0), mIsStream(false), mModelType(DoNotCare){ mStarting = true; @@ -101,10 +102,10 @@ void PlayerWidget::setupGui(QSplashScreen *splash){ qApp->processEvents(); albumsView->populate(); cIdx = mCollectionStack->addWidget(albumsView); - QAction *viewByAlbumsA = new QAction(QIcon(":/album.png"), tr("View by album"), this); - viewByAlbumsA->setCheckable(true); - connect(viewByAlbumsA, &QAction::triggered, [this, cIdx] { mCollectionStack->setCurrentIndex(cIdx); }); - bottomTBG->addAction(viewByAlbumsA); + mViewByAlbumsA = new QAction(QIcon(":/album.png"), tr("View by album"), this); + mViewByAlbumsA->setCheckable(true); + connect(mViewByAlbumsA, &QAction::triggered, [this, cIdx] { mCollectionStack->setCurrentIndex(cIdx); }); + bottomTBG->addAction(mViewByAlbumsA); //dates view CollectionDatesView *datesView = new CollectionDatesView;; datesView->setHeaders(QStringList() << tr("Date added")); @@ -180,6 +181,9 @@ void PlayerWidget::setupGui(QSplashScreen *splash){ connect(searchMBA, &QAction::triggered, [this, curW] { searchMusicbrainz(curW->view()->selectionModel()->currentIndex()); }); curW->view()->addAction(searchMBA); } + QAction *gotoAlbumA = new QAction(QIcon(":/next.png"), tr("Goto album"), this); + connect(gotoAlbumA, &QAction::triggered, this, &PlayerWidget::gotoAlbum); + artistsView->view()->addAction(gotoAlbumA); //left widget QWidget *leftWidget = new QWidget; @@ -985,3 +989,20 @@ void PlayerWidget::aboutDlg(){ aboutText.append(tr("<tr><td>License</td><td style=\"padding-left: 30px\">GPL 2 or later</td></tr></table>")); QMessageBox::about(this, title, aboutText); } + +void PlayerWidget::gotoAlbum(){ + CollectionArtistsView *artistView = mCollectionStack->findChild<CollectionArtistsView*>("artists"); + CollectionAlbumsView *albumView = mCollectionStack->findChild<CollectionAlbumsView*>("albums"); + QString album = artistView->view()->selectionModel()->currentIndex().data(AlbumRole).toString(); + if(!album.isEmpty()){ + const CollectionWidgetProxy *proxy = qobject_cast<const CollectionWidgetProxy*>(albumView->view()->model()); + QModelIndexList albumIdxs = proxy->match(proxy->index(0, 0, QModelIndex()), AlbumRole, album); + if(!albumIdxs.isEmpty()){ + mViewByAlbumsA->trigger(); + QModelIndex albumIdx = albumIdxs.first(); + albumView->view()->selectionModel()->select(albumIdx, QItemSelectionModel::ClearAndSelect); + albumView->view()->scrollTo(albumIdx, QAbstractItemView::PositionAtCenter); + albumView->view()->expand(albumIdx); + } + } +} diff --git a/playerwidget.h b/playerwidget.h index c4ca8ec..3d190a7 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -61,7 +61,6 @@ class PlayerWidget : public QWidget { void webDlDone(); void doMetadataChange(const QString &key, const QVariant &value); void updateStreamData(); - void mute(bool triggered); void volumeChanged(int volume); void next(); @@ -72,6 +71,7 @@ class PlayerWidget : public QWidget { void readSettings(); void writeSettings(); void aboutDlg(); + void gotoAlbum(); signals: void viewModeChanged(const QString &viewMode); @@ -110,6 +110,7 @@ class PlayerWidget : public QWidget { QAction *mPlayA; QAction *mStopA; QAction *mPauseA; + QAction *mViewByAlbumsA; qint64 mDurSecs; quint64 mPlayListLength; QString mCurWinTitle; |