File indexing completed on 2024-04-28 17:06:03

0001 /*
0002     SPDX-FileCopyrightText: 2011 Jan Lepper <jan_lepper@gmx.de>
0003     SPDX-FileCopyrightText: 2011-2022 Krusader Krew <https://krusader.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef FILTERSETTINGS_H
0009 #define FILTERSETTINGS_H
0010 
0011 #include "../FileSystem/krquery.h"
0012 
0013 #include <KConfigCore/KConfigGroup>
0014 
0015 class FilterSettings
0016 {
0017     friend class FilterTabs;
0018     friend class GeneralFilter;
0019     friend class AdvancedFilter;
0020 
0021 public:
0022     FilterSettings();
0023     FilterSettings(const FilterSettings &other);
0024     FilterSettings &operator=(const FilterSettings &other);
0025 
0026     bool isValid() const
0027     {
0028         return valid;
0029     }
0030     void load(const KConfigGroup &cfg);
0031     void save(KConfigGroup cfg) const;
0032     KrQuery toQuery() const;
0033 
0034 private:
0035     enum SizeUnit { Byte = 0, KiloByte, MegaByte, GigaByte };
0036 
0037     enum TimeUnit { Day = 0, Week, Month, Year };
0038 
0039     class FileSize
0040     {
0041     public:
0042         FileSize()
0043             : amount(0)
0044             , unit(Byte)
0045         {
0046         }
0047         FileSize(const FileSize &other);
0048         FileSize &operator=(const FileSize &other);
0049 
0050         KIO::filesize_t size() const;
0051 
0052         KIO::filesize_t amount;
0053         SizeUnit unit;
0054     };
0055 
0056     class TimeSpan
0057     {
0058     public:
0059         TimeSpan()
0060             : amount(0)
0061             , unit(Day)
0062         {
0063         }
0064         TimeSpan(const TimeSpan &other);
0065         TimeSpan &operator=(const TimeSpan &other);
0066 
0067         int days() const;
0068 
0069         int amount;
0070         TimeUnit unit;
0071     };
0072 
0073     static void saveDate(const QString &key, const QDate &date, KConfigGroup &cfg);
0074     static time_t qdate2time_t(QDate d, bool start);
0075 
0076     bool valid;
0077     QString searchFor;
0078     bool searchForCase;
0079     QString mimeType;
0080     bool searchInArchives;
0081     bool recursive;
0082     bool followLinks;
0083     QList<QUrl> searchIn;
0084     QList<QUrl> dontSearchIn;
0085     QStringList excludeFolderNames;
0086     QString contentEncoding;
0087     QString containsText;
0088     bool containsTextCase;
0089     bool containsWholeWord;
0090     bool containsRegExp;
0091     bool minSizeEnabled;
0092     FileSize minSize;
0093     bool maxSizeEnabled;
0094     FileSize maxSize;
0095     bool modifiedBetweenEnabled;
0096     QDate modifiedBetween1;
0097     QDate modifiedBetween2;
0098     bool notModifiedAfterEnabled;
0099     QDate notModifiedAfter;
0100     bool modifiedInTheLastEnabled;
0101     TimeSpan modifiedInTheLast;
0102     TimeSpan notModifiedInTheLast;
0103     bool ownerEnabled;
0104     QString owner;
0105     bool groupEnabled;
0106     QString group;
0107     bool permissionsEnabled;
0108     QString permissions;
0109 };
0110 
0111 #endif // FILTERSETTINGS_H