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->boardToolBar->show();
if (mMainMode == Document && UBApplication::documentController->getSelectedItemIndex() != -1)
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), UBApplication::documentController->getSelectedItemIndex());
mMainMode = Board;
adaptToolBar();

@ -160,6 +160,9 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr
mDocumentUI->documentTreeWidget->scrollToItem(selected);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView();
mSelectionType = Document;
}
}
@ -268,11 +271,10 @@ void UBDocumentController::refreshDocumentThumbnailsView()
if (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
if (proxy == mBoardController->activeDocument() && mBoardController->activeSceneIndex() == i)
@ -507,7 +509,7 @@ void UBDocumentController::openSelectedItem()
if (proxy && isOKToOpenDocument(proxy))
{
mBoardController->setActiveDocumentScene(proxy, thumb->sceneIndex());
//mBoardController->setActiveDocumentScene(proxy, thumb->sceneIndex());
UBApplication::applicationController->showBoard();
}
}
@ -561,6 +563,7 @@ void UBDocumentController::duplicateSelectedItem()
foreach (int sceneIndex, selectedSceneIndexes)
{
UBPersistenceManager::persistenceManager()->duplicateDocumentScene(proxy, sceneIndex + offset);
mDocumentThumbs.insert(sceneIndex + offset, mDocumentThumbs.at(sceneIndex + offset));
offset++;
}
}
@ -921,6 +924,7 @@ void UBDocumentController::itemClicked(QTreeWidgetItem * item, int column )
Q_UNUSED(item);
Q_UNUSED(column);
selectDocument(selectedDocumentProxy(), false);
itemSelectionChanged();
}
@ -1043,6 +1047,7 @@ void UBDocumentController::addFolderOfImages()
{
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView();
}
}
@ -1057,6 +1062,7 @@ void UBDocumentController::addFileToDocument()
if (document)
{
addFileToDocument(document);
mDocumentThumbs = UBThumbnailAdaptor::load(document);
refreshDocumentThumbnailsView();
}
}
@ -1108,12 +1114,9 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source,
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy);
mDocumentThumbs.insert(target, mDocumentThumbs.takeAt(source));
refreshDocumentThumbnailsView();
// Notify the move to anyone interested in knowing it
emit movedToIndex(target);
UBApplication::boardController->setActiveDocumentScene(proxy, target);
mDocumentUI->thumbnailWidget->hightlightItem(target);
}
@ -1321,7 +1324,8 @@ void UBDocumentController::addToDocument()
}
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()));
UBMetadataDcSubsetAdaptor::persist(mBoardController->activeDocument());
@ -1495,6 +1499,7 @@ void UBDocumentController::addImages()
{
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
refreshDocumentThumbnailsView();
}
}
@ -1605,6 +1610,13 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy);
int offset = 0;
foreach(int index, sceneIndexes)
{
mDocumentThumbs.removeAt(index - offset);
offset++;
}
refreshDocumentThumbnailsView();
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();
UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy);
bool addFileToDocument(UBDocumentProxy* document);
UBDocumentProxy* getCurrentDocument();
UBDocumentProxy* getCurrentDocument() { return mCurrentDocument; };
void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex();
signals:
void refreshThumbnails();
@ -111,6 +112,7 @@ class UBDocumentController : public QObject
bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi;
UBDocumentProxy* mCurrentDocument;
QList<QPixmap> mDocumentThumbs;
// UBKeyboardPalette *mKeyboardPalette;

@ -56,7 +56,6 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra
setFrameShadow(QFrame::Plain);
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(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int)));
}

Loading…
Cancel
Save