Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/qml/NewStuffList.qml
Show All 14 Lines | |||||
15 | * Lesser General Public License for more details. | 15 | * Lesser General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | 17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | * | 19 | * | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | import QtQuick 2.2 | 22 | import QtQuick 2.2 | ||
23 | 23 | import QtQuick.Controls 2.5 as QtControls | |||
24 | import org.kde.newstuff 1.0 as NewStuff | 24 | import QtQuick.Layouts 1.12 as QtLayouts | ||
25 | import org.kde.newstuff 1.1 as NewStuff | ||||
25 | 26 | | |||
26 | /** | 27 | /** | ||
27 | * To use NewStuffList, simply instantiate it and pass the | 28 | * To use NewStuffList, simply instantiate it and pass the | ||
28 | * local file location of a knsrc file to the configFile property. | 29 | * local file location of a knsrc file to the configFile property. | ||
29 | * The components will, in this case, take care of the rest for you. | 30 | * The components will, in this case, take care of the rest for you. | ||
30 | * If you want more, you can look at what NewStuffItem does with the | 31 | * If you want more, you can look at what NewStuffItem does with the | ||
31 | * various bits, and be inspired by that. | 32 | * various bits, and be inspired by that. | ||
32 | * | 33 | * | ||
Show All 21 Lines | 49 | ListView { | |||
54 | * KNS3::DownloadDialog | 55 | * KNS3::DownloadDialog | ||
55 | */ | 56 | */ | ||
56 | property alias configFile: newStuffEngine.configFile; | 57 | property alias configFile: newStuffEngine.configFile; | ||
57 | signal message(string message); | 58 | signal message(string message); | ||
58 | signal idleMessage(string message); | 59 | signal idleMessage(string message); | ||
59 | signal busyMessage(string message); | 60 | signal busyMessage(string message); | ||
60 | signal errorMessage(string message); | 61 | signal errorMessage(string message); | ||
61 | signal downloadedItemClicked(variant installedFiles); | 62 | signal downloadedItemClicked(variant installedFiles); | ||
63 | header: QtLayouts.RowLayout { | ||||
64 | anchors { | ||||
65 | left: parent.left | ||||
66 | right: parent.right | ||||
67 | } | ||||
68 | QtControls.ComboBox { | ||||
69 | id: categoriesCombo | ||||
70 | QtLayouts.Layout.fillWidth: true | ||||
71 | model: newStuffEngine.categories | ||||
72 | textRole: "displayName" | ||||
73 | onCurrentIndexChanged: { | ||||
74 | newStuffEngine.categoriesFilter = model.data(currentIndex, NewStuff.CategoriesModel.NameRole); | ||||
75 | } | ||||
76 | } | ||||
77 | QtControls.ComboBox { | ||||
78 | id: filterCombo | ||||
79 | QtLayouts.Layout.fillWidth: true | ||||
80 | model: ListModel {} | ||||
81 | Component.onCompleted: { | ||||
82 | filterCombo.model.append({ text: i18nc("List option which will set the filter to show everything", "Show Everything") }); | ||||
83 | filterCombo.model.append({ text: i18nc("List option which will set the filter so only installed items are shown", "Installed Only") }); | ||||
84 | filterCombo.model.append({ text: i18nc("List option which will set the filter so only installed items with updates available are shown", "Updateable Only") }); | ||||
85 | filterCombo.currentIndex = newStuffEngine.filter; | ||||
86 | } | ||||
87 | onCurrentIndexChanged: { | ||||
88 | newStuffEngine.filter = currentIndex; | ||||
89 | } | ||||
90 | } | ||||
91 | QtControls.ComboBox { | ||||
92 | id: sortCombo | ||||
93 | QtLayouts.Layout.fillWidth: true | ||||
94 | model: ListModel { } | ||||
95 | Component.onCompleted: { | ||||
96 | sortCombo.model.append({ text: i18nc("List option which will set the sort order to based on when items were most recently updated", "Show most recent first") }); | ||||
97 | sortCombo.model.append({ text: i18nc("List option which will set the sort order to be alphabetical based on the name", "Sort alphabetically") }); | ||||
98 | sortCombo.model.append({ text: i18nc("List option which will set the sort order to based on user ratings", "Show highest rated first") }); | ||||
99 | sortCombo.model.append({ text: i18nc("List option which will set the sort order to based on number of downloads", "Show most downloaded first") }); | ||||
100 | sortCombo.currentIndex = newStuffEngine.sortOrder; | ||||
101 | } | ||||
102 | onCurrentIndexChanged: { | ||||
103 | newStuffEngine.sortOrder = currentIndex; | ||||
104 | } | ||||
105 | } | ||||
106 | } | ||||
62 | delegate: NewStuffItem { | 107 | delegate: NewStuffItem { | ||
63 | listModel: newStuffModel; | 108 | listModel: newStuffModel; | ||
64 | onClicked: { | 109 | onClicked: { | ||
65 | if(model.status == NewStuff.ItemsModel.InstalledStatus) { | 110 | if(model.status == NewStuff.ItemsModel.InstalledStatus) { | ||
66 | root.downloadedItemClicked(model.installedFiles); | 111 | root.downloadedItemClicked(model.installedFiles); | ||
67 | } | 112 | } | ||
68 | } | 113 | } | ||
69 | } | 114 | } | ||
70 | model: NewStuff.ItemsModel { | 115 | model: NewStuff.ItemsModel { | ||
71 | id: newStuffModel; | 116 | id: newStuffModel; | ||
72 | engine: newStuffEngine.engine; | 117 | engine: newStuffEngine; | ||
73 | } | 118 | } | ||
74 | NewStuff.Engine { | 119 | NewStuff.Engine { | ||
75 | id: newStuffEngine; | 120 | id: newStuffEngine; | ||
76 | onMessage: root.message(message); | 121 | onMessage: root.message(message); | ||
77 | onIdleMessage: root.idleMessage(message); | 122 | onIdleMessage: root.idleMessage(message); | ||
78 | onBusyMessage: root.busyMessage(message); | 123 | onBusyMessage: root.busyMessage(message); | ||
79 | onErrorMessage: root.errorMessage(message); | 124 | onErrorMessage: root.errorMessage(message); | ||
80 | } | 125 | } | ||
126 | NewStuff.QuestionAsker {} | ||||
81 | } | 127 | } |