summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index da91986..bc30aa0 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -101,6 +101,10 @@ void PlayerWidget::setupGui(){
viewByDateA->setCheckable(true);
viewAG->addAction(viewByDateA);
connect(viewByDateA, &QAction::triggered, this, &PlayerWidget::doPopulateByDate);
+ QAction *viewByFavA = new QAction(QIcon(":/male_chastity_belt.png"), tr("View by favorites"), this);
+ viewByFavA->setCheckable(true);
+ viewAG->addAction(viewByFavA);
+ connect(viewByFavA, &QAction::triggered, this, &PlayerWidget::doPopulateByFavorites);
viewAG->addAction(Helper::createSeparator(this));
QAction *viewByFolderA = new QAction(QIcon(":/folder.png"), tr("View by folder"), this);
viewByFolderA->setCheckable(true);
@@ -797,6 +801,48 @@ void PlayerWidget::doPopulateByWebradio(){
emit modelChanged();
}
+void PlayerWidget::doPopulateByFavorites(){
+ qApp->setOverrideCursor(Qt::BusyCursor);
+ mView->setModel(mViewModel);
+ mCurrentModel = mViewModel;
+ mViewModel->clear();
+ mViewModel->setHorizontalHeaderLabels(QStringList() << tr("Favorites"));
+ QStandardItem *root = mViewModel->invisibleRootItem();
+ emit message(QString(tr("Populating by Favorites... Please wait!")));
+ qApp->processEvents();
+ populateByFavorites(root);
+ qApp->restoreOverrideCursor();
+ emit viewModeChanged(tr("Favorites"));
+ emit message(QString(tr("Done!")));
+ emit modelChanged();
+}
+
+void PlayerWidget::populateByFavorites(QStandardItem *parent){
+ QSqlDatabase db = QSqlDatabase::database("beetplayerdb");
+ QStandardItem *root = parent;
+ QIcon songIcon(":/song.png");
+ QSqlQuery favQ(db);
+ favQ.prepare("SELECT sipos, persistent_favorites.ttitle, tfullpath, igenres_id, artists.tartists_name, albums.talbum_name, ilength FROM songs, artists, albums, persistent_favorites WHERE persistent_favorites.tartist_name = artists.tartists_name AND persistent_favorites.talbum_name = albums.talbum_name AND persistent_favorites.ttitle = songs.ttitle ORDER BY tartists_name");
+ favQ.exec();
+ while(favQ.next()){
+ QStandardItem *curSong = new QStandardItem;
+ curSong->setEditable(false);
+ curSong->setFont(QFont("courier"));
+ QString songText = QString(tr("%1 - %2 (%3)")).arg(favQ.value(4).toString()).arg(favQ.value(1).toString()).arg(favQ.value(5).toString());
+ curSong->setText(songText);
+ curSong->setIcon(songIcon);
+ curSong->setData(Song, TypeRole);
+ curSong->setData(favQ.value(0), IdRole);
+ curSong->setData(favQ.value(2), FullPathRole);
+ curSong->setData(favQ.value(3), GenreRole);
+ curSong->setData(favQ.value(4), ArtistRole);
+ curSong->setData(favQ.value(1), TitleRole);
+ curSong->setData(favQ.value(5), AlbumRole);
+ curSong->setData(favQ.value(6), LengthRole);
+ root->appendRow(curSong);
+ }
+}
+
void PlayerWidget::doModelChanged(){
if(mCurrentModel == mFolderModel){
mSelectFilesA->setEnabled(true);