summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-02-19 02:46:37 +0100
committerArno <arno@disconnect.de>2018-02-19 02:46:37 +0100
commit7de8b0574b37d32e91939461c7bab93b818af620 (patch)
tree81eddf770f7e4f7ef2e91dbc4c205c5e35311e56 /playerwidget.cpp
parenta960ea0552ccc84a19bc3b2a5b2c902901c7cafd (diff)
downloadBeetPlayer-7de8b0574b37d32e91939461c7bab93b818af620.tar.gz
BeetPlayer-7de8b0574b37d32e91939461c7bab93b818af620.tar.bz2
BeetPlayer-7de8b0574b37d32e91939461c7bab93b818af620.zip
Implement QAction to fill playlist with favorites
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp18
1 files changed, 18 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();
+}