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:
parent
0c17b03543
commit
ac1d1b0cdf
@ -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
|
int space = term.indexOf(' ');
|
||||||
|
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);
|
||||||
|
|
||||||
//KUriFilterData filter(term);
|
if (!url.protocol().isEmpty() && !url.host().isEmpty()) {
|
||||||
//bool filtered = KUriFilter::self()->filterUri(filter);
|
d->type = NetworkLocation;
|
||||||
|
} else if (QFile::exists(term)) {
|
||||||
//if (filtered) {
|
QFileInfo info(term);
|
||||||
// switch (filter.uriType()) {
|
if (info.isDir()) {
|
||||||
// case KUriFilterData::LocalDir:
|
d->type = Directory;
|
||||||
// d->type = Directory;
|
d->mimetype = "inode/folder";
|
||||||
// d->mimetype = "inode/folder";
|
} else {
|
||||||
// break;
|
d->type = File;
|
||||||
// case KUriFilterData::LocalFile: {
|
KMimeType::Ptr mimetype = KMimeType::findByPath(term);
|
||||||
// d->type = File;
|
if (mimetype) {
|
||||||
// KMimeType::Ptr mimetype = KMimeType::findByPath(filter.uri().path());
|
d->mimetype = mimetype->name();
|
||||||
// if (mimetype) {
|
}
|
||||||
// d->mimetype = mimetype->name();
|
}
|
||||||
// }
|
} else if (term.contains('.')) {
|
||||||
// break;
|
// default to a network location so we can can do things like www.kde.org
|
||||||
// }
|
d->type = NetworkLocation;
|
||||||
// case KUriFilterData::NetProtocol:
|
}
|
||||||
// //kDebug() << "term is a network protocol?" << term << filter.uriType();
|
}
|
||||||
// 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
|
||||||
|
Loading…
Reference in New Issue
Block a user