summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxlistview.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-05-12 05:20:16 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-05-12 05:20:16 (GMT)
commit4e19d0393dd4b4ddcdbe1677987d9370a5d605bb (patch)
tree2a4ff75f98fab22c4073e3ab4cf5cacf467e83f8 /src/declarative/fx/qfxlistview.cpp
parent8d90fe1e4a3d50b64cff84ac10bfa2e6a17a35b9 (diff)
downloadQt-4e19d0393dd4b4ddcdbe1677987d9370a5d605bb.zip
Qt-4e19d0393dd4b4ddcdbe1677987d9370a5d605bb.tar.gz
Qt-4e19d0393dd4b4ddcdbe1677987d9370a5d605bb.tar.bz2
More robust error handling (in ListView) and reporting (in VisualModel).
Diffstat (limited to 'src/declarative/fx/qfxlistview.cpp')
-rw-r--r--src/declarative/fx/qfxlistview.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index fcd6e1f..46166e2 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -438,6 +438,7 @@ FxListItem *QFxListViewPrivate::createItem(int modelIndex)
else
QObject::connect(listItem->item, SIGNAL(widthChanged()), q, SLOT(itemResized()));
}
+
return listItem;
}
@@ -484,7 +485,8 @@ void QFxListViewPrivate::refill(qreal from, qreal to)
int pos = itemEnd + 1;
while (modelIndex < model->count() && pos <= to) {
//qDebug() << "refill: append item" << modelIndex;
- item = getItem(modelIndex);
+ if (!(item = getItem(modelIndex)))
+ break;
item->setPosition(pos);
pos += item->size();
visibleItems.append(item);
@@ -493,7 +495,8 @@ void QFxListViewPrivate::refill(qreal from, qreal to)
}
while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos > from) {
//qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos;
- item = getItem(visibleIndex-1);
+ if (!(item = getItem(visibleIndex-1)))
+ break;
--visibleIndex;
visiblePos -= item->size();
item->setPosition(visiblePos);
@@ -719,26 +722,30 @@ void QFxListViewPrivate::updateCurrent(int modelIndex)
currentItem = visibleItem(modelIndex);
if (!currentItem) {
currentItem = getItem(modelIndex);
- if (modelIndex == visibleIndex - 1) {
- // We can calculate exact postion in this case
- currentItem->setPosition(visibleItems.first()->position() - currentItem->size());
- } else {
- // Create current item now and position as best we can.
- // Its position will be corrected when it becomes visible.
- currentItem->setPosition(positionAt(modelIndex));
+ if (currentItem) {
+ if (modelIndex == visibleIndex - 1) {
+ // We can calculate exact postion in this case
+ currentItem->setPosition(visibleItems.first()->position() - currentItem->size());
+ } else {
+ // Create current item now and position as best we can.
+ // Its position will be corrected when it becomes visible.
+ currentItem->setPosition(positionAt(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
if (oldCurrentItem && !visibleItem(oldCurrentIndex)) {
- if (oldCurrentItem->item == currentItem->item)
+ if (!currentItem || oldCurrentItem->item == currentItem->item)
delete oldCurrentItem;
else
releaseItem(oldCurrentItem);