From 13d26b59848dce276051f8f322bf82d291aa0c23 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Wed, 21 Feb 2024 00:11:00 +0300 Subject: Make metadata loading optional See: https://mirror.git.trinitydesktop.org/gitea/TDE/gwenview/issues/17#issuecomment-44076 Signed-off-by: Alexander Golubev --- src/app/configimagelistpage.ui | 27 ++++++++++++++++++++++++++- src/gvcore/filethumbnailviewitem.cpp | 4 ++-- src/gvcore/fileviewconfig.kcfg | 3 +++ src/gvcore/fileviewcontroller.cpp | 9 +++++++-- src/gvcore/timeutils.cpp | 19 ++++++++++++------- src/gvcore/timeutils.h | 3 ++- 6 files changed, 52 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/app/configimagelistpage.ui b/src/app/configimagelistpage.ui index 01cfe95..892ec88 100644 --- a/src/app/configimagelistpage.ui +++ b/src/app/configimagelistpage.ui @@ -1,4 +1,4 @@ - + ConfigImageListPage @@ -29,6 +29,31 @@ Show folders and archives + + Alt+S + + + If enabled, folders and archives will be displayed alongside images in the browse view. + + + + + kcfg_loadMetadata + + + Load &metadata from files + + + Alt+M + + + <p>This will cause metadata to be loaded from all the files in the current folder.</p> +<p>The metadata will be used to display the creation timestamp of the image instead of the file's mtime. Also, if the preview load fails, it may be used to display the image dimensions as a fallback. +</p> +<p>For this option to work, you will need to have appropriate file plugins from <i></i> to be installed. +</p> +<p>This may have some performance impact when browsing very large folders.</p> + diff --git a/src/gvcore/filethumbnailviewitem.cpp b/src/gvcore/filethumbnailviewitem.cpp index be74115..899bffd 100644 --- a/src/gvcore/filethumbnailviewitem.cpp +++ b/src/gvcore/filethumbnailviewitem.cpp @@ -238,7 +238,7 @@ void FileThumbnailViewItem::updateLines() { TQSize sz; if (mImageSize.isValid()) { sz=mImageSize; - } else { + } else if (FileViewConfig::loadMetadata()) { const KFileMetaInfo& info = mFileItem->metaInfo(/*autogen=*/false); if (info.isValid()) { sz = info.value("Dimensions").toSize(); @@ -247,7 +247,7 @@ void FileThumbnailViewItem::updateLines() { if (sz.isValid()) { TQString txt = TQString::number(sz.width())+"x"+TQString::number(sz.height()); mLines.append( new CroppedLine(this, txt) ); - } else if ( iconView()->itemTextPos()==TQIconView::Right) { + } else if (iconView()->itemTextPos()==TQIconView::Right) { // add empty line for they would nicely alligned; // for text at the bottom it doesn't look that nice mLines.append( new CroppedLine(this, TQString())); diff --git a/src/gvcore/fileviewconfig.kcfg b/src/gvcore/fileviewconfig.kcfg index 9ec2ed6..489b48c 100644 --- a/src/gvcore/fileviewconfig.kcfg +++ b/src/gvcore/fileviewconfig.kcfg @@ -7,6 +7,9 @@ true + + true + false diff --git a/src/gvcore/fileviewcontroller.cpp b/src/gvcore/fileviewcontroller.cpp index 4da91b0..576f9c6 100644 --- a/src/gvcore/fileviewcontroller.cpp +++ b/src/gvcore/fileviewcontroller.cpp @@ -1053,7 +1053,9 @@ void FileViewController::dirListerNewItems(const KFileItemList& items) { LOG(""); mThumbnailsNeedUpdate=true; currentFileView()->addItemList(items); - loadMetaInfo(items); + if (FileViewConfig::loadMetadata()) { + loadMetaInfo(items); + } } @@ -1063,7 +1065,10 @@ void FileViewController::dirListerRefreshItems(const KFileItemList& list) { for (; *it!=0L; ++it) { updateViewItem(*it); } - loadMetaInfo(list, true); + + if (FileViewConfig::loadMetadata()) { + loadMetaInfo(list, true); + } } void FileViewController::updateViewItem(const KFileItem *item, bool metaDataOnly) { diff --git a/src/gvcore/timeutils.cpp b/src/gvcore/timeutils.cpp index c917232..75dd41f 100644 --- a/src/gvcore/timeutils.cpp +++ b/src/gvcore/timeutils.cpp @@ -25,17 +25,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include #include - + +// Local +#include "fileviewconfig.h" + namespace Gwenview { namespace TimeUtils { time_t getTime(const KFileItem* item) { - const KFileMetaInfo& info = item->metaInfo(/*autogen=*/false); - if (info.isValid()) { - TQVariant value = info.value("Date/time"); - TQDateTime dt = value.toDateTime(); - if (dt.isValid()) { - return dt.toTime_t(); + + if (FileViewConfig::loadMetadata()) { + const KFileMetaInfo& info = item->metaInfo(/*autogen=*/false); + if (info.isValid()) { + TQDateTime dt = info.value("Date/time").toDateTime(); + if (dt.isValid()) { + return dt.toTime_t(); + } } } return item->time(TDEIO::UDS_MODIFICATION_TIME); diff --git a/src/gvcore/timeutils.h b/src/gvcore/timeutils.h index 8570b36..53eb065 100644 --- a/src/gvcore/timeutils.h +++ b/src/gvcore/timeutils.h @@ -29,7 +29,8 @@ namespace Gwenview { namespace TimeUtils { /** - * Returns the time of an item, using EXIF info if available and already loaded + * Returns the time of an item, using EXIF info if available, enabled and + * already loaded */ time_t getTime(const KFileItem*); -- cgit v1.2.1