kio/0005-Fix-template-discovery-in-KNewFileMenu.patch

55 lines
2.1 KiB
Diff

From c42e52d366ffcc016a487627b935b34183af759a Mon Sep 17 00:00:00 2001
From: Eike Hein <hein@kde.org>
Date: Sat, 5 Jul 2014 20:52:52 +0200
Subject: [PATCH 05/10] Fix template discovery in KNewFileMenu.
Incorrect port to QStandardPaths was collecting dirs instead of
files within them.
Reviewed-By: David Faure
REVIEW:119130
---
src/filewidgets/knewfilemenu.cpp | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/filewidgets/knewfilemenu.cpp b/src/filewidgets/knewfilemenu.cpp
index 4f1ca10..a24ac9c 100644
--- a/src/filewidgets/knewfilemenu.cpp
+++ b/src/filewidgets/knewfilemenu.cpp
@@ -841,10 +841,12 @@ void KNewFileMenuPrivate::_k_slotFillTemplates()
{
KNewFileMenuSingleton *s = kNewMenuGlobals();
//qDebug();
+
+ const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "templates", QStandardPaths::LocateDirectory);
+
// Ensure any changes in the templates dir will call this
if (! s->dirWatch) {
s->dirWatch = new KDirWatch;
- const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "templates", QStandardPaths::LocateDirectory);
for (QStringList::const_iterator it = dirs.constBegin(); it != dirs.constEnd(); ++it) {
//qDebug() << "Templates resource dir:" << *it;
s->dirWatch->addDir(*it);
@@ -863,7 +865,17 @@ void KNewFileMenuPrivate::_k_slotFillTemplates()
s->templatesList->clear();
// Look into "templates" dirs.
- const QStringList files = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "templates", QStandardPaths::LocateDirectory);
+ QStringList files;
+ QDir dir;
+
+ Q_FOREACH (const QString &path, dirs) {
+ dir.setPath(path);
+ const QStringList &entryList(dir.entryList(QStringList() << "*.desktop", QDir::Files));
+ Q_FOREACH (const QString &entry, entryList) {
+ files.append(dir.path() + dir.separator() + entry);
+ }
+ }
+
QMap<QString, KNewFileMenuSingleton::Entry> slist; // used for sorting
Q_FOREACH (const QString &file, files) {
//qDebug() << file;
--
2.0.0