File indexing completed on 2024-04-14 05:38:08
0001 /*************************************************************************** 0002 * Copyright (C) 2012-2018 by Daniel Nicoletti * 0003 * dantti12@gmail.com * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; see the file COPYING. If not, write to * 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0018 * Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 #ifndef APPLICATIONSORTFILTERMODEL_H 0021 #define APPLICATIONSORTFILTERMODEL_H 0022 0023 #include <QSortFilterProxyModel> 0024 0025 0026 #include <Transaction> 0027 0028 using namespace PackageKit; 0029 0030 class PackageModel; 0031 class Q_DECL_EXPORT ApplicationSortFilterModel : public QSortFilterProxyModel 0032 { 0033 Q_OBJECT 0034 Q_PROPERTY(PackageModel* sourcePkgModel READ sourcePkgModel WRITE setSourcePkgModel NOTIFY changed) 0035 Q_PROPERTY(Transaction::Info infoFilter READ infoFilter WRITE setInfoFilter NOTIFY changed) 0036 Q_PROPERTY(bool applicationFilter READ applicationFilter WRITE setApplicationFilter NOTIFY changed) 0037 public: 0038 explicit ApplicationSortFilterModel(QObject *parent = nullptr); 0039 0040 PackageModel* sourcePkgModel() const; 0041 void setSourcePkgModel(PackageModel *packageModel); 0042 0043 Transaction::Info infoFilter() const; 0044 bool applicationFilter() const; 0045 0046 public Q_SLOTS: 0047 void setInfoFilter(Transaction::Info info); 0048 void setApplicationFilter(bool enable); 0049 void sortNow(); 0050 0051 Q_SIGNALS: 0052 void changed(); 0053 0054 private: 0055 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 0056 bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; 0057 0058 Transaction::Info m_info; 0059 bool m_applicationsOnly; 0060 }; 0061 0062 #endif // APPLICATIONSORTFILTERMODEL_H