Changeset View
Changeset View
Standalone View
Standalone View
examples/gallerydata/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.4 | 20 | import QtQuick 2.4 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import QtQuick.Controls 2.0 as Controls | 22 | import QtQuick.Controls 2.0 as Controls | ||
23 | import org.kde.kirigami 2.4 as Kirigami | 23 | import org.kde.kirigami 2.5 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 { | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 75 | ListView { | |||
76 | model: 100 | 76 | model: 100 | ||
77 | implicitWidth: Kirigami.Units.gridUnit * 30 | 77 | implicitWidth: Kirigami.Units.gridUnit * 30 | ||
78 | delegate: Kirigami.BasicListItem { | 78 | delegate: Kirigami.BasicListItem { | ||
79 | label: "Item in sheet" + modelData | 79 | label: "Item in sheet" + modelData | ||
80 | } | 80 | } | ||
81 | } | 81 | } | ||
82 | } | 82 | } | ||
83 | 83 | | |||
84 | ListView { | 84 | Component { | ||
85 | Timer { | 85 | id: delegateComponent | ||
86 | id: refreshRequestTimer | 86 | Kirigami.SwipeListItem { | ||
87 | interval: 3000 | | |||
88 | onTriggered: page.refreshing = false | | |||
89 | } | | |||
90 | model: 200 | | |||
91 | delegate: Kirigami.SwipeListItem { | | |||
92 | id: listItem | 87 | id: listItem | ||
93 | contentItem: Controls.Label { | 88 | contentItem: RowLayout { | ||
89 | Kirigami.ListItemDragHandle { | ||||
90 | listItem: listItem | ||||
91 | listView: mainList | ||||
92 | onMoveRequested: listModel.move(oldIndex, newIndex, 1) | ||||
93 | } | ||||
94 | | ||||
95 | Controls.Label { | ||||
96 | Layout.fillWidth: true | ||||
94 | height: Math.max(implicitHeight, Kirigami.Units.iconSizes.smallMedium) | 97 | height: Math.max(implicitHeight, Kirigami.Units.iconSizes.smallMedium) | ||
95 | anchors.verticalCenter: parent.verticalCenter | 98 | text: model.title | ||
96 | text: "Item " + modelData | | |||
97 | color: listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) ? listItem.activeTextColor : listItem.textColor | 99 | color: listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) ? listItem.activeTextColor : listItem.textColor | ||
98 | } | 100 | } | ||
101 | } | ||||
99 | actions: [ | 102 | actions: [ | ||
100 | Kirigami.Action { | 103 | Kirigami.Action { | ||
101 | iconName: "document-decrypt" | 104 | iconName: "document-decrypt" | ||
102 | text: "Action 1" | 105 | text: "Action 1" | ||
103 | onTriggered: showPassiveNotification(model.text + " Action 1 clicked") | 106 | onTriggered: showPassiveNotification(model.text + " Action 1 clicked") | ||
104 | }, | 107 | }, | ||
105 | Kirigami.Action { | 108 | Kirigami.Action { | ||
106 | iconName: "mail-reply-sender" | 109 | iconName: "mail-reply-sender" | ||
107 | text: "Action 2" | 110 | text: "Action 2" | ||
108 | onTriggered: showPassiveNotification(model.text + " Action 2 clicked") | 111 | onTriggered: showPassiveNotification(model.text + " Action 2 clicked") | ||
109 | }] | 112 | }] | ||
110 | } | 113 | } | ||
111 | } | 114 | } | ||
115 | ListView { | ||||
116 | id: mainList | ||||
117 | Timer { | ||||
118 | id: refreshRequestTimer | ||||
119 | interval: 3000 | ||||
120 | onTriggered: page.refreshing = false | ||||
121 | } | ||||
122 | model: ListModel { | ||||
123 | id: listModel | ||||
124 | | ||||
125 | Component.onCompleted: { | ||||
126 | for (var i = 0; i < 200; ++i) { | ||||
127 | listModel.append({"title": "Item " + i, | ||||
128 | "actions": [{text: "Action 1", icon: "document-decrypt"}, | ||||
129 | {text: "Action 2", icon: "mail-reply-sender"}] | ||||
130 | }) | ||||
131 | } | ||||
132 | } | ||||
133 | } | ||||
134 | moveDisplaced: Transition { | ||||
135 | YAnimator { | ||||
136 | duration: Kirigami.Units.longDuration | ||||
137 | easing.type: Easing.InOutQuad | ||||
138 | } | ||||
139 | } | ||||
140 | delegate: Kirigami.DelegateRecycler { | ||||
141 | width: parent ? parent.width : implicitWidth | ||||
142 | sourceComponent: delegateComponent | ||||
143 | } | ||||
144 | } | ||||
112 | } | 145 | } |