Warning, /plasma/kdeplasma-addons/applets/quicklaunch/package/contents/ui/UrlModel.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 2.2 0008 0009 ListModel { 0010 id: listModel 0011 0012 property int dropMarkerIndex : -1 0013 0014 signal urlsChanged() 0015 0016 function urls() 0017 { 0018 var out = []; 0019 for (var i = 0; i < listModel.count; ++i) { 0020 out.push(get(i).url); 0021 } 0022 return out; 0023 } 0024 0025 function setUrls(urls) 0026 { 0027 clear(); 0028 insertUrls(0, urls); 0029 0030 urlsChanged(); 0031 } 0032 0033 function appendUrl(url) 0034 { 0035 append({ url: url }); 0036 0037 urlsChanged(); 0038 } 0039 0040 function insertUrl(index, url) 0041 { 0042 insert(index, { url: url }); 0043 0044 urlsChanged(); 0045 } 0046 0047 function insertUrls(index, urls) 0048 { 0049 for (var i = 0; i < urls.length; ++i) { 0050 insert(index + i, { url: urls[i] }); 0051 } 0052 0053 if (urls.length) { 0054 urlsChanged(); 0055 } 0056 } 0057 0058 function changeUrl(index, url) 0059 { 0060 // Force reloading delegate data 0061 set(index, { url: "quicklaunch:empty" }); 0062 set(index, { url: url }); 0063 0064 urlsChanged(); 0065 } 0066 0067 function moveUrl(from, to) 0068 { 0069 if (from == -1 || to == -1 || from == to) { 0070 return false; 0071 } 0072 0073 move(from, to, 1); 0074 0075 urlsChanged(); 0076 return true; 0077 } 0078 0079 function removeUrl(index) 0080 { 0081 remove(index, 1); 0082 0083 urlsChanged(); 0084 } 0085 0086 // Drop marker is internally represented as "quicklaunch:drop" url 0087 function showDropMarker(index) 0088 { 0089 if (index == -1) { 0090 index = dropMarkerIndex == -1 ? count : count - 1; 0091 } 0092 0093 if (dropMarkerIndex != -1) { 0094 move(dropMarkerIndex, index, 1); 0095 dropMarkerIndex = index; 0096 } else { 0097 insert(index, { url: "quicklaunch:drop" }); 0098 dropMarkerIndex = index; 0099 } 0100 } 0101 0102 function clearDropMarker() 0103 { 0104 if (dropMarkerIndex != -1) { 0105 remove(dropMarkerIndex, 1); 0106 dropMarkerIndex = -1; 0107 } 0108 } 0109 }