Changeset View
Changeset View
Standalone View
Standalone View
krusader/FileSystem/krquery.cpp
Show All 39 Lines | |||||
40 | #define STATUS_SEND_DELAY 250 | 40 | #define STATUS_SEND_DELAY 250 | ||
41 | #define MAX_LINE_LEN 1000 | 41 | #define MAX_LINE_LEN 1000 | ||
42 | 42 | | |||
43 | // set the defaults | 43 | // set the defaults | ||
44 | KRQuery::KRQuery() | 44 | KRQuery::KRQuery() | ||
45 | : QObject(), matchesCaseSensitive(true), bNull(true), contain(QString()), | 45 | : QObject(), matchesCaseSensitive(true), bNull(true), contain(QString()), | ||
46 | containCaseSensetive(true), containWholeWord(false), containRegExp(false), minSize(0), | 46 | containCaseSensetive(true), containWholeWord(false), containRegExp(false), minSize(0), | ||
47 | maxSize(0), newerThen(0), olderThen(0), owner(QString()), group(QString()), perm(QString()), | 47 | maxSize(0), newerThen(0), olderThen(0), owner(QString()), group(QString()), perm(QString()), | ||
48 | type(QString()), inArchive(false), recurse(true), followLinksP(true), receivedBuffer(0), | 48 | type(QString()), m_inArchive(false), m_recurse(true), m_followLinks(true), | ||
49 | receivedBufferLen(0), processEventsConnected(0), codec(QTextCodec::codecForLocale()) | 49 | m_ignoreHidden(false), receivedBuffer(0), receivedBufferLen(0), processEventsConnected(0), | ||
50 | codec(QTextCodec::codecForLocale()) | ||||
50 | { | 51 | { | ||
51 | QChar ch = '\n'; | 52 | QChar ch = '\n'; | ||
52 | QTextCodec::ConverterState state(QTextCodec::IgnoreHeader); | 53 | QTextCodec::ConverterState state(QTextCodec::IgnoreHeader); | ||
53 | encodedEnterArray = codec->fromUnicode(&ch, 1, &state); | 54 | encodedEnterArray = codec->fromUnicode(&ch, 1, &state); | ||
54 | encodedEnter = encodedEnterArray.data(); | 55 | encodedEnter = encodedEnterArray.data(); | ||
55 | encodedEnterLen = encodedEnterArray.size(); | 56 | encodedEnterLen = encodedEnterArray.size(); | ||
56 | } | 57 | } | ||
57 | 58 | | |||
58 | // set the defaults | 59 | // set the defaults | ||
59 | KRQuery::KRQuery(const QString &name, bool matchCase) | 60 | KRQuery::KRQuery(const QString &name, bool matchCase) | ||
60 | : QObject(), bNull(true), contain(QString()), containCaseSensetive(true), | 61 | : QObject(), bNull(true), contain(QString()), containCaseSensetive(true), | ||
61 | containWholeWord(false), containRegExp(false), minSize(0), maxSize(0), newerThen(0), | 62 | containWholeWord(false), containRegExp(false), minSize(0), maxSize(0), newerThen(0), | ||
62 | olderThen(0), owner(QString()), group(QString()), perm(QString()), type(QString()), | 63 | olderThen(0), owner(QString()), group(QString()), perm(QString()), type(QString()), | ||
63 | inArchive(false), recurse(true), followLinksP(true), receivedBuffer(0), receivedBufferLen(0), | 64 | m_inArchive(false), m_recurse(true), m_followLinks(true), m_ignoreHidden(false), | ||
64 | processEventsConnected(0), codec(QTextCodec::codecForLocale()) | 65 | receivedBuffer(0), receivedBufferLen(0), processEventsConnected(0), | ||
66 | codec(QTextCodec::codecForLocale()) | ||||
65 | { | 67 | { | ||
66 | QChar ch = '\n'; | 68 | QChar ch = '\n'; | ||
67 | QTextCodec::ConverterState state(QTextCodec::IgnoreHeader); | 69 | QTextCodec::ConverterState state(QTextCodec::IgnoreHeader); | ||
68 | encodedEnterArray = codec->fromUnicode(&ch, 1, &state); | 70 | encodedEnterArray = codec->fromUnicode(&ch, 1, &state); | ||
69 | encodedEnter = encodedEnterArray.data(); | 71 | encodedEnter = encodedEnterArray.data(); | ||
70 | encodedEnterLen = encodedEnterArray.size(); | 72 | encodedEnterLen = encodedEnterArray.size(); | ||
71 | 73 | | |||
72 | setNameFilter(name, matchCase); | 74 | setNameFilter(name, matchCase); | ||
Show All 28 Lines | 91 | { | |||
101 | maxSize = old.maxSize; | 103 | maxSize = old.maxSize; | ||
102 | newerThen = old.newerThen; | 104 | newerThen = old.newerThen; | ||
103 | olderThen = old.olderThen; | 105 | olderThen = old.olderThen; | ||
104 | owner = old.owner; | 106 | owner = old.owner; | ||
105 | group = old.group; | 107 | group = old.group; | ||
106 | perm = old.perm; | 108 | perm = old.perm; | ||
107 | type = old.type; | 109 | type = old.type; | ||
108 | customType = old.customType; | 110 | customType = old.customType; | ||
109 | inArchive = old.inArchive; | 111 | m_inArchive = old.m_inArchive; | ||
110 | recurse = old.recurse; | 112 | m_recurse = old.m_recurse; | ||
111 | followLinksP = old.followLinksP; | 113 | m_followLinks = old.m_followLinks; | ||
112 | whereToSearch = old.whereToSearch; | 114 | m_ignoreHidden = old.m_ignoreHidden; | ||
113 | excludedFolderNames = old.excludedFolderNames; | 115 | m_whereToSearch = old.m_whereToSearch; | ||
114 | whereNotToSearch = old.whereNotToSearch; | 116 | m_whereNotToSearch = old.m_whereNotToSearch; | ||
115 | origFilter = old.origFilter; | 117 | origFilter = old.origFilter; | ||
116 | 118 | | |||
117 | codec = old.codec; | 119 | codec = old.codec; | ||
118 | 120 | | |||
119 | encodedEnterArray = old.encodedEnterArray; | 121 | encodedEnterArray = old.encodedEnterArray; | ||
120 | encodedEnter = encodedEnterArray.data(); | 122 | encodedEnter = encodedEnterArray.data(); | ||
121 | encodedEnterLen = encodedEnterArray.size(); | 123 | encodedEnterLen = encodedEnterArray.size(); | ||
122 | 124 | | |||
Show All 25 Lines | 135 | #define LOAD(key, var) (var = cfg.readEntry(key, var)) | |||
148 | olderThen = QDateTime::fromString( | 150 | olderThen = QDateTime::fromString( | ||
149 | cfg.readEntry("OlderThan", QDateTime::fromTime_t(olderThen).toString())) | 151 | cfg.readEntry("OlderThan", QDateTime::fromTime_t(olderThen).toString())) | ||
150 | .toTime_t(); | 152 | .toTime_t(); | ||
151 | LOAD("Owner", owner); | 153 | LOAD("Owner", owner); | ||
152 | LOAD("Group", group); | 154 | LOAD("Group", group); | ||
153 | LOAD("Perm", perm); | 155 | LOAD("Perm", perm); | ||
154 | LOAD("Type", type); | 156 | LOAD("Type", type); | ||
155 | LOAD("CustomType", customType); | 157 | LOAD("CustomType", customType); | ||
156 | LOAD("InArchive", inArchive); | 158 | LOAD("InArchive", m_inArchive); | ||
157 | LOAD("Recurse", recurse); | 159 | LOAD("Recurse", m_recurse); | ||
158 | LOAD("FollowLinks", followLinksP); | 160 | LOAD("FollowLinks", m_followLinks); | ||
161 | LOAD("IgnoreHidden", m_ignoreHidden); | ||||
159 | // KF5 TODO? | 162 | // KF5 TODO? | ||
160 | // LOAD("WhereToSearch", whereToSearch); | 163 | // LOAD("WhereToSearch", whereToSearch); | ||
161 | // LOAD("WhereNotToSearch", whereNotToSearch); | 164 | // LOAD("WhereNotToSearch", whereNotToSearch); | ||
162 | LOAD("OrigFilter", origFilter); | 165 | LOAD("OrigFilter", origFilter); | ||
163 | 166 | | |||
164 | codec = QTextCodec::codecForName(cfg.readEntry("Codec", codec->name())); | 167 | codec = QTextCodec::codecForName(cfg.readEntry("Codec", codec->name())); | ||
165 | if (!codec) | 168 | if (!codec) | ||
166 | codec = QTextCodec::codecForLocale(); | 169 | codec = QTextCodec::codecForLocale(); | ||
Show All 26 Lines | 180 | { | |||
193 | cfg.writeEntry("MaxSize", maxSize); | 196 | cfg.writeEntry("MaxSize", maxSize); | ||
194 | cfg.writeEntry("NewerThan", QDateTime::fromTime_t(newerThen).toString()); | 197 | cfg.writeEntry("NewerThan", QDateTime::fromTime_t(newerThen).toString()); | ||
195 | cfg.writeEntry("OlderThan", QDateTime::fromTime_t(olderThen).toString()); | 198 | cfg.writeEntry("OlderThan", QDateTime::fromTime_t(olderThen).toString()); | ||
196 | cfg.writeEntry("Owner", owner); | 199 | cfg.writeEntry("Owner", owner); | ||
197 | cfg.writeEntry("Group", group); | 200 | cfg.writeEntry("Group", group); | ||
198 | cfg.writeEntry("Perm", perm); | 201 | cfg.writeEntry("Perm", perm); | ||
199 | cfg.writeEntry("Type", type); | 202 | cfg.writeEntry("Type", type); | ||
200 | cfg.writeEntry("CustomType", customType); | 203 | cfg.writeEntry("CustomType", customType); | ||
201 | cfg.writeEntry("InArchive", inArchive); | 204 | cfg.writeEntry("InArchive", m_inArchive); | ||
202 | cfg.writeEntry("Recurse", recurse); | 205 | cfg.writeEntry("Recurse", m_recurse); | ||
203 | cfg.writeEntry("FollowLinks", followLinksP); | 206 | cfg.writeEntry("FollowLinks", m_followLinks); | ||
207 | cfg.writeEntry("IgnoreHidden", m_ignoreHidden); | ||||
204 | // KF5 TODO? | 208 | // KF5 TODO? | ||
205 | // cfg.writeEntry("WhereToSearch", whereToSearch); | 209 | // cfg.writeEntry("WhereToSearch", whereToSearch); | ||
206 | // cfg.writeEntry("WhereNotToSearch", whereNotToSearch); | 210 | // cfg.writeEntry("WhereNotToSearch", whereNotToSearch); | ||
207 | cfg.writeEntry("OrigFilter", origFilter); | 211 | cfg.writeEntry("OrigFilter", origFilter); | ||
208 | 212 | | |||
209 | cfg.writeEntry("Codec", codec->name()); | 213 | cfg.writeEntry("Codec", codec->name()); | ||
210 | cfg.writeEntry("EncodedEnterArray", encodedEnterArray); | 214 | cfg.writeEntry("EncodedEnterArray", encodedEnterArray); | ||
211 | cfg.writeEntry("EncodedEnter", encodedEnter); | 215 | cfg.writeEntry("EncodedEnter", encodedEnter); | ||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 298 | { | |||
316 | if (!owner.isEmpty() && item->getOwner() != owner) | 320 | if (!owner.isEmpty() && item->getOwner() != owner) | ||
317 | return false; | 321 | return false; | ||
318 | // check group name | 322 | // check group name | ||
319 | if (!group.isEmpty() && item->getGroup() != group) | 323 | if (!group.isEmpty() && item->getGroup() != group) | ||
320 | return false; | 324 | return false; | ||
321 | // check permission | 325 | // check permission | ||
322 | if (!perm.isEmpty() && !checkPerm(item->getPerm())) | 326 | if (!perm.isEmpty() && !checkPerm(item->getPerm())) | ||
323 | return false; | 327 | return false; | ||
328 | // check hidden | ||||
329 | if (m_ignoreHidden && item->getUrl().fileName().startsWith('.')) | ||||
330 | return false; | ||||
324 | 331 | | |||
325 | if (!contain.isEmpty()) { | 332 | if (!contain.isEmpty()) { | ||
326 | if ((totalBytes = item->getSize()) == 0) | 333 | if ((totalBytes = item->getSize()) == 0) | ||
327 | totalBytes++; // sanity | 334 | totalBytes++; // sanity | ||
328 | receivedBytes = 0; | 335 | receivedBytes = 0; | ||
329 | if (receivedBuffer) | 336 | if (receivedBuffer) | ||
330 | delete receivedBuffer; | 337 | delete receivedBuffer; | ||
331 | receivedBuffer = 0; | 338 | receivedBuffer = 0; | ||
▲ Show 20 Lines • Show All 394 Lines • ▼ Show 20 Line(s) | |||||
726 | 733 | | |||
727 | void KRQuery::setMimeType(const QString &typeIn, QStringList customList) | 734 | void KRQuery::setMimeType(const QString &typeIn, QStringList customList) | ||
728 | { | 735 | { | ||
729 | bNull = false; | 736 | bNull = false; | ||
730 | type = typeIn; | 737 | type = typeIn; | ||
731 | customType = customList; | 738 | customType = customList; | ||
732 | } | 739 | } | ||
733 | 740 | | |||
734 | bool KRQuery::isExcluded(const QUrl &url) | 741 | bool KRQuery::isExcluded(const QUrl &url) const | ||
735 | { | 742 | { | ||
736 | for (QUrl &item : whereNotToSearch) | 743 | for (const QUrl excludedUrl: m_whereNotToSearch) | ||
737 | if (item.isParentOf(url) || url.matches(item, QUrl::StripTrailingSlash)) | 744 | if (excludedUrl.isParentOf(url) || url.matches(excludedUrl, QUrl::StripTrailingSlash)) | ||
738 | return true; | 745 | return true; | ||
739 | 746 | | |||
740 | // Exclude folder names that are configured in settings | 747 | // Exclude folder names that are configured in settings | ||
741 | QString filename = url.fileName(); | 748 | const QString filename = url.fileName(); | ||
742 | for (QString &item : excludedFolderNames) | 749 | for (const QString &item : excludedFolderNames) | ||
743 | if (filename == item) | 750 | if (filename == item) | ||
744 | return true; | 751 | return true; | ||
745 | 752 | | |||
746 | if (!matchDirName(filename)) | 753 | if (!matchDirName(filename)) | ||
747 | return true; | 754 | return true; | ||
748 | 755 | | |||
749 | return false; | 756 | return false; | ||
750 | } | 757 | } | ||
751 | 758 | | |||
752 | void KRQuery::setSearchInDirs(const QList<QUrl> &urls) | 759 | void KRQuery::setSearchInDirs(const QList<QUrl> &urls) | ||
753 | { | 760 | { | ||
754 | whereToSearch.clear(); | 761 | m_whereToSearch.clear(); | ||
755 | for (int i = 0; i < urls.count(); ++i) { | 762 | for (int i = 0; i < urls.count(); ++i) { | ||
756 | QString url = urls[i].url(); | 763 | QString url = urls[i].url(); | ||
757 | QUrl completed = QUrl::fromUserInput(KUrlCompletion::replacedPath(url, true, true), | 764 | QUrl completed = QUrl::fromUserInput(KUrlCompletion::replacedPath(url, true, true), | ||
758 | QString(), QUrl::AssumeLocalFile); | 765 | QString(), QUrl::AssumeLocalFile); | ||
759 | whereToSearch.append(completed); | 766 | m_whereToSearch.append(completed); | ||
760 | } | 767 | } | ||
761 | } | 768 | } | ||
762 | 769 | | |||
763 | void KRQuery::setDontSearchInDirs(const QList<QUrl> &urls) | 770 | void KRQuery::setDontSearchInDirs(const QList<QUrl> &urls) | ||
764 | { | 771 | { | ||
765 | whereNotToSearch.clear(); | 772 | m_whereNotToSearch.clear(); | ||
766 | for (int i = 0; i < urls.count(); ++i) { | 773 | for (int i = 0; i < urls.count(); ++i) { | ||
767 | QString url = urls[i].url(); | 774 | QString url = urls[i].url(); | ||
768 | QUrl completed = QUrl::fromUserInput(KUrlCompletion::replacedPath(url, true, true), | 775 | QUrl completed = QUrl::fromUserInput(KUrlCompletion::replacedPath(url, true, true), | ||
769 | QString(), QUrl::AssumeLocalFile); | 776 | QString(), QUrl::AssumeLocalFile); | ||
770 | whereNotToSearch.append(completed); | 777 | m_whereNotToSearch.append(completed); | ||
771 | } | 778 | } | ||
772 | } | 779 | } | ||
773 | void KRQuery::setExcludeFolderNames(const QStringList &paths) | 780 | void KRQuery::setExcludeFolderNames(const QStringList &paths) | ||
774 | { | 781 | { | ||
775 | excludedFolderNames.clear(); | 782 | excludedFolderNames.clear(); | ||
776 | excludedFolderNames.append(paths); | 783 | excludedFolderNames.append(paths); | ||
777 | } | 784 | } |