diff --git a/src/gvcore/filedetailview.cpp b/src/gvcore/filedetailview.cpp index 50d2b3f..2a73176 100644 --- a/src/gvcore/filedetailview.cpp +++ b/src/gvcore/filedetailview.cpp @@ -251,7 +251,7 @@ void FileDetailView::updateView( bool b ) } } -void FileDetailView::updateView( const KFileItem *i ) +void FileDetailView::updateView( const KFileItem *i, bool /*metaDataOnly*/ ) { if ( !i ) return; diff --git a/src/gvcore/filedetailview.h b/src/gvcore/filedetailview.h index b0eafac..aced4ba 100644 --- a/src/gvcore/filedetailview.h +++ b/src/gvcore/filedetailview.h @@ -55,7 +55,8 @@ public: virtual void clearView(); virtual void updateView( bool ); - virtual void updateView(const KFileItem*); + using FileViewBase::updateView; + virtual void updateView(const KFileItem*, bool metaInfoOnly); virtual void removeItem( const KFileItem* ); virtual void listingCompleted(); diff --git a/src/gvcore/filethumbnailview.cpp b/src/gvcore/filethumbnailview.cpp index e12f652..16e491d 100644 --- a/src/gvcore/filethumbnailview.cpp +++ b/src/gvcore/filethumbnailview.cpp @@ -454,15 +454,19 @@ void FileThumbnailView::insertItem(KFileItem* item) { } -void FileThumbnailView::updateView(const KFileItem* fileItem) { +void FileThumbnailView::updateView(const KFileItem* fileItem, bool metaInfoOnly) { if (!fileItem) return; - FileThumbnailViewItem* iconItem=viewItem(this, fileItem); if (iconItem) { - iconItem->setText(fileItem->text()); - updateThumbnail(fileItem); + if (metaInfoOnly) { + iconItem->updateLines(); + // Note: resort will be done when metadata is completely loaded + } else { + iconItem->setText(fileItem->text()); + updateThumbnail(fileItem); + sortView(); + } } - sort(); } @@ -565,7 +569,7 @@ void FileThumbnailView::setSorting(TQDir::SortSpec spec) { if (iconItem) setSortingKey(iconItem, item); } - TDEIconView::sort(! (spec & TQDir::Reversed) ); + sortView(); } //-------------------------------------------------------------------------- @@ -769,6 +773,10 @@ void FileThumbnailView::prefetchDone() { } } +void FileThumbnailView::sortView() { + TDEIconView::sort( !(KFileView::sorting() & TQDir::Reversed) ); +} + //-------------------------------------------------------------------------- // // Protected diff --git a/src/gvcore/filethumbnailview.h b/src/gvcore/filethumbnailview.h index 37788fd..4312b8a 100644 --- a/src/gvcore/filethumbnailview.h +++ b/src/gvcore/filethumbnailview.h @@ -65,7 +65,7 @@ public: void setSelected(const KFileItem* item,bool enable); bool isSelected(const KFileItem* item) const; void removeItem(const KFileItem* item); - void updateView(const KFileItem* item); + void updateView(const KFileItem* item, bool metaInfoOnly); void setSorting(TQDir::SortSpec); KFileItem* firstFileItem() const; @@ -95,6 +95,8 @@ public slots: void showThumbnailDetailsDialog(); + void sortView(); + signals: void dropped(TQDropEvent*, KFileItem* target); diff --git a/src/gvcore/fileviewbase.h b/src/gvcore/fileviewbase.h index 7b09ac7..8d22182 100644 --- a/src/gvcore/fileviewbase.h +++ b/src/gvcore/fileviewbase.h @@ -34,9 +34,15 @@ public: KFileItem* shownFileItem() const { return mShownFileItem; } virtual void setShownFileItem(KFileItem* fileItem) { mShownFileItem=fileItem; } - + virtual void updateFromSettings() {} + using KFileView::updateView; + void updateView(const KFileItem* fileItem) override { + updateView(fileItem, false); + } + virtual void updateView(const KFileItem* fileItem, bool metaDataOnly) = 0; + protected: KFileItem* mShownFileItem; }; diff --git a/src/gvcore/fileviewcontroller.cpp b/src/gvcore/fileviewcontroller.cpp index 1a1005a..4da91b0 100644 --- a/src/gvcore/fileviewcontroller.cpp +++ b/src/gvcore/fileviewcontroller.cpp @@ -1063,10 +1063,11 @@ void FileViewController::dirListerRefreshItems(const KFileItemList& list) { for (; *it!=0L; ++it) { updateViewItem(*it); } + loadMetaInfo(list, true); } -void FileViewController::updateViewItem(const KFileItem *item) { - currentFileView()->updateView(item); +void FileViewController::updateViewItem(const KFileItem *item, bool metaDataOnly) { + currentFileView()->updateView(item, metaDataOnly); if (item==currentFileView()->shownFileItem()) { emit shownFileItemRefreshed(item); } @@ -1114,7 +1115,7 @@ void FileViewController::delayedDirListerCompleted() { // around is not in firstFileItem() because it's const and sort() is a non // const method if (mMode!=FILE_LIST) { - mFileThumbnailView->sort(mFileThumbnailView->sortDirection()); + mFileThumbnailView->sortView(); } if (mChangeDirStatus != CHANGE_DIR_STATUS_NONE) { @@ -1339,7 +1340,14 @@ KFileItem* FileViewController::findItemByFileName(const TQString& fileName) cons // //----------------------------------------------------------------------------- -void FileViewController::loadMetaInfo(const KFileItemList& items) { +void FileViewController::loadMetaInfo(const KFileItemList& items, bool forceReload) { + if (forceReload) { + // Reset metadata of all items if we want MetaInfoJob to reload it + for(const auto& item: items) { + item->setMetaInfo(KFileMetaInfo()); + } + } + if(d->mMetaInfoTodo.isEmpty()) { d->mMetaInfoTodo = items; } else { @@ -1359,10 +1367,16 @@ void FileViewController::nextMetaInfoJob() { connect( d->mMetaInfoJob, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(nextMetaInfoJob()) ); connect( d->mMetaInfoJob, TQ_SIGNAL( gotMetaInfo(const KFileItem *)), - this, TQ_SLOT(updateViewItem(const KFileItem *)) ); + this, TQ_SLOT(updateItemMetaInfo(const KFileItem *)) ); d->mMetaInfoTodo.clear(); } else { d->mMetaInfoJob = NULL; + + // When we finished all metadata load we should update view sorting + // We can't do it during the item update due to performance impact + if (mMode!=FILE_LIST) { + mFileThumbnailView->sortView(); + } } } @@ -1374,4 +1388,8 @@ void FileViewController::stopMetaInfoUpdate() { } } +void FileViewController::updateItemMetaInfo(const KFileItem *item) { + updateViewItem(item, /* metaInfoOnly = */ true); +} + } // namespace diff --git a/src/gvcore/fileviewcontroller.h b/src/gvcore/fileviewcontroller.h index b863614..55c2ebd 100644 --- a/src/gvcore/fileviewcontroller.h +++ b/src/gvcore/fileviewcontroller.h @@ -174,7 +174,6 @@ private slots: void toggleShowDotFiles(); void setSorting(); void updateSortMenu(TQDir::SortSpec); - void updateViewItem(const KFileItem *item); // Dir lister slots void dirListerDeleteItem(KFileItem* item); @@ -185,10 +184,11 @@ private slots: void dirListerCanceled(); void dirListerCompleted(); - // Metadata info loader jobs - void loadMetaInfo(const KFileItemList& items); + // Metadata info loader job's slots + void loadMetaInfo(const KFileItemList& items, bool forceReload=false); void nextMetaInfoJob(); void stopMetaInfoUpdate(); + void updateItemMetaInfo(const KFileItem *item); void openDropURLMenu(TQDropEvent*, KFileItem*); @@ -246,6 +246,7 @@ private: void emitURLChanged(); void updateActions(); void prefetch( KFileItem* item ); + void updateViewItem(const KFileItem *item, bool metaInfoOnly=false); KFileItem* findFirstImage() const; KFileItem* findLastImage() const;