summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--playerwidget.cpp46
-rw-r--r--playerwidget.h2
2 files changed, 48 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);
diff --git a/playerwidget.h b/playerwidget.h
index 91f34e0..44896db 100644
--- a/playerwidget.h
+++ b/playerwidget.h
@@ -43,6 +43,7 @@ class PlayerWidget : public QWidget {
void doPopulateByDate();
void doPopulateByFolder();
void doPopulateByWebradio();
+ void doPopulateByFavorites();
void doModelChanged();
void viewDoubleClicked(const QModelIndex &idx);
void rightCurrentChanged(const QModelIndex &cur, const QModelIndex &prev);
@@ -109,6 +110,7 @@ class PlayerWidget : public QWidget {
void populateByDate(QStandardItem *parent);
void populateByGenre(QStandardItem *parent, const QString &filter);
void populateByWebradio(QStandardItem *parent);
+ void populateByFavorites(QStandardItem *parent);
void recurse(const QModelIndex &parent);
void addSong(const QModelIndex &idx);
void play(const QString &fullPath);