Add saved grouping to the Group by menu
This commit is contained in:
parent
5c256f349a
commit
862b9a8635
@ -118,6 +118,22 @@ LibraryFilterWidget::LibraryFilterWidget(QWidget* parent)
|
||||
|
||||
LibraryFilterWidget::~LibraryFilterWidget() { delete ui_; }
|
||||
|
||||
void LibraryFilterWidget::UpdateGroupByActions() {
|
||||
if (group_by_group_) {
|
||||
disconnect(group_by_group_,0,0,0);
|
||||
delete group_by_group_;
|
||||
}
|
||||
|
||||
group_by_group_ = CreateGroupByActions(this);
|
||||
group_by_menu_->clear();
|
||||
group_by_menu_->addActions(group_by_group_->actions());
|
||||
connect(group_by_group_, SIGNAL(triggered(QAction*)),
|
||||
SLOT(GroupByClicked(QAction*)));
|
||||
if (model_) {
|
||||
CheckCurrentGrouping(model_->GetGroupBy());
|
||||
}
|
||||
}
|
||||
|
||||
QActionGroup* LibraryFilterWidget::CreateGroupByActions(QObject* parent) {
|
||||
QActionGroup* ret = new QActionGroup(parent);
|
||||
ret->addAction(CreateGroupByAction(
|
||||
@ -188,6 +204,7 @@ void LibraryFilterWidget::SaveGroupBy() {
|
||||
QInputDialog::getText(this, tr("Grouping Name"), tr("Grouping name:"));
|
||||
if (!text.isEmpty() && model_) {
|
||||
model_->SaveGrouping(text);
|
||||
UpdateGroupByActions();
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,6 +270,10 @@ void LibraryFilterWidget::GroupingChanged(const LibraryModel::Grouping& g) {
|
||||
}
|
||||
|
||||
// Now make sure the correct action is checked
|
||||
CheckCurrentGrouping(g);
|
||||
}
|
||||
|
||||
void LibraryFilterWidget::CheckCurrentGrouping(const LibraryModel::Grouping& g) {
|
||||
for (QAction* action : group_by_group_->actions()) {
|
||||
if (action->property("group_by").isNull()) continue;
|
||||
|
||||
|
@ -51,6 +51,7 @@ class LibraryFilterWidget : public QWidget {
|
||||
|
||||
static QActionGroup* CreateGroupByActions(QObject* parent);
|
||||
|
||||
void UpdateGroupByActions();
|
||||
void SetFilterHint(const QString& hint);
|
||||
void SetApplyFilterToLibrary(bool filter_applies_to_model) {
|
||||
filter_applies_to_model_ = filter_applies_to_model;
|
||||
@ -92,6 +93,7 @@ signals:
|
||||
private:
|
||||
static QAction* CreateGroupByAction(const QString& text, QObject* parent,
|
||||
const LibraryModel::Grouping& grouping);
|
||||
void CheckCurrentGrouping(const LibraryModel::Grouping& g);
|
||||
|
||||
private:
|
||||
Ui_LibraryFilterWidget* ui_;
|
||||
|
@ -183,6 +183,7 @@ signals:
|
||||
void SetFilterQueryMode(QueryOptions::QueryMode query_mode);
|
||||
|
||||
void SetGroupBy(const LibraryModel::Grouping& g);
|
||||
const LibraryModel::Grouping& GetGroupBy() const { return group_by_; }
|
||||
void Init(bool async = true);
|
||||
void Reset();
|
||||
void ResetAsync();
|
||||
|
Loading…
x
Reference in New Issue
Block a user