From 68c3133498edca4a73be32f976783bd9d4e08e55 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 16 Jun 2018 15:25:57 +0200 Subject: [PATCH] Use Array.map() instead of for loop --- qml/main.qml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/qml/main.qml b/qml/main.qml index 677c46f..5d4abbe 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -48,7 +48,7 @@ Kirigami.ApplicationWindow { Kirigami.Action { text: qsTr("Recently opened ...") iconName: "document-open-recent" - children: createRecentFileActions() + children: createFileActions(nativeInterface.recentFiles) }, Kirigami.Action { text: "Save modifications" @@ -151,7 +151,7 @@ Kirigami.ApplicationWindow { } Component { - id: recentFileActionComponent + id: fileActionComponent Kirigami.Action { property string filePath text: filePath.substring(filePath.lastIndexOf('/') + 1) @@ -179,14 +179,11 @@ Kirigami.ApplicationWindow { })) } - function createRecentFileActions() { - var recentFiles = nativeInterface.recentFiles - var actions = [] - for (var i = 0, count = recentFiles.length; i !== count; ++i) { - actions.push(recentFileActionComponent.createObject(root, { - filePath: recentFiles[i] - })) - } - return actions + function createFileActions(files) { + return files.map(function (filePath) { + return this.createObject(root, { + filePath: filePath + }) + }, fileActionComponent) } }