File indexing completed on 2024-03-03 05:04:09

0001 /*
0002     SPDX-FileCopyrightText: 2022 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003 
0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include "bin/model/markerlistmodel.hpp"
0010 #include "ui_guideslist_ui.h"
0011 
0012 #include <QIdentityProxyModel>
0013 #include <QSortFilterProxyModel>
0014 
0015 class MarkerSortModel;
0016 class QActionGroup;
0017 class ProjectClip;
0018 
0019 /** @class GuideFilterEventEater
0020     @brief \@todo Describe class LineEventEater
0021     @todo Describe class LineEventEater
0022  */
0023 class GuideFilterEventEater : public QObject
0024 {
0025     Q_OBJECT
0026 public:
0027     explicit GuideFilterEventEater(QObject *parent = nullptr);
0028 
0029 protected:
0030     bool eventFilter(QObject *obj, QEvent *event) override;
0031 
0032 Q_SIGNALS:
0033     void clearSearchLine();
0034 };
0035 
0036 /** @class GuidesList
0037     @brief A widget listing project guides and allowing some advanced editing.
0038     @author Jean-Baptiste Mardelle
0039  */
0040 class GuidesList : public QWidget, public Ui::GuidesList_UI
0041 {
0042     Q_OBJECT
0043 public:
0044     explicit GuidesList(QWidget *parent = nullptr);
0045     ~GuidesList() override;
0046     void setModel(std::weak_ptr<MarkerListModel> model, std::shared_ptr<MarkerSortModel> viewModel);
0047     void setClipMarkerModel(std::shared_ptr<ProjectClip> clip);
0048     /** @brief Reset all filters. */
0049     void reset();
0050 
0051 public Q_SLOTS:
0052     void removeGuide();
0053     void selectAll();
0054 
0055 private Q_SLOTS:
0056     void saveGuides();
0057     void editGuides();
0058     void importGuides();
0059     void editGuide(const QModelIndex &ix);
0060     void selectionChanged(const QItemSelection &selected, const QItemSelection &);
0061     void addGuide();
0062     void configureGuides();
0063     void rebuildCategories();
0064     void updateFilter(QList<int> categories);
0065     void filterView(const QString &text);
0066     void sortView(QAction *ac);
0067     void changeSortOrder(bool descending);
0068     void refreshDefaultCategory();
0069     void switchFilter(bool enable);
0070 
0071 private:
0072     /** @brief Set the marker model that will be displayed. */
0073     std::weak_ptr<MarkerListModel> m_model;
0074     QIdentityProxyModel *m_proxy{nullptr};
0075     MarkerSortModel *m_sortModel{nullptr};
0076     std::shared_ptr<ProjectClip> m_clip;
0077     QButtonGroup *catGroup{nullptr};
0078     QActionGroup *m_sortGroup;
0079     QList<int> m_lastSelectedGuideCategories;
0080     QList<int> m_lastSelectedMarkerCategories;
0081     bool m_markerMode;
0082 
0083 Q_SIGNALS:
0084 };