do tilde expansion
BUG:153326 svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=750316
This commit is contained in:
parent
f0637a2e9a
commit
86ccea46b6
@ -27,6 +27,7 @@
|
|||||||
#include <KCompletion>
|
#include <KCompletion>
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
#include <KMimeType>
|
#include <KMimeType>
|
||||||
|
#include <KShell>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
#include <KUrl>
|
#include <KUrl>
|
||||||
|
|
||||||
@ -158,27 +159,28 @@ void SearchContext::determineType()
|
|||||||
{
|
{
|
||||||
d->lockForWrite();
|
d->lockForWrite();
|
||||||
QString term = d->term;
|
QString term = d->term;
|
||||||
|
QString path = KShell::tildeExpand(term);
|
||||||
|
|
||||||
int space = term.indexOf(' ');
|
int space = term.indexOf(' ');
|
||||||
if (space > 0) {
|
if (space > 0) {
|
||||||
if (!KStandardDirs::findExe(term.left(space)).isEmpty()) {
|
if (!KStandardDirs::findExe(path.left(space)).isEmpty()) {
|
||||||
d->type = ShellCommand;
|
d->type = ShellCommand;
|
||||||
}
|
}
|
||||||
} else if (!KStandardDirs::findExe(term.left(space)).isEmpty()) {
|
} else if (!KStandardDirs::findExe(path.left(space)).isEmpty()) {
|
||||||
d->type = Executable;
|
d->type = Executable;
|
||||||
} else {
|
} else {
|
||||||
KUrl url(term);
|
KUrl url(term);
|
||||||
|
|
||||||
if (!url.protocol().isEmpty() && !url.host().isEmpty()) {
|
if (!url.protocol().isEmpty() && !url.host().isEmpty()) {
|
||||||
d->type = NetworkLocation;
|
d->type = NetworkLocation;
|
||||||
} else if (QFile::exists(term)) {
|
} else if (QFile::exists(path)) {
|
||||||
QFileInfo info(term);
|
QFileInfo info(path);
|
||||||
if (info.isDir()) {
|
if (info.isDir()) {
|
||||||
d->type = Directory;
|
d->type = Directory;
|
||||||
d->mimetype = "inode/folder";
|
d->mimetype = "inode/folder";
|
||||||
} else {
|
} else {
|
||||||
d->type = File;
|
d->type = File;
|
||||||
KMimeType::Ptr mimetype = KMimeType::findByPath(term);
|
KMimeType::Ptr mimetype = KMimeType::findByPath(path);
|
||||||
if (mimetype) {
|
if (mimetype) {
|
||||||
d->mimetype = mimetype->name();
|
d->mimetype = mimetype->name();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user