Browse Source

Verify that every View other than SimpleListView still works

Donald Carr 6 years ago
parent
commit
5fc06462d4

+ 6 - 6
qml/common/ArtImage.qml

@@ -12,7 +12,7 @@ Item {
 
     //color: Qt.rgba(Math.random(255), Math.random(255), Math.random(255), 1.0)
 
-    height: width*imageModel.data(modelIndex, PictureModel.SizeRole).height/imageModel.data(modelIndex, PictureModel.SizeRole).width
+    height: width*globalUtil.imageModel.data(modelIndex, PictureModel.SizeRole).height/globalUtil.imageModel.data(modelIndex, PictureModel.SizeRole).width
     width: parent ? parent.width : 0
 
     Image {
@@ -20,8 +20,8 @@ Item {
         cache: false
         opacity: globalSettings.fadeInImages ? 0 : 1.0
 
-        height: globalVars.imageWidthOverride > 0 ? Math.ceil(globalVars.imageWidthOverride*imageModel.data(modelIndex, PictureModel.SizeRole).height/imageModel.data(modelIndex, PictureModel.SizeRole).width) : imageModel.data(modelIndex, PictureModel.SizeRole).height
-        width: globalVars.imageWidthOverride > 0 ? globalVars.imageWidthOverride : imageModel.data(modelIndex, PictureModel.SizeRole).width
+        height: globalVars.imageWidthOverride > 0 ? Math.ceil(globalVars.imageWidthOverride*globalUtil.imageModel.data(modelIndex, PictureModel.SizeRole).height/globalUtil.imageModel.data(modelIndex, PictureModel.SizeRole).width) : globalUtil.imageModel.data(modelIndex, PictureModel.SizeRole).height
+        width: globalVars.imageWidthOverride > 0 ? globalVars.imageWidthOverride : globalUtil.imageModel.data(modelIndex, PictureModel.SizeRole).width
 
         transformOrigin: Item.TopLeft
         scale: root.width/image.width
@@ -29,7 +29,7 @@ Item {
         asynchronous: true
         fillMode: Image.PreserveAspectFit
 
-        source: imageModel.data(modelIndex)
+        source: globalUtil.imageModel.data(modelIndex)
 
         mirror: globalSettings.randomlyMirrorArt && (Math.random() < globalSettings.randomlyMirrorArtFreq)
         smooth: globalSettings.smoothArt
@@ -54,7 +54,7 @@ Item {
     }
 
     Component.onCompleted: {
-        modelIndex = imageModel.requestIndex()
+        modelIndex = globalUtil.imageModel.requestIndex()
         if (globalSettings.effect !== "" && Effects.validate(globalSettings.effect)) {
             var component = Qt.createComponent("VisualEffect.qml");
             component.status !== Component.Ready && console.log('Component failed with:' + component.errorString())
@@ -62,5 +62,5 @@ Item {
         }
     }
 
-    Component.onDestruction: imageModel.retireIndex(modelIndex)
+    Component.onDestruction: globalUtil.imageModel.retireIndex(modelIndex)
 }

+ 8 - 0
qml/common/View.qml

@@ -1,4 +1,5 @@
 import QtQuick 2.5
+import PictureModel 1.0
 
 Item {
     id: root
@@ -22,4 +23,11 @@ Item {
         model: globalSettings.columnCount
         delegate: columnComponent
     }
+
+    PictureModel {
+        id: imageModel
+        Component.onCompleted: {
+            globalUtil.imageModel = imageModel
+        }
+    }
 }

+ 1 - 0
qml/main.qml

@@ -25,6 +25,7 @@ Item {
 
     QtObject {
         id: globalUtil
+        property var imageModel
         property int itemCount
         property int currentColumn: 0
         property bool primed: d.primedColumns === globalSettings.columnCount

+ 9 - 0
qml/views/animator/Animator.qml

@@ -2,6 +2,8 @@ import QtQuick 2.5
 
 import "../.."
 
+import PictureModel 1.0
+
 Item {
     id: root
 
@@ -130,4 +132,11 @@ Item {
         target: globalSettings
         onColumnCountChanged: console.log('Col count:' + globalSettings.columnCount)
     }
+
+    PictureModel {
+        id: imageModel
+        Component.onCompleted: {
+            globalUtil.imageModel = imageModel
+        }
+    }
 }

+ 8 - 0
qml/views/cascade/Cascade.qml

@@ -1,6 +1,7 @@
 import QtQuick 2.5
 import Box2D 2.0
 import Qt.labs.settings 1.0
+import PictureModel 1.0
 
 // Forgive me
 import "../.."
@@ -163,4 +164,11 @@ Item {
     Component.onCompleted: {
         pictureDelegate.status !== Component.Ready && console.log('Component failed with:' + pictureDelegate.errorString())
     }
+
+    PictureModel {
+        id: imageModel
+        Component.onCompleted: {
+            globalUtil.imageModel = imageModel
+        }
+    }
 }

+ 7 - 1
qml/views/conveyor/Conveyor.qml

@@ -118,7 +118,7 @@ Item {
 
             density: 1
             height: root.height/conveyorSettings.rowCount
-            width: height/imageModel.data(modelIndex, PictureModel.SizeRole).height*imageModel.data(modelIndex, PictureModel.SizeRole).width
+            width: height/globalUtil.imageModel.data(modelIndex, PictureModel.SizeRole).height*globalUtil.imageModel.data(modelIndex, PictureModel.SizeRole).width
             bodyType: Body.Dynamic
             fixedRotation: true
 
@@ -213,4 +213,10 @@ Item {
             }
         "
     }
+    PictureModel {
+        id: imageModel
+        Component.onCompleted: {
+            globalUtil.imageModel = imageModel
+        }
+    }
 }

+ 10 - 5
qml/views/simplelistview/SimpleListView.qml

@@ -1,13 +1,18 @@
 import QtQuick 2.5
 
+import PictureModel 1.0
+
 // Forgive me
 import "../.."
 
 ListView {
-    delegate: ArtImage {
-        source: path
-        height: size.height
-        width: size.width
+    delegate: ArtImage {}
+    model: globalUtil.imageModel
+
+    PictureModel {
+        id: imageModel
+        Component.onCompleted: {
+            globalUtil.imageModel = imageModel
+        }
     }
-    model: imageModel
 }

+ 9 - 0
qml/views/trivial/Trivial.qml

@@ -2,6 +2,8 @@ import QtQuick 2.5
 
 import "../.."
 
+import PictureModel 1.0
+
 Item {
     id: root
 
@@ -130,4 +132,11 @@ Item {
         target: globalSettings
         onColumnCountChanged: console.log('Col count:' + globalSettings.columnCount)
     }
+
+    PictureModel {
+        id: imageModel
+        Component.onCompleted: {
+            globalUtil.imageModel = imageModel
+        }
+    }
 }

+ 1 - 1
qml/widgets/CollectionSize.qml

@@ -1,5 +1,5 @@
 import QtQuick 2.6
 
 Widget {
-    text: "DB:" + imageModel.count
+    text: "DB:" + globalUtil.imageModel.count
 }

+ 0 - 1
src/main.cpp

@@ -125,7 +125,6 @@ void ArtView::populateScreen(QScreen *screen)
         sharedQmlEngine = view->engine();
         sharedQmlEngine->addImportPath(qmlPath);
         sharedQmlEngine->rootContext()->setContextProperty("nativeUtils", new NativeUtils(sharedQmlEngine));
-        sharedQmlEngine->rootContext()->setContextProperty("imageModel", new PictureModel(sharedQmlEngine));
         QObject::connect(sharedQmlEngine, &QQmlEngine::quit, qApp, &QCoreApplication::quit);
     }
     if (screen) {