PosterView.qml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import QtQuick 1.0
  2. PathView {
  3. id: pathView
  4. property variant posterModel
  5. property alias rootIndex : visualDataModel.rootIndex
  6. property int delegateWidth: 50
  7. property int delegateHeight: 50
  8. anchors.fill: parent
  9. property variant currentItem
  10. signal clicked(string filePath)
  11. signal rootIndexChanged() // this should be automatic, but doesn't trigger :/
  12. function currentModelIndex() {
  13. return visualDataModel.modelIndex(currentIndex);
  14. }
  15. model: visualDataModel
  16. pathItemCount: (width+2*delegateWidth)/delegateWidth
  17. preferredHighlightBegin : 0.5
  18. preferredHighlightEnd : 0.5
  19. path: Path {
  20. startX: -pathView.delegateWidth; startY: pathView.height/2.0
  21. PathAttribute { name: "scale"; value: 1 }
  22. PathAttribute { name: "z"; value: 1 }
  23. PathAttribute { name: "opacity"; value: 0.2 }
  24. PathLine { x: pathView.width/2.5; y: pathView.height/2.0 }
  25. PathAttribute { name: "scale"; value: 1.0 }
  26. PathLine { x: pathView.width/2.0; y: pathView.height/2.0 }
  27. PathAttribute { name: "scale"; value: 1.5 }
  28. PathAttribute { name: "z"; value: 2 }
  29. PathAttribute { name: "opacity"; value: 1.0 }
  30. PathLine { x: pathView.width/1.5; y: pathView.height/2.0 }
  31. PathAttribute { name: "scale"; value: 1.0 }
  32. PathLine { x: pathView.width+pathView.delegateWidth; y: pathView.height/2.0 }
  33. PathAttribute { name: "scale"; value: 1 }
  34. PathAttribute { name: "z"; value: 1 }
  35. PathAttribute { name: "opacity"; value: 0.2 }
  36. }
  37. VisualDataModel {
  38. id: visualDataModel
  39. delegate: PosterViewDelegate { }
  40. model: pathView.posterModel
  41. Component.onCompleted: {
  42. model = pathView.posterModel // Workaroud for QTBUG-16357
  43. // Workaround for QTBUG-16365
  44. var was = rootIndex
  45. rootIndex = modelIndex(0)
  46. rootIndex = was
  47. }
  48. }
  49. Keys.onRightPressed: { pathView.incrementCurrentIndex(); }
  50. Keys.onLeftPressed: { pathView.decrementCurrentIndex(); }
  51. }