summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-12 18:09:55 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-12 18:09:55 +0000
commit630b7196d93786595546565329160ff26332704b (patch)
tree16f570c8f65cf789945d96ab7c4c7c9a46c10e2f /src
downloadtdeio-locate-630b7196d93786595546565329160ff26332704b.tar.gz
tdeio-locate-630b7196d93786595546565329160ff26332704b.zip
Added KDE3 version of kio-locate
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kio-locate@1089224 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src')
-rw-r--r--src/SConscript40
-rw-r--r--src/kio_locate.cpp1035
-rw-r--r--src/kio_locate.h273
-rw-r--r--src/kio_locate.kcfg62
-rw-r--r--src/klocateconfig.kcfgc6
-rw-r--r--src/klocateconfigfilterwidget.ui105
-rw-r--r--src/klocateconfiglocatewidget.ui211
-rw-r--r--src/klocateconfigwidget.ui391
-rw-r--r--src/locate.desktop8
-rw-r--r--src/locate.protocol18
-rw-r--r--src/locater.cpp131
-rw-r--r--src/locater.h103
-rw-r--r--src/locater.protocol15
-rw-r--r--src/pattern.cpp124
-rw-r--r--src/pattern.h114
-rw-r--r--src/rlocate.protocol18
16 files changed, 2654 insertions, 0 deletions
diff --git a/src/SConscript b/src/SConscript
new file mode 100644
index 0000000..141cd59
--- /dev/null
+++ b/src/SConscript
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+# kio-locate
+#
+# Copyright (C) 2005 by Tobi Vollebregt
+# tobivollebregt@gmail.com
+#
+# Thanks to Google's Summer Of Code Program!
+#
+# Copyright (C) 2005 by Armin Straub
+# linux@arminstraub.de
+#
+# Adapted from the example shipping with bksys.
+# Thomas Nagy, 2004, 2005
+# Thanks for this great tool!
+
+Import('env')
+
+# The kioslave library is kio_test5.so and not libkio_test5.so (empty string)
+obj=env.kobject('kioslave')
+obj.target='kio_locate'
+obj.source="""
+ klocateconfig.kcfgc
+ klocateconfigwidget.ui
+ klocateconfigfilterwidget.ui
+ klocateconfiglocatewidget.ui
+ kio_locate.cpp
+ locater.cpp
+ pattern.cpp
+"""
+obj.libs='qt-mt kio'
+obj.linkflags='-module -avoid-version' # add more link flags
+obj.execute()
+
+# Install the protocol files
+env.KDEinstall('KDESERV', '', 'locate.protocol')
+env.KDEinstall('KDESERV', '', 'locater.protocol')
+env.KDEinstall('KDESERV', '', 'rlocate.protocol')
+
+# Install the searchprovider file
+env.KDEinstall('KDESERV', '/searchproviders', 'locate.desktop')
diff --git a/src/kio_locate.cpp b/src/kio_locate.cpp
new file mode 100644
index 0000000..9beee51
--- /dev/null
+++ b/src/kio_locate.cpp
@@ -0,0 +1,1035 @@
+/***************************************************************************
+ * kio-locate: KDE I/O Slave for the locate command *
+ * *
+ * Copyright (C) 2005 by Tobi Vollebregt *
+ * tobivollebregt@gmail.com *
+ * *
+ * Thanks to Google's Summer Of Code Program! *
+ * *
+ * Copyright (C) 2004 by Armin Straub *
+ * linux@arminstraub.de *
+ * *
+ * This program was initially written by Michael Schuerig. *
+ * Although I have completely rewritten it, most ideas are adopted *
+ * from his original work. *
+ * *
+ * Copyright (C) 2002 by Michael Schuerig *
+ * michael@schuerig.de *
+ * *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#include <algorithm>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <pwd.h>
+#include <grp.h>
+
+#include <kapplication.h>
+#include <kconfigdialog.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kurl.h>
+#include <kuser.h>
+#include <qfile.h>
+
+#include "kio_locate.h"
+#include "klocateconfig.h"
+#include "klocateconfigwidget.h"
+#include "klocateconfigfilterwidget.h"
+#include "klocateconfiglocatewidget.h"
+
+using namespace KIO;
+
+
+static const QString queryQuery = "q";
+static const QString queryDirectory = "directory";
+static const QString queryCase = "case";
+static const QString queryRegExp = "regexp";
+
+static const QString iconToStringTable[] = {
+ "folder", "folder_green", "folder_grey", "folder_orange",
+ "folder_red", "folder_violet", "folder_yellow"
+};
+
+
+/////////////////////////////////////////////////////////////////////
+// HELPERS
+
+/**
+ * Determines if a string contains unescaped wildcard characters.
+ * Currently, wildcard characters are: * + ? [ ]
+ * For older versions of Konqueror: + behaves identical to *
+ * @param s the string to inspect
+ */
+static bool hasWildcards(const QString& s)
+{
+ for (unsigned int i = 0; i < s.length(); ++i) {
+ if ((s[i] == '*' || s[i] == '+' || s[i] == '?' || s[i] == '[' || s[i] == ']') && (i < 1 || s[i-1] != '\\'))
+ return true;
+ }
+ return false;
+}
+
+
+/**
+ * Converts a string containing shell wildcard characters (globbing characters)
+ * to a regular expression. This function takes care of escaped wildcards and
+ * any regexp special characters which happen to be in the string.
+ * @param s the string to convert
+ * @return the converted string
+ */
+static QString convertWildcardsToRegExp(QString s)
+{
+ bool in_set = false;
+
+ // No support for regexp searches.
+ // (Konqueror makes passing chars like "/" almost impossible anyway.)
+ // Note that this converts actual wildcards to escaped wildcards (\wildcard),
+ // and escaped wildcards to 'triple'-escaped wildcards (\\\wildcard).
+ s = QRegExp::escape(s);
+
+ // Walk through the string, converting \wildcard to regexp and
+ // \\\wildcard back to \wildcard.
+ for (unsigned i = 1; i < s.length(); ++i) {
+ //DEBUGSTR << s.left(i+1) << endl;
+ if (i < 3 || s[i-3] != '\\' || s[i-2] != '\\') {
+ // If it was an unescaped character (now possibly escaped once)
+ if (s[i-1] == '\\') {
+ // If it actually was escaped once
+ if (!in_set) {
+ // If it's NOT inside a character set, we need to convert *?[
+ if (s[i] == '*' || s[i] == '+') {
+ s = s.left(i-1) + "[^/]*" + s.mid(i+1);
+ i += 3; // 3 == strlen("[^/]*")-strlen("\\*")
+ } else if (s[i] == '?') {
+ s = s.left(i-1) + "[^/]" + s.mid(i+1);
+ i += 2; // 2 == strlen("[^/]")-strlen("\\*")
+ } else if (s[i] == '[') {
+ s = s.left(i-1) + s.mid(i);
+ --i;
+ in_set = true;
+ }
+ } else {
+ // If it's inside a character set, we need to convert ]^
+ // and to unescape everything else.
+ if (s[i] == ']') {
+ s = s.left(i-1) + s.mid(i);
+ --i;
+ in_set = false;
+ } else if (s[i] == '^' && i >= 2 && s[i-2] == '[') {
+ s = s.left(i-1) + s.mid(i);
+ --i;
+ } else {
+ s = s.left(i-1) + s.mid(i);
+ }
+ }
+ }
+ } else {
+ // If it's an escaped character, remove the extra escape characters.
+ s = s.left(i-3) + s.mid(i-1);
+ i -= 2; // 2 == strlen("\\\\")-strlen("")
+ }
+ }
+ return s;
+}
+
+
+/**
+ * Determines if path includes a trailing slash.
+ * @param path the path to inspect
+ */
+static bool hasTrailingSlash(const QString& path)
+{
+ int n = path.length();
+ return ((n > 0) && (path[n-1] == '/'));
+}
+
+
+/**
+ * Strips a trailing slash / from a path.
+ * @param path the path to strip the slash off
+ */
+static QString stripTrailingSlash(const QString& path)
+{
+ int n = path.length();
+ if ((n > 0) && (path[n-1] == '/')) {
+ return path.left(n-1);
+ }
+ return path;
+}
+
+
+/**
+ * Add a trailing slash / to a path if there is none yet.
+ * @param path the path to append the slash to
+ */
+static QString addTrailingSlash(const QString& path)
+{
+ int n = path.length();
+ if ((n > 0) && (path[n-1] == '/')) {
+ return path;
+ }
+ return path + '/';
+}
+
+
+static void addAtom(UDSEntry& entry, unsigned int uds, const QString& s)
+{
+ UDSAtom a;
+ a.m_uds = uds;
+ a.m_str = s;
+ entry.append(a);
+}
+
+
+static void addAtom(UDSEntry& entry, unsigned int uds, long l)
+{
+ UDSAtom a;
+ a.m_uds = uds;
+ a.m_long = l;
+ entry.append(a);
+}
+
+
+static const UDSEntry pathToUDSEntry(const QString& path, const QString& display,
+ const QString& url = QString::null, const QString& icon = QString::null)
+{
+ UDSEntry entry;
+ addAtom(entry, KIO::UDS_NAME, display);
+
+ if (!path.isEmpty()) {
+ struct stat info;
+ lstat(path.local8Bit(), &info);
+
+ addAtom(entry, KIO::UDS_SIZE, info.st_size);
+ addAtom(entry, KIO::UDS_ACCESS, info.st_mode);
+ addAtom(entry, KIO::UDS_MODIFICATION_TIME, info.st_mtime);
+ addAtom(entry, KIO::UDS_ACCESS_TIME, info.st_atime);
+ addAtom(entry, KIO::UDS_CREATION_TIME, info.st_ctime);
+
+ struct passwd * user = getpwuid(info.st_uid);
+ struct group * group = getgrgid(info.st_gid);
+ addAtom(entry, KIO::UDS_USER, ((user != NULL) ? user->pw_name : "???" ));
+ addAtom(entry, KIO::UDS_GROUP, ((group != NULL) ? group->gr_name : "???" ));
+
+ if (url.isEmpty()) {
+ // List an existing file.
+ addAtom(entry, KIO::UDS_URL, "file:" + path);
+
+ mode_t type = info.st_mode;
+ if (S_ISLNK(type)) {
+ QString slink = QString::null;
+ char buff[1000];
+ int n = readlink(path, buff, 1000);
+ if (n != -1) {
+ buff[n] = 0;
+ slink = buff;
+ }
+ addAtom(entry, KIO::UDS_LINK_DEST, slink);
+ } else {
+ type &= S_IFMT;
+ }
+ addAtom(entry, KIO::UDS_FILE_TYPE, type);
+
+#ifdef HAVE_UDS_HIDDEN
+ if (path.contains("/.")) {
+ addAtom(entry, KIO::UDS_HIDDEN, 1);
+ }
+#endif
+ } else {
+ // List a locate link.
+ addAtom(entry, KIO::UDS_URL, url);
+ addAtom(entry, KIO::UDS_FILE_TYPE, S_IFDIR);
+ }
+ } else {
+ addAtom(entry, KIO::UDS_URL, url);
+ }
+
+ if (!icon.isEmpty()) {
+ addAtom(entry, KIO::UDS_ICON_NAME, icon);
+ }
+
+ return entry;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// INITIALIZATION
+
+LocateProtocol::LocateProtocol(const QCString &pool_socket, const QCString &app_socket)
+ : SlaveBase("kio_locate", pool_socket, app_socket)
+{
+ DEBUGSTR << "LocateProtocol::LocateProtocol()" << endl;
+
+ connect(&m_locater, SIGNAL(found(const QStringList&)),
+ this, SLOT(processLocateOutput(const QStringList&)));
+ connect(&m_locater, SIGNAL(finished()),
+ this, SLOT(locateFinished()));
+
+ m_baseDir = NULL;
+ m_curDir = NULL;
+}
+
+
+LocateProtocol::~LocateProtocol()
+{
+ DEBUGSTR << "LocateProtocol::~LocateProtocol()" << endl;
+
+ delete m_baseDir;
+}
+
+
+const LocateRegExp& LocateProtocol::getRegExp() const
+{
+ return m_locateRegExp;
+}
+
+
+int LocateProtocol::getCollapseDirectoryThreshold() const
+{
+ return m_config.m_collapseDirectoryThreshold;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// KIO STUFF
+
+void LocateProtocol::setUrl(const KURL& url)
+{
+ if (url.protocol() != "locater") {
+ QString pattern = KURL::decode_string(url.url());
+ pattern = pattern.mid(url.protocol().length() + 1);
+
+ KURL newUrl;
+ newUrl.setProtocol("locater");
+
+ if (pattern.isEmpty() || pattern == "/") {
+ // Give help.
+ newUrl.setPath("help");
+ } else if (hasTrailingSlash(pattern)) {
+ // Detect auto-completion from within konqueror and "stop"
+ // this search.
+ newUrl.setPath("autosearch");
+ newUrl.addQueryItem(queryQuery, pattern);
+ } else if (url.protocol() == "rlocate") {
+ // Standard regexp search.
+ newUrl.setPath("search");
+ newUrl.addQueryItem(queryQuery, pattern);
+ newUrl.addQueryItem(queryRegExp, "1");
+ } else {
+ // Standard wildcard search.
+ newUrl.setPath("search");
+ newUrl.addQueryItem(queryQuery, pattern);
+ }
+ m_url = newUrl;
+
+ DEBUGSTR << "Redirect: " << m_url << endl;
+ } else {
+ m_url = url;
+ }
+ // Perhaps this will be unneccessary most times, but who knows...
+ updateConfig();
+}
+
+void LocateProtocol::get(const KURL& url)
+{
+ DEBUGSTR << "LocateProtocol::get(" << url << ")" << endl;
+
+ setUrl(url);
+
+ if (isSearchRequest()) {
+ if (m_locater.binaryExists()) {
+ error(KIO::ERR_IS_DIRECTORY, QString::null);
+ } else {
+ QString html = i18n("<h1>\"%1\" could not be started.</h1><p>Please note that kio-locate can't be used on its own. You need an additional program for doing searches. Typically this is the command line tool <i>locate</i> that can be found in many distributions by default. You can check if the correct tool is used by looking at the <a href=\"locater:config\">setting</a> \"Locate Binary\".<p>Besides the mentioned tool <i>locate</i>, kio-locate can use any tool that uses the same syntax. In particular, it was reported to work with <i>slocate</i> and <i>rlocate</i>.").arg(m_locater.binary());
+ outputHtml(html);
+ }
+ } else if (isConfigRequest()) {
+ configRequest();
+ } else if (isHelpRequest()) {
+ helpRequest();
+ } else {
+ // What's this?
+ error(KIO::ERR_DOES_NOT_EXIST, QString::null);
+ }
+}
+
+
+void LocateProtocol::stat(const KURL& url)
+{
+ DEBUGSTR << "LocateProtocol::stat(" << url << ")" << endl ;
+
+ setUrl(url);
+
+ if (isSearchRequest() || isConfigRequest() || isHelpRequest()) {
+ bool isDir = isSearchRequest() && m_locater.binaryExists();
+ /// \todo Is UDS_NAME used for anything in stat? If so we should
+ /// at least strip of the protocol part.
+ UDSEntry entry;
+ addAtom(entry, KIO::UDS_NAME, url.decode_string(url.url()));
+ addAtom(entry, KIO::UDS_FILE_TYPE, isDir ? S_IFDIR : S_IFREG);
+ statEntry(entry);
+ finished();
+ /// \todo Somehow locate: and locate:/ is thought to be a directory
+ /// by konqueror anyway. How to change this?
+ } else {
+ // What's this?
+ error(KIO::ERR_DOES_NOT_EXIST, QString::null);
+ }
+}
+
+
+void LocateProtocol::listDir(const KURL& url)
+{
+ DEBUGSTR << "LocateProtocol::listDir(" << url << ")" << endl ;
+
+ setUrl(url);
+
+ if (isSearchRequest()) {
+ searchRequest();
+ } else if (isConfigRequest() || isHelpRequest()) {
+ error(KIO::ERR_IS_FILE, QString::null);
+ } else {
+ // What's this?
+ error(KIO::ERR_DOES_NOT_EXIST, QString::null);
+ }
+}
+
+
+void LocateProtocol::mimetype(const KURL& url)
+{
+ DEBUGSTR << "LocateProtocol::mimetype(" << url << ")" << endl ;
+
+ setUrl(url);
+
+ if (isSearchRequest()) {
+ if (m_locater.binaryExists()) {
+ mimeType("inode/directory");
+ } else {
+ mimeType("text/html");
+ }
+ } else if (isConfigRequest() || isHelpRequest()) {
+ mimeType("text/html");
+ }
+ finished();
+}
+
+
+void LocateProtocol::outputHtml(const QString& body)
+{
+ mimeType("text/html");
+
+ QString theData = "<html><body>" + body + "</body></html>";
+ data(theData.local8Bit());
+ finished();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// SEARCHING
+
+bool LocateProtocol::isSearchRequest()
+{
+ return m_url.path() == "search";
+}
+
+
+void LocateProtocol::searchRequest()
+{
+ // Reset old values.
+ m_caseSensitivity = caseAuto;
+ m_useRegExp = false;
+ m_locatePattern = QString::null;
+ m_locateDirectory = QString::null;
+ m_regExps.clear();
+ m_pendingPath = QString::null;
+
+ delete m_baseDir;
+ m_baseDir = NULL;
+ m_curDir = NULL;
+
+ updateConfig();
+
+ QString query = m_url.queryItem(queryQuery);
+ m_locateDirectory = addTrailingSlash(m_url.queryItem(queryDirectory));
+
+ QString caseSensitivity = m_url.queryItem(queryCase);
+ if (caseSensitivity == "sensitive") {
+ m_caseSensitivity = caseSensitive;
+ } else if (caseSensitivity == "insensitive") {
+ m_caseSensitivity = caseInsensitive;
+ }
+
+ QString useRegExp = m_url.queryItem(queryRegExp);
+ if (!useRegExp.isEmpty() && useRegExp != "0") {
+ m_useRegExp = true;
+ }
+
+ // Split query into components. The first component is the query
+ // for locate. The others are filtering regular expressions. They are
+ // delimited by (not escaped) whitespace.
+ // If the last component starts with two backslahes \\, then the search
+ // is only to be done within the directory following them.
+ query = query.simplifyWhiteSpace();
+ int s = 0;
+ int n = query.length();
+ bool regexp;
+ QString display;
+ for (int i = 0; i <= n; i++) {
+ if ((i == n) || ((query[i] == ' ') && (i > 0)
+ && (query[i-1] != '\\') && (i-s > 0))) {
+ QString temp = query.mid(s, i-s);
+ QString part = partToPattern(temp, s==0);
+ if (s == 0) {
+ // We don't want to show the escaped regexpified string to
+ // the user, so we store the string we get in for later display.
+ display = temp;
+ // This is the same check as in partToPattern.
+ // ie. regexp is used if locate pattern contains wildcards,
+ // or regexp searching was enabled.
+ regexp = hasWildcards(temp);
+ m_locatePattern = part;
+ } else {
+ // For each regular expression determine if it should be
+ // case sensitive.
+ m_regExps += LocateRegExp(part, !isCaseSensitive(part));
+ }
+ s = i+1;
+ }
+ }
+
+ DEBUGSTR << "Pattern: " << m_locatePattern << endl;
+ DEBUGSTR << "Directory: " << m_locateDirectory << endl;
+
+ // We set up the regexp used to see whether the match was in the
+ // directory part or the filename part of a path.
+ m_locateRegExp = LocateRegExp(convertWildcardsToRegExp(m_locatePattern), !isCaseSensitive(m_locatePattern));
+
+ // Now perform the search...
+ infoMessage(i18n("Locating %1 ...").arg(display));
+
+ bool started = m_locater.locate(m_locatePattern, !isCaseSensitive(m_locatePattern), regexp);
+
+ if (!started) {
+ DEBUGSTR << "Locate could not be found." << endl;
+ finished();
+ }
+}
+
+
+bool LocateProtocol::isCaseSensitive(const QString& text)
+{
+ if (m_caseSensitivity == caseSensitive) {
+ return true;
+ } else if (m_caseSensitivity == caseInsensitive) {
+ return false;
+ } else if (m_config.m_caseSensitivity == caseSensitive) {
+ return true;
+ } else if (m_config.m_caseSensitivity == caseInsensitive) {
+ return false;
+ } else {
+ return text != text.lower();
+ }
+}
+
+
+void LocateProtocol::addHit(const QString& path, int subItems)
+{
+ // DEBUGSTR << "LocateProtocol::addHit( " << path << ", " << subItems << " )" << endl;
+ if (QFile::exists(path)) {
+ if (subItems > 0) {
+ m_entries += pathToUDSEntry(path, pathToDisplay(path, subItems), makeLocaterUrl(path), iconToStringTable[m_config.m_collapsedIcon]);
+ } else {
+ m_entries += pathToUDSEntry(path, pathToDisplay(path));
+ }
+ }
+}
+
+
+void LocateProtocol::addPreviousLocateOutput()
+{
+ if (m_baseDir == NULL) {
+ return;
+ }
+ // m_baseDir->debugTrace();
+ if (m_locateDirectory == "/") {
+ // Allow toplevel directories to collapse (e.g. when locating "/usr/").
+ m_baseDir->prepareListing(this, 0);
+ } else {
+ m_baseDir->prepareListing(this, m_locateDirectory.length());
+ }
+ m_baseDir->listItems(this);
+ delete m_baseDir;
+ m_baseDir = NULL;
+ m_curDir = NULL;
+
+ listEntries(m_entries);
+ m_entries.clear();
+}
+
+
+void LocateProtocol::processPath(const QString &path, const QString &nextPath)
+{
+ if (!nextPath) {
+ // We need to know the next path, so we remember this path for later processing.
+ m_pendingPath = path;
+ } else if (!nextPath.startsWith(path + '/')) {
+ if (isMatching(path)) {
+ if ((m_baseDir != NULL) && !path.startsWith(m_baseDir->m_path)) {
+ addPreviousLocateOutput();
+ }
+ // Add path to current directory.
+ if (m_baseDir == NULL) {
+ int p = path.find('/', 1);
+ QString base = path;
+ if (p >= 0) {
+ base = path.left(p+1);
+ }
+ m_baseDir = new LocateDirectory(NULL, base);
+ m_curDir = m_baseDir;
+ }
+ m_curDir = m_curDir->addPath(path);
+ }
+ }
+}
+
+
+void LocateProtocol::processLocateOutput(const QStringList& items)
+{
+ // I don't know if this really necessary, but if we were signaled, we'll
+ // better stop.
+ if (wasKilled()) {
+ m_locater.stop();
+ return;
+ }
+ // Go through what we have found.
+ QStringList::ConstIterator it = items.begin();
+ if (m_pendingPath) {
+ processPath(m_pendingPath, *it);
+ m_pendingPath = QString::null;
+ }
+ for (; it != items.end();) {
+ QString path = *it;
+ ++it;
+ processPath(path, it != items.end() ? *it : QString::null);
+ }
+}
+
+
+void LocateProtocol::locateFinished()
+{
+ // Add any pending items.
+ if (m_pendingPath) {
+ processPath(m_pendingPath, "");
+ m_pendingPath = QString::null;
+ }
+ addPreviousLocateOutput();
+
+ DEBUGSTR << "LocateProtocol::locateFinished" << endl;
+ infoMessage(i18n("Finished."));
+ finished();
+}
+
+
+QString LocateProtocol::partToPattern(const QString& part, bool forLocate)
+{
+ DEBUGSTR << "BEG part: " << part << endl;
+ QString pattern = part;
+ // Unescape whitespace.
+ pattern.replace("\\ ", " ");
+ // Unquote quoted pattern.
+ int n = pattern.length(), index;
+ if ((n > 1) && (pattern[0] == '"') && (pattern[n-1] == '"')) {
+ pattern = pattern.mid(1, n-2);
+ }
+
+ // We can't do regular expression matching on the locate pattern,
+ // the regular expression format used by locate is incompatible
+ // with the format used by QRegExp.
+ if (!m_useRegExp || forLocate) {
+ // Escape regexp characters for filtering pattern, and for locate,
+ // but the latter only if it is actually necessary to pass a regexp to locate.
+ // (ie. the pattern contains wildcards.)
+ if (!forLocate || hasWildcards(pattern)) {
+ pattern = convertWildcardsToRegExp(pattern);
+ } else {
+ // Special case for locate pattern without wildcards:
+ // Unescape all escaped wildcards.
+ pattern.replace("\\*", "*");
+ pattern.replace("\\+", "+");
+ pattern.replace("\\?", "?");
+ pattern.replace("\\[", "[");
+ pattern.replace("\\]", "]");
+ }
+ }
+
+ // Special treatment for the pattern used for locate:
+ if (forLocate) {
+ // Replace ~/ and ~user/ at the beginning (as the shell does)
+ if ((pattern.length() > 0) && (pattern[0] == '~')) {
+ index = pattern.find('/');
+ if (index >= 0) {
+ QString name = pattern.mid(1, index-1);
+ QString homeDir;
+ if (name.isEmpty()) {
+ homeDir = KUser(KUser::UseRealUserID).homeDir();
+ } else {
+ homeDir = KUser(name).homeDir();
+ }
+ if (!homeDir.isEmpty()) {
+ pattern.replace(0, index, homeDir);
+ }
+ }
+ }
+ pattern.replace("\\~", "~");
+ }
+ DEBUGSTR << "END part: " << pattern << endl;
+ return pattern;
+}
+
+
+bool LocateProtocol::isMatching(const QString& path)
+{
+ // The file has to belong to our directory.
+ if (!path.startsWith(m_locateDirectory)) {
+ return false;
+ }
+ // And it has to match at least one regular expression in the whitelist.
+ if (!m_config.m_whiteList.isMatchingOne(path)) {
+ return false;
+ }
+ // And it may not match any regular expression in the blacklist.
+ if (m_config.m_blackList.isMatchingOne(path)) {
+ return false;
+ }
+ // And it has to match against all regular expressions specified in the URL.
+ if (!m_regExps.isMatchingAll(path)) {
+ return false;
+ }
+ // And it must not solely match m_locateDirectory.
+ return m_locateRegExp.isMatching(path.mid(m_locateDirectory.length()));
+}
+
+
+QString LocateProtocol::pathToDisplay(const QString& path, int subItems)
+{
+ // Split off the directory part. If it is not just the minimal '/'.
+ QString display = path;
+ if ((m_locateDirectory != "/") && display.startsWith(m_locateDirectory)) {
+ display = display.mid(m_locateDirectory.length());
+ }
+ if (subItems > 0) {
+ // Can't use m_collapsedDisplay.arg(subItems).arg(display); here
+ // because user might forget to type %1 or %2, or type it twice.
+ // In both cases the result of arg() is undefined.
+ QString output = m_config.m_collapsedDisplay, temp;
+ temp.setNum(subItems);
+ output.replace("%1", temp);
+ output.replace("%2", display);
+ display = output;
+ }
+ return display;
+}
+
+
+QString LocateProtocol::makeLocaterUrl(const QString& directory)
+{
+ KURL url(m_url);
+ url.removeQueryItem(queryDirectory);
+ url.addQueryItem(queryDirectory, directory);
+ return url.url();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// CONFIG
+
+bool LocateProtocol::isConfigRequest()
+{
+ return m_url.path() == "config";
+}
+
+
+void LocateProtocol::configRequest()
+{
+ // This flag is used to show either a "succesful" or an "unchanged" message
+ // in configFinished().
+ m_configUpdated = false;
+
+ // Don't show it twice. During my tests I never got there however.
+ if(KConfigDialog::showDialog("settings"))
+ return;
+
+ KConfigDialog *dialog = new KConfigDialog(0, "settings", KLocateConfig::self(),
+ KDialogBase::IconList,
+ KDialogBase::Default|KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::Help,
+ KDialogBase::Ok, true);
+ dialog->setCaption(i18n("Configure - kio-locate"));
+ dialog->setIcon(SmallIcon("find"));
+
+ dialog->addPage(new KLocateConfigWidget(), i18n("General"), "package_settings");
+ dialog->addPage(new KLocateConfigFilterWidget(), i18n("Filters"), "filter");
+ dialog->addPage(new KLocateConfigLocateWidget(), i18n("Locate"), "find");
+
+ // React on user's actions.
+ connect(dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfig()));
+ connect(dialog, SIGNAL(finished()), this, SLOT(configFinished()));
+
+ dialog->show();
+ qApp->enter_loop();
+ delete dialog;
+}
+
+
+void LocateProtocol::configFinished()
+{
+ DEBUGSTR << "LocateProtocol::configFinished" << endl;
+
+ qApp->exit_loop();
+
+ QString html;
+ if (m_configUpdated) {
+ html = i18n("Configuration succesfully updated.");
+ } else {
+ html = i18n("Configuration unchanged.");
+ }
+ outputHtml("<h1>" + html + "</h1>");
+}
+
+
+void LocateProtocol::updateConfig()
+{
+ // It's not needed to update the config if it's still up to date.
+ DEBUGSTR << "LocateProtocol::updateConfig" << endl;
+
+ KLocateConfig::self()->readConfig();
+ m_config.m_caseSensitivity = (LocateCaseSensitivity) KLocateConfig::caseSensitivity();
+ m_config.m_collapseDirectoryThreshold = KLocateConfig::collapseDirectoryThreshold();
+ m_config.m_collapsedDisplay = KLocateConfig::collapsedDisplay();
+ m_config.m_collapsedIcon = (LocateCollapsedIcon) KLocateConfig::collapsedIcon();
+ m_config.m_whiteList = KLocateConfig::whiteList();
+ m_config.m_blackList = KLocateConfig::blackList();
+
+ m_locater.setupLocate(KLocateConfig::locateBinary(),
+ KLocateConfig::locateAdditionalArguments());
+
+ m_configUpdated = true;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// HELP
+
+bool LocateProtocol::isHelpRequest()
+{
+ return m_url.path() == "help";
+}
+
+
+void LocateProtocol::helpRequest()
+{
+ // Redirect the user to our help documents.
+ redirection("help:/kio-locate/");
+ finished();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// SEARCH STRUCTURES
+
+LocateDirectory::LocateDirectory(LocateDirectory *parent, const QString& path)
+{
+ m_parent = parent;
+ m_path = path;
+ m_childs.setAutoDelete(true);
+ m_itemsCount = 0;
+}
+
+
+LocateDirectory *LocateDirectory::addPath(const QString& path)
+{
+ if (path.startsWith(m_path)) {
+ QString relPath = path.mid(m_path.length());
+ int p = relPath.findRev('/');
+ if (p >= 0) {
+ LocateDirectory *child = getSubDirectory(relPath.left(p));
+ child->addItem(relPath.mid(p+1));
+ return child;
+ }
+ addItem(relPath);
+ return this;
+ }
+ if (m_parent != NULL) {
+ return m_parent->addPath(path);
+ }
+ // This should not happen
+ return this;
+}
+
+
+LocateDirectory *LocateDirectory::getSubDirectory(const QString& relPath)
+{
+ QString base = relPath;
+ int p = relPath.find('/');
+ if (p >= 0) {
+ base = relPath.left(p);
+ }
+ LocateDirectory *child = m_childs.find(base);
+ if (child == NULL) {
+ child = new LocateDirectory(this, addTrailingSlash(m_path + base));
+ m_childs.insert(base, child);
+ }
+ if (p >= 0) {
+ return child->getSubDirectory(relPath.mid(p+1));
+ }
+ return child;
+}
+
+
+void LocateDirectory::addItem(const QString& path)
+{
+ m_items += LocateItem(m_path + path, 0);
+ m_itemsCount++;
+}
+
+
+int LocateDirectory::countMatchingItems(const LocateProtocol* protocol, int skip)
+{
+ int count = 0;
+ LocateItems::ConstIterator item = m_items.begin();
+ for (; item != m_items.end(); ++item) {
+ if ((*item).m_subItems) {
+ count += (*item).m_subItems;
+ } else if (protocol->getRegExp().isMatching((*item).m_path.mid(skip))) {
+ ++count;
+ }
+ }
+ return count;
+}
+
+
+void LocateDirectory::prepareListing(const LocateProtocol* protocol, int skip)
+{
+ int n = m_path.length(), newSkip = n;
+ if (skip > newSkip) newSkip = skip;
+
+ // Recursively walk through all childs.
+ LocateDirectoriesIterator child(m_childs);
+ for (; child.current(); ++child) {
+ child.current()->prepareListing(protocol, newSkip);
+ }
+
+ // Set m_fullCount to the total number of childs matching the pattern.
+ m_fullCount = countMatchingItems(protocol, newSkip);
+
+ // Collapse if directory part matches.
+ LocateDirectory* parent = m_parent;
+ if (parent == NULL) {
+ parent = this;
+ }
+ if (n > skip && protocol->getRegExp().isMatching(m_path.mid(skip))) {
+ // Directory part matches.
+ m_childs.clear();
+ m_items.clear();
+ m_itemsCount = 0;
+ parent->m_items += LocateItem(m_path, m_fullCount);
+ ++parent->m_itemsCount;
+ if (m_fullCount != 0) {
+ parent->m_items += LocateItem(m_path, 0);
+ ++parent->m_itemsCount;
+ }
+ }
+
+ // Collapse if we got too many hits.
+ int maxHits = protocol->getCollapseDirectoryThreshold();
+ if (n > skip && maxHits != 0 && m_itemsCount > maxHits) {
+ if (m_parent != NULL) {
+ m_parent->m_items += LocateItem(m_path, m_fullCount);
+ ++m_parent->m_itemsCount;
+ } else {
+ m_items.clear();
+ m_items += LocateItem(m_path, m_fullCount);
+ ++m_itemsCount;
+ }
+ } else {
+ // Propagate items to parent.
+ // (only root LocateDirectory runs listItems)
+ if (m_parent != NULL) {
+ m_parent->m_items += m_items;
+ m_parent->m_itemsCount += m_itemsCount;
+ }
+ }
+}
+
+
+void LocateDirectory::listItems(LocateProtocol *protocol)
+{
+ LocateItems::ConstIterator item = m_items.begin();
+ for (; item != m_items.end(); ++item) {
+ protocol->addHit(stripTrailingSlash((*item).m_path), (*item).m_subItems);
+ }
+}
+
+
+void LocateDirectory::debugTrace(int level)
+{
+ QString ws;
+ ws.fill(' ', level);
+ DEBUGSTR << ws << m_path << endl;
+ LocateItems::ConstIterator item = m_items.begin();
+ for (; item != m_items.end(); ++item) {
+ DEBUGSTR << ws << "+ " << (*item).m_path << endl;
+ }
+ LocateDirectoriesIterator child(m_childs);
+ for (; child.current(); ++child) {
+ child.current()->debugTrace(level+2);
+ }
+}
+
+
+LocateItem::LocateItem()
+{
+}
+
+
+LocateItem::LocateItem(const QString& path, int subItems)
+{
+ m_path = path;
+ m_subItems = subItems;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// INVOKATION
+
+extern "C"
+{
+ int kdemain(int argc, char **argv)
+ {
+ // We use KApplication instead of KInstance here, because we use a
+ // config dialog and such gui stuff.
+ KApplication app(argc, argv, "kio_locate", false, true);
+
+ DEBUGSTR << "*** Starting kio_locate " << endl;
+
+ if (argc != 4) {
+ DEBUGSTR << "Usage: kio_locate protocol domain-socket1 domain-socket2" << endl;
+ exit(-1);
+ }
+
+ LocateProtocol slave(argv[2], argv[3]);
+ slave.dispatchLoop();
+
+ DEBUGSTR << "*** kio_locate Done" << endl;
+ return 0;
+ }
+}
+
+
+#include "kio_locate.moc"
diff --git a/src/kio_locate.h b/src/kio_locate.h
new file mode 100644
index 0000000..d5df32c
--- /dev/null
+++ b/src/kio_locate.h
@@ -0,0 +1,273 @@
+/***************************************************************************
+ * kio-locate: KDE I/O Slave for the locate command *
+ * *
+ * Copyright (C) 2005 by Tobi Vollebregt *
+ * tobivollebregt@gmail.com *
+ * *
+ * Thanks to Google's Summer Of Code Program! *
+ * *
+ * Copyright (C) 2004 by Armin Straub *
+ * linux@arminstraub.de *
+ * *
+ * This program was initially written by Michael Schuerig. *
+ * Although I have completely rewritten it, most ideas are adopted *
+ * from his original work. *
+ * *
+ * Copyright (C) 2002 by Michael Schuerig *
+ * michael@schuerig.de *
+ * *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+/**
+ * \mainpage KDE I/O Slave for the locate command
+ *
+ * \section intro_sec What is kio-locate?
+ * kio-locate is a KDE I/O Slave for the locate command.
+ * <p>This means that you can use kio-locate by simply typing in konquerors
+ * address box. You can e.g. type "locate:index.html" to find all files that
+ * contain "index.html" in their name.
+ * <p>There's even more: You can use kio-locate in all KDE applications, that
+ * accept URLs.
+ * <p>To find out more about kio-locate and to look for new versions, you
+ * should take a look at
+ * <a href="http://arminstraub.de/browse.php?page=programs_kiolocate">
+ * arminstraub.de</a>.
+ *
+ *
+ * \todo Implement locater:help.
+ *
+ * \todo If a directory matches then don't add its childs.\ At least make
+ * this configurable.
+ *
+ * \todo Use different icons for collapsed directories and make this
+ * configurable.
+ *
+ * \todo After updating the settings show a success html message instead
+ * of a blank page.
+ *
+ * \todo Check if locate's databases are outdated and warn about that.
+ *
+ * \todo Provide a means of updating the locate database (configurable
+ * of course).
+ */
+
+#ifndef _kio_locate_H_
+#define _kio_locate_H_
+
+#include <qcstring.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qdict.h>
+#include <qvaluelist.h>
+
+#include <kio/global.h>
+#include <kio/slavebase.h>
+
+#include "locater.h"
+#include "pattern.h"
+
+class QCString;
+
+class KURL;
+
+
+class LocateItem;
+class LocateDirectory;
+
+typedef QValueList<LocateItem> LocateItems;
+typedef QDict<LocateDirectory> LocateDirectories;
+typedef QDictIterator<LocateDirectory> LocateDirectoriesIterator;
+
+enum LocateCaseSensitivity { caseAuto, caseSensitive, caseInsensitive };
+enum LocateCollapsedIcon { iconBlue, iconGreen, iconGrey, iconOrange, iconRed, iconViolet, iconYellow };
+
+
+/**
+ * Implementation of the kioslave for the locate protocol.
+ *
+ * Enables you to enter "locate:pattern" wherever an URL can be used
+ * in KDE.
+ */
+class LocateProtocol : public QObject, public KIO::SlaveBase
+{
+ Q_OBJECT
+ public:
+ /**
+ * Constructor
+ */
+ LocateProtocol(const QCString &pool_socket, const QCString &app_socket);
+
+ virtual ~LocateProtocol();
+
+ /**
+ * Returns the mimetype "inode/directory".
+ * @param url the url to work on
+ */
+ virtual void mimetype(const KURL& url);
+
+ /**
+ * Raises an error so that eyerone notes we are dealing with
+ * directories only.
+ * @param url the url to work on
+ */
+ virtual void get(const KURL& url);
+
+ /**
+ * Marks the url as a directory.
+ * @param url the url to work on
+ */
+ virtual void stat(const KURL& url);
+
+ /**
+ * Searches for the pattern specified in the url.
+ * Every file found is listed.
+ * @param url the url to work on
+ */
+ virtual void listDir(const KURL& url);
+
+ /**
+ * Actually report a hit.
+ * If subItems > 0 then this hit is a "directory subsearch".
+ * @param path the path of the hit
+ * @param subItems the number of hits beneath this one
+ * (or 0 for a regular hit)
+ */
+ virtual void addHit(const QString& path, int subItems = 0);
+
+ const LocateRegExp& getRegExp() const;
+ int getCollapseDirectoryThreshold() const;
+
+ private slots:
+ void processLocateOutput(const QStringList& items);
+ void locateFinished();
+ void configFinished();
+ void updateConfig();
+
+ private:
+ Locater m_locater;
+ KURL m_url;
+
+ QString m_locatePattern;
+ LocateRegExp m_locateRegExp; // Equals m_locatePattern, but regexp.
+ QString m_locateDirectory; // Includes a trailing slash.
+ LocateRegExpList m_regExps; // List of extra filtering regexps.
+
+ LocateCaseSensitivity m_caseSensitivity; // For current search.
+ bool m_useRegExp;
+
+ // Options
+ struct
+ {
+ LocateCaseSensitivity m_caseSensitivity; // Default case sensitivity.
+ int m_collapseDirectoryThreshold; // Maximum number of hits in a directory
+ // before a directory search is created
+ QString m_collapsedDisplay; // Format string used for collapsed directories.
+ LocateCollapsedIcon m_collapsedIcon; // Icon used for collapsed directories.
+ LocateRegExpList m_whiteList; // Path must match at least one regexp in this list.
+ LocateRegExpList m_blackList; // Path may not match any regexp in this list.
+ } m_config;
+
+ bool m_configUpdated; // Used in config methods to check if config was cancelled or okay'ed.
+ QString m_pendingPath; // Must be processed as soon as new output becomes available.
+
+ LocateDirectory *m_baseDir; // The toplevel directory, e.g. "/usr/".
+ LocateDirectory *m_curDir; // The current directory (while locating).
+
+ KIO::UDSEntryList m_entries; // Used to cache a lot of hits and list them all at once.
+
+ QString partToPattern(const QString& part, bool forLocate);
+ bool isMatching(const QString& file);
+ QString pathToDisplay(const QString& path, int subItems = 0);
+ void addPreviousLocateOutput();
+ void processPath(const QString &path, const QString &nextPath);
+
+ bool isSearchRequest();
+ bool isConfigRequest();
+ bool isHelpRequest();
+
+ void searchRequest();
+ void configRequest();
+ void helpRequest();
+
+ bool isCaseSensitive(const QString& text);
+
+ /**
+ * Composes a locater:... url for the current search parameters
+ * bound to a given directory.
+ * @param directory the directory in which we should be searched
+ * @return the url that envokes the specified search
+ */
+ QString makeLocaterUrl(const QString& dir);
+
+ /**
+ * This function has to check whether we are accessed via the standard
+ * locater protocol. If this is not the case we have to redirect
+ * this access to an access via the locater protocol.
+ * There are other ways, that I have tried to achieve this:
+ * - Use a search provider. This works perfectly for konqueror but
+ * not for any other KDE application.
+ * - Really use redirection. But this turned out not to be a good
+ * solution. Seemed not to work from OpenDialogs ...
+ * - So no we just internally redirect... Works, isn't it?
+ */
+ void setUrl(const KURL& url);
+
+ void outputHtml(const QString& body);
+};
+
+
+/**
+ * Internally used class to represent a hit as kio-locate will
+ * report.
+ *
+ * This may either be a path as given by locate or a directory
+ * search (if the number of subItems is set to a positive number).
+ */
+class LocateItem
+{
+ public:
+ LocateItem();
+ LocateItem(const QString& path, int subItems);
+
+ public:
+ QString m_path;
+ int m_subItems;
+};
+
+
+/**
+ * Internally used class to represent a directory while kio-locate
+ * gathers data from locate.
+ *
+ * Each directory has a list of files found in just that directory
+ * and a list of all subdirectories.
+ */
+class LocateDirectory
+{
+ public:
+ LocateDirectory(LocateDirectory *parent, const QString& path);
+
+ LocateDirectory *addPath(const QString& path);
+ void prepareListing(const LocateProtocol* protocol, int skip);
+ void listItems(LocateProtocol *protocol);
+ void debugTrace(int level = 0);
+
+ public:
+ QString m_path; // Including trailing slash.
+ LocateDirectory *m_parent;
+ LocateDirectories m_childs;
+ LocateItems m_items;
+ int m_itemsCount;
+ int m_fullCount;
+
+ LocateDirectory *getSubDirectory(const QString& relPath);
+ void addItem(const QString& path);
+ int countMatchingItems(const LocateProtocol *protocol, int skip);
+};
+
+#endif
diff --git a/src/kio_locate.kcfg b/src/kio_locate.kcfg
new file mode 100644
index 0000000..e0fdddc
--- /dev/null
+++ b/src/kio_locate.kcfg
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+
+ <kcfgfile name="kio_locaterc"/>
+ <include>klocale.h</include>
+ <group name="General">
+ <entry name="caseSensitivity" type="Int">
+ <label>Case sensitivity</label>
+ <whatsthis>0 for automatic case sensitivity determination (lowercase pattern -> case insensitive, upper- or mixedcase pattern -> case sensitive), 1 for case sensitive and 2 for case insensitive.</whatsthis>
+ <default>0</default>
+ </entry>
+
+ <entry name="collapseDirectoryThreshold" type="Int">
+ <label>Collapse directory</label>
+ <whatsthis>Collapse a directory with more hits.</whatsthis>
+ <default>5</default>
+ </entry>
+
+ <entry name="collapsedDisplay" type="String">
+ <label>How to display a collapsed directory entry</label>
+ <whatsthis>Hint: %1 is substituted by the number of hits, %2 by the name of the directory.</whatsthis>
+ <default code="true">i18n("(%1 Hits) %2")</default>
+ </entry>
+
+ <entry name="collapsedIcon" type="Int">
+ <label>Icon to use for a collapsed directory entry</label>
+ <whatsthis>0-Blue, 1-Green, 2-Grey, 3-Orange, 4-Red, 5-Violet, 6-Yellow</whatsthis>
+ <default>1</default>
+ </entry>
+ </group>
+
+ <group name="Filtering">
+ <entry name="whiteList" type="StringList">
+ <label>White list</label>
+ <whatsthis>A path must match at least one of these regular expressions.</whatsthis>
+ <default>.</default>
+ </entry>
+
+ <entry name="blackList" type="StringList">
+ <label>Black list</label>
+ <whatsthis>A path may not match any of these regular expressions.</whatsthis>
+ <default></default>
+ </entry>
+ </group>
+
+ <group name="Locate">
+ <entry name="locateBinary" type="String">
+ <label>Locate Binary</label>
+ <default></default>
+ </entry>
+
+ <entry name="locateAdditionalArguments" type="String">
+ <label>Additional Arguments for locate</label>
+ <whatsthis>Do not use -r or -i here. The first will confuse kio-locate, while the latter can be changed through the caseSensitivity option.</whatsthis>
+ <default></default>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/src/klocateconfig.kcfgc b/src/klocateconfig.kcfgc
new file mode 100644
index 0000000..453e65f
--- /dev/null
+++ b/src/klocateconfig.kcfgc
@@ -0,0 +1,6 @@
+# Code generation options for kconfig_compiler
+File=kio_locate.kcfg
+ClassName=KLocateConfig
+Singleton=true
+Mutators=true
+# will create the necessary code for setting those variables
diff --git a/src/klocateconfigfilterwidget.ui b/src/klocateconfigfilterwidget.ui
new file mode 100644
index 0000000..523e5c9
--- /dev/null
+++ b/src/klocateconfigfilterwidget.ui
@@ -0,0 +1,105 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KLocateConfigFilterWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KLocateConfigFilterWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>497</width>
+ <height>347</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>KLocateConfigFilterWidget</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox6</cstring>
+ </property>
+ <property name="title">
+ <string>Filter Settings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>A path must match at least one of the regular expressions in the White List and it must not match any of the expressions in the Black List for being displayed as a hit.</string>
+ </property>
+ <property name="textFormat">
+ <enum>RichText</enum>
+ </property>
+ </widget>
+ <widget class="KEditListBox" row="1" column="0">
+ <property name="name">
+ <cstring>kcfg_whiteList</cstring>
+ </property>
+ <property name="title">
+ <string>&amp;White List</string>
+ </property>
+ <property name="buttons">
+ <set>Remove|Add</set>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>A path must match at least one of these regular expressions.</string>
+ </property>
+ </widget>
+ <widget class="KEditListBox" row="1" column="1">
+ <property name="name">
+ <cstring>kcfg_blackList</cstring>
+ </property>
+ <property name="title">
+ <string>&amp;Black List</string>
+ </property>
+ <property name="buttons">
+ <set>Remove|Add</set>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>A path may not match any of these regular expressions.</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;i&gt;Hint:&lt;/i&gt; E.g. replacing the default '.' entry by '^/home/user/' will only allow hits in the home directory of user.</string>
+ </property>
+ <property name="textFormat">
+ <enum>RichText</enum>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;i&gt;Hint:&lt;/i&gt; Adding e.g. '/\.' will no longer display hidden files (this will be unnecessary in some next version of kde though).</string>
+ </property>
+ <property name="textFormat">
+ <enum>RichText</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>keditlistbox.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>keditlistbox.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/src/klocateconfiglocatewidget.ui b/src/klocateconfiglocatewidget.ui
new file mode 100644
index 0000000..e1fb7a8
--- /dev/null
+++ b/src/klocateconfiglocatewidget.ui
@@ -0,0 +1,211 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KLocateConfigLocateWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KLocateConfigLocateWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>567</width>
+ <height>385</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>KLocateConfigLocateWidget</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox4</cstring>
+ </property>
+ <property name="title">
+ <string>Locate Settings</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel3_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p&gt;kio-locate does not handle the settings of locate, because this setup varies among different distributions. There are even distributions that use replacements like slocate.&lt;/p&gt;
+&lt;p&gt;To configure locate you should take a look at the manpage of locate. Since most distributions use cron for updating locate's database, it may also be useful to take a look at the manpage of crontab.&lt;/p&gt;</string>
+ </property>
+ <property name="textFormat">
+ <enum>RichText</enum>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Locate Binary</string>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_3_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Use these settings only if you really know what you do. Otherwise the default should be ok.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_4</cstring>
+ </property>
+ <property name="text">
+ <string>Locate &amp;binary:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_locateBinary</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>81</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>kcfg_locateBinary</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;i&gt;Hint:&lt;/i&gt; If you don't specify a value here (which is the default), kio-locate will automatically pick slocate, rlocate or locate (in that order).</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout12</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_4_2</cstring>
+ </property>
+ <property name="text">
+ <string>Additional &amp;arguments:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_locateAdditionalArguments</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>51</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>kcfg_locateAdditionalArguments</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;i&gt;Hint:&lt;/i&gt; Do not use -r or -i here. The first will confuse kio-locate, and the latter can be changed through the "Case sensitivity" option.</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/src/klocateconfigwidget.ui b/src/klocateconfigwidget.ui
new file mode 100644
index 0000000..2e1d946
--- /dev/null
+++ b/src/klocateconfigwidget.ui
@@ -0,0 +1,391 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KLocateConfigWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KLocateConfigWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>442</width>
+ <height>298</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>KLocateConfigWidget</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>General Settings</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout10</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Case se&amp;nsitivity:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_caseSensitivity</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>284</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>Auto</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Sensitive</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Insensitive</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>kcfg_caseSensitivity</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>150</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;i&gt;Hint:&lt;/i&gt; With "Auto" case sensitivity a pattern will be case insensitive if it is lowercase and case sensitive if it is mixed- or uppercase.</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Collapsing Search Results</string>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Collapse a directory with more hits:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_collapseDirectoryThreshold</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>141</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>kcfg_collapseDirectoryThreshold</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Collapse a directory with more hits.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Text of a collapsed &amp;directory:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_collapsedDisplay</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>100</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>kcfg_collapsedDisplay</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;i&gt;Hint:&lt;/i&gt; %1 is substituted by the number of hits and %2 by the name of the directory.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Icon of a collapsed directory:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_collapsedIcon</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>161</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>Blue</string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image0</pixmap>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Green</string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image1</pixmap>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Grey</string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image2</pixmap>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Orange</string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image3</pixmap>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Red</string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image4</pixmap>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Violet</string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image5</pixmap>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Yellow</string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image6</pixmap>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>kcfg_collapsedIcon</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>150</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+</widget>
+<images>
+ <image name="image0">
+ <data format="PNG" length="1136">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000043749444154388d9d946f88545518c67f3b7347cea551eec49833667507ffac635acdd29a2e19ecc6464ebb8a9b164cf9410721dc224a0824a2c22ff9519420c824d3faa0ad41ba94e55ad6ba90b42bacb962e68cecb273d91d766eeb65ee69f6b8b70f77d6dd30f0cff3e570e03dbff739cf793941ee459aa1c756b66f7c66f3be4fae3b2ae4483922c20fcd5565ab3455527397c0a06136d4a79ab7b6373436ac935a7c4ed7b727fa13517dbcb7af3797fff1bdd741fe0da0dd29d358b07a49726dfb6be9d674464423f37216c8d112ab5735d4f65c90976c5588a361a0b8152cc231216289650076beef024a56442c154f36665e6d6a79715b6a4562d1804d4d61c8459f009b083d97dc9adca0bc219461a019f7a3ac6bd3604d04cca733f54d9bb26fb4ad493d9f77e4e4e12f3a3eb70bb96be90dd9cdabeb137512b4812117a120a2e9f48d42ce0284ae19213b2e893b68910560f5f96021428ddbf66dcf6ec9bc935eaecf270475e824cdecdbaec2d335820316946c97b8d0b95884fc28146c1080841aa119115b163c114e98d2190020105b9a5e98dd9279f395943e5f84fc4824908812888409e62c1f100febe41cb05d4081d0fc3a14e01212447484590bcc0208d84ee11fa4bc3195b3acaeaeaa1e522e86809c33b5afd629bfa16b038a00a02396d582300002a9b5ed2df1a8884e41c5cdd1829c0d86d0b16515a2a69b0a40daa0cb6a13618410e642118e99008148d4a84dc674c3e56666b82ef45d011c10c23f28673845f95024b8d20520b95806b6b6c617602c5b0910bc2ea5b362cdba171e9b17bacf01064bd03f04f130cc9e03c50a941c9093201d70ca20c7fda6b20cb36729d6d7db649b25894708f6ffe54c58574e7f17b0ce779debfca1e78c3b0185eb902b42caf4937215c86ae852829ca8aed51ba44c971d1b6c32cd121176d101636efc71446c71102555a9a2d1d4bcbe5569687a002211702a604bffdac5aa3bbbecbbd627e1e514bcb4c661494c838a2437a4f8f8eb9ec2b99f3b0fcb627f9706605de8faa9e374eff9ec86ba551725c4abce50d3f0a92949c6a06d05240cffbf29146d3a7f2954f61fe9ecce9f3fbc17277f0a18d70064313fda79ace3ab7463dd4a1401b73aa733472b22a029054d26800b4ad077c962ff91de42c7b1cf0e4aebec0194fd273009109c9a2ecb1ab412cb9f6b8e3f38f7819a80ff58b68452191206ac5f020d0f0301508ee2cbef072a1feeed3873fa9bddefabb173079994c380c7ff29d9b2e3ada3bddec4f1cb9e776ac4f38e5ef5bc3f46bcffe8eae5b2b775e7f121c36cfb0844addfea361286392fb3bbfbd743bf79deef639e37569906962b9e77b46b58a65a769d246cae0366df163853b127331bb7ef1f1e1f1e9b860e8f78debb7bba078da56dbbd0c4a23b72798b34a19b9b3e3d70e88c4f3e7e7658366ede7792b0d90a84ef1e3843229a7a34bdb3bb6fc79eeeabb127321fdcbbcb5bd135c4524f09c37c96bbcdb2aa7f01e2660a8dfb27078d0000000049454e44ae426082</data>
+ </image>
+ <image name="image1">
+ <data format="PNG" length="1276">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000004c349444154388d955451681c55143dbb99a46fcaa6ddd5adce486a76a5d5cc62c4867eb8512909feb816d12952bbb18211a9b445a8890af6332a141205493e84b622a42dd5742b9444a19248216d699b9d62da8e92a52f1fa5b392907936e3ce257dcdf8319bb4552bf5c1e5f26698f3ce3be7ce89044180ffbb5cd7ad2d5c2c6c1a991ad94b826accf566a7e33a8d669b6965d299390088fc4fe0c8b035dc34668fedf075ff7591140ff349fe872ef4a2231dad15adeff7bed7fb230028f705771328968a0d23d3236f8a98e8749bddc76cb223b806a4f5f46a0ebed62a597354a2b5beeb434da87703bbaecb0a970acdae70eb3a9ee928ea6b749fcff0f8a10b874c2ef9cec4bac4d336d935eeac0b1d3a100346c5288410b544544ba04749125454817ddf8f162e155a2c61edd634ed259bd9caee93bb8f18f5c60562b495a5d8262858519c2d42870e2da6c1220b5c700000632c4992161de9343a65a72eb126b1a038334eddc0c5811d4c631f6637661bb8e4d0a50e8ad3bbae741755a6466dcf8e400046ccc0b49c06270e971c000081c0185b09895502a2c1be66afce346766a2a7a74f1bf164bc7bc3ba0d0db6b421204020e8313d4231aae11e8fa4a141d334d88a054772f8d207c042b660204111c6980a059a35693d020051e18905482c966539145a86cd973e20012619e2c9046c69812481aaef212964ec12e00150b002313cc0057f1c3781a8edd9cfa931b59e2d3150c2ae2a2a8808baa2c381b36c3053aa872b0c980720aa7b861a30acb666ad8dceac13897297b7a51a520f3ab2aa599589239c906d9ca12ccbcb4c97bb209020806e0f6d2e65322d9e7eb6f86b714d8d99376fd5c66a5f5457a9cc931ebc450fceac0363a501f5a108a6a253f0681e80844712524a78c2839c97900b125804b43a0d3b1a3f82a96f4504caaac9d2f973d1dc93b95376c99e606010520002c837986049064771966f40145ed9f7fcdbd3a030b42773e835fa914be6a02a71e8313d7ea664bd1c6d4db5cef933fe10f3d82d48201bcf42650990224092b0a4fd9261aa12ca65d41bd8bbfe13f434f7221dcb000a603b7670ecec619b5bf659052ab0a579cb0fa3a5d1dfb4262dc33d1e8ed0125349a1399240007c0998c93c3ae21d482b69f84410d2c7a1f387ff1c192b145a74a36ff8cbe15f1400c83665a7477f1a3d9e90890c971c04111a5235c647380569a6239fec442b6b0d0ff708f62c0f064ef4d9e529fe45f7abbb8eeedabe6b1e6ad54f5555a1433fea949c37a0a15110c155dc2a631f2a54b4c75ad1117f1b716880049cd9320ae78f7907be3b38d4a21b9ff77f367429b321b31c95cbb1e9ceb891ee13ddfb5a9e6ff9c0555c08cd01f7a6919629e4625bd05edf0ef8a11456a918f41defbb629fb1faba5eeb1aca6fcbcfabf5ea9d7976771e0f5bc34d63e5b1efb575f127ca49078692418e99d06bf5f06f9cf771f0e783dec091812183197d3d7b7a2e679a33ff1ee841102c57a55241d7375d7b769edab9307e633cb8735dbd7e7531bf2f3f696c36deeaffaabf3ea804777dfbf7fac783f1e278b26da0ede4e095c1200882a0b25009064f0fde30b61b07cc77cccce5e2e5ff04bc27701004e829f4bc607e6bfe3e717d62b173a0d332361bdbf71fd81fabdca8dc17e83d81e7e6e66a739fe63e4e6d4b7d9d7d25fbd4c4b989fb065caabf0002b81688eda386d60000000049454e44ae426082</data>
+ </image>
+ <image name="image2">
+ <data format="PNG" length="1233">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000049849444154388d95945d68145714c7ffbb199b3b4ddacea2a13b6583b9904067a9d40d15dc102a2b163158b0115f126cadd052941644fbd04a2b69f0a5d207212d48fd409a4ac192521b93076b22a19b209a2cc4246b35cda446338b59666ee93073dc0cb97dd8754df1033d70b8dc0f7efccfc73d2129259ed59c05273c7069a03193c97ceae41dab7d677b07b91435d61ad3baae2f0240e899c08bc0d8c4d8ea81c181f7225a6497d160f0befebe5b8e702e0b57e84d6f347db8f793bd5900509e963995995a353832b843abd63e6a5ad7f41a0284cd9b26781dafc52cbcd99bb3ae75db8a017818ec2c384af67a963bc209373537fd158944026bceaa1ebb3ab625b790db9b58934842c173d66d0be413a00056ce0a99b3e692239c15e6ac19f3fff5a1bea096c03e30757dca18b932f201e77c1b1185cffc70e604636c9c29ec5dcef9665ecfabccdb26c82d02110056ce020303632c4a01fd635a26475014a95896a50c5c18d8a9ebfa672d6fb7d40308810033677e0942a045b54a2144283b9d45a43a0230402c0858c202001008ac9abd44010570c1b3b3d9cac648e3bdb0396dc6f55afd50727db201400841f1318f72458fe94ce4458888c0631c080022020504555101000c0ce45285c634d511ce6a2b674500204c444b4c6121222a2a0896ad2550341a857005fcc0072d16effdc00700e4f2390857000a98aaa8af64ae64560340d89ab3d631c6aa98c28000600a2b2509705c078c95cec1ca0a0140850ae10a38c201168148754481821a73da7cddf77d84852b36f33abe5290281705281646b802da2aad1cfef2482c61c1110eee470a86502ad5f262ce111bb213d9ca8ab61d6d4b4a95b2a546aba90c0a01c82358390bdaf31a6a63b5081542208f80254078024121c082bd00f2a8d8214b80b652c3c60dad48ac7b136e3e5f3577d7bca02492894be675f32a8ff18d44042b6f81d77330858188cab9242a2a15ae28e75e652af8ab71341a49a094b2688cd70e0ef66c52e246dcce64323f0b2136f8e457e8511d5af523c207408b0406062770108d71180d06788c830820f2317c6d24e8ebefb92cf2d67818000c6ef48d4d8cfda956ab705ce7e1eeb8df0541b1a88944021b532d88d71b0000211cfc78f6e4c2c953df7e63aca96b3f7feefc4505008cb5c6dfe62f660f02c4414518032baf22100000ad46038fc511d1b4e2087009996b53c18953dffd81c0ffbaf3ab8317b7bfb3bd509e15aaaa8237f09fcc69b39d698c97bf6d49315318a27551e8515eee1c73d644cfd99e5c4fff99ef53a9d4b103fb0edce19c3f183c52caa21764a8fb74f7e1d1e15139393e29ed795b4e4e4dca991b33d2b33d29a5949e27a5677bb2f7dcc542ebd6d6df5b36b5bcd5dbd3bb4216e4034ec9ffb7191d1ead3f7eecf8447a382de76fcd4bdbb6a52cc8b2cdcfdbb2b3e3c89de4fae4a1ce8e4eddb6ed87808f047b9e87aea35d7bba4f77dfb3efda72b98d0e8fde6bdbd1d6dfbab535951e4a2b8f033e122ca5c4cc8d19ede017077f4b0fa5a59452dab62dbb8e76dd4a36a73eefece87cd9befb78954f044b29d17baeb7f9c8e12373e9a134ed7e7ff7afaddb5a9bd343e98aa7013e112c3d59b1e7e33dbb126b13fbf7efdbffd42a97fb7fa1807393b78b271b0000000049454e44ae426082</data>
+ </image>
+ <image name="image3">
+ <data format="PNG" length="1135">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000043649444154388d9d946f8814651cc73fbbfbdcf14ccdc5acac3a2b1beca679adfd6305cd3b5438c3b235ad4c0bb67ca18b905e1275d09b080b09ea45ef34903249bc8490eb4597889282751d78b527dec549c2edc9c5ee72b7dc4e3aec3cade34e2f66cf5b4af0cff7e5cceff9f079bebf6142dc470c89d6bdc1dc7aa067ed21575d6f51557beae1889c5fb2dccaec4ce01e81a1cec78c153b37a5ba3b3b3a3747a57ae8c79fcf8e6846e25a6e3497fff0c8c4dbcae56f0071b7d08eb8b1b47b5bf2ad74573a13d6e542ac3c155bd1d9d1d1ae8a83978bba154560703bb0a94b9930e53280e1096b54b9d4523119cdbc907cf3d5f5e95d89787209e5b180532e82ae1116164e7930a054fea66148c390cc2b29aede024b4130b32abe22fbcababda9355b3628ab54effbfef037f9b27535fb727a7b22d9b11ca584531e0329d1f430d8c360e7d10442e946346a2a3b6c102b590c0308296939b0bd6b4f6647f67ded89f42214684a91dd9d780f1c0fb410e5311cb782664441e5c11a03b708484005649b0c83e52522323e36a10008a697988b333bb2ef681d6f2cc2958d5214e88920221cc2ca832ee7a06a76f1d29f13804e4bb84d6a719376a0152058b4ad7f94e226371af3aef20fb90eb8e008401a60e7c19d7ddf34271d10041168cb12b44b810110ec5e9f7a5146a2915ba6a2c9c4cea3490394d578eeccad5b4a900aa406280c5db6c4e32c3623320e103422e1762d9634709d86a9f26d4bc33e44cc3e6b36058402094ee39c12c96034b933b62cc64a809052d7edcd6b9edcd8623ef520351bac49981a01230ac1365065a855a00ed46d102e888adfa4ab705bdbb0f48d283d0b3211b24b2337ce5d2c9d0a9e1d2d0d0d9e3b791ed701bb08561ecc5453cf0d432cbf22ac5be68e91c28af4a08c0c0e06a0118d194f9b068f86948b2b6a155e7a7edd265c21686d817ad8b77315e0825b86ba82bae5d7130cc0a2d7b1e7bd86786029ca05b77c85c1335f144ffe30d43b32aece86002ab69a5ebb34dc156d5f196366125ae743adecc3ab65dfb45e8120a027e0912c15a313826d58d5698aa3a76b7dbd9f9c3fd83bb46ff0b23aead6991600136535ddd77ff2f8f235e99540d0dfbef46f2e00a54046c14c82b90e07897415a5d230b933878b5f1fef3bfaeb4575c4525cc1df06a1d9ffc4e454a9f45c2ab17efe82e8020834be04cb378d2420be11a29d7ebd35c5d86fdfd6fabefcf8fc6787ceed1bfad33daa5c0a80c7edd2b32df9ae973b71c3cbf57bdea59f3c2f77c2f30a7f78cda94e8d7bfd8776feb56595f1a914b4fb37bc43e211b970e060e617efc231cf1bffddf3aad53962adea157227d4fedda9d37193cd40db1d81cdc9ac36b716bedb73cd9b29cc41670ade40ef07935b5619fba564c95d59fe3752a27db52b7e64e6c231cff33caf70a95f1dd8db753a1e6113a0df33b039a9987c7ce0f3f4f0c0e19ef1cc6af32329eed3f27fd682402ac633f1887c967bedb2917f01b258f688d5631b0b0000000049454e44ae426082</data>
+ </image>
+ <image name="image4">
+ <data format="PNG" length="1154">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000044949444154388d9d945d6c145514803fb677e50e5dc8349466568ab4b1a05b6a4c1112b6d2041a6a604c7dd8a431a962848607bb068dc89b890fbe49786b8da8c410a02406d104e98326954068496abb468b8b8add461a7702851dcbd8b92cb71d1f66a5e527043cc97db973f39d6fce393965fc8fb060f16b96f5eafbebd67fe44ebad3b78aea9fb8904b2667f5df00f6161bf1284009d1a494cf776e48bed9d2dab4d58472c775a25d954d337d3f0e9ccf4eaabd4011c14383176c96b2e195864497dd66b7c72db9d41fcfe3b88a96c6647d6e70f062dc532b24980aaea0ef025b8245b531d6282d67b29e1a058ab582951d4f275e4fb5d93bea1b122bfd892cf9d13c0889a514ce5026e28fe76e298d2961b1822bb78d25947554cb64676b7277635be716f7724e9f387cf050c1534e6a5b6a7b7d73d333f86ea4707104b4812980892ceaaa8b19938f2929aba452d74c8de5c21f681012a2dd9b6adeeae87a77afb1295505607805d289c43b68054246fc6c063559400ac0c9423e8f522005b882052a2697a254b1425033ae398780484b254f76ec4a7719ede92a04a054782ae3116266c4ff3d0b425281c2b894c1700b61238544010a40ca4552c8f25a580d44d010f13545a599c1f74103da075d827b2e0a3050e0e400f051a5022ad090f714521a65866089855c05942320926eb052152b6aabd0255b4d78f0f12fe7a8302bc02b8430ad3090a5ef90572a34064cd334e252d65bb01c0d1115ab78829ac412941bbed00adc3c7e6610a4846829218000ff5698dcf114aa2421854436b788c4f6f4aab8e0390494e179532f3cbbda36ea1a634ce5612c0397734457ad275a1e85ab79987241dd04cf0bf34e2bf4ac44690d562d46dbcb2c7eb183e8f215d11b438353ee12f96da4df513f0c9cfcf2349e1bd6512bd89c829811764687a6281f7c50f3ec65b38ddcbd07d96a83340088c7ccb5264675c4859bbd6733c7b9f48b8f06ac44f848c81028e695a2340d325e8bdcb10763479a8aba46d0a07e1e09063e7cefd7bed1cce72e5c13000313eee98193bdc34ded1d1b7172509df86f904ad052c30c09eb9b60db4ea88c8386c2449edc5727bc13c77a4ef53b4e8f0343b640098071cdb5beeffa8f35b5a63670a320d085d058cf1bad9a04246d58d7021848e5933f3f383bf8c9fedf8e9eee3f90d1ea0b057920b863571cbde87c9d3adbdf9968a85d6b4cba730b44c839e0b238f8809367e0d3835edfe183a77a27c67b5c189afb45ee5d6d5d75567afac0be62d07724087e3a1704678e07c1d858101483308a41f0d799e1d9cfb6a6b24929df061e0716dc85c1de62df796109967dd3bef9fbe943dd41f0e78520989e0e6ec7f5ebc1f0feeea99dd535bd16348785bf7fd85bed7b2f5395e64b1776a5dc606c6c8e39323c73a4bd63b451cab404eb7e960f3426d458f881657e7cfdc0be20989a0e2ef4744f75d5d51c3621093cf620e0038d016ae0a9e31b1bcf1f69b7479231f906a1e543c77d8de7c1d798d0082c7c142884c6ff02ebb2fb9af346c6500000000049454e44ae426082</data>
+ </image>
+ <image name="image5">
+ <data format="PNG" length="1194">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000047149444154388d95945f6c145514c6bf9d4ef50e4ee3dcb8c4dd80a6230bba95865283ba4422d4c43f0d3eb8ca832598501e88c43e348d4f0d26c0830f92a8498d12f1c18855b4f4c1204d508201bb25c0ee9a005d024d072d74d652772e769c7b7427bd3eec6e5b2328dce4e46672cffd9def7e2773224a29dce9f23c5997f9bef0547ea4d04da1184a6f4a1d1482ee4dad5ffdb3d16000002277042e03991f7389fc49775bacd1de623f602f19fc7af02c63ec5a3e9f973dbbdbb7af5db7f67700d06f97397acebd3f7fb2f02a63b1eda90d6d2b4086e65c76904cac5d55186326f9e257d7712dacc34dc065d43957bd072591168f3187733eeb4eb866eeacbb515ca73792cda9c701d4bb1302e41781d0865b949a3b21ca9ecf1af23f15a22fbf865fe6c1656074cc5de65ca56d71d37ac5b94a91e343b98f98695c62b0b6dacbede79a1af922a7e8417a048416880c8869c0d08d3aa018856efde1095a0a200700ba9c91dac8a9621a3a7bab35613f4a80c6a31c6ed47a1b21422bc619094446afb830740b0087108010f30f650d8c23842a9c739779d73df0c51c5ae162d186ce76af5e196fa6101a420021108ff1fa788c1b621a11411eb819879c31403e4021c0163848c0dd8c714682ad708b6e1d0068c2f766990e8da89224c3f95d8600851e2c93c3131520550b5335cf151e1022029d2d229f2f77ae38160068de345a98c9cc5a75439fdfc9072cc6502b8a054a990e78be84573de326bf0bbafd9098201b0034c7719f8d47f99285971102eeb4048512d00d100154ae3ebb7aee0809e11388082803d6621969db105b9a3955780252424b26e3836ed1fb8db1ca051902ae9060a6016655a00801563f6f81ebcbb95ca633c46d42fb464436bcc4eb31836772e70bf76876829f72aeb823355f852f61371a60acd2959a972401518552081011b809b43e29d0f682048f130c93010d6c4dffc7834d5a53d29e21290e912fcb140276ac0a0de7bbef51054a04305466819d00da5e24a45200332bf999a1bc2c9cc9ff009da67400482eb7becb9d772eb4ae6c6af17c893833e6947a0450cd7b006012a966829d2040af14731da1063f3b72b97031f3deb6eecdfd9d5b3b6e54c02df635e772fe900ce52a222352535a83a3dab8584c22d90c700b40c8e0098191a1d1e0d017fddfd8cdd6defdfd7b73ada956052c986eb991d187c5b4719845638978d4802700e1035ef50fb39702762300784008142ebaeaf30f8f8c1d3f73e4dd9e3737f7776ce9b8511b990000a554250285039f0cefce664ab3d9d381ca9e56ead851a5b219a54a534a29a5541028559a0ad4c0be63417b4be7c1f6f5e9c7864f0c6b738c05f18f8f6ce6c2b2031f0c9fcb9e085436a7d4e4b852ea2f35b7262f9554efeb7d63a947dabbf6ecdcc34ba5d2bf803705074180fdef1fde31f0e9853f6b2a95aac0878f8e07e9f53bbe4a3fdfb1e6562a6f09564a617c749cf7760d7c9bcd4c2aa5942a4d06b37dbb06c6522de9ae3dbbdee1a5a95babfc4fb0520a07f61d7eba6fe7b1c9e1a3e341e7a6de2f6f57e5ff824b5381dedbddd7996a4977f574f7dc77bb2a17c6df8cbd46ed068731d30000000049454e44ae426082</data>
+ </image>
+ <image name="image6">
+ <data format="PNG" length="1211">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000048249444154388d95944f6c54551487bf695ff53e9cea0c69c94c6cb02fb4d84682b601a30425d3c4a8c0c63646a9ff426b62005920246aaa0b52c584d2850b1660d005200b086cccc0a653443b1a10c604e96b80f40db6ce1b6bed7bb193be0b73e5ba98a1b4091238c9c9c9bdb9f73b27e777cf0d69adb96f0b82d0f0a96f9ff42fa6b67b8aacf5f2963e5379b5b1156dd74cd35400a1fb0217c11d49d7c98ba9b7a976375acfc41bd2075357e5a47916e5c6bda6ee773bbab68c0218f7caf41c67a17df24087552b375989c872c2540623195a9aad25b26057b8e7ec69fbeaf0a3c01dc0c5a032c866164b4988bae66c341abde98d390bfc5f922fa29cf75b5e88ac3663de038c3b042311ccb0807006dfb19529657550c8d605d30166b5590617c11b492d259bee8ed6d02efd8cb607c57e8475296e78efc45646d7994d224c3e03bf4540c430635990c320cc9010625144492dff722c29c1ac0623980e2afd9ff7be2ef07ba2abad26a24e284a8c96a6ec2e0a6ed16c889b4827c4af1284053117940d05ff9692448578385014a3ca5bea8cdb46b4b65519fe48ea0921646ff439cb82f46c574cabbe0a64156336e463506f020e4817a40443800c4a8727658529446544e597f879f711e0ef0a6fd2d7200cb0a128e7b85f8a79010d71306c501ec87266e5956256c2a40443565882c5f6b9c13a800a39966915029322a54ad49c98f7c1b0c0704b6b55a62a0998909730564e2444c8aaa656f8de72800a0ace5ab3deaca160972e48bf14b32e8cc7202640e54105b7e10a18f74a5059eeb521427259bbe9e5f36b5cc7312adf7bad3d1479c878a92a9c7f901bd3505090ad02e369585a050b1c9005b8a9402a985130aec0036e144019040b1ab9d2b883f1c73af1738ee94979ca88af5c3b98bf78fc82158badc17760b2191a2c88b8805f6a0b4041420198e476e54604b7ae0d37de8d4f0414881acb4a1d3d9ca88837ac9a747d8ee15bff520062cd10714a5005204a82493147b800a2ad388d9fe1357f82147104e06406d58593c7cf66b2cee50a4c88b7ac4dba23f92b080b7c67be805296804a9645130475dd380dbd04b1b6524edf257da4ffcfe4377bfacc952d6f1e4ea64f1b00d653cf8e0e1f499d882beb630a0ea848a9d232a8f4b404849b09eadec0375a1040e04bdc4cba983cd8ff435e89dd9dbbf6a43a5ee928defe2b4c13bfda3ae25cb5375811ea29081065a8f4c088424d1b41b813a9040270b30e3f1dfdda4d9e3cfc959568dfb767db8e9c6559b30336fb6d069e17b28f7efe456ba3f8908807f5f9f284b540b81d8c560205c800fbc764f1f8fefed3b62f77777dd0fbfdbaf5eb8a5431dfb4d6b33e9a1e78fcd2decdf6cc991ead27bab4fee790d67a4adfb2a9df73fad8ceed639d2bea7bb66fea8ae54673f3eecff5f91b33330c7dd9b3357760f3753d715ecfb55c7ae07aefab8964d7fab56b86524386be7167e09dc15a93bb7c69e1775b13c9a93387b4d65acf4ce4f4407fcfb5aed5cd1ff5edec5d3435317557e0ff82b5d60ceceb7dfefca7ed7f8ca68e057d1b1227bad627560d9d19aabc17e05dc133135395bd6f2536b62f8b6cebd9b6f99eab9cebff01a7a517d9791775a00000000049454e44ae426082</data>
+ </image>
+</images>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>knuminput.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/src/locate.desktop b/src/locate.desktop
new file mode 100644
index 0000000..20bfdb7
--- /dev/null
+++ b/src/locate.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+Name=locate - Search for local files
+ServiceTypes=SearchProvider
+Keys=locate
+Query=locate:\\{@}
+Charset=utf8
diff --git a/src/locate.protocol b/src/locate.protocol
new file mode 100644
index 0000000..61e4810
--- /dev/null
+++ b/src/locate.protocol
@@ -0,0 +1,18 @@
+[Protocol]
+exec=kio_locate
+protocol=locate
+input=none
+output=filesystem
+listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group,Link
+reading=true
+Icon=find
+Description=KDE I/O Slave for the locate command
+
+# Using this will e.g. display previews etc.
+Class=:local
+
+# No special parsing needed. locate does not use URL syntax.
+URIMode=rawuri
+
+# Our very sophisticated documentation
+DocPath=kio-locate/index.html
diff --git a/src/locater.cpp b/src/locater.cpp
new file mode 100644
index 0000000..4072209
--- /dev/null
+++ b/src/locater.cpp
@@ -0,0 +1,131 @@
+/***************************************************************************
+ * kio-locate: KDE I/O Slave for the locate command *
+ * *
+ * Copyright (C) 2005 by Tobi Vollebregt *
+ * tobivollebregt@gmail.com *
+ * *
+ * Thanks to Google's Summer Of Code Program! *
+ * *
+ * Copyright (C) 2004 by Armin Straub *
+ * linux@arminstraub.de *
+ * *
+ * This program was initially written by Michael Schuerig. *
+ * Although I have completely rewritten it, most ideas are adopted *
+ * from his original work. *
+ * *
+ * Copyright (C) 2002 by Michael Schuerig *
+ * michael@schuerig.de *
+ * *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#include <qtextcodec.h>
+
+#include <kdebug.h>
+#include <kstandarddirs.h>
+
+#include "locater.h"
+
+
+Locater::Locater(QObject *parent, const char *name)
+ : QObject(parent, name), m_process(QTextCodec::codecForLocale())
+{
+ DEBUGSTR << "Locater::Locater" << endl;
+
+ connect(&m_process, SIGNAL(processExited(KProcess*)),
+ this, SLOT(finished(KProcess*)));
+ connect(&m_process, SIGNAL(readReady(KProcIO*)),
+ this, SLOT(gotOutput(KProcIO*)));
+
+ setupLocate();
+}
+
+
+Locater::~Locater()
+{
+ DEBUGSTR << "Locater::~Locater" << endl;
+}
+
+
+void Locater::setupLocate(const QString& binary, const QString& additionalArguments)
+{
+ DEBUGSTR << "Locater::setupLocate(" << binary << ", " << additionalArguments << ")" << endl;
+
+ // Automatically choose the correct binary if not specified.
+ if (binary.isEmpty()) {
+ if (KStandardDirs::findExe("slocate")) {
+ m_binary = "slocate";
+ } else if (KStandardDirs::findExe("rlocate")) {
+ m_binary = "rlocate";
+ } else {
+ m_binary = "locate";
+ }
+ DEBUGSTR << "Using binary:" << m_binary << endl;
+ } else {
+ m_binary = binary;
+ }
+ m_additionalArguments = additionalArguments;
+ m_binaryExists = KStandardDirs::findExe(m_binary) != QString::null;
+}
+
+
+bool Locater::locate(const QString& pattern, bool ignoreCase, bool regExp)
+{
+ DEBUGSTR << "Locater::locate(" << pattern << "," << ignoreCase << "," << regExp << ")" << endl;
+
+ m_process.resetAll();
+ m_process << m_binary;
+ if (!m_additionalArguments.isEmpty()) {
+ m_process << m_additionalArguments;
+ }
+ if (ignoreCase) {
+ // m_process << "--ignore-case";
+ m_process << "-i";
+ }
+ if (regExp) {
+ m_process << "-r";
+ }
+ m_process << pattern;
+
+ return m_process.start(KProcess::Block, false);
+}
+
+void Locater::stop()
+{
+ DEBUGSTR << "Locater::stop()" << endl;
+
+ m_process.kill();
+ emit finished();
+}
+
+
+void Locater::gotOutput(KProcIO* /*proc*/)
+{
+ //DEBUGSTR << "Locater::gotOutput" << endl;
+
+ QStringList items;
+ QString line;
+
+ while (m_process.readln(line) != -1) {
+ //DEBUGSTR << "OUTPUT>> '" << line << "'" << endl;
+
+ items << line;
+ }
+
+ emit found(items);
+}
+
+
+void Locater::finished(KProcess* /*proc*/)
+{
+ DEBUGSTR << "Locater::finished" << endl;
+
+ emit finished();
+}
+
+
+#include "locater.moc"
diff --git a/src/locater.h b/src/locater.h
new file mode 100644
index 0000000..e083d2a
--- /dev/null
+++ b/src/locater.h
@@ -0,0 +1,103 @@
+/***************************************************************************
+ * kio-locate: KDE I/O Slave for the locate command *
+ * *
+ * Copyright (C) 2005 by Tobi Vollebregt *
+ * tobivollebregt@gmail.com *
+ * *
+ * Thanks to Google's Summer Of Code Program! *
+ * *
+ * Copyright (C) 2004 by Armin Straub *
+ * linux@arminstraub.de *
+ * *
+ * This program was initially written by Michael Schuerig. *
+ * Although I have completely rewritten it, most ideas are adopted *
+ * from his original work. *
+ * *
+ * Copyright (C) 2002 by Michael Schuerig *
+ * michael@schuerig.de *
+ * *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#ifndef LOCATER_H
+#define LOCATER_H
+
+#include <qobject.h>
+#include <qstringlist.h>
+
+#include <kprocio.h>
+
+
+#define DEBUGSTR kdDebug(7199)
+
+
+/**
+ * Interface to the locate command.
+ *
+ * Usage is very simple:
+ * - Calling locate searches for the given pattern.
+ * - You can then collect the found files by connecting to the signal
+ * found.
+ * - When finished the signal finished is emitted.
+ */
+class Locater : public QObject
+{
+ Q_OBJECT
+ public:
+ /**
+ * Constructor
+ */
+ Locater(QObject *parent = 0, const char *name = 0);
+
+ virtual ~Locater();
+
+ /**
+ * Starts the search.
+ * @param pattern the pattern to search for
+ * @param ignoreCase whether to ignore case or not
+ * @param regExp whether to treat pattern as a regular expression or not
+ * @return true if locate could be started
+ */
+ bool locate(const QString& pattern, bool ignoreCase = false, bool regExp = false);
+
+ /**
+ * Set parameters for using locate.
+ * @param binary the binary to use (default: automatically chosen from
+ * slocate, rlocate and locate)
+ * @param additionalArguments additional arguments to use
+ */
+ void setupLocate(const QString& binary = "", const QString& additionalArguments = "");
+
+ void stop();
+
+ QString binary() { return m_binary; }
+ bool binaryExists() { return m_binaryExists; }
+
+ signals:
+ /**
+ * Emitted whenever some new files are found.
+ * @param items a list of the new filenames
+ */
+ void found(const QStringList& items);
+
+ /**
+ * Emitted when the search is finished.
+ */
+ void finished();
+
+ private slots:
+ void gotOutput(KProcIO* proc);
+ void finished(KProcess* proc);
+
+ private:
+ KProcIO m_process;
+ QString m_binary;
+ QString m_additionalArguments;
+ bool m_binaryExists;
+};
+
+#endif
diff --git a/src/locater.protocol b/src/locater.protocol
new file mode 100644
index 0000000..b40c6a2
--- /dev/null
+++ b/src/locater.protocol
@@ -0,0 +1,15 @@
+[Protocol]
+exec=kio_locate
+protocol=locater
+input=none
+output=filesystem
+listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group,Link
+reading=true
+Icon=find
+Description=KDE I/O Slave for the locate command
+
+# Using this will e.g. display previews etc.
+Class=:local
+
+# Our very sophisticated documentation
+DocPath=kio-locate/index.html
diff --git a/src/pattern.cpp b/src/pattern.cpp
new file mode 100644
index 0000000..14c74e3
--- /dev/null
+++ b/src/pattern.cpp
@@ -0,0 +1,124 @@
+/***************************************************************************
+ * kio-locate: KDE I/O Slave for the locate command *
+ * *
+ * Copyright (C) 2005 by Tobi Vollebregt *
+ * tobivollebregt@gmail.com *
+ * *
+ * Thanks to Google's Summer Of Code Program! *
+ * *
+ * Copyright (C) 2004 by Armin Straub *
+ * linux@arminstraub.de *
+ * *
+ * This program was initially written by Michael Schuerig. *
+ * Although I have completely rewritten it, most ideas are adopted *
+ * from his original work. *
+ * *
+ * Copyright (C) 2002 by Michael Schuerig *
+ * michael@schuerig.de *
+ * *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#include <kdebug.h>
+
+#include "pattern.h"
+
+
+LocateRegExp::LocateRegExp(const QString& pattern, bool ignoreCase)
+{
+ m_ignoreCase = ignoreCase;
+ setPattern(pattern);
+}
+
+
+LocateRegExp::LocateRegExp()
+{
+}
+
+
+LocateRegExp::~LocateRegExp()
+{
+}
+
+
+bool LocateRegExp::isMatching(const QString& file) const
+{
+ bool matching = m_regExp.search(file) >= 0;
+ if (m_negated) {
+ matching = !matching;
+ }
+ return matching;
+}
+
+
+int LocateRegExp::getMatchPosition() const
+{
+ // Why is QRegExp::pos() non const?
+ return const_cast<LocateRegExp*>(this)->m_regExp.pos();
+}
+
+
+int LocateRegExp::getMatchedLength() const
+{
+ return m_regExp.matchedLength();
+}
+
+
+void LocateRegExp::setPattern(const QString& pattern)
+{
+ m_negated = false;
+ m_pattern = pattern;
+ if ((m_pattern.length() > 0) && (m_pattern[0] == '!')) {
+ m_negated = true;
+ m_pattern = m_pattern.mid(1, m_pattern.length()-1);
+ }
+ m_regExp = QRegExp(m_pattern, !m_ignoreCase);
+}
+
+
+QString LocateRegExp::getPattern() const
+{
+ return m_pattern;
+}
+
+
+LocateRegExpList::~LocateRegExpList()
+{
+}
+
+
+LocateRegExpList& LocateRegExpList::operator = (const QStringList& list)
+{
+ clear();
+ QStringList::ConstIterator it = list.begin();
+ for (; it != list.end(); ++it) {
+ append(LocateRegExp((*it), (*it) == (*it).lower()));
+ }
+ return *this;
+}
+
+
+bool LocateRegExpList::isMatchingOne(const QString& file) const
+{
+ bool matches = false;
+ LocateRegExpList::ConstIterator it = begin();
+ for (; !matches && (it != end()); ++it) {
+ matches = (*it).isMatching(file);
+ }
+ return matches;
+}
+
+
+bool LocateRegExpList::isMatchingAll(const QString& file) const
+{
+ bool matches = true;
+ LocateRegExpList::ConstIterator it = begin();
+ for (; matches && (it != end()); ++it) {
+ matches = (*it).isMatching(file);
+ }
+ return matches;
+}
diff --git a/src/pattern.h b/src/pattern.h
new file mode 100644
index 0000000..8e17a69
--- /dev/null
+++ b/src/pattern.h
@@ -0,0 +1,114 @@
+/***************************************************************************
+ * kio-locate: KDE I/O Slave for the locate command *
+ * *
+ * Copyright (C) 2005 by Tobi Vollebregt *
+ * tobivollebregt@gmail.com *
+ * *
+ * Thanks to Google's Summer Of Code Program! *
+ * *
+ * Copyright (C) 2004 by Armin Straub *
+ * linux@arminstraub.de *
+ * *
+ * This program was initially written by Michael Schuerig. *
+ * Although I have completely rewritten it, most ideas are adopted *
+ * from his original work. *
+ * *
+ * Copyright (C) 2002 by Michael Schuerig *
+ * michael@schuerig.de *
+ * *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#ifndef PATTERN_H
+#define PATTERN_H
+
+#include <qregexp.h>
+#include <qstring.h>
+#include <qvaluelist.h>
+
+/**
+ * Regular Expression adapted to the needs of kio-locate.
+ */
+class LocateRegExp
+{
+public:
+ /**
+ * Constructor
+ * @param pattern the pattern to start with
+ * @param ignoreCase specifies, if the search should be case sensitive
+ */
+ LocateRegExp(const QString& pattern, bool ignoreCase = false);
+ LocateRegExp();
+
+ virtual ~LocateRegExp();
+
+ /**
+ * Determines whether a file name is matching this regular expression.
+ * @param file the filename to match
+ */
+ virtual bool isMatching(const QString& file) const;
+
+ /**
+ * @return The position of the last match.
+ */
+ virtual int getMatchPosition() const;
+
+ /**
+ * @return The length of the last match.
+ */
+ virtual int getMatchedLength() const;
+
+ /**
+ * Set the pattern.
+ * @param pattern the pattern to search for. It may be prepended by an
+ * exclamation mark, to invert its meaning.
+ */
+ virtual void setPattern(const QString& pattern);
+
+ /**
+ * Get the pattern.
+ * @return search pattern
+ */
+ virtual QString getPattern() const;
+
+ private:
+ bool m_negated;
+ bool m_ignoreCase;
+ QRegExp m_regExp;
+ QString m_pattern;
+};
+
+/**
+ * List of regular expressions
+ */
+class LocateRegExpList: public QValueList<LocateRegExp>
+{
+ public:
+ virtual ~LocateRegExpList();
+
+ /**
+ * Converts a stringlist into a regexplist.
+ * @param list the stringlist to convert
+ */
+ LocateRegExpList& operator = (const QStringList& list);
+
+ /**
+ * Determines whether a file name is matching at least one regular
+ * expression in the list.
+ * @param file the filename to match
+ */
+ virtual bool isMatchingOne(const QString& file) const;
+
+ /**
+ * Determines whether a file name is matching all regular expressions
+ * in the list.
+ * @param file the filename to match
+ */
+ virtual bool isMatchingAll(const QString& file) const;
+};
+
+#endif
diff --git a/src/rlocate.protocol b/src/rlocate.protocol
new file mode 100644
index 0000000..a994b32
--- /dev/null
+++ b/src/rlocate.protocol
@@ -0,0 +1,18 @@
+[Protocol]
+exec=kio_locate
+protocol=rlocate
+input=none
+output=filesystem
+listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group,Link
+reading=true
+Icon=find
+Description=KDE I/O Slave for the locate command
+
+# Using this will e.g. display previews etc.
+Class=:local
+
+# No special parsing needed. locate does not use URL syntax.
+URIMode=rawuri
+
+# Our very sophisticated documentation
+DocPath=kio-locate/index.html