From d73f06281b1fa320d64900f6694d9ea64cf54155 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 27 Jun 2013 16:08:05 +0200 Subject: [PATCH] selected thumbnail updated correctly --- src/gui/UBDocumentNavigator.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 11f5400d..7f2e26df 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -84,13 +84,18 @@ UBDocumentNavigator::~UBDocumentNavigator() */ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) { - mThumbsWithLabels.clear(); - foreach(QGraphicsItem* it, mScene->items()) +// foreach(QGraphicsItem* it, mScene->items()) + int selectedIndex = -1; + QList graphicsItemList = mScene->items(); + for(int i = 0; i < graphicsItemList.size(); i+=1) { - mScene->removeItem(it); - delete it; - it = NULL; + QGraphicsItem* item = graphicsItemList.at(i); + if(item->isSelected()) + selectedIndex = i; + mScene->removeItem(item); + delete item; + item = NULL; } for(int i = 0; i < source->selectedDocument()->pageCount(); i++) @@ -112,6 +117,11 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) mScene->addItem(labelItem); } + if (selectedIndex >= 0 && selectedIndex < mThumbsWithLabels.count()) + mSelectedThumbnail = mThumbsWithLabels.at(selectedIndex).getThumbnail(); + else + mSelectedThumbnail = NULL; + // Draw the items refreshScene(); } @@ -274,6 +284,7 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event) { if (mThumbsWithLabels.at(i).getThumbnail() == pCrntItem) { + mSelectedThumbnail = pCrntItem; index = i; break; }