Commit 8ed1cc36 authored by Camilo Higuita's avatar Camilo Higuita

implement basic browsing features: go next and previous #3

parent 25a766f2
......@@ -10,11 +10,10 @@ PixPage
property int picSpacing: 50
property int picRadius : 4
property alias gridModel: gridModel
property alias grid: grid
/*signals*/
signal picClicked(var pic)
signal picClicked(int index)
headerbarTitle: gridModel.count+" "+qsTr("images")
......@@ -83,7 +82,7 @@ PixPage
target: delegate
onClicked:
{
picClicked(grid.model.get(index))
picClicked(index)
grid.currentIndex = index
}
}
......
......@@ -17,8 +17,17 @@ PixGrid
{
var map = pix.get(Q.Query.allPics)
for(var i in map)
gridModel.append(map[i])
grid.model.append(map[i])
}
onPicClicked: VIEWER.view(pic)
onPicClicked: openPic(index)
function openPic(index)
{
var data = []
for(var i = 0; i < grid.model.count; i++)
data.push(grid.model.get(i))
VIEWER.view(data, index)
}
}
......@@ -2,6 +2,7 @@ import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../../view_models"
import "../../../widgets/views/Viewer/Viewer.js" as VIEWER
PixPage
{
......@@ -9,7 +10,8 @@ PixPage
property alias viewer : viewer
property var currentPic : ({})
property var picContext : []
property int currentPicIndex : 0
headerbarTitle: currentPic.title || ""
headerbarExit: false
......@@ -89,6 +91,8 @@ PixPage
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Previous")
onClicked: VIEWER.previous()
}
}
......@@ -129,6 +133,8 @@ PixPage
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Next")
onClicked: VIEWER.next()
}
}
......@@ -145,7 +151,6 @@ PixPage
{
anchors.centerIn: parent
iconName: "view-fullscreen"
hoverEnabled: !isMobile
......@@ -168,7 +173,7 @@ PixPage
content: Viewer
{
id: viewer
id: viewer
}
}
function view(pic)
function view(model, index)
{
pixViewer.currentPic = pic
console.log(model.length, index)
pixViewer.currentPicIndex = index
pixViewer.picContext = model
console.log(pixViewer.picContext.length, pixViewer.currentPicIndex)
pixViewer.currentPic = pixViewer.picContext[pixViewer.currentPicIndex]
console.log(model[7].url)
if(currentView !== views.viewer)
currentView = views.viewer
......@@ -13,15 +18,32 @@ function fullscreen()
function next()
{
if(pixViewer.picContext && pixViewer.picContext.length > 0)
{
if(pixViewer.currentPicIndex < pixViewer.picContext.length)
pixViewer.currentPicIndex++
else
pixViewer.currentPicIndex = 0
pixViewer.currentPic = pixViewer.picContext[pixViewer.currentPicIndex]
}
}
function previous()
{
if(pixViewer.picContext && pixViewer.picContext.length > 0)
{
if(pixViewer.currentPicIndex > 0)
pixViewer.currentPicIndex--
else
pixViewer.currentPicIndex = pixViewer.picContext.length-1
pixViewer.currentPic = pixViewer.picContext[pixViewer.currentPicIndex]
}
}
function fav(url)
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment