mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-07 05:12:00 +02:00
[ui] ImageGallery: improve synced selection with 3D view
Fix synchronization with 3D camera selection when the corresponding image has not been instantiated in ImageGallery (outside visible viewport). * SortFilterDelegateModel: add "find" method * ImageGallery * move passive selection logic out of the Delegate as it's created only when visible in the GridView * use SortFilterDelegateModel.find to get item index based on selected "viewId" and set GridView's currentIndex
This commit is contained in:
parent
c606c1d3e2
commit
df1dc2bab6
2 changed files with 30 additions and 15 deletions
|
@ -48,6 +48,16 @@ Panel {
|
||||||
highlightFollowsCurrentItem: true
|
highlightFollowsCurrentItem: true
|
||||||
keyNavigationEnabled: true
|
keyNavigationEnabled: true
|
||||||
|
|
||||||
|
// Update grid current item when selected view changes
|
||||||
|
Connections {
|
||||||
|
target: _reconstruction
|
||||||
|
onSelectedViewIdChanged: {
|
||||||
|
var idx = grid.model.find(_reconstruction.selectedViewId, "viewId")
|
||||||
|
if(idx >= 0)
|
||||||
|
grid.currentIndex = idx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
model: SortFilterDelegateModel {
|
model: SortFilterDelegateModel {
|
||||||
id: sortedModel
|
id: sortedModel
|
||||||
model: _reconstruction.viewpoints
|
model: _reconstruction.viewpoints
|
||||||
|
@ -61,8 +71,11 @@ Panel {
|
||||||
|
|
||||||
// override modelData to return basename of viewpoint's path for sorting
|
// override modelData to return basename of viewpoint's path for sorting
|
||||||
function modelData(item, roleName) {
|
function modelData(item, roleName) {
|
||||||
|
var value = item.model.object.value.get(roleName).value
|
||||||
if(roleName == sortRole)
|
if(roleName == sortRole)
|
||||||
return Filepath.basename(item.model.object.value.get(roleName).value)
|
return Filepath.basename(value)
|
||||||
|
else
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: ImageDelegate {
|
delegate: ImageDelegate {
|
||||||
|
@ -70,25 +83,17 @@ Panel {
|
||||||
viewpoint: object.value
|
viewpoint: object.value
|
||||||
width: grid.cellWidth
|
width: grid.cellWidth
|
||||||
height: grid.cellHeight
|
height: grid.cellHeight
|
||||||
property bool isGridCurrentItem: GridView.isCurrentItem
|
|
||||||
property bool isSelectedViewId: _reconstruction.selectedViewId == viewpoint.get("viewId").value
|
|
||||||
readOnly: root.readOnly
|
readOnly: root.readOnly
|
||||||
|
|
||||||
// need to handle this both ways
|
|
||||||
// since arrow keys navigation modifies GridView.isCurrentItem out of our scope
|
|
||||||
onIsGridCurrentItemChanged: {
|
|
||||||
if(isGridCurrentItem && !isSelectedViewId)
|
|
||||||
_reconstruction.selectedViewId = viewpoint.get("viewId").value
|
|
||||||
}
|
|
||||||
onIsSelectedViewIdChanged: {
|
|
||||||
if(isSelectedViewId && !isGridCurrentItem)
|
|
||||||
grid.currentIndex = DelegateModel.filteredIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
isCurrentItem: GridView.isCurrentItem
|
isCurrentItem: GridView.isCurrentItem
|
||||||
|
|
||||||
onPressed: {
|
onIsCurrentItemChanged: {
|
||||||
|
if(isCurrentItem)
|
||||||
_reconstruction.selectedViewId = viewpoint.get("viewId").value
|
_reconstruction.selectedViewId = viewpoint.get("viewId").value
|
||||||
|
}
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
grid.currentIndex = DelegateModel.filteredIndex
|
||||||
if(mouse.button == Qt.LeftButton)
|
if(mouse.button == Qt.LeftButton)
|
||||||
grid.forceActiveFocus()
|
grid.forceActiveFocus()
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,16 @@ DelegateModel {
|
||||||
return item.model[roleName]
|
return item.model[roleName]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the index of the first element which matches 'value' for the given 'roleName'
|
||||||
|
function find(value, roleName) {
|
||||||
|
for(var i = 0; i < filteredItems.count; ++i)
|
||||||
|
{
|
||||||
|
if(modelData(filteredItems.get(i), roleName) == value)
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether 'value' respects 'filter' condition
|
* Return whether 'value' respects 'filter' condition
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue