1- // ImageGridView.qml
2-
31import QtQuick
42import QtQuick.Controls
53import QtQuick.Layouts
@@ -11,11 +9,11 @@ import MaterialIcons 2.2
119import Utils 1.0
1210
1311GridView {
14- id: grid
12+ id: root
1513
16- // Exposed properties from parent - with default values
14+ // Exposed properties from ImageGallery
1715 property var m: null
18- property var root : null
16+ property var gallery : null
1917 property var searchBar: null
2018 property var thumbnailSizeSlider: null
2119 property var displayViewIdsAction: null
@@ -39,49 +37,48 @@ GridView {
3937 cellHeight: cellWidth
4038 highlightFollowsCurrentItem: true
4139 keyNavigationEnabled: true
42- property bool updateSelectedViewFromGrid: true
4340
4441 // Update grid current item when selected view changes
4542 Connections {
4643 target: _reconstruction
4744 function onSelectedViewIdChanged () {
4845 if (_reconstruction .selectedViewId > - 1 ) {
49- grid .updateCurrentIndexFromSelectionViewId ()
46+ root .updateCurrentIndexFromSelectionViewId ()
5047 }
5148 }
5249 }
5350
5451 function makeCurrentItemVisible () {
55- grid .positionViewAtIndex (grid .currentIndex , GridView .Visible )
52+ root .positionViewAtIndex (root .currentIndex , GridView .Visible )
5653 }
5754
5855 function updateCurrentIndexFromSelectionViewId () {
5956 if (! sortedModel) return
6057 var idx = sortedModel .find (_reconstruction .selectedViewId , " viewId" )
61- if (idx >= 0 && grid .currentIndex !== idx) {
62- grid .currentIndex = idx
58+ if (idx >= 0 && root .currentIndex !== idx) {
59+ root .currentIndex = idx
6360 }
6461 }
6562
6663 onCurrentItemChanged: {
67- if (grid . updateSelectedViewFromGrid && grid .currentItem ) {
68- if (tempCameraInit !== null && grid .currentIndex == 0 )
64+ if (root .currentItem ) {
65+ if (tempCameraInit !== null && root .currentIndex == 0 )
6966 _reconstruction .selectedViewId = - 1
70- _reconstruction .selectedViewId = grid .currentItem .viewpoint .get (" viewId" ).value
67+ _reconstruction .selectedViewId = root .currentItem .viewpoint .get (" viewId" ).value
7168 }
7269 }
7370
7471 // Update grid item when corresponding thumbnail is computed
7572 Connections {
7673 target: ThumbnailCache
7774 function onThumbnailCreated (imgSource , callerID ) {
78- let item = grid .itemAtIndex (callerID);
75+ let item = root .itemAtIndex (callerID);
7976 if (item && item .source === imgSource) {
8077 item .updateThumbnail ()
8178 return
8279 }
83- for (let idx = 0 ; idx < grid .count ; idx++ ) {
84- item = grid .itemAtIndex (idx)
80+ for (let idx = 0 ; idx < root .count ; idx++ ) {
81+ item = root .itemAtIndex (idx)
8582 if (item && item .source === imgSource) {
8683 item .updateThumbnail ()
8784 }
@@ -95,25 +92,25 @@ GridView {
9592 Keys .priority : Keys .BeforeItem
9693 Keys .onPressed : function (event ) {
9794 if (event .modifiers & Qt .AltModifier ) {
98- if (event .key === Qt .Key_Right && root && root .cameraInits ) {
99- _reconstruction .cameraInitIndex = Math .min (root .cameraInits .count - 1 , root .cameraInitIndex + 1 )
95+ if (event .key === Qt .Key_Right && gallery && gallery .cameraInits ) {
96+ _reconstruction .cameraInitIndex = Math .min (gallery .cameraInits .count - 1 , gallery .cameraInitIndex + 1 )
10097 event .accepted = true
10198 } else if (event .key === Qt .Key_Left ) {
102- _reconstruction .cameraInitIndex = Math .max (0 , root .cameraInitIndex - 1 )
99+ _reconstruction .cameraInitIndex = Math .max (0 , gallery .cameraInitIndex - 1 )
103100 event .accepted = true
104101 }
105102 } else {
106103 if (event .key === Qt .Key_Right ) {
107- grid .moveCurrentIndexRight ()
104+ root .moveCurrentIndexRight ()
108105 event .accepted = true
109106 } else if (event .key === Qt .Key_Left ) {
110- grid .moveCurrentIndexLeft ()
107+ root .moveCurrentIndexLeft ()
111108 event .accepted = true
112109 } else if (event .key === Qt .Key_Up ) {
113- grid .moveCurrentIndexUp ()
110+ root .moveCurrentIndexUp ()
114111 event .accepted = true
115112 } else if (event .key === Qt .Key_Down ) {
116- grid .moveCurrentIndexDown ()
113+ root .moveCurrentIndexDown ()
117114 event .accepted = true
118115 } else if (event .key === Qt .Key_Tab ) {
119116 if (searchBar)
@@ -144,7 +141,7 @@ GridView {
144141 Column {
145142 id: noImageImagePlaceholder
146143 anchors .centerIn : parent
147- visible: (m && m .viewpoints ? m .viewpoints .count !== 0 : false ) && ! dropImagePlaceholder .visible && grid .count === 0 && (! intrinsicsFilterButton || ! intrinsicsFilterButton .checked )
144+ visible: (m && m .viewpoints ? m .viewpoints .count !== 0 : false ) && ! dropImagePlaceholder .visible && root .count === 0 && (! intrinsicsFilterButton || ! intrinsicsFilterButton .checked )
148145 spacing: 4
149146 Label {
150147 anchors .horizontalCenter : parent .horizontalCenter
@@ -173,9 +170,9 @@ GridView {
173170 nbMeshroomScenes = filesByType[" meshroomScenes" ].length
174171 }
175172 onDropped : function (drop ) {
176- if (nbMeshroomScenes == nbDraggedFiles || nbMeshroomScenes == 0 ) {
177- if (root )
178- root .filesDropped (filesByType)
173+ if (nbMeshroomScenes === nbDraggedFiles || nbMeshroomScenes = == 0 ) {
174+ if (gallery )
175+ gallery .filesDropped (filesByType)
179176 } else {
180177 if (errorDialog)
181178 errorDialog .open ()
@@ -186,7 +183,7 @@ GridView {
186183 Rectangle {
187184 visible: dropArea .containsDrag
188185 anchors .fill : parent
189- color: root ? root .palette .window : palette .window
186+ color: gallery ? gallery .palette .window : palette .window
190187 opacity: 0.8
191188 }
192189
@@ -222,7 +219,7 @@ GridView {
222219 anchors .fill : parent
223220 onPressed : function (mouse ) {
224221 if (mouse .button == Qt .LeftButton )
225- grid .forceActiveFocus ()
222+ root .forceActiveFocus ()
226223 mouse .accepted = false
227224 }
228225 }
0 commit comments