Add support to enable fetching from QML

This commit is contained in:
Luca Beltrame 2015-02-05 23:49:26 +01:00
parent b88e8a6268
commit 6ee35b842c

View file

@ -5,7 +5,7 @@
* *
* Danbooru Client is free software: you can redistribute it and/or modify * Danbooru Client is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version version of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Danbooru Client is distributed in the hope that it will be useful, * Danbooru Client is distributed in the hope that it will be useful,
@ -27,8 +27,6 @@ import org.kde.kio 1.0
import DanbooruClient 1.0 import DanbooruClient 1.0
Rectangle { Rectangle {
id: rootObj id: rootObj
width: 500 width: 500
@ -47,6 +45,17 @@ Rectangle {
nameFilters: [ "Image files (*.jpg *.png *.tiff *.gif)", "All files (*)" ] nameFilters: [ "Image files (*.jpg *.png *.tiff *.gif)", "All files (*)" ]
} }
Component {
id: highlight
Rectangle {
width: grid.cellWidth; height: grid.cellHeight
color: "lightsteelblue"; radius: 5
x: grid.currentItem.x
y: grid.currentItem.y
}
}
Component { Component {
id: viewDelegate id: viewDelegate
Item { Item {
@ -59,6 +68,7 @@ Rectangle {
id: postElement id: postElement
anchors.fill: parent anchors.fill: parent
QPixmapItem { QPixmapItem {
id: pixItem id: pixItem
pixmap: thumbPix pixmap: thumbPix
@ -72,6 +82,7 @@ Rectangle {
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onClicked: { onClicked: {
grid.currentIndex = index grid.currentIndex = index
@ -164,11 +175,18 @@ Rectangle {
flow: GridView.FlowLeftToRight flow: GridView.FlowLeftToRight
anchors.fill: parent anchors.fill: parent
highlight: highlight
highlightFollowsCurrentItem: false
model: danbooruModel model: danbooruModel
delegate: viewDelegate delegate: viewDelegate
focus: true focus: true
Component.onCompleted: currentIndex = -1 Component.onCompleted: currentIndex = -1
onAtYEndChanged: {
if (grid.atYEnd) {
// danbooruService.getPostList(2, "", 10)
}
}
} }