replace the rather expensive (but exact and thorough) KUriFilter based analysis of the search term with inexact but fast and good enough to not be annoying

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=734739
This commit is contained in:
Aaron J. Seigo 2007-11-09 19:14:15 +00:00
parent 0c17b03543
commit ac1d1b0cdf

View File

@ -19,10 +19,14 @@
#include "searchcontext.h" #include "searchcontext.h"
#include <QFile>
#include <QFileInfo>
#include <KCompletion> #include <KCompletion>
#include <KDebug> #include <KDebug>
#include <KMimeType> #include <KMimeType>
#include <KUriFilterData> #include <KStandardDirs>
#include <KUrl>
#include "searchaction.h" #include "searchaction.h"
@ -99,44 +103,36 @@ void SearchContext::setSearchTerm(const QString &term)
} }
d->term = term; d->term = term;
//FIXME: this is insanely slow =/
// the below lines commented out until we can find a much faster way to do the same
//KUriFilterData filter(term); int space = term.indexOf(' ');
//bool filtered = KUriFilter::self()->filterUri(filter); if (space > 0) {
if (!KStandardDirs::findExe(term.left(space)).isEmpty()) {
d->type = ShellCommand;
}
} else if (!KStandardDirs::findExe(term.left(space)).isEmpty()) {
d->type = Executable;
} else {
KUrl url(term);
//if (filtered) { if (!url.protocol().isEmpty() && !url.host().isEmpty()) {
// switch (filter.uriType()) { d->type = NetworkLocation;
// case KUriFilterData::LocalDir: } else if (QFile::exists(term)) {
// d->type = Directory; QFileInfo info(term);
// d->mimetype = "inode/folder"; if (info.isDir()) {
// break; d->type = Directory;
// case KUriFilterData::LocalFile: { d->mimetype = "inode/folder";
// d->type = File; } else {
// KMimeType::Ptr mimetype = KMimeType::findByPath(filter.uri().path()); d->type = File;
// if (mimetype) { KMimeType::Ptr mimetype = KMimeType::findByPath(term);
// d->mimetype = mimetype->name(); if (mimetype) {
// } d->mimetype = mimetype->name();
// break; }
// } }
// case KUriFilterData::NetProtocol: } else if (term.contains('.')) {
// //kDebug() << "term is a network protocol?" << term << filter.uriType(); // default to a network location so we can can do things like www.kde.org
// d->type = NetworkLocation; d->type = NetworkLocation;
// break; }
// case KUriFilterData::Executable: }
// d->type = Executable;
// break;
// case KUriFilterData::Shell:
// d->type = ShellCommand;
// break;
// case KUriFilterData::Help:
// d->type = Help;
// break;
// default:
// break;
// }
//}
} }
QString SearchContext::searchTerm() const QString SearchContext::searchTerm() const