Warning, /frameworks/knewstuff/src/qtquick/qml/NewStuffList.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2015 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 import QtQuick 2.11 0008 import QtQuick.Controls 2.11 as QtControls 0009 import QtQuick.Layouts 1.11 as QtLayouts 0010 0011 import org.kde.newstuff 1.62 as NewStuff 0012 0013 /** 0014 * To use NewStuffList, simply instantiate it and pass the 0015 * local file location of a knsrc file to the configFile property. 0016 * The components will, in this case, take care of the rest for you. 0017 * If you want more, you can look at what NewStuffItem does with the 0018 * various bits, and be inspired by that. 0019 * 0020 * An (overly simple) example which might be used for managing 0021 * wallpapers and just outputting any messages onto the console can 0022 * be seen below. Note that you should obviously not be using 0023 * hardcoded paths, it is done here to get the idea across. 0024 * 0025 * \code 0026 NewStuff.NewStuffList { 0027 configFile: "/some/filesystem/location/wallpaper.knsrc"; 0028 onMessage: console.log("KNS Message: " + message); 0029 onIdleMessage: console.log("KNS Idle: " + message); 0030 onBusyMessage: console.log("KNS Busy: " + message); 0031 onErrorMessage: console.log("KNS Error: " + message); 0032 } 0033 \endcode 0034 */ 0035 ListView { 0036 id: root; 0037 /** 0038 * @brief The configuration file which describes the application (knsrc) 0039 * 0040 * The format and location of this file is found in the documentation for 0041 * KNS3::DownloadDialog 0042 */ 0043 property alias configFile: newStuffEngine.configFile; 0044 signal message(string message); 0045 signal idleMessage(string message); 0046 signal busyMessage(string message); 0047 signal errorMessage(string message); 0048 signal downloadedItemClicked(variant installedFiles); 0049 header: QtLayouts.RowLayout { 0050 anchors { 0051 left: parent.left 0052 right: parent.right 0053 } 0054 QtControls.ComboBox { 0055 id: categoriesCombo 0056 QtLayouts.Layout.fillWidth: true 0057 model: newStuffEngine.categories 0058 textRole: "displayName" 0059 onCurrentIndexChanged: { 0060 newStuffEngine.categoriesFilter = model.data(model.index(currentIndex, 0), NewStuff.CategoriesModel.NameRole); 0061 } 0062 } 0063 QtControls.ComboBox { 0064 id: filterCombo 0065 QtLayouts.Layout.fillWidth: true 0066 model: ListModel {} 0067 Component.onCompleted: { 0068 filterCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the filter to show everything", "Show Everything") }); 0069 filterCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the filter so only installed items are shown", "Installed Only") }); 0070 filterCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the filter so only installed items with updates available are shown", "Updateable Only") }); 0071 filterCombo.currentIndex = newStuffEngine.filter; 0072 } 0073 onCurrentIndexChanged: { 0074 newStuffEngine.filter = currentIndex; 0075 } 0076 } 0077 QtControls.ComboBox { 0078 id: sortCombo 0079 QtLayouts.Layout.fillWidth: true 0080 model: ListModel { } 0081 Component.onCompleted: { 0082 sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to based on when items were most recently updated", "Show most recent first") }); 0083 sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to be alphabetical based on the name", "Sort alphabetically") }); 0084 sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to based on user ratings", "Show highest rated first") }); 0085 sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to based on number of downloads", "Show most downloaded first") }); 0086 sortCombo.currentIndex = newStuffEngine.sortOrder; 0087 } 0088 onCurrentIndexChanged: { 0089 newStuffEngine.sortOrder = currentIndex; 0090 } 0091 } 0092 } 0093 delegate: NewStuffItem { 0094 listModel: newStuffModel; 0095 onClicked: { 0096 if(model.status == NewStuff.ItemsModel.InstalledStatus) { 0097 root.downloadedItemClicked(model.installedFiles); 0098 } 0099 } 0100 } 0101 model: NewStuff.ItemsModel { 0102 id: newStuffModel; 0103 engine: newStuffEngine; 0104 } 0105 NewStuff.Engine { 0106 id: newStuffEngine; 0107 onMessage: root.message(message); 0108 onIdleMessage: root.idleMessage(message); 0109 onBusyMessage: root.busyMessage(message); 0110 onErrorMessage: root.errorMessage(message); 0111 } 0112 NewStuff.QuestionAsker {} 0113 }