Browse Source

Move away from braindead ratio storage

Change-Id: Ide0263ba793316ed15e883c7d05c5b260befd154
Donald Carr 8 years ago
parent
commit
fb444f36a9
3 changed files with 3 additions and 10 deletions
  1. 2 2
      qml/common/ArtImage.qml
  2. 1 1
      qml/conveyor/Conveyor.qml
  3. 0 7
      src/picturemodel.cpp

+ 2 - 2
qml/common/ArtImage.qml

@@ -12,7 +12,7 @@ Item {
 
 
     //color: Qt.rgba(Math.random(255), Math.random(255), Math.random(255), 1.0)
     //color: Qt.rgba(Math.random(255), Math.random(255), Math.random(255), 1.0)
 
 
-    height: width/imageModel.data(modelIndex, PictureModel.RatioRole)
+    height: width*imageModel.data(modelIndex, PictureModel.SizeRole).height/imageModel.data(modelIndex, PictureModel.SizeRole).width
     width: parent ? parent.width : 0
     width: parent ? parent.width : 0
 
 
     Image {
     Image {
@@ -20,7 +20,7 @@ Item {
         cache: false
         cache: false
         opacity: globalSettings.fadeInImages ? 0 : 1.0
         opacity: globalSettings.fadeInImages ? 0 : 1.0
 
 
-        height: globalVars.imageWidthOverride > 0 ? Math.ceil(globalVars.imageWidthOverride/imageModel.data(modelIndex, PictureModel.RatioRole)) : imageModel.data(modelIndex, PictureModel.SizeRole).height
+        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
         width: globalVars.imageWidthOverride > 0 ? globalVars.imageWidthOverride : imageModel.data(modelIndex, PictureModel.SizeRole).width
 
 
         transformOrigin: Item.TopLeft
         transformOrigin: Item.TopLeft

+ 1 - 1
qml/conveyor/Conveyor.qml

@@ -117,7 +117,7 @@ Item {
 
 
             density: 1
             density: 1
             height: root.height/conveyorSettings.rowCount
             height: root.height/conveyorSettings.rowCount
-            width: height*imageModel.data(modelIndex, PictureModel.RatioRole)
+            width: height/imageModel.data(modelIndex, PictureModel.SizeRole).height*imageModel.data(modelIndex, PictureModel.SizeRole).width
             bodyType: Body.Dynamic
             bodyType: Body.Dynamic
             fixedRotation: true
             fixedRotation: true
 
 

+ 0 - 7
src/picturemodel.cpp

@@ -39,7 +39,6 @@ struct FSNode {
 struct FSLeafNode : public FSNode {
 struct FSLeafNode : public FSNode {
     using FSNode::FSNode;
     using FSNode::FSNode;
     QSize size;
     QSize size;
-    qreal ratio;
 };
 };
 
 
 FSNode::FSNode(const QString& rname, const FSNode *pparent)
 FSNode::FSNode(const QString& rname, const FSNode *pparent)
@@ -124,7 +123,6 @@ void FSNodeTree::addModelNode(const FSNode* parentNode)
                 qDebug() << "Image" << fullPath << "has excessive ratio" << ratio << "excluded";
                 qDebug() << "Image" << fullPath << "has excessive ratio" << ratio << "excluded";
             } else {
             } else {
                 rational = true;
                 rational = true;
-                file->ratio = ratio;
             }
             }
         } else {
         } else {
             qDebug() << "Discarding" << fullPath << "due to invalid size";
             qDebug() << "Discarding" << fullPath << "due to invalid size";
@@ -209,8 +207,6 @@ QVariant PictureModel::data(const QModelIndex &index, int role) const
         switch (role) {
         switch (role) {
         case SizeRole:
         case SizeRole:
             return QSize(1222,900);
             return QSize(1222,900);
-        case RatioRole:
-            return 1222/900;
         case NameRole:
         case NameRole:
             return "Qt logo";
             return "Qt logo";
         case PathRole:
         case PathRole:
@@ -223,8 +219,6 @@ QVariant PictureModel::data(const QModelIndex &index, int role) const
     switch (role) {
     switch (role) {
     case SizeRole:
     case SizeRole:
         return d->fsTree->files.at(index.row())->size;
         return d->fsTree->files.at(index.row())->size;
-    case RatioRole:
-        return d->fsTree->files.at(index.row())->ratio;
     case NameRole:
     case NameRole:
         return d->fsTree->files.at(index.row())->name;
         return d->fsTree->files.at(index.row())->name;
     case PathRole:
     case PathRole:
@@ -241,7 +235,6 @@ QHash<int, QByteArray> PictureModel::roleNames() const
     roles[NameRole] = "name";
     roles[NameRole] = "name";
     roles[PathRole] = "path";
     roles[PathRole] = "path";
     roles[SizeRole] = "size";
     roles[SizeRole] = "size";
-    roles[RatioRole] = "ratio";
     return roles;
     return roles;
 }
 }