PDF view: performance fix

preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent e6f84716f0
commit 921953e069
  1. 3
      src/core/UBApplicationController.cpp
  2. 44
      src/document/UBDocumentController.cpp
  3. 4
      src/document/UBDocumentController.h
  4. 1
      src/gui/UBDocumentNavigator.cpp

@ -337,6 +337,9 @@ void UBApplicationController::showBoard()
mMainWindow->tutorialToolBar->hide(); mMainWindow->tutorialToolBar->hide();
mMainWindow->boardToolBar->show(); mMainWindow->boardToolBar->show();
if (mMainMode == Document && UBApplication::documentController->getSelectedItemIndex() != -1)
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), UBApplication::documentController->getSelectedItemIndex());
mMainMode = Board; mMainMode = Board;
adaptToolBar(); adaptToolBar();

@ -160,6 +160,9 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr
mDocumentUI->documentTreeWidget->scrollToItem(selected); mDocumentUI->documentTreeWidget->scrollToItem(selected);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView();
mSelectionType = Document; mSelectionType = Document;
} }
} }
@ -268,11 +271,10 @@ void UBDocumentController::refreshDocumentThumbnailsView()
if (proxy) if (proxy)
{ {
mCurrentDocument = proxy; mCurrentDocument = proxy;
QList<QPixmap> thumbs = UBThumbnailAdaptor::load(proxy);
for (int i = 0; i < thumbs.count(); i++) for (int i = 0; i < mDocumentThumbs.count(); i++)
{ {
QPixmap pix = thumbs.at(i); QPixmap pix = mDocumentThumbs.at(i);
QGraphicsPixmapItem *pixmapItem = new UBSceneThumbnailPixmap(pix, proxy, i); // deleted by the tree widget QGraphicsPixmapItem *pixmapItem = new UBSceneThumbnailPixmap(pix, proxy, i); // deleted by the tree widget
if (proxy == mBoardController->activeDocument() && mBoardController->activeSceneIndex() == i) if (proxy == mBoardController->activeDocument() && mBoardController->activeSceneIndex() == i)
@ -507,7 +509,7 @@ void UBDocumentController::openSelectedItem()
if (proxy && isOKToOpenDocument(proxy)) if (proxy && isOKToOpenDocument(proxy))
{ {
mBoardController->setActiveDocumentScene(proxy, thumb->sceneIndex()); //mBoardController->setActiveDocumentScene(proxy, thumb->sceneIndex());
UBApplication::applicationController->showBoard(); UBApplication::applicationController->showBoard();
} }
} }
@ -561,6 +563,7 @@ void UBDocumentController::duplicateSelectedItem()
foreach (int sceneIndex, selectedSceneIndexes) foreach (int sceneIndex, selectedSceneIndexes)
{ {
UBPersistenceManager::persistenceManager()->duplicateDocumentScene(proxy, sceneIndex + offset); UBPersistenceManager::persistenceManager()->duplicateDocumentScene(proxy, sceneIndex + offset);
mDocumentThumbs.insert(sceneIndex + offset, mDocumentThumbs.at(sceneIndex + offset));
offset++; offset++;
} }
} }
@ -921,6 +924,7 @@ void UBDocumentController::itemClicked(QTreeWidgetItem * item, int column )
Q_UNUSED(item); Q_UNUSED(item);
Q_UNUSED(column); Q_UNUSED(column);
selectDocument(selectedDocumentProxy(), false);
itemSelectionChanged(); itemSelectionChanged();
} }
@ -1043,6 +1047,7 @@ void UBDocumentController::addFolderOfImages()
{ {
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document); UBMetadataDcSubsetAdaptor::persist(document);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
} }
} }
@ -1057,6 +1062,7 @@ void UBDocumentController::addFileToDocument()
if (document) if (document)
{ {
addFileToDocument(document); addFileToDocument(document);
mDocumentThumbs = UBThumbnailAdaptor::load(document);
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
} }
} }
@ -1108,12 +1114,9 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source,
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy); UBMetadataDcSubsetAdaptor::persist(proxy);
mDocumentThumbs.insert(target, mDocumentThumbs.takeAt(source));
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
mDocumentUI->thumbnailWidget->hightlightItem(target);
// Notify the move to anyone interested in knowing it
emit movedToIndex(target);
UBApplication::boardController->setActiveDocumentScene(proxy, target);
} }
@ -1321,7 +1324,8 @@ void UBDocumentController::addToDocument()
} }
int newActiveSceneIndex = selectedItems.count() == mBoardController->activeDocument()->pageCount() ? 0 : oldActiveSceneIndex + 1; int newActiveSceneIndex = selectedItems.count() == mBoardController->activeDocument()->pageCount() ? 0 : oldActiveSceneIndex + 1;
mBoardController->setActiveDocumentScene(mBoardController->activeDocument(), newActiveSceneIndex); mDocumentUI->thumbnailWidget->selectItemAt(newActiveSceneIndex, false);
selectDocument(mBoardController->activeDocument());
mBoardController->activeDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); mBoardController->activeDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(mBoardController->activeDocument()); UBMetadataDcSubsetAdaptor::persist(mBoardController->activeDocument());
@ -1495,6 +1499,7 @@ void UBDocumentController::addImages()
{ {
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document); UBMetadataDcSubsetAdaptor::persist(document);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
} }
} }
@ -1605,6 +1610,13 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes); UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy); UBMetadataDcSubsetAdaptor::persist(proxy);
int offset = 0;
foreach(int index, sceneIndexes)
{
mDocumentThumbs.removeAt(index - offset);
offset++;
}
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
int minIndex = proxy->pageCount() - 1; int minIndex = proxy->pageCount() - 1;
@ -1616,3 +1628,15 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
} }
} }
} }
int UBDocumentController::getSelectedItemIndex()
{
QList<QGraphicsItem*> selectedItems = mDocumentUI->thumbnailWidget->selectedItems();
if (selectedItems.count() > 0)
{
UBSceneThumbnailPixmap* thumb = dynamic_cast<UBSceneThumbnailPixmap*> (selectedItems.last());
return thumb->sceneIndex();
}
else return -1;
}

@ -48,8 +48,9 @@ class UBDocumentController : public QObject
QWidget* controlView(); QWidget* controlView();
UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy); UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy);
bool addFileToDocument(UBDocumentProxy* document); bool addFileToDocument(UBDocumentProxy* document);
UBDocumentProxy* getCurrentDocument(); UBDocumentProxy* getCurrentDocument() { return mCurrentDocument; };
void deletePages(QList<QGraphicsItem*> itemsToDelete); void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex();
signals: signals:
void refreshThumbnails(); void refreshThumbnails();
@ -111,6 +112,7 @@ class UBDocumentController : public QObject
bool mToolsPalettePositionned; bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi; UBDocumentGroupTreeItem* mTrashTi;
UBDocumentProxy* mCurrentDocument; UBDocumentProxy* mCurrentDocument;
QList<QPixmap> mDocumentThumbs;
// UBKeyboardPalette *mKeyboardPalette; // UBKeyboardPalette *mKeyboardPalette;

@ -56,7 +56,6 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra
setFrameShadow(QFrame::Plain); setFrameShadow(QFrame::Plain);
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(addNewPage())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(addNewPage()));
connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(generateThumbnails()));
connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int))); connect(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int)));
} }

Loading…
Cancel
Save