summaryrefslogtreecommitdiffstats
path: root/collectionwebradioview.cpp
blob: 7fa01dee8ba624050595680b38312afa4a851a45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QStandardItem>

#include "collectionwebradioview.h"

CollectionWebradioView::CollectionWebradioView(QWidget *parent) : CollectionWidget(parent){
}

void CollectionWebradioView::populate(){
    disableSorting();
    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);
        curWr->setData(wrQ.value(0), TitleRole);
        curWr->setData(WebRadio, TypeRole);
        curWr->setData(true, RemoteRole);
        root->appendRow(curWr);
    }
    enableSorting();
}