mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-28 16:20:26 +01:00
Fix save/restore group by for internet collection
This commit is contained in:
parent
e0366d38f1
commit
d5e424eec8
@ -128,6 +128,19 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent)
|
||||
|
||||
CollectionFilterWidget::~CollectionFilterWidget() { delete ui_; }
|
||||
|
||||
QString CollectionFilterWidget::group_by() {
|
||||
|
||||
if (settings_prefix_.isEmpty()) {
|
||||
return QString("group_by");
|
||||
}
|
||||
else {
|
||||
return QString("%1_group_by").arg(settings_prefix_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString CollectionFilterWidget::group_by(const int number) { return group_by() + QString::number(number); }
|
||||
|
||||
void CollectionFilterWidget::UpdateGroupByActions() {
|
||||
|
||||
if (group_by_group_) {
|
||||
@ -247,9 +260,9 @@ void CollectionFilterWidget::SetCollectionModel(CollectionModel *model) {
|
||||
QSettings s;
|
||||
s.beginGroup(settings_group_);
|
||||
model_->SetGroupBy(CollectionModel::Grouping(
|
||||
CollectionModel::GroupBy(s.value("group_by1", int(CollectionModel::GroupBy_AlbumArtist)).toInt()),
|
||||
CollectionModel::GroupBy(s.value("group_by2", int(CollectionModel::GroupBy_Album)).toInt()),
|
||||
CollectionModel::GroupBy(s.value("group_by3", int(CollectionModel::GroupBy_None)).toInt())));
|
||||
CollectionModel::GroupBy(s.value(group_by(1), int(CollectionModel::GroupBy_AlbumArtist)).toInt()),
|
||||
CollectionModel::GroupBy(s.value(group_by(2), int(CollectionModel::GroupBy_Album)).toInt()),
|
||||
CollectionModel::GroupBy(s.value(group_by(3), int(CollectionModel::GroupBy_None)).toInt())));
|
||||
}
|
||||
|
||||
}
|
||||
@ -270,9 +283,9 @@ void CollectionFilterWidget::GroupingChanged(const CollectionModel::Grouping &g)
|
||||
// Save the settings
|
||||
QSettings s;
|
||||
s.beginGroup(settings_group_);
|
||||
s.setValue("group_by1", int(g[0]));
|
||||
s.setValue("group_by2", int(g[1]));
|
||||
s.setValue("group_by3", int(g[2]));
|
||||
s.setValue(group_by(1), int(g[0]));
|
||||
s.setValue(group_by(2), int(g[1]));
|
||||
s.setValue(group_by(3), int(g[2]));
|
||||
}
|
||||
|
||||
// Now make sure the correct action is checked
|
||||
|
@ -76,8 +76,12 @@ class CollectionFilterWidget : public QWidget {
|
||||
void AddMenuAction(QAction *action);
|
||||
|
||||
void SetSettingsGroup(const QString &group) { settings_group_ = group; }
|
||||
void SetSettingsPrefix(const QString &prefix) { settings_prefix_ = prefix; }
|
||||
void SetCollectionModel(CollectionModel *model);
|
||||
|
||||
QString group_by();
|
||||
QString group_by(const int number);
|
||||
|
||||
public slots:
|
||||
void SetQueryMode(QueryOptions::QueryMode view);
|
||||
void FocusOnFilter(QKeyEvent *e);
|
||||
@ -124,6 +128,7 @@ signals:
|
||||
DelayBehaviour delay_behaviour_;
|
||||
|
||||
QString settings_group_;
|
||||
QString settings_prefix_;
|
||||
};
|
||||
|
||||
#endif // COLLECTIONFILTERWIDGET_H
|
||||
|
@ -206,9 +206,9 @@ void InternetSearchView::ReloadSettings() {
|
||||
}
|
||||
|
||||
SetGroupBy(CollectionModel::Grouping(
|
||||
CollectionModel::GroupBy(s.value("group_by1", int(CollectionModel::GroupBy_AlbumArtist)).toInt()),
|
||||
CollectionModel::GroupBy(s.value("group_by2", int(CollectionModel::GroupBy_Album)).toInt()),
|
||||
CollectionModel::GroupBy(s.value("group_by3", int(CollectionModel::GroupBy_None)).toInt())));
|
||||
CollectionModel::GroupBy(s.value("search_group_by1", int(CollectionModel::GroupBy_AlbumArtist)).toInt()),
|
||||
CollectionModel::GroupBy(s.value("search_group_by2", int(CollectionModel::GroupBy_Album)).toInt()),
|
||||
CollectionModel::GroupBy(s.value("search_group_by3", int(CollectionModel::GroupBy_None)).toInt())));
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
@ -440,11 +440,11 @@ bool InternetSearchView::ResultsContextMenuEvent(QContextMenuEvent *event) {
|
||||
|
||||
if (artists_ || albums_ || songs_) {
|
||||
if (artists_)
|
||||
context_actions_ << context_menu_->addAction(IconLoader::Load("document-new"), tr("Add to artists"), this, SLOT(AddArtists()));
|
||||
context_actions_ << context_menu_->addAction(IconLoader::Load("folder-new"), tr("Add to artists"), this, SLOT(AddArtists()));
|
||||
if (albums_)
|
||||
context_actions_ << context_menu_->addAction(IconLoader::Load("document-new"), tr("Add to albums"), this, SLOT(AddAlbums()));
|
||||
context_actions_ << context_menu_->addAction(IconLoader::Load("folder-new"), tr("Add to albums"), this, SLOT(AddAlbums()));
|
||||
if (songs_)
|
||||
context_actions_ << context_menu_->addAction(IconLoader::Load("document-new"), tr("Add to songs"), this, SLOT(AddSongs()));
|
||||
context_actions_ << context_menu_->addAction(IconLoader::Load("folder-new"), tr("Add to songs"), this, SLOT(AddSongs()));
|
||||
context_menu_->addSeparator();
|
||||
}
|
||||
|
||||
@ -553,9 +553,9 @@ void InternetSearchView::SetGroupBy(const CollectionModel::Grouping &g) {
|
||||
// Save the setting
|
||||
QSettings s;
|
||||
s.beginGroup(settings_group_);
|
||||
s.setValue("group_by1", int(g.first));
|
||||
s.setValue("group_by2", int(g.second));
|
||||
s.setValue("group_by3", int(g.third));
|
||||
s.setValue("search_group_by1", int(g.first));
|
||||
s.setValue("search_group_by2", int(g.second));
|
||||
s.setValue("search_group_by3", int(g.third));
|
||||
s.endGroup();
|
||||
|
||||
// Make sure the correct action is checked.
|
||||
|
@ -55,6 +55,8 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
||||
ui_->artists_collection->view()->Init(app_, service_->artists_collection_backend(), service_->artists_collection_model());
|
||||
ui_->artists_collection->view()->setModel(service_->artists_collection_sort_model());
|
||||
ui_->artists_collection->view()->SetFilter(ui_->artists_collection->filter());
|
||||
ui_->artists_collection->filter()->SetSettingsGroup(settings_group);
|
||||
ui_->artists_collection->filter()->SetSettingsPrefix("artists");
|
||||
ui_->artists_collection->filter()->SetCollectionModel(service_->artists_collection_model());
|
||||
|
||||
connect(ui_->artists_collection->view(), SIGNAL(GetSongs()), SLOT(GetArtists()));
|
||||
@ -85,6 +87,8 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
||||
ui_->albums_collection->view()->Init(app_, service_->albums_collection_backend(), service_->albums_collection_model());
|
||||
ui_->albums_collection->view()->setModel(service_->albums_collection_sort_model());
|
||||
ui_->albums_collection->view()->SetFilter(ui_->albums_collection->filter());
|
||||
ui_->albums_collection->filter()->SetSettingsGroup(settings_group);
|
||||
ui_->albums_collection->filter()->SetSettingsPrefix("albums");
|
||||
ui_->albums_collection->filter()->SetCollectionModel(service_->albums_collection_model());
|
||||
|
||||
connect(ui_->albums_collection->view(), SIGNAL(GetSongs()), SLOT(GetAlbums()));
|
||||
@ -115,6 +119,8 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
||||
ui_->songs_collection->view()->Init(app_, service_->songs_collection_backend(), service_->songs_collection_model());
|
||||
ui_->songs_collection->view()->setModel(service_->songs_collection_sort_model());
|
||||
ui_->songs_collection->view()->SetFilter(ui_->songs_collection->filter());
|
||||
ui_->songs_collection->filter()->SetSettingsGroup(settings_group);
|
||||
ui_->songs_collection->filter()->SetSettingsPrefix("songs");
|
||||
ui_->songs_collection->filter()->SetCollectionModel(service_->songs_collection_model());
|
||||
|
||||
connect(ui_->songs_collection->view(), SIGNAL(GetSongs()), SLOT(GetSongs()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user