00001 /* 00002 * Silence 00003 * 00004 * Copyright (C) 2009 Yves Adler, Manuel Unglaub 00005 * 00006 * This file is part of Silence. 00007 * 00008 * Silence is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, version GPLv2 only of the License. 00011 * 00012 * Silence is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 00017 * You should have received a copy of the GNU General Public License 00018 * along with Silence. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef FILTERMODEL_H 00022 #define FILTERMODEL_H 00023 00024 #include <QObject> 00025 #include <QSortFilterProxyModel> 00026 #include <QStringList> 00027 00028 00036 class FilterModel : public QSortFilterProxyModel 00037 { 00038 Q_OBJECT 00039 00040 public: 00046 FilterModel(QObject *parent = 0); 00047 00052 ~FilterModel(); 00053 00054 public slots: 00060 void setFilterFixedString(const QString &pattern); 00061 00067 void setFilterCreatedDateEnabled(bool enabled); 00068 00074 void setFilterCreatedFromDate(const QDate &date); 00075 00081 void setFilterCreatedToDate(const QDate &date); 00082 00088 void setFilterModifiedDateEnabled(bool enabled); 00089 00095 void setFilterModifiedFromDate(const QDate &date); 00096 00102 void setFilterModifiedToDate(const QDate &date); 00103 00109 void setFilterMimetypeEnabled(bool enabled); 00110 00116 void setFilterMimetypeString(const QString &type); 00117 00123 void setFilterFulltextEnabled(bool enabled); 00124 00130 void addLabel(QString label); 00131 00137 void removeLabel(QString label); 00138 00144 void addBannedLabel(QString label); 00145 00149 void clearLabels(); 00150 00156 void removeBannedLabel(QString label); 00157 00161 void clearBannedLabels(); 00162 00163 protected: 00171 virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; 00172 00173 private: 00174 bool filterCreated, 00175 filterModified, 00176 filterMimetype, 00177 filterFulltext; 00178 QString *mimetype, 00179 searchString; 00180 QDateTime *createdFromDate, 00181 *createdToDate, 00182 *modifiedFromDate, 00183 *modifiedToDate; 00184 QStringList labels, 00185 bannedLabels; 00186 }; 00187 00188 #endif // FILTERMODEL_H 00189 00190 00191