Fix sorting of radios
This commit is contained in:
parent
99fbbf70de
commit
d9e378211a
|
@ -405,7 +405,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
|||
|
||||
organize_dialog_->SetDestinationModel(app_->collection()->model()->directory_model());
|
||||
|
||||
radio_view_->view()->SetModel(app_->radio_services()->radio_model());
|
||||
radio_view_->view()->setModel(app_->radio_services()->sort_model());
|
||||
|
||||
// Icons
|
||||
qLog(Debug) << "Creating UI";
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/application.h"
|
||||
|
@ -36,6 +37,7 @@ RadioServices::RadioServices(Application *app, QObject *parent)
|
|||
network_(new NetworkAccessManager(this)),
|
||||
backend_(nullptr),
|
||||
model_(new RadioModel(app, this)),
|
||||
sort_model_(new QSortFilterProxyModel(this)),
|
||||
channels_refresh_(false) {
|
||||
|
||||
backend_ = new RadioBackend(app->database());
|
||||
|
@ -43,6 +45,12 @@ RadioServices::RadioServices(Application *app, QObject *parent)
|
|||
|
||||
QObject::connect(backend_, &RadioBackend::NewChannels, this, &RadioServices::GotChannelsFromBackend);
|
||||
|
||||
sort_model_->setSourceModel(model_);
|
||||
sort_model_->setSortRole(RadioModel::Role_SortText);
|
||||
sort_model_->setDynamicSortFilter(true);
|
||||
sort_model_->setSortLocaleAware(true);
|
||||
sort_model_->sort(0);
|
||||
|
||||
AddService(new SomaFMService(app, network_, this));
|
||||
AddService(new RadioParadiseService(app, network_, this));
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "core/song.h"
|
||||
#include "radiochannel.h"
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
class Application;
|
||||
class NetworkAccessManager;
|
||||
class RadioBackend;
|
||||
|
@ -53,6 +55,7 @@ class RadioServices : public QObject {
|
|||
|
||||
RadioBackend *radio_backend() const { return backend_; }
|
||||
RadioModel *radio_model() const { return model_; }
|
||||
QSortFilterProxyModel *sort_model() const { return sort_model_; }
|
||||
|
||||
private slots:
|
||||
void ServiceDeleted();
|
||||
|
@ -67,6 +70,7 @@ class RadioServices : public QObject {
|
|||
NetworkAccessManager *network_;
|
||||
RadioBackend *backend_;
|
||||
RadioModel *model_;
|
||||
QSortFilterProxyModel *sort_model_;
|
||||
QMap<Song::Source, RadioService*> services_;
|
||||
bool channels_refresh_;
|
||||
};
|
||||
|
|
|
@ -54,12 +54,6 @@ RadioView::RadioView(QWidget *parent)
|
|||
|
||||
RadioView::~RadioView() { delete menu_; }
|
||||
|
||||
void RadioView::SetModel(RadioModel *model) {
|
||||
|
||||
AutoExpandingTreeView::setModel(model);
|
||||
|
||||
}
|
||||
|
||||
void RadioView::showEvent(QShowEvent*) {
|
||||
|
||||
if (!initialized_) {
|
||||
|
|
|
@ -39,7 +39,6 @@ class RadioView : public AutoExpandingTreeView {
|
|||
explicit RadioView(QWidget *parent = nullptr);
|
||||
~RadioView();
|
||||
|
||||
void SetModel(RadioModel *model);
|
||||
void showEvent(QShowEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue