KNewStuff

NewStuffList.qml
1 /*
2  SPDX-FileCopyrightText: 2015 Dan Leinir Turthra Jensen <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 import QtQuick 2.11
8 import QtQuick.Controls 2.11 as QtControls
9 import QtQuick.Layouts 1.11 as QtLayouts
10 
11 import org.kde.newstuff 1.62 as NewStuff
12 
35 ListView {
36  id: root;
43  property alias configFile: newStuffEngine.configFile;
44  signal message(string message);
45  signal idleMessage(string message);
46  signal busyMessage(string message);
47  signal errorMessage(string message);
48  signal downloadedItemClicked(variant installedFiles);
49  header: QtLayouts.RowLayout {
50  anchors {
51  left: parent.left
52  right: parent.right
53  }
54  QtControls.ComboBox {
55  id: categoriesCombo
56  QtLayouts.Layout.fillWidth: true
57  model: newStuffEngine.categories
58  textRole: "displayName"
59  onCurrentIndexChanged: {
60  newStuffEngine.categoriesFilter = model.data(model.index(currentIndex, 0), NewStuff.CategoriesModel.NameRole);
61  }
62  }
63  QtControls.ComboBox {
64  id: filterCombo
65  QtLayouts.Layout.fillWidth: true
66  model: ListModel {}
67  Component.onCompleted: {
68  filterCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the filter to show everything", "Show Everything") });
69  filterCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the filter so only installed items are shown", "Installed Only") });
70  filterCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the filter so only installed items with updates available are shown", "Updateable Only") });
71  filterCombo.currentIndex = newStuffEngine.filter;
72  }
73  onCurrentIndexChanged: {
74  newStuffEngine.filter = currentIndex;
75  }
76  }
77  QtControls.ComboBox {
78  id: sortCombo
79  QtLayouts.Layout.fillWidth: true
80  model: ListModel { }
81  Component.onCompleted: {
82  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") });
83  sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to be alphabetical based on the name", "Sort alphabetically") });
84  sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to based on user ratings", "Show highest rated first") });
85  sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to based on number of downloads", "Show most downloaded first") });
86  sortCombo.currentIndex = newStuffEngine.sortOrder;
87  }
88  onCurrentIndexChanged: {
89  newStuffEngine.sortOrder = currentIndex;
90  }
91  }
92  }
93  delegate: NewStuffItem {
94  listModel: newStuffModel;
95  onClicked: {
96  if(model.status == NewStuff.ItemsModel.InstalledStatus) {
97  root.downloadedItemClicked(model.installedFiles);
98  }
99  }
100  }
101  model: NewStuff.ItemsModel {
102  id: newStuffModel;
103  engine: newStuffEngine;
104  }
105  NewStuff.Engine {
106  id: newStuffEngine;
107  onMessage: root.message(message);
108  onIdleMessage: root.idleMessage(message);
109  onBusyMessage: root.busyMessage(message);
110  onErrorMessage: root.errorMessage(message);
111  }
112  NewStuff.QuestionAsker {}
113 }
KCOREADDONS_EXPORT void message(KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
QTextStream & right(QTextStream &stream)
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QTextStream & left(QTextStream &stream)
QTextStream & left(QTextStream &s)
KCALUTILS_EXPORT QString errorMessage(const KCalendarCore::Exception &exception)
QTextStream & right(QTextStream &s)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.