43
class KRQuery : public QObject {
43
class KRQuery : public QObject
49
// query only with name filter
50
KRQuery( const QString &name, bool matchCase = true );
52
KRQuery( const KRQuery & );
54
KRQuery& operator=(const KRQuery &);
58
// matching a file with the query
59
bool match( vfile *file ) const;// checks if the given vfile object matches the conditions
60
// matching a KIO file with the query
61
bool match( KFileItem *file ) const;// checks if the given vfile object matches the conditions
62
// matching a name with the query
63
bool match( const QString &name ) const;// matching the filename only
64
// matching the name of the directory
65
bool matchDirName( const QString &name ) const;
67
// sets the text for name filtering
68
void setNameFilter( const QString &text, bool cs=true );
69
// returns the current filter mask
70
const QString& nameFilter() const { return origFilter; }
71
// returns whether the filter is case sensitive
72
bool isCaseSensitive() { return matchesCaseSensitive; }
74
// returns if the filter is null (was cancelled)
75
bool isNull() {return bNull;};
77
// sets the content part of the query
78
void setContent( const QString &content, bool cs=true, bool wholeWord=false, bool remoteSearch=false, QString encoding=QString(), bool regExp=false);
80
// sets the minimum file size limit
81
void setMinimumFileSize( KIO::filesize_t );
82
// sets the maximum file size limit
83
void setMaximumFileSize( KIO::filesize_t );
85
// sets the time the file newer than
86
void setNewerThan( time_t time );
87
// sets the time the file older than
88
void setOlderThan( time_t time );
91
void setOwner( const QString &ownerIn );
93
void setGroup( const QString &groupIn );
94
// sets the permissions
95
void setPermissions( const QString &permIn );
97
// sets the mimetype for the query
98
// type, must be one of the following:
99
// 1. a valid mime type name
100
// 2. one of: i18n("Archives"), i18n("Directories"), i18n("Image Files")
101
// i18n("Text Files"), i18n("Video Files"), i18n("Audio Files")
102
// 3. i18n("Custom") in which case you must supply a list of valid mime-types
103
// in the member QStringList customType
104
void setMimeType( const QString &typeIn, QStringList customList = QStringList() );
105
// true if setMimeType was called
106
bool hasMimeType() { return type.isEmpty(); }
108
// sets the search in archive flag
109
void setSearchInArchives( bool flag ) { inArchive = flag; }
110
// gets the search in archive flag
111
bool searchInArchives() { return inArchive; }
112
// sets the recursive flag
113
void setRecursive( bool flag ) { recurse = flag; }
114
// gets the recursive flag
115
bool isRecursive() { return recurse; }
116
// sets whether to follow symbolic links
117
void setFollowLinks( bool flag ) { followLinksP = flag; }
118
// gets whether to follow symbolic links
119
bool followLinks() { return followLinksP; }
121
// sets the folders where the searcher will search
122
void setSearchInDirs( const KUrl::List &urls );
123
// gets the folders where the searcher searches
124
const KUrl::List & searchInDirs() { return whereToSearch; }
125
// sets the folders where search is not permitted
126
void setDontSearchInDirs( const KUrl::List &urls );
127
// gets the folders where search is not permitted
128
const KUrl::List & dontSearchInDirs() { return whereNotToSearch; }
129
// checks if a URL is excluded
130
bool isExcluded( const KUrl &url );
131
// gives whether we search for content
132
bool isContentSearched() const { return !contain.isEmpty(); }
134
const QString& foundText() const { return lastSuccessfulGrep; }
137
// important to know whether the event processor is connected
138
virtual void connectNotify ( const char * signal );
139
// important to know whether the event processor is connected
140
virtual void disconnectNotify ( const char * signal );
143
QStringList matches; // what to search
144
QStringList excludes; // what to exclude
145
QStringList includedDirs; // what dirs to include
146
QStringList excludedDirs; // what dirs to exclude
147
bool matchesCaseSensitive;
149
bool bNull; // flag if the query is null
151
QString contain; // file must contain this string
152
bool containCaseSensetive;
153
bool containWholeWord;
155
bool containOnRemote;
157
KIO::filesize_t minSize;
158
KIO::filesize_t maxSize;
168
QStringList customType;
170
bool inArchive; // if true- search in archive.
171
bool recurse; // if true recurse ob sub-dirs...
174
KUrl::List whereToSearch; // directorys to search
175
KUrl::List whereNotToSearch; // directorys NOT to search
50
// query only with name filter
51
KRQuery(const QString &name, bool matchCase = true);
53
KRQuery(const KRQuery &);
55
KRQuery& operator=(const KRQuery &);
59
// matching a file with the query
60
bool match(vfile *file) const; // checks if the given vfile object matches the conditions
61
// matching a KIO file with the query
62
bool match(KFileItem *file) const; // checks if the given vfile object matches the conditions
63
// matching a name with the query
64
bool match(const QString &name) const; // matching the filename only
65
// matching the name of the directory
66
bool matchDirName(const QString &name) const;
68
// sets the text for name filtering
69
void setNameFilter(const QString &text, bool cs = true);
70
// returns the current filter mask
71
const QString& nameFilter() const {
74
// returns whether the filter is case sensitive
75
bool isCaseSensitive() {
76
return matchesCaseSensitive;
79
// returns if the filter is null (was cancelled)
84
// sets the content part of the query
85
void setContent(const QString &content, bool cs = true, bool wholeWord = false, bool remoteSearch = false, QString encoding = QString(), bool regExp = false);
87
// sets the minimum file size limit
88
void setMinimumFileSize(KIO::filesize_t);
89
// sets the maximum file size limit
90
void setMaximumFileSize(KIO::filesize_t);
92
// sets the time the file newer than
93
void setNewerThan(time_t time);
94
// sets the time the file older than
95
void setOlderThan(time_t time);
98
void setOwner(const QString &ownerIn);
100
void setGroup(const QString &groupIn);
101
// sets the permissions
102
void setPermissions(const QString &permIn);
104
// sets the mimetype for the query
105
// type, must be one of the following:
106
// 1. a valid mime type name
107
// 2. one of: i18n("Archives"), i18n("Directories"), i18n("Image Files")
108
// i18n("Text Files"), i18n("Video Files"), i18n("Audio Files")
109
// 3. i18n("Custom") in which case you must supply a list of valid mime-types
110
// in the member QStringList customType
111
void setMimeType(const QString &typeIn, QStringList customList = QStringList());
112
// true if setMimeType was called
114
return type.isEmpty();
117
// sets the search in archive flag
118
void setSearchInArchives(bool flag) {
121
// gets the search in archive flag
122
bool searchInArchives() {
125
// sets the recursive flag
126
void setRecursive(bool flag) {
129
// gets the recursive flag
133
// sets whether to follow symbolic links
134
void setFollowLinks(bool flag) {
137
// gets whether to follow symbolic links
142
// sets the folders where the searcher will search
143
void setSearchInDirs(const KUrl::List &urls);
144
// gets the folders where the searcher searches
145
const KUrl::List & searchInDirs() {
146
return whereToSearch;
148
// sets the folders where search is not permitted
149
void setDontSearchInDirs(const KUrl::List &urls);
150
// gets the folders where search is not permitted
151
const KUrl::List & dontSearchInDirs() {
152
return whereNotToSearch;
154
// checks if a URL is excluded
155
bool isExcluded(const KUrl &url);
156
// gives whether we search for content
157
bool isContentSearched() const {
158
return !contain.isEmpty();
161
bool checkLine(const QString &line, bool backwards = false) const;
162
const QString& foundText() const {
163
return lastSuccessfulGrep;
165
int matchIndex() const {
166
return lastSuccessfulGrepMatchIndex;
168
int matchLength() const {
169
return lastSuccessfulGrepMatchLength;
173
// important to know whether the event processor is connected
174
virtual void connectNotify(const char * signal);
175
// important to know whether the event processor is connected
176
virtual void disconnectNotify(const char * signal);
179
QStringList matches; // what to search
180
QStringList excludes; // what to exclude
181
QStringList includedDirs; // what dirs to include
182
QStringList excludedDirs; // what dirs to exclude
183
bool matchesCaseSensitive;
185
bool bNull; // flag if the query is null
187
QString contain; // file must contain this string
188
bool containCaseSensetive;
189
bool containWholeWord;
191
bool containOnRemote;
193
KIO::filesize_t minSize;
194
KIO::filesize_t maxSize;
204
QStringList customType;
206
bool inArchive; // if true- search in archive.
207
bool recurse; // if true recurse ob sub-dirs...
210
KUrl::List whereToSearch; // directories to search
211
KUrl::List whereNotToSearch; // directories NOT to search
178
void status( const QString &name );
179
void processEvents( bool & stopped );
214
void status(const QString &name);
215
void processEvents(bool & stopped);
182
bool matchCommon( const QString &, const QStringList &, const QStringList & ) const;
183
bool checkPerm(QString perm) const;
184
bool checkType(QString mime) const;
185
bool containsContent( QString file ) const;
186
bool containsContent( KUrl url ) const;
187
bool checkBuffer( const char * data, int len ) const;
188
bool checkLine( const QString &line ) const;
189
bool checkTimer() const;
190
QStringList split( QString );
218
bool matchCommon(const QString &, const QStringList &, const QStringList &) const;
219
bool checkPerm(QString perm) const;
220
bool checkType(QString mime) const;
221
bool containsContent(QString file) const;
222
bool containsContent(KUrl url) const;
223
bool checkBuffer(const char * data, int len) const;
224
bool checkTimer() const;
225
QStringList split(QString);
193
void containsContentData(KIO::Job *, const QByteArray &);
194
void containsContentFinished(KJob*);
228
void containsContentData(KIO::Job *, const QByteArray &);
229
void containsContentFinished(KJob*);
199
mutable bool containsContentResult;
200
mutable char * receivedBuffer;
201
mutable int receivedBufferLen;
202
mutable QString lastSuccessfulGrep;
203
mutable QString fileName;
204
mutable KIO::filesize_t receivedBytes;
205
mutable KIO::filesize_t totalBytes;
206
mutable int processEventsConnected;
211
const char * encodedEnter;
213
QByteArray encodedEnterArray;
234
mutable bool containsContentResult;
235
mutable char * receivedBuffer;
236
mutable int receivedBufferLen;
237
mutable QString lastSuccessfulGrep;
238
mutable int lastSuccessfulGrepMatchIndex;
239
mutable int lastSuccessfulGrepMatchLength;
240
mutable QString fileName;
241
mutable KIO::filesize_t receivedBytes;
242
mutable KIO::filesize_t totalBytes;
243
mutable int processEventsConnected;
248
const char * encodedEnter;
250
QByteArray encodedEnterArray;