File indexing completed on 2024-04-21 09:38:43

0001 /*******************************************************************************
0002  * Copyright (C) 2016 Ragnar Thomsen <rthomsen6@gmail.com>                     *
0003  *                                                                             *
0004  * This program is free software: you can redistribute it and/or modify it     *
0005  * under the terms of the GNU General Public License as published by the Free  *
0006  * Software Foundation, either version 2 of the License, or (at your option)   *
0007  * any later version.                                                          *
0008  *                                                                             *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT *
0010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
0011  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    *
0012  * more details.                                                               *
0013  *                                                                             *
0014  * You should have received a copy of the GNU General Public License along     *
0015  * with this program. If not, see <http://www.gnu.org/licenses/>.              *
0016  *******************************************************************************/
0017 
0018 #ifndef SORTFILTERUNITMODEL_H
0019 #define SORTFILTERUNITMODEL_H
0020 
0021 #include <QSortFilterProxyModel>
0022 
0023 enum filterType
0024 {
0025     activeState, unitType, unitName
0026 };
0027 
0028 class SortFilterUnitModel : public QSortFilterProxyModel
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     explicit SortFilterUnitModel(QObject *parent = 0);
0034     void initFilterMap(const QMap<filterType, QString> &map);
0035     void addFilterRegExp(filterType type, const QString &pattern);
0036 
0037 protected:
0038     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
0039 
0040 private:
0041     QMap<filterType, QString> filtersMap;
0042 };
0043 
0044 #endif // SORTFILTERUNITMODEL_H