diff options
author | Arno <arno@disconnect.de> | 2018-02-17 07:14:46 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2018-02-17 07:14:46 +0100 |
commit | 7ea45995fe16be78ebeebd8d79b8145802699eaa (patch) | |
tree | 5b9d1069e776bccc8994bea3579a4fe75396621e | |
parent | 3095a50fe57b9ccefca133106651f3bc2c3d7895 (diff) | |
download | BeetPlayer-7ea45995fe16be78ebeebd8d79b8145802699eaa.tar.gz BeetPlayer-7ea45995fe16be78ebeebd8d79b8145802699eaa.tar.bz2 BeetPlayer-7ea45995fe16be78ebeebd8d79b8145802699eaa.zip |
New class: CollectionWebradioView
Basically the same as populateByWebradio, just wrapped in a shiny, new
CollectionWidget.
-rw-r--r-- | BeetPlayer.pro | 6 | ||||
-rw-r--r-- | collectionwebradioview.cpp | 26 | ||||
-rw-r--r-- | collectionwebradioview.h | 14 |
3 files changed, 44 insertions, 2 deletions
diff --git a/BeetPlayer.pro b/BeetPlayer.pro index db46255..270c436 100644 --- a/BeetPlayer.pro +++ b/BeetPlayer.pro @@ -39,7 +39,8 @@ SOURCES += main.cpp\ collectionartistsview.cpp \ collectionalbumsview.cpp \ collectiondatesview.cpp \ - collectionfavoritesview.cpp + collectionfavoritesview.cpp \ + collectionwebradioview.cpp HEADERS += beetplayer.h \ configurationdialog.h \ @@ -55,7 +56,8 @@ HEADERS += beetplayer.h \ collectionartistsview.h \ collectionalbumsview.h \ collectiondatesview.h \ - collectionfavoritesview.h + collectionfavoritesview.h \ + collectionwebradioview.h LIBS += -ltag diff --git a/collectionwebradioview.cpp b/collectionwebradioview.cpp new file mode 100644 index 0000000..53d7cbd --- /dev/null +++ b/collectionwebradioview.cpp @@ -0,0 +1,26 @@ +#include <QSqlDatabase> +#include <QSqlQuery> +#include <QStandardItem> + +#include "collectionwebradioview.h" + +CollectionWebradioView::CollectionWebradioView(QWidget *parent) : CollectionWidget(parent){ +} + +void CollectionWebradioView::populate(){ + model()->clear(); + model()->setHorizontalHeaderLabels(headers()); + QSqlDatabase db = QSqlDatabase::database("beetplayerdb"); + QStandardItem *root = model()->invisibleRootItem(); + QIcon wrIcon(":/dog_hood.png"); + QSqlQuery wrQ = QSqlQuery("SELECT tdescription, turl FROM webradio ORDER BY tdescription DESC", db); + while(wrQ.next()){ + QStandardItem *curWr = new QStandardItem; + curWr->setEditable(false); + curWr->setFont(QFont("courier")); + curWr->setText(wrQ.value(0).toString()); + curWr->setIcon(wrIcon); + curWr->setData(wrQ.value(1), UrlRole); + root->appendRow(curWr); + } +} diff --git a/collectionwebradioview.h b/collectionwebradioview.h new file mode 100644 index 0000000..e55ae6c --- /dev/null +++ b/collectionwebradioview.h @@ -0,0 +1,14 @@ +#ifndef COLLECTIONWEBRADIOVIEW_H +#define COLLECTIONWEBRADIOVIEW_H + +#include "collectionwidget.h" + +class CollectionWebradioView : public CollectionWidget { + public: + CollectionWebradioView(QWidget *parent = nullptr); + + public slots: + virtual void populate(); +}; + +#endif // COLLECTIONWEBRADIOVIEW_H |