File indexing completed on 2024-04-28 04:39:08

0001 /*
0002     SPDX-FileCopyrightText: 2013 Milian Wolff <mail@milianw.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #ifndef FILTERMODEL_H
0008 #define FILTERMODEL_H
0009 
0010 #include <QAbstractTableModel>
0011 
0012 #include "filter.h"
0013 
0014 namespace KDevelop {
0015 
0016 class FilterModel : public QAbstractTableModel
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     explicit FilterModel(QObject* parent = nullptr);
0022     ~FilterModel() override;
0023 
0024     SerializedFilters filters() const;
0025     void setFilters(const SerializedFilters& filters);
0026 
0027     void moveFilterUp(int row);
0028     void moveFilterDown(int row);
0029 
0030     int rowCount(const QModelIndex& parent = QModelIndex()) const override;
0031     int columnCount(const QModelIndex& parent = QModelIndex()) const override;
0032 
0033     Qt::DropActions supportedDropActions() const override;
0034     Qt::ItemFlags flags(const QModelIndex& index) const override;
0035     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
0036     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
0037     bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
0038     bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
0039     bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
0040     QMap< int, QVariant > itemData(const QModelIndex& index) const override;
0041     bool setItemData(const QModelIndex& index, const QMap< int, QVariant >& roles) override;
0042 
0043     enum Columns {
0044         Pattern,
0045         Targets,
0046         Inclusive,
0047         NUM_COLUMNS
0048     };
0049 
0050 private:
0051     SerializedFilters m_filters;
0052     // workaround a strange behavior in Qt when we try to drop after the last item in the list
0053     bool m_ignoredLastInsert;
0054 };
0055 
0056 }
0057 
0058 #endif // FILTERMODEL_H