Commit c96d8bfa authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Remember categories filter independantly for clip markers and timeline guides

parent 269ff0c5
Pipeline #263583 passed with stage
in 5 minutes and 23 seconds
......@@ -2384,6 +2384,7 @@ void MainWindow::connectDocument()
m_buttonSelectTool->setChecked(true);
connect(m_projectMonitorDock, &QDockWidget::visibilityChanged, m_projectMonitor, &Monitor::slotRefreshMonitor, Qt::UniqueConnection);
connect(m_clipMonitorDock, &QDockWidget::visibilityChanged, m_clipMonitor, &Monitor::slotRefreshMonitor, Qt::UniqueConnection);
pCore->guidesList()->reset();
pCore->guidesList()->setModel(project->getGuideModel(), project->getFilteredGuideModel());
getCurrentTimeline()->focusTimeline();
}
......
......@@ -301,7 +301,8 @@ void GuidesList::setClipMarkerModel(std::shared_ptr<ProjectClip> clip)
rebuildCategories();
if (auto markerModel = m_model.lock()) {
show_categories->setMarkerModel(markerModel.get());
switchFilter(true);
show_categories->setCurrentCategories(m_lastSelectedMarkerCategories);
switchFilter(!m_lastSelectedMarkerCategories.isEmpty() && !m_lastSelectedMarkerCategories.contains(-1));
connect(markerModel.get(), &MarkerListModel::categoriesChanged, this, &GuidesList::rebuildCategories);
}
}
......@@ -329,7 +330,8 @@ void GuidesList::setModel(std::weak_ptr<MarkerListModel> model, std::shared_ptr<
connect(guides_list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &GuidesList::selectionChanged);
if (auto markerModel = m_model.lock()) {
show_categories->setMarkerModel(markerModel.get());
switchFilter(true);
show_categories->setCurrentCategories(m_lastSelectedGuideCategories);
switchFilter(!m_lastSelectedGuideCategories.isEmpty() && !m_lastSelectedGuideCategories.contains(-1));
connect(markerModel.get(), &MarkerListModel::categoriesChanged, this, &GuidesList::rebuildCategories);
}
rebuildCategories();
......@@ -393,12 +395,13 @@ void GuidesList::refreshDefaultCategory()
void GuidesList::switchFilter(bool enable)
{
if (enable) {
QList<int> cats = show_categories->currentCategories();
cats.removeAll(-1);
QList<int> cats = m_markerMode ? m_lastSelectedMarkerCategories : m_lastSelectedGuideCategories; // show_categories->currentCategories();
if (enable && !cats.contains(-1)) {
updateFilter(cats);
show_categories->setChecked(true);
} else {
updateFilter({});
show_categories->setChecked(false);
}
}
......@@ -406,8 +409,10 @@ void GuidesList::updateFilter(QList<int> categories)
{
if (m_markerMode) {
m_clip->getFilteredMarkerModel()->slotSetFilters(categories);
m_lastSelectedMarkerCategories = categories;
} else {
pCore->currentDoc()->setGuidesFilter(categories);
m_lastSelectedGuideCategories = categories;
emit pCore->refreshActiveGuides();
}
}
......@@ -439,3 +444,11 @@ void GuidesList::changeSortOrder(bool descending)
m_sortModel->slotSetSortOrder(descending);
}
}
void GuidesList::reset()
{
m_lastSelectedGuideCategories.clear();
m_lastSelectedMarkerCategories.clear();
show_categories->setCurrentCategories({-1});
filter_line->clear();
}
......@@ -45,6 +45,8 @@ public:
~GuidesList() override;
void setModel(std::weak_ptr<MarkerListModel> model, std::shared_ptr<MarkerSortModel> viewModel);
void setClipMarkerModel(std::shared_ptr<ProjectClip> clip);
/** @brief Reset all filters. */
void reset();
public slots:
void removeGuide();
......@@ -74,6 +76,8 @@ private:
std::shared_ptr<ProjectClip> m_clip;
QButtonGroup *catGroup{nullptr};
QActionGroup *m_sortGroup;
QList<int> m_lastSelectedGuideCategories;
QList<int> m_lastSelectedMarkerCategories;
bool m_markerMode;
signals:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment