diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-14 07:11:04 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-14 07:11:04 (GMT) |
commit | 99804fe10538bf267493d2be679c991f12e0548e (patch) | |
tree | 953c01feec37997a4cbcb236785195505eaed5a4 | |
parent | a598867353ed121e0b55e82af69253d0e94bb487 (diff) | |
parent | 0a27e429eed494a39d3bbb8cf67c50be035329bb (diff) | |
download | Qt-99804fe10538bf267493d2be679c991f12e0548e.zip Qt-99804fe10538bf267493d2be679c991f12e0548e.tar.gz Qt-99804fe10538bf267493d2be679c991f12e0548e.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | demos/declarative/flickr/content/ImageDetails.qml | 19 | ||||
-rw-r--r-- | src/declarative/fx/qfxgridview.cpp | 19 | ||||
-rw-r--r-- | src/declarative/fx/qfximage.cpp | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxrect.cpp | 4 |
4 files changed, 33 insertions, 13 deletions
diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index d575be9..b8091f2 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -12,6 +12,7 @@ Flipable { property string photoDate property string photoUrl property int rating: 2 + property var prevScale: 1.0 signal closed @@ -93,7 +94,8 @@ Flipable { // Default scale shows the entire image. if (status == 0 && width != 0) { Slider.minimum = Math.min(Flick.width / width, Flick.height / height); - Slider.value = Math.min(Slider.minimum, 1); + prevScale = Math.min(Slider.minimum, 1); + Slider.value = prevScale; } } } @@ -109,7 +111,20 @@ Flipable { anchors.centeredIn: parent; color: "white"; font.bold: true } - Slider { id: Slider; x: 25; y: 374; visible: { BigImage.status == 0 && maximum > minimum } } + Slider { + id: Slider; x: 25; y: 374; visible: { BigImage.status == 0 && maximum > minimum } + onValueChanged: { + if (BigImage.width * value > Flick.width) { + var xoff = (Flick.width/2 + Flick.xPosition) * value / prevScale; + Flick.xPosition = xoff - Flick.width/2; + } + if (BigImage.height * value > Flick.height) { + var yoff = (Flick.height/2 + Flick.yPosition) * value / prevScale; + Flick.yPosition = yoff - Flick.height/2; + } + prevScale = value; + } + } } states: [ diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 5156d06..876172d 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -409,7 +409,8 @@ void QFxGridViewPrivate::refill(qreal from, qreal to) FxGridItem *item = 0; while (modelIndex < model->count() && rowPos <= to) { //qDebug() << "refill: append item" << modelIndex; - item = getItem(modelIndex); + if (!(item = getItem(modelIndex))) + break; item->setPosition(colPos, rowPos); visibleItems.append(item); colPos += colSize(); @@ -431,7 +432,8 @@ void QFxGridViewPrivate::refill(qreal from, qreal to) } while (visibleIndex > 0 && rowPos + rowSize() - 1 >= from){ //qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos; - item = getItem(visibleIndex-1); + if (!(item = getItem(visibleIndex-1))) + break; --visibleIndex; item->setPosition(colPos, rowPos); visibleItems.prepend(item); @@ -472,7 +474,7 @@ void QFxGridViewPrivate::refill(qreal from, qreal to) void QFxGridViewPrivate::updateGrid() { Q_Q(QFxGridView); - columns = (int)qMax((flow == QFxGridView::LeftToRight ? q->width() : q->height()) / colSize(), 1.); + columns = (int)qMax((flow == QFxGridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.)); if (isValid()) { if (flow == QFxGridView::LeftToRight) q->setViewportHeight(endPosition() - startPosition()); @@ -629,14 +631,17 @@ void QFxGridViewPrivate::updateCurrent(int modelIndex) currentItem = visibleItem(modelIndex); if (!currentItem) { currentItem = getItem(modelIndex); - currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex)); + if (currentItem) + currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex)); } currentIndex = modelIndex; fixCurrentVisibility = true; - if (oldCurrentItem && oldCurrentItem->item != currentItem->item) + if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item)) oldCurrentItem->attached->setIsCurrentItem(false); - currentItem->item->setFocus(true); - currentItem->attached->setIsCurrentItem(true); + if (currentItem) { + currentItem->item->setFocus(true); + currentItem->attached->setIsCurrentItem(true); + } updateHighlight(); emit q->currentIndexChanged(); // Release the old current item diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index dfd6915..9d7a36a 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -365,8 +365,8 @@ void QFxImage::paintContents(QPainter &p) const int sgr = d->_scaleGrid->right(); const int sgt = d->_scaleGrid->top(); const int sgb = d->_scaleGrid->bottom(); - const int xSide = sgl + sgr; - const int ySide = sgt + sgb; + const int xSide = qMin(sgl + sgr, int(width())); + const int ySide = qMin(sgt + sgb, int(height())); // Upper left if (sgt && sgl) diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 371aa0c..dafd8a2 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -486,8 +486,8 @@ void QFxRect::drawRect(QPainter &p) } //basically same code as QFxImage uses to paint sci images - int xSide = offset * 2; - int ySide = offset * 2; + int xSide = qMin(offset * 2, int(width())); + int ySide = qMin(offset * 2, int(height()));; // Upper left p.drawImage(QRect(0, 0, offset, offset), d->_rectImage, QRect(0, 0, offset, offset)); |