Commit d73f0628 authored by Claudio Valerio's avatar Claudio Valerio

selected thumbnail updated correctly

parent 9e0239e3
...@@ -84,13 +84,18 @@ UBDocumentNavigator::~UBDocumentNavigator() ...@@ -84,13 +84,18 @@ UBDocumentNavigator::~UBDocumentNavigator()
*/ */
void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
{ {
mThumbsWithLabels.clear(); mThumbsWithLabels.clear();
foreach(QGraphicsItem* it, mScene->items()) // foreach(QGraphicsItem* it, mScene->items())
int selectedIndex = -1;
QList<QGraphicsItem*> graphicsItemList = mScene->items();
for(int i = 0; i < graphicsItemList.size(); i+=1)
{ {
mScene->removeItem(it); QGraphicsItem* item = graphicsItemList.at(i);
delete it; if(item->isSelected())
it = NULL; selectedIndex = i;
mScene->removeItem(item);
delete item;
item = NULL;
} }
for(int i = 0; i < source->selectedDocument()->pageCount(); i++) for(int i = 0; i < source->selectedDocument()->pageCount(); i++)
...@@ -112,6 +117,11 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) ...@@ -112,6 +117,11 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
mScene->addItem(labelItem); mScene->addItem(labelItem);
} }
if (selectedIndex >= 0 && selectedIndex < mThumbsWithLabels.count())
mSelectedThumbnail = mThumbsWithLabels.at(selectedIndex).getThumbnail();
else
mSelectedThumbnail = NULL;
// Draw the items // Draw the items
refreshScene(); refreshScene();
} }
...@@ -274,6 +284,7 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event) ...@@ -274,6 +284,7 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
{ {
if (mThumbsWithLabels.at(i).getThumbnail() == pCrntItem) if (mThumbsWithLabels.at(i).getThumbnail() == pCrntItem)
{ {
mSelectedThumbnail = pCrntItem;
index = i; index = i;
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment