diff options
author | Arno <arno@disconnect.de> | 2018-02-19 02:46:37 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2018-02-19 02:46:37 +0100 |
commit | 7de8b0574b37d32e91939461c7bab93b818af620 (patch) | |
tree | 81eddf770f7e4f7ef2e91dbc4c205c5e35311e56 | |
parent | a960ea0552ccc84a19bc3b2a5b2c902901c7cafd (diff) | |
download | BeetPlayer-7de8b0574b37d32e91939461c7bab93b818af620.tar.gz BeetPlayer-7de8b0574b37d32e91939461c7bab93b818af620.tar.bz2 BeetPlayer-7de8b0574b37d32e91939461c7bab93b818af620.zip |
Implement QAction to fill playlist with favorites
-rw-r--r-- | playerwidget.cpp | 18 | ||||
-rw-r--r-- | playerwidget.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp index e9349f3..be4eb62 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -208,6 +208,11 @@ void PlayerWidget::setupGui(QSplashScreen *splash){ QAction *searchMBA = new QAction(QIcon(":/bizarre_amputee.png"), tr("Search Musicbrainz"), this); connect(searchMBA, &QAction::triggered, [this, curW] { searchMusicbrainz(curW->view()->selectionModel()->currentIndex()); }); curW->view()->addAction(searchMBA); + if(name == "favorites"){ + QAction *addAllFavsA = new QAction((QIcon(":/shuffle.png")), tr("Clear and Add all"), this); + connect(addAllFavsA, &QAction::triggered, this, &PlayerWidget::clearAndAddAllFavorites); + curW->customActions()->addAction(addAllFavsA); + } curW->view()->addActions(curW->customActions()->actions()); } } @@ -1067,3 +1072,16 @@ void PlayerWidget::addToFavorites(const QModelIndexList &idxs){ fav->populate(); } } + +void PlayerWidget::clearAndAddAllFavorites(){ + mSongModel->clear(); + mSongModel->setHorizontalHeaderLabels(QStringList() << "Song"); + CollectionWidget *favWidget = qobject_cast<CollectionWidget*>(mCollectionStack->currentWidget()); + QStandardItemModel *m = favWidget->model(); + QStandardItem *root = m->invisibleRootItem(); + for(int i = 0; i < root->rowCount(); ++i){ + QModelIndex curIdx = m->indexFromItem(root->child(i, 0)); + addSong(curIdx); + } + shufflePlayList(); +} diff --git a/playerwidget.h b/playerwidget.h index 180c232..5859cb1 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -71,6 +71,7 @@ class PlayerWidget : public QWidget { void gotoAlbum(); void setCollectionIndex(int collectionIndex, bool isWebradio); void addToFavorites(const QModelIndexList &idxs); + void clearAndAddAllFavorites(); signals: void viewModeChanged(const QString &viewMode); |