SVN commit 632982 by mwiesweg:
Add preloading for preview view CCMAIL: [hidden email] M +2 -2 albumwidgetstack.cpp M +1 -1 albumwidgetstack.h M +15 -7 digikamview.cpp M +9 -6 imagepreviewview.cpp M +6 -6 imagepreviewview.h M +43 -2 imagepreviewwidget.cpp M +2 -0 imagepreviewwidget.h --- trunk/extragear/graphics/digikam/digikam/albumwidgetstack.cpp #632981:632982 @@ -122,7 +122,7 @@ return d->imagePreviewView; } -void AlbumWidgetStack::setPreviewItem(ImageInfo* info, bool hasPrev, bool hasNext) +void AlbumWidgetStack::setPreviewItem(ImageInfo* info, ImageInfo *previous, ImageInfo *next) { if (!info) { @@ -152,7 +152,7 @@ if (previewMode() == MediaPlayerMode) setPreviewItem(); - d->imagePreviewView->setImageInfo(info, hasPrev, hasNext); + d->imagePreviewView->setImageInfo(info, previous, next); // NOTE: No need to toggle imediatly in PreviewImageMode here, // because we will recieve a signal for that when the image preview will be loaded. --- trunk/extragear/graphics/digikam/digikam/albumwidgetstack.h #632981:632982 @@ -64,7 +64,7 @@ AlbumIconView *albumIconView(); ImagePreviewView *imagePreviewView(); - void setPreviewItem(ImageInfo* info=0, bool hasPrev=false, bool hasNext=false); + void setPreviewItem(ImageInfo* info=0, ImageInfo *previous=0, ImageInfo *next=0); int previewMode(void); void setPreviewMode(int mode); --- trunk/extragear/graphics/digikam/digikam/digikamview.cpp #632981:632982 @@ -655,16 +655,21 @@ else { d->rightSideBar->itemChanged(list); + AlbumIconItem *selectedItem = d->iconView->firstSelectedItem(); - bool hasPrev = d->iconView->firstItem() != selectedItem; - bool hasNext = d->iconView->lastItem() != selectedItem; + ImageInfo *previousInfo=0, *nextInfo=0; + if (selectedItem->prevItem()) + previousInfo = static_cast<AlbumIconItem*>(selectedItem->prevItem())->imageInfo(); + if (selectedItem->nextItem()) + nextInfo = static_cast<AlbumIconItem*>(selectedItem->nextItem())->imageInfo(); + // we fed a list of copies d->rightSideBar->takeImageInfoOwnership(true); if (!d->albumWidgetStack->previewMode() == AlbumWidgetStack::PreviewAlbumMode) - d->albumWidgetStack->setPreviewItem(selectedItem->imageInfo(), hasPrev, hasNext); + d->albumWidgetStack->setPreviewItem(list.first(), previousInfo, nextInfo); - emit signalImageSelected(list, hasPrev, hasNext); + emit signalImageSelected(list, previousInfo, nextInfo); } d->needDispatchSelection = false; @@ -895,9 +900,12 @@ if (d->albumWidgetStack->previewMode() == AlbumWidgetStack::PreviewAlbumMode && iconItem) { // We will go to ImagePreview Mode. - bool hasPrev = d->iconView->firstItem() != iconItem; - bool hasNext = d->iconView->lastItem() != iconItem; - d->albumWidgetStack->setPreviewItem(iconItem->imageInfo(), hasPrev, hasNext); + ImageInfo *previousInfo=0, *nextInfo=0; + if (iconItem->prevItem()) + previousInfo = static_cast<AlbumIconItem*>(iconItem->prevItem())->imageInfo(); + if (iconItem->nextItem()) + nextInfo = static_cast<AlbumIconItem*>(iconItem->nextItem())->imageInfo(); + d->albumWidgetStack->setPreviewItem(iconItem->imageInfo(), previousInfo, nextInfo); } else { --- trunk/extragear/graphics/digikam/digikam/imagepreviewview.cpp #632981:632982 @@ -117,16 +117,19 @@ setPaletteBackgroundColor(ThemeEngine::instance()->baseColor()); } -void ImagePreviewView::setImageInfo(ImageInfo* info, bool hasPrev, bool hasNext) +void ImagePreviewView::setImageInfo(ImageInfo* info, ImageInfo *previous, ImageInfo *next) { d->imageInfo = info; - d->hasPrev = hasPrev; - d->hasNext = hasNext; + d->hasPrev = previous; + d->hasNext = next; if (d->imageInfo) - d->imagePreviewWidget->setImagePath(info->kurl().path()); - else - d->imagePreviewWidget->setImagePath(); + d->imagePreviewWidget->setImagePath(info->filePath()); + else + d->imagePreviewWidget->setImagePath(); + + d->imagePreviewWidget->setPreviousNextPaths(previous ? previous->filePath() : QString(), + next ? next->filePath() : QString()); } ImageInfo* ImagePreviewView::getImageInfo() --- trunk/extragear/graphics/digikam/digikam/imagepreviewview.h #632981:632982 @@ -42,9 +42,9 @@ public: ImagePreviewView(QWidget *parent=0); - ~ImagePreviewView(); - - void setImageInfo(ImageInfo* info=0, bool hasPrev=false, bool hasNext=false); + ~ImagePreviewView(); + + void setImageInfo(ImageInfo* info=0, ImageInfo *previous=0, ImageInfo *next=0); ImageInfo* getImageInfo(); void reload(); @@ -55,8 +55,8 @@ void signalPrevItem(); void signalDeleteItem(); void signalEditItem(); - void signalPreviewLoaded(); - void signalBack2Album(); + void signalPreviewLoaded(); + void signalBack2Album(); private slots: @@ -71,7 +71,7 @@ private: - ImagePreviewViewPriv* d; + ImagePreviewViewPriv* d; }; } // NameSpace Digikam --- trunk/extragear/graphics/digikam/digikam/imagepreviewwidget.cpp #632981:632982 @@ -52,16 +52,20 @@ ImagePreviewWidgetPriv() { - previewThread = 0; + previewThread = 0; + previewPreloadThread = 0; } QString path; + QString nextPath; + QString previousPath; QPixmap pixmap; QImage preview; PreviewLoadThread *previewThread; + PreviewLoadThread *previewPreloadThread; }; ImagePreviewWidget::ImagePreviewWidget(QWidget *parent) @@ -74,7 +78,7 @@ setFrameStyle(QFrame::NoFrame); setMargin(0); setLineWidth(0); - + // --------------------------------------------------------------- connect(ThemeEngine::instance(), SIGNAL(signalThemeChanged()), @@ -84,6 +88,7 @@ ImagePreviewWidget::~ImagePreviewWidget() { delete d->previewThread; + delete d->previewPreloadThread; delete d; } @@ -98,6 +103,9 @@ setCursor( KCursor::waitCursor() ); d->path = path; + d->nextPath = QString(); + d->previousPath = QString(); + if (d->path.isEmpty()) { d->pixmap = QPixmap(contentsRect().size()); @@ -114,12 +122,24 @@ connect(d->previewThread, SIGNAL(signalPreviewLoaded(const LoadingDescription &, const QImage &)), this, SLOT(slotGotImagePreview(const LoadingDescription &, const QImage&))); } + if (!d->previewPreloadThread) + { + d->previewPreloadThread = new PreviewLoadThread(); + connect(d->previewPreloadThread, SIGNAL(signalPreviewLoaded(const LoadingDescription &, const QImage &)), + this, SLOT(slotNextPreload())); + } d->previewThread->load(LoadingDescription(path, 1024, AlbumSettings::instance()->getExifRotate())); emit signalPreviewStarted(); } +void ImagePreviewWidget::setPreviousNextPaths(const QString& previous, const QString &next) +{ + d->nextPath = next; + d->previousPath = previous; +} + void ImagePreviewWidget::slotGotImagePreview(const LoadingDescription &description, const QImage& preview) { if (description.filePath != d->path) @@ -136,8 +156,29 @@ emit signalPreviewFailed(); else emit signalPreviewComplete(); + + slotNextPreload(); } +void ImagePreviewWidget::slotNextPreload() +{ + QString loadPath; + if (!d->nextPath.isNull()) + { + loadPath = d->nextPath; + d->nextPath = QString(); + } + else if (!d->previousPath.isNull()) + { + loadPath = d->previousPath; + d->previousPath = QString(); + } + else + return; + + d->previewPreloadThread->load(LoadingDescription(loadPath, 1024, AlbumSettings::instance()->getExifRotate())); +} + void ImagePreviewWidget::updatePixmap( void ) { d->pixmap.fill(ThemeEngine::instance()->baseColor()); --- trunk/extragear/graphics/digikam/digikam/imagepreviewwidget.h #632981:632982 @@ -50,6 +50,7 @@ ~ImagePreviewWidget(); void setImagePath(const QString& path=QString::null); + void setPreviousNextPaths(const QString& previous, const QString &next); void reload(); signals: @@ -74,6 +75,7 @@ private slots: void slotGotImagePreview(const LoadingDescription &loadingDescription, const QImage &image); + void slotNextPreload(); private: _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |