191
191
RunnerContext::Executable;
194
QString correctCasePath;
195
// check if we have a local network location first, otherwise assume a path,
196
// but if a path doesn't have any slashes is a single word or
197
// sentence: it's too ambiguous to be sure we're in a filesystem context
198
if (KProtocolInfo::protocolClass(url.protocol()) == ":local" && !url.isLocalFile()) {
194
// check for a normal URL first
195
//kDebug() << url << KProtocolInfo::protocolClass(url.protocol()) << url.hasHost() <<
196
// url.host() << url.isLocalFile() << path << path.indexOf('/');
197
const bool hasProtocol = !url.protocol().isEmpty();
198
const bool isLocalProtocol = KProtocolInfo::protocolClass(url.protocol()) == ":local";
200
((!isLocalProtocol && url.hasHost()) ||
201
(isLocalProtocol && url.protocol() != "file"))) {
202
// we either have a network protocol with a host, so we can show matches for it
203
// or we have a non-file url that may be local so a host isn't required
199
204
type = RunnerContext::NetworkLocation;
200
} else if ((path.indexOf('/') != -1 || path.indexOf('\\') != -1) &&
201
correctPathCase(path, correctCasePath)) {
202
path = correctCasePath;
203
QFileInfo info(path);
205
} else if (isLocalProtocol) {
206
// at this point in the game, we assume we have a path,
207
// but if a path doesn't have any slashes
208
// it's too ambiguous to be sure we're in a filesystem context
209
path = QDir::cleanPath(url.toLocalFile());
210
//kDebug( )<< "slash check" << path;
211
if (hasProtocol || ((path.indexOf('/') != -1 || path.indexOf('\\') != -1))) {
212
QString correctCasePath;
213
if (correctPathCase(path, correctCasePath)) {
214
path = correctCasePath;
215
QFileInfo info(path);
216
//kDebug( )<< "correct cas epath is" << correctCasePath << info.isSymLink() <<
217
// info.isDir() << info.isFile();
205
if (info.isSymLink()) {
206
path = info.canonicalFilePath();
207
info = QFileInfo(path);
210
type = RunnerContext::Directory;
211
mimeType = "inode/folder";
212
} else if (info.isFile()) {
213
type = RunnerContext::File;
214
KMimeType::Ptr mimeTypePtr = KMimeType::findByPath(path);
216
mimeType = mimeTypePtr->name();
219
if (info.isSymLink()) {
220
path = info.canonicalFilePath();
221
info = QFileInfo(path);
224
type = RunnerContext::Directory;
225
mimeType = "inode/folder";
226
} else if (info.isFile()) {
227
type = RunnerContext::File;
228
KMimeType::Ptr mimeTypePtr = KMimeType::findByPath(path);
230
mimeType = mimeTypePtr->name();
238
//kDebug() << "term2type" << term << type;
223
241
void invalidate()