KNewStuff

NewStuffList.qml
1 /*
2  * Copyright (C) 2015 Dan Leinir Turthra Jensen <[email protected]>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) version 3, or any
8  * later version accepted by the membership of KDE e.V. (or its
9  * successor approved by the membership of KDE e.V.), which shall
10  * act as a proxy defined in Section 6 of version 3 of the license.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
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/>.
19  *
20  */
21 
22 import QtQuick 2.11
23 import QtQuick.Controls 2.11 as QtControls
24 import QtQuick.Layouts 1.11 as QtLayouts
25 
26 import org.kde.newstuff 1.62 as NewStuff
27 
50 ListView {
51  id: root;
58  property alias configFile: newStuffEngine.configFile;
59  signal message(string message);
60  signal idleMessage(string message);
61  signal busyMessage(string message);
62  signal errorMessage(string message);
63  signal downloadedItemClicked(variant installedFiles);
64  header: QtLayouts.RowLayout {
65  anchors {
66  left: parent.left
67  right: parent.right
68  }
69  QtControls.ComboBox {
70  id: categoriesCombo
71  QtLayouts.Layout.fillWidth: true
72  model: newStuffEngine.categories
73  textRole: "displayName"
74  onCurrentIndexChanged: {
75  newStuffEngine.categoriesFilter = model.data(model.index(currentIndex, 0), NewStuff.CategoriesModel.NameRole);
76  }
77  }
78  QtControls.ComboBox {
79  id: filterCombo
80  QtLayouts.Layout.fillWidth: true
81  model: ListModel {}
82  Component.onCompleted: {
83  filterCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the filter to show everything", "Show Everything") });
84  filterCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the filter so only installed items are shown", "Installed Only") });
85  filterCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the filter so only installed items with updates available are shown", "Updateable Only") });
86  filterCombo.currentIndex = newStuffEngine.filter;
87  }
88  onCurrentIndexChanged: {
89  newStuffEngine.filter = currentIndex;
90  }
91  }
92  QtControls.ComboBox {
93  id: sortCombo
94  QtLayouts.Layout.fillWidth: true
95  model: ListModel { }
96  Component.onCompleted: {
97  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") });
98  sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to be alphabetical based on the name", "Sort alphabetically") });
99  sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to based on user ratings", "Show highest rated first") });
100  sortCombo.model.append({ text: i18ndc("knewstuff5", "List option which will set the sort order to based on number of downloads", "Show most downloaded first") });
101  sortCombo.currentIndex = newStuffEngine.sortOrder;
102  }
103  onCurrentIndexChanged: {
104  newStuffEngine.sortOrder = currentIndex;
105  }
106  }
107  }
108  delegate: NewStuffItem {
109  listModel: newStuffModel;
110  onClicked: {
111  if(model.status == NewStuff.ItemsModel.InstalledStatus) {
112  root.downloadedItemClicked(model.installedFiles);
113  }
114  }
115  }
116  model: NewStuff.ItemsModel {
117  id: newStuffModel;
118  engine: newStuffEngine;
119  }
120  NewStuff.Engine {
121  id: newStuffEngine;
122  onMessage: root.message(message);
123  onIdleMessage: root.idleMessage(message);
124  onBusyMessage: root.busyMessage(message);
125  onErrorMessage: root.errorMessage(message);
126  }
127  NewStuff.QuestionAsker {}
128 }
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-2020 The KDE developers.
Generated on Sun Aug 9 2020 22:43:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.