1 /***************************************************************************** 2 * Copyright (C) 2011 Jan Lepper <jan_lepper@gmx.de> * 3 * Copyright (C) 2011-2019 Krusader Krew [https://krusader.org] * 4 * * 5 * This file is part of Krusader [https://krusader.org]. * 6 * * 7 * Krusader is free software: you can redistribute it and/or modify * 8 * it under the terms of the GNU General Public License as published by * 9 * the Free Software Foundation, either version 2 of the License, or * 10 * (at your option) any later version. * 11 * * 12 * Krusader is distributed in the hope that it will be useful, * 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 * GNU General Public License for more details. * 16 * * 17 * You should have received a copy of the GNU General Public License * 18 * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * 19 *****************************************************************************/ 20 21 #ifndef FILTERSETTINGS_H 22 #define FILTERSETTINGS_H 23 24 #include "../FileSystem/krquery.h" 25 26 #include <KConfigCore/KConfigGroup> 27 28 29 class FilterSettings 30 { 31 friend class FilterTabs; 32 friend class GeneralFilter; 33 friend class AdvancedFilter; 34 35 public: 36 FilterSettings(); 37 FilterSettings& operator=(const FilterSettings& other); 38 isValid()39 bool isValid() const { 40 return valid; 41 } 42 void load(KConfigGroup cfg); 43 void save(KConfigGroup cfg) const; 44 KRQuery toQuery() const; 45 46 private: 47 enum SizeUnit { 48 Byte = 0, KiloByte, MegaByte, GigaByte 49 }; 50 51 enum TimeUnit { 52 Day = 0, Week, Month, Year 53 }; 54 55 class FileSize 56 { 57 public: FileSize()58 FileSize() : amount(0), unit(Byte) {} 59 FileSize& operator=(const FileSize &other); 60 61 KIO::filesize_t size() const; 62 63 KIO::filesize_t amount; 64 SizeUnit unit; 65 }; 66 67 class TimeSpan 68 { 69 public: TimeSpan()70 TimeSpan() : amount(0), unit(Day) {} 71 TimeSpan& operator=(const TimeSpan &other); 72 73 int days() const; 74 75 int amount; 76 TimeUnit unit; 77 }; 78 79 static void saveDate(QString key, const QDate &date, KConfigGroup &cfg); 80 static time_t qdate2time_t(QDate d, bool start); 81 82 bool valid; 83 QString searchFor; 84 bool searchForCase; 85 QString mimeType; 86 bool searchInArchives; 87 bool recursive; 88 bool followLinks; 89 QList<QUrl> searchIn; 90 QList<QUrl> dontSearchIn; 91 QStringList excludeFolderNames; 92 QString contentEncoding; 93 QString containsText; 94 bool containsTextCase; 95 bool containsWholeWord; 96 bool containsRegExp; 97 bool minSizeEnabled; 98 FileSize minSize; 99 bool maxSizeEnabled; 100 FileSize maxSize; 101 bool modifiedBetweenEnabled; 102 QDate modifiedBetween1; 103 QDate modifiedBetween2; 104 bool notModifiedAfterEnabled; 105 QDate notModifiedAfter; 106 bool modifiedInTheLastEnabled; 107 TimeSpan modifiedInTheLast; 108 TimeSpan notModifiedInTheLast; 109 bool ownerEnabled; 110 QString owner; 111 bool groupEnabled; 112 QString group; 113 bool permissionsEnabled; 114 QString permissions; 115 }; 116 117 #endif //FILTERSETTINGS_H 118