[vlc-commits] qml: rename ExpandGridView.model to ExpandGridView.delegateModel
Pierre Lamot
git at videolan.org
Thu Feb 20 13:56:39 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Feb 13 18:05:52 2020 +0100| [de38cc0f4f340d90b422dbc35c002246672cc044] | committer: Jean-Baptiste Kempf
qml: rename ExpandGridView.model to ExpandGridView.delegateModel
This prepare for next patch where the ExpandGridView needs both the model and
the delegate model
Fix name collision in calling sites.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=de38cc0f4f340d90b422dbc35c002246672cc044
---
modules/gui/qt/medialibrary/qml/MusicAlbums.qml | 55 ++++++++++----------
modules/gui/qt/medialibrary/qml/MusicGenres.qml | 59 +++++++++++-----------
modules/gui/qt/medialibrary/qml/VideoDisplay.qml | 8 +--
.../gui/qt/network/qml/NetworkBrowseDisplay.qml | 51 +++++++++----------
modules/gui/qt/widgets/qml/ExpandGridView.qml | 31 ++++++------
5 files changed, 100 insertions(+), 104 deletions(-)
diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
index 3d4e998dd8..1a2c68481a 100644
--- a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
@@ -36,8 +36,8 @@ Widgets.NavigableFocusScope {
{ text: i18n.qtr("Artist"), criteria: "main_artist" },
]
- property alias model: delegateModel.model
- property alias parentId: delegateModel.parentId
+ property alias model: delegateModelId.model
+ property alias parentId: delegateModelId.parentId
readonly property var currentIndex: view.currentItem.currentIndex
//the index to "go to" when the view is loaded
property var initialIndex: 0
@@ -60,20 +60,20 @@ Widgets.NavigableFocusScope {
onParentIdChanged: resetFocus()
function resetFocus() {
- if (delegateModel.items.count === 0) {
+ if (delegateModelId.items.count === 0) {
return
}
var initialIndex = root.initialIndex
- if (initialIndex >= delegateModel.items.count)
+ if (initialIndex >= delegateModelId.items.count)
initialIndex = 0
- delegateModel.selectNone()
- delegateModel.items.get(initialIndex).inSelected = true
+ delegateModelId.selectNone()
+ delegateModelId.items.get(initialIndex).inSelected = true
view.currentItem.currentIndex = initialIndex
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
Util.SelectableDelegateModel {
- id: delegateModel
+ id: delegateModelId
property alias parentId: albumModelId.parentId
model: MLAlbumModel {
@@ -100,7 +100,7 @@ Widgets.NavigableFocusScope {
line2: model.main_artist || i18n.qtr("Unknown artist")
onItemClicked : {
- delegateModel.updateSelection( modifier, view.currentItem.currentIndex, index )
+ delegateModelId.updateSelection( modifier, view.currentItem.currentIndex, index )
view.currentItem.currentIndex = index
this.forceActiveFocus()
}
@@ -110,19 +110,19 @@ Widgets.NavigableFocusScope {
}
onCountChanged: {
- if (delegateModel.items.count > 0 && delegateModel.selectedGroup.count === 0) {
+ if (delegateModelId.items.count > 0 && delegateModelId.selectedGroup.count === 0) {
root.resetFocus()
}
}
function actionAtIndex(index) {
- if (delegateModel.selectedGroup.count > 1) {
+ if (delegateModelId.selectedGroup.count > 1) {
var list = []
- for (var i = 0; i < delegateModel.selectedGroup.count; i++)
- list.push(delegateModel.selectedGroup.get(i).model.id)
+ for (var i = 0; i < delegateModelId.selectedGroup.count; i++)
+ list.push(delegateModelId.selectedGroup.get(i).model.id)
medialib.addAndPlay( list )
} else {
- medialib.addAndPlay( delegateModel.items.get(index).model.id )
+ medialib.addAndPlay( delegateModelId.items.get(index).model.id )
}
}
}
@@ -140,11 +140,13 @@ Widgets.NavigableFocusScope {
headerDelegate: root.header
+ delegateModel: delegateModelId
+
delegate: AudioGridItem {
id: audioGridItem
onItemClicked : {
- delegateModel.updateSelection( modifier , root.currentIndex, index)
+ delegateModelId.updateSelection( modifier , root.currentIndex, index)
gridView_id.currentIndex = index
gridView_id.forceActiveFocus()
}
@@ -167,18 +169,15 @@ Widgets.NavigableFocusScope {
}
- model: delegateModel
- modelCount: delegateModel.items.count
-
onActionAtIndex: {
- if (delegateModel.selectedGroup.count === 1) {
+ if (delegateModelId.selectedGroup.count === 1) {
view._switchExpandItem(index)
} else {
- delegateModel.actionAtIndex(index)
+ delegateModelId.actionAtIndex(index)
}
}
- onSelectAll: delegateModel.selectAll()
- onSelectionUpdated: delegateModel.updateSelection( keyModifiers, oldIndex, newIndex )
+ onSelectAll: delegateModelId.selectAll()
+ onSelectionUpdated: delegateModelId.updateSelection( keyModifiers, oldIndex, newIndex )
navigationParent: root
}
@@ -194,12 +193,12 @@ Widgets.NavigableFocusScope {
spacing: VLCStyle.margin_xxxsmall
- model: delegateModel.parts.list
- modelCount: delegateModel.items.count
+ model: delegateModelId.parts.list
+ modelCount: delegateModelId.items.count
- onActionAtIndex: delegateModel.actionAtIndex(index)
- onSelectAll: delegateModel.selectAll()
- onSelectionUpdated: delegateModel.updateSelection( keyModifiers, oldIndex, newIndex )
+ onActionAtIndex: delegateModelId.actionAtIndex(index)
+ onSelectAll: delegateModelId.selectAll()
+ onSelectionUpdated: delegateModelId.updateSelection( keyModifiers, oldIndex, newIndex )
navigationParent: root
navigationCancel: function() {
@@ -215,7 +214,7 @@ Widgets.NavigableFocusScope {
id: view
anchors.fill: parent
- focus: delegateModel.items.count !== 0
+ focus: delegateModelId.items.count !== 0
initialItem: medialib.gridView ? gridComponent : listComponent
@@ -241,7 +240,7 @@ Widgets.NavigableFocusScope {
EmptyLabel {
anchors.fill: parent
- visible: delegateModel.items.count === 0
+ visible: delegateModelId.items.count === 0
focus: visible
text: i18n.qtr("No albums found\nPlease try adding sources, by going to the Network tab")
navigationParent: root
diff --git a/modules/gui/qt/medialibrary/qml/MusicGenres.qml b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
index d87dfa901d..c67a33892f 100644
--- a/modules/gui/qt/medialibrary/qml/MusicGenres.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
@@ -27,7 +27,7 @@ import "qrc:///style/"
Widgets.NavigableFocusScope {
id: root
- property alias model: delegateModel.model
+ property alias model: delegateModelId.model
property var sortModel: [
{ text: i18n.qtr("Alphabetic"), criteria: "title" }
]
@@ -60,14 +60,14 @@ Widgets.NavigableFocusScope {
}
function resetFocus() {
- if (delegateModel.items.count === 0) {
+ if (delegateModelId.items.count === 0) {
return
}
var initialIndex = root.initialIndex
- if (initialIndex >= delegateModel.items.count)
+ if (initialIndex >= delegateModelId.items.count)
initialIndex = 0
- delegateModel.selectNone()
- delegateModel.items.get(initialIndex).inSelected = true
+ delegateModelId.selectNone()
+ delegateModelId.items.get(initialIndex).inSelected = true
view.currentItem.currentIndex = initialIndex
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
@@ -86,8 +86,9 @@ Widgets.NavigableFocusScope {
}
Util.SelectableDelegateModel {
- id: delegateModel
+ id: delegateModelId
model: MLGenreModel {
+ id: genreModel
ml: medialib
}
@@ -108,7 +109,7 @@ Widgets.NavigableFocusScope {
line1: (model.name || "Unknown genre")+" - "+model.nb_tracks+" tracks"
onItemClicked: {
- delegateModel.updateSelection( modifier, view.currentItem.currentIndex, index )
+ delegateModelId.updateSelection( modifier, view.currentItem.currentIndex, index )
view.currentItem.currentIndex = index
this.forceActiveFocus()
}
@@ -125,34 +126,34 @@ Widgets.NavigableFocusScope {
}
onCountChanged: {
- if (delegateModel.items.count > 0 && delegateModel.selectedGroup.count === 0) {
+ if (delegateModelId.items.count > 0 && delegateModelId.selectedGroup.count === 0) {
root.resetFocus()
}
}
function actionAtIndex(index) {
- if (delegateModel.selectedGroup.count > 1) {
+ if (delegateModelId.selectedGroup.count > 1) {
var list = []
- for (var i = 0; i < delegateModel.selectedGroup.count; i++)
- list.push(delegateModel.selectedGroup.get(i).model.id)
+ for (var i = 0; i < delegateModelId.selectedGroup.count; i++)
+ list.push(delegateModelId.selectedGroup.get(i).model.id)
medialib.addAndPlay( list )
- } else if (delegateModel.selectedGroup.count === 1) {
- showAlbumView(delegateModel.selectedGroup.get(0).model.id, delegateModel.selectedGroup.get(0).model.name)
+ } else if (delegateModelId.selectedGroup.count === 1) {
+ showAlbumView(delegateModelId.selectedGroup.get(0).model.id, delegateModelId.selectedGroup.get(0).model.name)
}
}
}
/*
*define the intial position/selection
- * This is done on activeFocus rather than Component.onCompleted because delegateModel.
+ * This is done on activeFocus rather than Component.onCompleted because delegateModelId.
* selectedGroup update itself after this event
*/
onActiveFocusChanged: {
- if (activeFocus && delegateModel.items.count > 0 && delegateModel.selectedGroup.count === 0) {
+ if (activeFocus && delegateModelId.items.count > 0 && delegateModelId.selectedGroup.count === 0) {
var initialIndex = 0
if (view.currentItem.currentIndex !== -1)
initialIndex = view.currentItem.currentIndex
- delegateModel.items.get(initialIndex).inSelected = true
+ delegateModelId.items.get(initialIndex).inSelected = true
view.currentItem.currentIndex = initialIndex
}
}
@@ -163,8 +164,7 @@ Widgets.NavigableFocusScope {
Widgets.ExpandGridView {
id: gridView_id
- model: delegateModel
- modelCount: delegateModel.items.count
+ delegateModel: delegateModelId
headerDelegate: headerComponent
@@ -174,10 +174,10 @@ Widgets.NavigableFocusScope {
image: model.cover || VLCStyle.noArtAlbum
title: model.name || "Unknown genre"
subtitle: ""
- //selected: element.DelegateModel.inSelected
+ //selected: element.delegateModelId.inSelected
onItemClicked: {
- delegateModel.updateSelection( modifier , view.currentItem.currentIndex, index)
+ delegateModelId.updateSelection( modifier , view.currentItem.currentIndex, index)
view.currentItem.currentIndex = index
view.currentItem.forceActiveFocus()
}
@@ -190,10 +190,10 @@ Widgets.NavigableFocusScope {
cellWidth: VLCStyle.gridItem_music_width
cellHeight: VLCStyle.gridItem_music_height
- onSelectAll: delegateModel.selectAll()
- onSelectionUpdated: delegateModel.updateSelection( keyModifiers, oldIndex, newIndex )
+ onSelectAll: delegateModelId.selectAll()
+ onSelectionUpdated: delegateModelId.updateSelection( keyModifiers, oldIndex, newIndex )
onActionAtIndex: {
- delegateModel.actionAtIndex(index)
+ delegateModelId.actionAtIndex(index)
}
navigationParent: root
@@ -206,17 +206,16 @@ Widgets.NavigableFocusScope {
Widgets.KeyNavigableListView {
id: listView_id
- model: delegateModel.parts.list
- modelCount: delegateModel.items.count
+ model: delegateModelId.parts.list
header: headerComponent
focus: true
spacing: VLCStyle.margin_xxxsmall
- onSelectAll: delegateModel.selectAll()
- onSelectionUpdated: delegateModel.updateSelection( keyModifiers, oldIndex, newIndex )
- onActionAtIndex: delegateModel.actionAtIndex(index)
+ onSelectAll: delegateModelId.selectAll()
+ onSelectionUpdated: delegateModelId.updateSelection( keyModifiers, oldIndex, newIndex )
+ onActionAtIndex: delegateModelId.actionAtIndex(index)
navigationParent: root
}
@@ -228,12 +227,12 @@ Widgets.NavigableFocusScope {
initialItem: medialib.gridView ? gridComponent : listComponent
anchors.fill: parent
- focus: delegateModel.items.count !== 0
+ focus: delegateModelId.items.count !== 0
}
EmptyLabel {
anchors.fill: parent
- visible: delegateModel.items.count === 0
+ visible: delegateModelId.items.count === 0
focus: visible
text: i18n.qtr("No genres found\nPlease try adding sources, by going to the Network tab")
navigationParent: root
diff --git a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
index cb5cf7b0d9..c49dfb64ef 100644
--- a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
@@ -126,6 +126,7 @@ Widgets.NavigableFocusScope {
id: videosDelegate
model: MLVideoModel {
+ id: videoModel
ml: medialib
}
delegate: Package{
@@ -155,8 +156,7 @@ Widgets.NavigableFocusScope {
property Item currentItem: Item{}
activeFocusOnTab:true
- model: videosDelegate
- modelCount: videosDelegate.items.count
+ delegateModel: videosDelegate
headerDelegate: Widgets.LabelSeparator {
id: videosSeparator
@@ -211,8 +211,8 @@ Widgets.NavigableFocusScope {
cellWidth: VLCStyle.gridItem_video_width
cellHeight: VLCStyle.gridItem_video_height
- onSelectAll: videosGV.model.selectAll()
- onSelectionUpdated: videosGV.model.updateSelection( keyModifiers, oldIndex, newIndex )
+ onSelectAll:videosDelegate.selectAll()
+ onSelectionUpdated: videosDelegate.updateSelection( keyModifiers, oldIndex, newIndex )
onActionAtIndex: videosDelegate.actionAtIndex( index )
}
diff --git a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
index 74e87d4f00..79c0f0e02f 100644
--- a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
+++ b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
@@ -39,24 +39,24 @@ Widgets.NavigableFocusScope {
}
NetworksSectionSelectableDM{
- id: delegateModel
+ id: delegateModelId
model: providerModel
onCountChanged: resetFocus()
}
function resetFocus() {
- if (delegateModel.items.count > 0 && delegateModel.selectedGroup.count === 0) {
+ if (delegateModelId.items.count > 0 && delegateModelId.selectedGroup.count === 0) {
var initialIndex = 0
- if (delegateModel.currentIndex !== -1)
- initialIndex = delegateModel.currentIndex
- delegateModel.items.get(initialIndex).inSelected = true
- delegateModel.currentIndex = initialIndex
+ if (delegateModelId.currentIndex !== -1)
+ initialIndex = delegateModelId.currentIndex
+ delegateModelId.items.get(initialIndex).inSelected = true
+ delegateModelId.currentIndex = initialIndex
}
}
Widgets.MenuExt {
id: contextMenu
- property var delegateModel: undefined
+ property var delegateModelId: undefined
property var model: ({})
closePolicy: Popup.CloseOnReleaseOutside | Popup.CloseOnEscape
focus:true
@@ -65,14 +65,14 @@ Widgets.NavigableFocusScope {
id: instanciator
property var modelActions: {
"play": function() {
- if (delegateModel) {
- delegateModel.playSelection()
+ if (delegateModelId) {
+ delegateModelId.playSelection()
}
contextMenu.close()
},
"enqueue": function() {
- if (delegateModel)
- delegateModel.enqueueSelection()
+ if (delegateModelId)
+ delegateModelId.enqueueSelection()
contextMenu.close()
},
"index": function(index) {
@@ -118,8 +118,8 @@ Widgets.NavigableFocusScope {
Widgets.ExpandGridView {
id: gridView
- model: delegateModel
- modelCount: delegateModel.items.count
+
+ delegateModel: delegateModelId
headerDelegate: Widgets.LabelSeparator {
width: view.width
@@ -155,8 +155,8 @@ Widgets.NavigableFocusScope {
subtitle: ""
onItemClicked : {
- delegateModel.updateSelection( modifier , delegateModel.currentIndex, index)
- delegateModel.currentIndex = index
+ delegateModelId.updateSelection( modifier , delegateModelId.currentIndex, index)
+ delegateModelId.currentIndex = index
delegateGrid.forceActiveFocus()
}
@@ -164,19 +164,19 @@ Widgets.NavigableFocusScope {
if (model.type === NetworkMediaModel.TYPE_NODE || model.type === NetworkMediaModel.TYPE_DIRECTORY)
history.push( ["mc", "network", { tree: model.tree } ])
else
- delegateModel.model.addAndPlay( index )
+ delegateModelId.model.addAndPlay( index )
}
onContextMenuButtonClicked: {
contextMenu.model = model
- contextMenu.delegateModel = delegateModel
+ contextMenu.delegateModelId = delegateModelId
contextMenu.popup()
}
}
- onSelectAll: delegateModel.selectAll()
- onSelectionUpdated: delegateModel.updateSelection( keyModifiers, oldIndex, newIndex )
- onActionAtIndex: delegateModel.actionAtIndex(index)
+ onSelectAll: delegateModelId.selectAll()
+ onSelectionUpdated: delegateModelId.updateSelection( keyModifiers, oldIndex, newIndex )
+ onActionAtIndex: delegateModelId.actionAtIndex(index)
navigationParent: root
navigationUpItem: gridView.headerItem
@@ -192,16 +192,15 @@ Widgets.NavigableFocusScope {
id: listView
height: view.height
width: view.width
- model: delegateModel.parts.list
- modelCount: delegateModel.items.count
- currentIndex: delegateModel.currentIndex
+ model: delegateModelId.parts.list
+ currentIndex: delegateModelId.currentIndex
focus: true
spacing: VLCStyle.margin_xxxsmall
- onSelectAll: delegateModel.selectAll()
- onSelectionUpdated: delegateModel.updateSelection( keyModifiers, oldIndex, newIndex )
- onActionAtIndex: delegateModel.actionAtIndex(index)
+ onSelectAll: delegateModelId.selectAll()
+ onSelectionUpdated: delegateModelId.updateSelection( keyModifiers, oldIndex, newIndex )
+ onActionAtIndex: delegateModelId.actionAtIndex(index)
navigationParent: root
navigationUpItem: listView.headerItem
diff --git a/modules/gui/qt/widgets/qml/ExpandGridView.qml b/modules/gui/qt/widgets/qml/ExpandGridView.qml
index c5dd742d08..237a4ffea3 100644
--- a/modules/gui/qt/widgets/qml/ExpandGridView.qml
+++ b/modules/gui/qt/widgets/qml/ExpandGridView.qml
@@ -31,8 +31,7 @@ NavigableFocusScope {
property int marginBottom: root.cellHeight / 2
property int marginTop: root.cellHeight / 3
- property variant model
- property int modelCount: 0
+ property variant delegateModel
property int currentIndex: 0
property alias contentHeight: flickable.contentHeight
@@ -65,7 +64,7 @@ NavigableFocusScope {
Accessible.role: Accessible.Table
function switchExpandItem(index) {
- if (modelCount === 0)
+ if (delegateModel.count === 0)
return
if (index === _expandIndex)
@@ -111,7 +110,7 @@ NavigableFocusScope {
if (index <= 0) {
animateFlickableContentY(0)
return
- } else if (index >= modelCount) {
+ } else if (index >= delegateModel.count) {
return
}
@@ -152,7 +151,7 @@ NavigableFocusScope {
function _updateSelected() {
for (var id in _idChildrenMap) {
var item = _idChildrenMap[id]
- item.selected = model.items.get(id).inSelected
+ item.selected = delegateModel.items.get(id).inSelected
}
}
@@ -221,7 +220,7 @@ NavigableFocusScope {
var rowId = rowCol[1] + 1
ret = rowId * root.getNbItemsPerRow()
} else {
- ret = model.count
+ ret = delegateModel.count
}
return ret
}
@@ -247,7 +246,7 @@ NavigableFocusScope {
var firstId = Math.max(rowId * root.getNbItemsPerRow(), 0)
rowId = Math.ceil((contentYWithoutExpand + heightWithoutExpand) / root.cellHeight)
- var lastId = Math.min(rowId * root.getNbItemsPerRow(), model.count)
+ var lastId = Math.min(rowId * root.getNbItemsPerRow(), delegateModel.count)
return [firstId, lastId]
}
@@ -272,8 +271,8 @@ NavigableFocusScope {
var pos = root.getItemPos(i)
_defineObjProperty(item, "index", i)
//theses needs an actual binding
- //item.selected = Qt.binding(function() { return model.items.get(i).inSelected })
- item.model = model.items.get(i).model
+ //item.selected = Qt.binding(function() { return delegateModel.items.get(i).inSelected })
+ item.model = delegateModel.items.get(i).model
//console.log("initialize", .inSelected)
//theses properties are always defined in Item
@@ -345,7 +344,7 @@ NavigableFocusScope {
}
// Calculate and set the contentHeight
- var newContentHeight = root.getItemPos(model.count - 1)[1] + root.cellHeight
+ var newContentHeight = root.getItemPos(delegateModel.count - 1)[1] + root.cellHeight
if (root._expandIndex !== -1)
newContentHeight += expandItem.height
contentHeight = newContentHeight
@@ -355,7 +354,7 @@ NavigableFocusScope {
}
Connections {
- target: model.items
+ target: delegateModel.items
onChanged: {
// Hide the expandItem with no animation
_expandIndex = -1
@@ -399,7 +398,7 @@ NavigableFocusScope {
_expandIndex = _newExpandIndex
if (_expandIndex === -1)
return
- expandItem.model = model.items.get(_expandIndex).model
+ expandItem.model = delegateModel.items.get(_expandIndex).model
/* We must also start the expand animation here since the expandItem implicitHeight is not
changed if it had the same height at previous opening. */
expandAnimation()
@@ -492,18 +491,18 @@ NavigableFocusScope {
var newIndex = -1
if (KeyHelper.matchRight(event)) {
if ((currentIndex + 1) % colCount !== 0) {//are we not at the end of line
- newIndex = Math.min(root.modelCount - 1, currentIndex + 1)
+ newIndex = Math.min(delegateModel.count - 1, currentIndex + 1)
}
} else if (KeyHelper.matchLeft(event)) {
if (currentIndex % colCount !== 0) {//are we not at the begining of line
newIndex = Math.max(0, currentIndex - 1)
}
} else if (KeyHelper.matchDown(event)) {
- if (Math.floor(currentIndex / colCount) !== Math.floor(root.modelCount / colCount)) { //we are not on the last line
- newIndex = Math.min(root.modelCount - 1, currentIndex + colCount)
+ if (Math.floor(currentIndex / colCount) !== Math.floor(delegateModel.count / colCount)) { //we are not on the last line
+ newIndex = Math.min(delegateModel.count - 1, currentIndex + colCount)
}
} else if (KeyHelper.matchPageDown(event)) {
- newIndex = Math.min(root.modelCount - 1, currentIndex + colCount * 5)
+ newIndex = Math.min(delegateModel.count - 1, currentIndex + colCount * 5)
} else if (KeyHelper.matchUp(event)) {
if (Math.floor(currentIndex / colCount) !== 0) { //we are not on the first line
newIndex = Math.max(0, currentIndex - colCount)
More information about the vlc-commits
mailing list