File indexing completed on 2023-12-03 12:41:45
0001 /* 0002 kquery.h 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 0006 */ 0007 0008 #ifndef KQUERY_H 0009 #define KQUERY_H 0010 0011 #include <time.h> 0012 0013 #include <QList> 0014 #include <QObject> 0015 #include <QPair> 0016 #include <QQueue> 0017 #include <QRegExp> 0018 #include <QStringList> 0019 0020 #include <KIO/Job> 0021 #include <KProcess> 0022 0023 class KFileItem; 0024 0025 class KQuery : public QObject 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit KQuery(QObject *parent = nullptr); 0031 ~KQuery() override; 0032 0033 /* Functions to set Query requirements */ 0034 void setSizeRange(int mode, KIO::filesize_t value1, KIO::filesize_t value2); 0035 void setTimeRange(time_t from, time_t to); 0036 void setRegExp(const QString ®exp, bool caseSensitive); 0037 void setRecursive(bool recursive); 0038 void setPath(const QUrl &url); 0039 void setFileType(int filetype); 0040 void setMimeType(const QStringList &mimetype); 0041 void setContext(const QString &context, bool casesensitive, bool search_binary); 0042 void setUsername(const QString &username); 0043 void setGroupname(const QString &groupname); 0044 void setMetaInfo(const QString &metainfo, const QString &metainfokey); 0045 void setUseFileIndex(bool); 0046 void setShowHiddenFiles(bool); 0047 0048 void start(); 0049 void kill(); 0050 const QUrl &url() 0051 { 0052 return m_url; 0053 } 0054 0055 private: 0056 /* Check if file meets the find's requirements*/ 0057 inline void processQuery(const KFileItem &); 0058 0059 public Q_SLOTS: 0060 /* List of files found using slocate */ 0061 void slotListEntries(const QStringList&); 0062 0063 protected Q_SLOTS: 0064 /* List of files found using KIO */ 0065 void slotListEntries(KIO::Job *, const KIO::UDSEntryList &); 0066 void slotResult(KJob *); 0067 0068 void slotreadyReadStandardOutput(); 0069 void slotreadyReadStandardError(); 0070 void slotendProcessLocate(int, QProcess::ExitStatus); 0071 0072 Q_SIGNALS: 0073 void foundFileList(const QList< QPair<KFileItem, QString> > &); 0074 void result(int); 0075 0076 private: 0077 void checkEntries(); 0078 0079 int m_filetype; 0080 int m_sizemode; 0081 KIO::filesize_t m_sizeboundary1; 0082 KIO::filesize_t m_sizeboundary2; 0083 QUrl m_url; 0084 time_t m_timeFrom; 0085 time_t m_timeTo; 0086 QRegExp m_regexp;// regexp for file content 0087 bool m_recursive; 0088 QStringList m_mimetype; 0089 QString m_context; 0090 QString m_username; 0091 QString m_groupname; 0092 QString m_metainfo; 0093 QString m_metainfokey; 0094 bool m_casesensitive; 0095 bool m_search_binary; 0096 bool m_useLocate; 0097 bool m_showHiddenFiles; 0098 QByteArray bufferLocate; 0099 QStringList locateList; 0100 KProcess *processLocate = nullptr; 0101 QList<QRegExp *> m_regexps;// regexps for file name 0102 // QValueList<bool> m_regexpsContainsGlobs; // what should this be good for ? Alex 0103 KIO::ListJob *job; 0104 bool m_insideCheckEntries; 0105 QQueue<KFileItem> m_fileItems; 0106 QRegExp metaKeyRx; 0107 int m_result; 0108 QStringList ignore_mimetypes; 0109 QStringList ooo_mimetypes; // OpenOffice.org mimetypes 0110 QStringList koffice_mimetypes; 0111 0112 QList< QPair<KFileItem, QString> > m_foundFilesList; 0113 }; 0114 0115 #endif