81 lines
2.2 KiB
Diff
81 lines
2.2 KiB
Diff
From 1ae78f08474878e60d086ea60e933d62228eac2f Mon Sep 17 00:00:00 2001
|
|
From: Vishesh Handa <me@vhanda.in>
|
|
Date: Fri, 17 Oct 2014 17:45:42 +0200
|
|
Subject: [PATCH 1/2] LocationRunner: Convert case insensitive path to a proper
|
|
one
|
|
|
|
BUG: 333395
|
|
FIXED-IN: 5.2
|
|
---
|
|
runners/locations/locationrunner.cpp | 40 ++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 40 insertions(+)
|
|
|
|
diff --git a/runners/locations/locationrunner.cpp b/runners/locations/locationrunner.cpp
|
|
index 13035a9..0b79655 100644
|
|
--- a/runners/locations/locationrunner.cpp
|
|
+++ b/runners/locations/locationrunner.cpp
|
|
@@ -21,6 +21,7 @@
|
|
#include <QMimeData>
|
|
#include <QIcon>
|
|
#include <QUrl>
|
|
+#include <QDir>
|
|
|
|
#include <QDebug>
|
|
#include <KRun>
|
|
@@ -129,6 +130,43 @@ void LocationsRunner::match(Plasma::RunnerContext &context)
|
|
}
|
|
}
|
|
|
|
+static QString convertCaseInsensitivePath(const QString& path)
|
|
+{
|
|
+ // Split the string on /
|
|
+ QStringList dirNames = path.split(QDir::separator(), QString::SkipEmptyParts);
|
|
+
|
|
+ // Match folders
|
|
+ QDir dir("/");
|
|
+ for (int i = 0; i < dirNames.size() - 1; i++) {
|
|
+ QString dirName = dirNames[i];
|
|
+
|
|
+ bool foundMatch = false;
|
|
+ QStringList entries = dir.entryList(QDir::Dirs);
|
|
+ for (const QString& entry: entries) {
|
|
+ if (entry.compare(dirName, Qt::CaseInsensitive) == 0) {
|
|
+ foundMatch = dir.cd(entry);
|
|
+ if (foundMatch) {
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!foundMatch) {
|
|
+ return path;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ QString finalName = dirNames.last();
|
|
+ QStringList entries = dir.entryList();
|
|
+ for (const QString& entry: entries) {
|
|
+ if (entry.compare(finalName, Qt::CaseInsensitive) == 0) {
|
|
+ return dir.absoluteFilePath(entry);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return path;
|
|
+}
|
|
+
|
|
void LocationsRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
|
|
{
|
|
Q_UNUSED(match)
|
|
@@ -139,6 +177,8 @@ void LocationsRunner::run(const Plasma::RunnerContext &context, const Plasma::Qu
|
|
return;
|
|
}
|
|
|
|
+ location = convertCaseInsensitivePath(location);
|
|
+
|
|
//qDebug() << "command: " << context.query();
|
|
//qDebug() << "url: " << location << data;
|
|
|
|
--
|
|
2.1.2
|
|
|