[PATCH] Enumerate tabs correctly

1 view
Skip to first unread message

Rafael Brandao

unread,
Jun 15, 2012, 4:47:10 PM6/15/12
to snowsh...@googlegroups.com
As we use Repeater for each page, we get an index in the range from zero
to the number of items per page minus one for each component. By adding
the offset to the immediate parent, it becomes accessible inside the
delegate and then we can add the current page offset expected.

Reviewed-by: NOBODY
---
src/mobile/qml/PageFillGrid.qml | 1 +
src/mobile/qml/TabsPanel.qml | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mobile/qml/PageFillGrid.qml b/src/mobile/qml/PageFillGrid.qml
index 249df56..74e4c42 100644
--- a/src/mobile/qml/PageFillGrid.qml
+++ b/src/mobile/qml/PageFillGrid.qml
@@ -71,6 +71,7 @@ Item {

Grid {
property alias thumbs: thumbRepeater
+ property int pageOffset: index * itemsPerPage
width: pageWidth
height: pageHeight
spacing: root.spacing
diff --git a/src/mobile/qml/TabsPanel.qml b/src/mobile/qml/TabsPanel.qml
index d8c04dd..eab9d4c 100644
--- a/src/mobile/qml/TabsPanel.qml
+++ b/src/mobile/qml/TabsPanel.qml
@@ -34,8 +34,9 @@ Item {
}

Component {
- id: pagedItemDelegate
+ id: pagedItemComponent
Image {
+ id: pagedItem
property string url: model.url
source: model.thumbnail
height: UiConstants.PagedGridSizeTable[1]
@@ -44,7 +45,7 @@ Item {
clip: true

Text {
- text: index + (pagedGrid.currentPage * pagedGrid.itemsPerPage) + 1
+ text: pagedItem.parent.pageOffset + index + 1
color: "#C1C2C3"
font.pixelSize: 30
font.family: "Nokia Pure Headline Light"
@@ -78,7 +79,7 @@ Item {
PagedGrid {
id: pagedGrid
model: TabsModel
- delegate: pagedItemDelegate
+ delegate: pagedItemComponent
emptyItemDelegate: Image { source: "qrc:///mobile/grid/thumb_empty_slot" }
maxPages: indicatorRow.maxItems
anchors {
--
1.7.9.5

Caio Marcelo de Oliveira Filho

unread,
Jun 15, 2012, 4:56:23 PM6/15/12
to snowsh...@googlegroups.com
r=me
> + text: pagedItem.parent.pageOffset + index + 1

Maybe we could add a note here explaining that we could improve this
interface by exposing another property (like index) to our delegate in the
future? This would serve as a warning to people changing PagedGrid code.


Cheers,

--
Caio Marcelo de Oliveira Filho
openBossa @ INdT - Instituto Nokia de Tecnologia
Reply all
Reply to author
Forward
0 new messages