Changeset View
Changeset View
Standalone View
Standalone View
examples/gallery/contents/ui/gallery/ListViewGallery.qml
Show All 14 Lines | |||||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.0 | 20 | import QtQuick 2.0 | ||
21 | import QtQuick.Controls 1.2 as Controls | 21 | import QtQuick.Controls 1.2 as Controls | ||
22 | import QtQuick.Layouts 1.2 | 22 | import QtQuick.Layouts 1.2 | ||
23 | import org.kde.kirigami 1.0 as Kirigami | 23 | import org.kde.kirigami 2.0 as Kirigami | ||
24 | 24 | | |||
25 | Kirigami.ScrollablePage { | 25 | Kirigami.ScrollablePage { | ||
26 | id: page | 26 | id: page | ||
27 | Layout.fillWidth: true | 27 | Layout.fillWidth: true | ||
28 | title: "Long List view" | 28 | title: "Long List view" | ||
29 | 29 | | |||
30 | actions { | 30 | actions { | ||
31 | main: Kirigami.Action { | 31 | main: Kirigami.Action { | ||
32 | iconName: sheet.opened ? "dialog-cancel" : "document-edit" | 32 | iconName: sheet.sheetOpen ? "dialog-cancel" : "document-edit" | ||
33 | text: "Main Action Text" | 33 | text: "Main Action Text" | ||
34 | checked: sheet.opened | 34 | checked: sheet.sheetOpen | ||
35 | checkable: true | 35 | checkable: true | ||
36 | onCheckedChanged: sheet.opened = checked; | 36 | onCheckedChanged: sheet.sheetOpen = checked; | ||
37 | } | 37 | } | ||
38 | } | 38 | } | ||
39 | 39 | | |||
40 | supportsRefreshing: true | 40 | supportsRefreshing: true | ||
41 | onRefreshingChanged: { | 41 | onRefreshingChanged: { | ||
42 | if (refreshing) { | 42 | if (refreshing) { | ||
43 | refreshRequestTimer.running = true; | 43 | refreshRequestTimer.running = true; | ||
44 | } else { | 44 | } else { | ||
45 | showPassiveNotification("Example refreshing completed") | 45 | showPassiveNotification("Example refreshing completed") | ||
46 | } | 46 | } | ||
47 | } | 47 | } | ||
48 | 48 | | |||
49 | background: Rectangle { | 49 | background: Rectangle { | ||
50 | color: Theme.viewBackgroundColor | 50 | color: Kirigami.Theme.viewBackgroundColor | ||
51 | } | 51 | } | ||
52 | Kirigami.OverlaySheet { | 52 | Kirigami.OverlaySheet { | ||
53 | id: sheet | 53 | id: sheet | ||
54 | parent: applicationWindow().overlay | ||||
54 | ListView { | 55 | ListView { | ||
55 | model: 100 | 56 | model: 100 | ||
56 | implicitWidth: Units.gridUnit * 30 | 57 | implicitWidth: Kirigami.Units.gridUnit * 30 | ||
57 | delegate: Kirigami.BasicListItem { | 58 | delegate: Kirigami.BasicListItem { | ||
58 | label: "Item in sheet" + modelData | 59 | label: "Item in sheet" + modelData | ||
59 | } | 60 | } | ||
60 | } | 61 | } | ||
61 | } | 62 | } | ||
62 | 63 | | |||
63 | ListView { | 64 | ListView { | ||
64 | Timer { | 65 | Timer { | ||
65 | id: refreshRequestTimer | 66 | id: refreshRequestTimer | ||
66 | interval: 3000 | 67 | interval: 3000 | ||
67 | onTriggered: page.refreshing = false | 68 | onTriggered: page.refreshing = false | ||
68 | } | 69 | } | ||
69 | model: 200 | 70 | model: 200 | ||
70 | delegate: Kirigami.SwipeListItem { | 71 | delegate: Kirigami.SwipeListItem { | ||
71 | id: listItem | 72 | id: listItem | ||
72 | Kirigami.Label { | 73 | contentItem: Kirigami.Label { | ||
73 | height: Math.max(implicitHeight, Kirigami.Units.iconSizes.smallMedium) | 74 | height: Math.max(implicitHeight, Kirigami.Units.iconSizes.smallMedium) | ||
74 | anchors.verticalCenter: parent.verticalCenter | 75 | anchors.verticalCenter: parent.verticalCenter | ||
75 | x: y | | |||
76 | text: "Item " + modelData | 76 | text: "Item " + modelData | ||
77 | color: listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) ? listItem.activeTextColor : listItem.textColor | 77 | color: listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) ? listItem.activeTextColor : listItem.textColor | ||
78 | } | 78 | } | ||
79 | actions: [ | 79 | actions: [ | ||
80 | Kirigami.Action { | 80 | Kirigami.Action { | ||
81 | iconName: "document-decrypt" | 81 | iconName: "document-decrypt" | ||
82 | onTriggered: showPassiveNotification(model.text + " Action 1 clicked") | 82 | onTriggered: showPassiveNotification(model.text + " Action 1 clicked") | ||
83 | }, | 83 | }, | ||
84 | Kirigami.Action { | 84 | Kirigami.Action { | ||
85 | iconName: "mail-reply-sender" | 85 | iconName: "mail-reply-sender" | ||
86 | onTriggered: showPassiveNotification(model.text + " Action 2 clicked") | 86 | onTriggered: showPassiveNotification(model.text + " Action 2 clicked") | ||
87 | }] | 87 | }] | ||
88 | } | 88 | } | ||
89 | } | 89 | } | ||
90 | } | 90 | } |