[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [bodega-client] activeclient/package/contents/ui/storebrowser: New QML component, BrowserListView
From: Giorgos Tsiapaliokas <terietor () gmail ! com>
Date: 2013-06-13 13:38:36
Message-ID: 20130613133836.748F5A605A () git ! kde ! org
[Download RAW message or body]
Git commit 69245427a3c235cc9edcbe65b3a6f50256b864ac by Giorgos Tsiapaliokas.
Committed on 13/06/2013 at 15:38.
Pushed by tsiapaliwkas into branch 'master'.
New QML component, BrowserListView
REVIEW: 110635
A +101 -0 activeclient/package/contents/ui/storebrowser/BrowserListView.qml \
[License: LGPL (v2+)] M +22 -83 \
activeclient/package/contents/ui/storebrowser/ChannelsColumn.qml M +47 -116 \
activeclient/package/contents/ui/storebrowser/InstallJobsColumn.qml
http://commits.kde.org/bodega-client/69245427a3c235cc9edcbe65b3a6f50256b864ac
diff --git a/activeclient/package/contents/ui/storebrowser/BrowserListView.qml \
b/activeclient/package/contents/ui/storebrowser/BrowserListView.qml new file mode \
100644 index 0000000..0ee82ec
--- /dev/null
+++ b/activeclient/package/contents/ui/storebrowser/BrowserListView.qml
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2013 Giorgos Tsiapaliokas <terietor@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import QtQuick 1.1
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
+import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.plasma.extras 0.1 as PlasmaExtras
+import "../components"
+
+BrowserColumn {
+ clip: true
+ property alias abstractItemModel: visualDataModel.model
+ property alias customDelegate: listView.delegate
+ property alias view: listView
+ property alias customHeader: listView.header
+
+ VisualDataModel {
+ id: visualDataModel
+ rootIndex: root.rootIndex
+ delegate: listView.delegate
+ }
+
+ PlasmaExtras.ScrollArea {
+ anchors.fill:parent
+ ListView {
+ id: listView
+ currentIndex: -1
+ clip: true
+ anchors.fill:parent
+ model: visualDataModel
+
+ footer: PlasmaComponents.ListItem {
+ id: loaderFooter
+ visible: false
+ Connections {
+ target: listView
+ onAtYEndChanged: {
+ if (visualDataModel.model.canFetchMore == undefined) {
+ return;
+ }
+
+ if (listView.atYEnd) {
+ loaderFooter.visible = \
visualDataModel.model.canFetchMore(rootIndex) + } else {
+ loaderFooter.visible = false
+ }
+ }
+ }
+ PlasmaComponents.BusyIndicator {
+ running: parent.visible
+ anchors.centerIn: parent
+ }
+ }
+
+ header: customHeader
+ }
+ }
+
+ PlasmaComponents.ToolButton {
+ iconSource: "go-top"
+ z: 100
+ width: theme.largeIconSize
+ height: width
+ anchors {
+ top: parent.top
+ right: parent.right
+ margins: 16
+ }
+ opacity: listView.flicking && listView.moving ? 1 : 0
+ Behavior on opacity {
+ NumberAnimation {
+ duration: 250
+ easing.type: Easing.InOutQuad
+ }
+ }
+ onClicked: PropertyAnimation {
+ target: listView
+ properties: "contentY"
+ to: 0
+ duration: 250
+ }
+ }
+}
+
diff --git a/activeclient/package/contents/ui/storebrowser/ChannelsColumn.qml \
b/activeclient/package/contents/ui/storebrowser/ChannelsColumn.qml index \
74c1b2b..b09ca98 100644
--- a/activeclient/package/contents/ui/storebrowser/ChannelsColumn.qml
+++ b/activeclient/package/contents/ui/storebrowser/ChannelsColumn.qml
@@ -24,9 +24,9 @@ import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.extras 0.1 as PlasmaExtras
import "../components"
-BrowserColumn {
+BrowserListView {
id: root
- clip: true
+ abstractItemModel: bodegaClient.channelsModel
property variant rootIndex
property string channelId
@@ -48,106 +48,45 @@ BrowserColumn {
PlasmaComponents.ToolBar {
id: toolBar
- y: -categoriesView.contentY
+ y: -view.contentY
z: 1
tools: MobileComponents.ViewSearch {
id: searchField
onSearchQueryChanged: {
//var job = bodegaClient.session.search(searchQuery, -1, -1)
if (searchQuery.length > 3) {
- categoriesView.model = searchModel
+ listView.model = searchModel
bodegaClient.searchModel.topChannel = root.channelId
bodegaClient.searchModel.searchQuery = searchQuery
} else {
- categoriesView.model = channelsModel
+ listView.model = visualDataModel
bodegaClient.searchModel.searchQuery = ""
}
- categoriesView.currentIndex = -1
+ listView.currentIndex = -1
}
}
}
- PlasmaExtras.ScrollArea {
- anchors.fill: parent
-
- ListView {
- id: categoriesView
- currentIndex: -1
- clip: true
- anchors.fill: parent
-
- model: channelsModel
-
- Component {
- id: delegateComponent
- StoreListItem {
- checked: categoriesView.currentIndex == index
- onClicked: {
- if (categoriesView.currentIndex == index) {
- return
- }
- categoriesView.currentIndex = index
- itemBrowser.pop(root)
-
- if (model.ChannelIdRole) {
- var channelsPage = \
itemBrowser.push(Qt.createComponent("ChannelsColumn.qml"))
- channelsPage.rootIndex = \
categoriesView.model.modelIndex(index)
- channelsPage.channelId = model.ChannelIdRole
- } else if (model.AssetIdRole) {
- var assetPage = \
itemBrowser.push(Qt.createComponent("AssetColumn.qml"))
- assetPage.assetId = model.AssetIdRole
- }
- }
+ customDelegate: Component {
+ id: delegateComponent
+ StoreListItem {
+ checked: view.currentIndex == index
+ onClicked: {
+ if (view.currentIndex == index) {
+ return
}
- }
-
- header: Item {
- width: parent.width
- height: toolBar.height
- }
+ view.currentIndex = index
+ itemBrowser.pop(root)
- footer: PlasmaComponents.ListItem {
- id: loaderFooter
- Connections {
- target: categoriesView
- onAtYEndChanged: {
- if (categoriesView.atYEnd) {
- loaderFooter.visible = \
categoriesView.model.canFetchMore(rootIndex)
- } else {
- loaderFooter.visible = false
- }
- }
- }
- PlasmaComponents.BusyIndicator {
- running: parent.visible
- anchors.centerIn: parent
+ if (model.ChannelIdRole) {
+ var channelsPage = \
itemBrowser.push(Qt.createComponent("ChannelsColumn.qml")) + \
channelsPage.rootIndex = view.model.modelIndex(index) + \
channelsPage.channelId = model.ChannelIdRole + } else if \
(model.AssetIdRole) { + var assetPage = \
itemBrowser.push(Qt.createComponent("AssetColumn.qml")) + \
assetPage.assetId = model.AssetIdRole }
}
}
}
-
- PlasmaComponents.ToolButton {
- iconSource: "go-top"
- z: 100
- width: theme.largeIconSize
- height: width
- anchors {
- top: parent.top
- right: parent.right
- margins: 16
- }
- opacity: categoriesView.flicking && categoriesView.moving ? 1 : 0
- Behavior on opacity {
- NumberAnimation {
- duration: 250
- easing.type: Easing.InOutQuad
- }
- }
- onClicked: PropertyAnimation {
- target: categoriesView
- properties: "contentY"
- to: 0
- duration: 250
- }
- }
}
diff --git a/activeclient/package/contents/ui/storebrowser/InstallJobsColumn.qml \
b/activeclient/package/contents/ui/storebrowser/InstallJobsColumn.qml index \
a937756..95b75c1 100644
--- a/activeclient/package/contents/ui/storebrowser/InstallJobsColumn.qml
+++ b/activeclient/package/contents/ui/storebrowser/InstallJobsColumn.qml
@@ -24,134 +24,65 @@ import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.extras 0.1 as PlasmaExtras
import "../components"
-BrowserColumn {
- id: root
+BrowserListView {
clip: true
- property variant rootIndex
- property string channelId
-
- VisualDataModel {
- id: channelsModel
- model: bodegaClient.session.installJobsModel
- rootIndex: root.rootIndex
- delegate: delegateComponent
- }
-
-
- PlasmaExtras.ScrollArea {
- anchors.fill:parent
- ListView {
- id: categoriesView
- currentIndex: -1
- clip: true
- anchors.fill:parent
-
- model: channelsModel
-
- delegate: Component {
- id: delegateComponent
- PlasmaComponents.ListItem {
- id: listItem
- enabled: true
- checked: categoriesView.currentIndex == index
- Row {
- id: delegateRow
- spacing: theme.defaultFont.mSize.width
- anchors {
- left: parent.left
- right: parent.right
- }
- Image {
- id: iconImage
- source: model.ImageMediumRole
- width: theme.mediumIconSize
- height: width
+ abstractItemModel: bodegaClient.session.installJobsModel
+ customDelegate: Component {
+ id: delegateComponent
+ PlasmaComponents.ListItem {
+ id: listItem
+ enabled: true
+ checked: view.currentIndex == index
+ Row {
+ id: delegateRow
+ spacing: theme.defaultFont.mSize.width
+ Image {
+ id: iconImage
+ source: model.ImageMediumRole
+ width: theme.mediumIconSize
+ height: width
+ }
+ Column {
+ PlasmaComponents.Label {
+ text: model.DisplayRole
+ width: delegateRow.width - iconImage.width - \
theme.defaultFont.mSize.width + elide: Text.ElideRight
}
- Column {
- PlasmaComponents.Label {
- text: model.DisplayRole
- width: delegateRow.width - iconImage.width - \
theme.defaultFont.mSize.width
- elide: Text.ElideRight
- }
- PlasmaComponents.ProgressBar {
- id: downloadProgress
- visible: value < maximumValue
- minimumValue: 0
- maximumValue: 100
- value: model.ProgressRole*100
- height: doneLabel.height
- anchors {
- left: parent.left
- right: parent.right
- }
- }
- PlasmaComponents.Label {
- id: doneLabel
- text: i18n("Download finished")
- height: paintedHeight
- visible: !downloadProgress.visible
- font.pointSize: theme.smallestFont.pointSize
+ PlasmaComponents.ProgressBar {
+ id: downloadProgress
+ visible: value < maximumValue
+ minimumValue: 0
+ maximumValue: 100
+ value: model.ProgressRole*100
+ height: doneLabel.height
+ anchors {
+ left: parent.left
+ right: parent.right
}
}
- }
- onClicked: {
- if (categoriesView.currentIndex == index) {
- return
- }
- categoriesView.currentIndex = index
- itemBrowser.pop(root)
+ PlasmaComponents.Label {
+ id: doneLabel
+ text: i18n("Download finished")
+ height: paintedHeight
+ visible: !downloadProgress.visible
+ font.pointSize: theme.smallestFont.pointSize
- if (model.AssetIdRole) {
- var assetPage = \
itemBrowser.push(Qt.createComponent("AssetColumn.qml"))
- assetPage.assetId = model.AssetIdRole
}
}
}
- }
+ onClicked: {
+ if (view.currentIndex == index) {
+ return
+ }
+ view.currentIndex = index
+ itemBrowser.pop(browserColumn)
- footer: PlasmaComponents.ListItem {
- id: loaderFooter
- Connections {
- target: categoriesView
- onAtYEndChanged: {
- if (categoriesView.atYEnd) {
- loaderFooter.visible = \
bodegaClient.channelsModel.canFetchMore(rootIndex)
- } else {
- loaderFooter.visible = false
- }
+ if (model.AssetIdRole) {
+ var assetPage = \
itemBrowser.push(Qt.createComponent("AssetColumn.qml")) + \
assetPage.assetId = model.AssetIdRole }
}
- PlasmaComponents.BusyIndicator {
- running: parent.visible
- anchors.centerIn: parent
- }
- }
- }
- }
-
- PlasmaComponents.ToolButton {
- iconSource: "go-top"
- z: 100
- width: theme.largeIconSize
- height: width
- anchors {
- top: parent.top
- right: parent.right
- margins: 16
- }
- opacity: categoriesView.flicking && categoriesView.moving ? 1 : 0
- Behavior on opacity {
- NumberAnimation {
- duration: 250
- easing.type: Easing.InOutQuad
- }
- }
- onClicked: PropertyAnimation {
- target: categoriesView
- properties: "contentY"
- to: 0
- duration: 250
}
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic