File indexing completed on 2024-04-21 04:51:05

0001 /*
0002 SPDX-FileCopyrightText: 2022 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003 This file is part of Kdenlive. See www.kdenlive.org.
0004 
0005 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QCollator>
0011 #include <QSortFilterProxyModel>
0012 
0013 /**
0014  * @class MarkerSortModel
0015  * @brief Acts as an filtering proxy for the Bin Views, used when triggering the lineedit filter.
0016  */
0017 class MarkerSortModel : public QSortFilterProxyModel
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     explicit MarkerSortModel(QObject *parent = nullptr);
0023 
0024 public Q_SLOTS:
0025     /** @brief Set search tag that will filter the view */
0026     void slotSetFilters(const QList<int> filter);
0027     /** @brief Reset search filters */
0028     void slotClearSearchFilters();
0029     void slotSetFilterString(const QString &filter);
0030     void slotSetSortColumn(int column);
0031     void slotSetSortOrder(bool descending);
0032     std::vector<int> getIgnoredSnapPoints() const;
0033 
0034 protected:
0035     /** @brief Decide which items should be displayed depending on the search string  */
0036     // cppcheck-suppress unusedFunction
0037     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
0038     bool filterAcceptsRowItself(int source_row, const QModelIndex &source_parent) const;
0039     bool filterString(int sourceRow, const QModelIndex &sourceParent) const;
0040     /** @brief Reimplemented to allow sorting by category, time or comment  */
0041     bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
0042 
0043 private:
0044     QList<int> m_filterList;
0045     mutable QList<int> m_ignoredPositions;
0046     QString m_searchString;
0047     int m_sortColumn;
0048     int m_sortOrder;
0049 };