Make metadata loading optional

See: https://mirror.git.trinitydesktop.org/gitea/TDE/gwenview/issues/17#issuecomment-44076
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit 13d26b5984)
pull/34/head
Alexander Golubev 7 months ago committed by Michele Calgaro
parent 8f266257f3
commit c42622ee63
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -1,4 +1,4 @@
<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> <!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>ConfigImageListPage</class> <class>ConfigImageListPage</class>
<widget class="TQWidget"> <widget class="TQWidget">
<property name="name"> <property name="name">
@ -29,6 +29,31 @@
<property name="text"> <property name="text">
<string>Show folders and archives</string> <string>Show folders and archives</string>
</property> </property>
<property name="accel">
<string>Alt+S</string>
</property>
<property name="whatsThis" stdset="0">
<string>If enabled, folders and archives will be displayed alongside images in the browse view.</string>
</property>
</widget>
<widget class="TQCheckBox">
<property name="name">
<cstring>kcfg_loadMetadata</cstring>
</property>
<property name="text">
<string>Load &amp;metadata from files</string>
</property>
<property name="accel">
<string>Alt+M</string>
</property>
<property name="whatsThis" stdset="0">
<string>&lt;p&gt;This will cause metadata to be loaded from all the files in the current folder.&lt;/p&gt;
&lt;p&gt;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.
&lt;/p&gt;
&lt;p&gt;For this option to work, you will need to have appropriate file plugins from &lt;i&gt;&lt;/i&gt; to be installed.
&lt;/p&gt;
&lt;p&gt;This may have some performance impact when browsing very large folders.&lt;/p&gt;</string>
</property>
</widget> </widget>
<spacer> <spacer>
<property name="name"> <property name="name">

@ -238,7 +238,7 @@ void FileThumbnailViewItem::updateLines() {
TQSize sz; TQSize sz;
if (mImageSize.isValid()) { if (mImageSize.isValid()) {
sz=mImageSize; sz=mImageSize;
} else { } else if (FileViewConfig::loadMetadata()) {
const KFileMetaInfo& info = mFileItem->metaInfo(/*autogen=*/false); const KFileMetaInfo& info = mFileItem->metaInfo(/*autogen=*/false);
if (info.isValid()) { if (info.isValid()) {
sz = info.value("Dimensions").toSize(); sz = info.value("Dimensions").toSize();
@ -247,7 +247,7 @@ void FileThumbnailViewItem::updateLines() {
if (sz.isValid()) { if (sz.isValid()) {
TQString txt = TQString::number(sz.width())+"x"+TQString::number(sz.height()); TQString txt = TQString::number(sz.width())+"x"+TQString::number(sz.height());
mLines.append( new CroppedLine(this, txt) ); 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; // add empty line for they would nicely alligned;
// for text at the bottom it doesn't look that nice // for text at the bottom it doesn't look that nice
mLines.append( new CroppedLine(this, TQString())); mLines.append( new CroppedLine(this, TQString()));

@ -7,6 +7,9 @@
<entry name="showDirs" key="show dirs" type="Bool"> <entry name="showDirs" key="show dirs" type="Bool">
<default>true</default> <default>true</default>
</entry> </entry>
<entry name="loadMetadata" key="load metadata" type="Bool">
<default>true</default>
</entry>
<entry name="showDotFiles" key="show dot files" type="Bool"> <entry name="showDotFiles" key="show dot files" type="Bool">
<default>false</default> <default>false</default>
</entry> </entry>

@ -1053,7 +1053,9 @@ void FileViewController::dirListerNewItems(const KFileItemList& items) {
LOG(""); LOG("");
mThumbnailsNeedUpdate=true; mThumbnailsNeedUpdate=true;
currentFileView()->addItemList(items); currentFileView()->addItemList(items);
loadMetaInfo(items); if (FileViewConfig::loadMetadata()) {
loadMetaInfo(items);
}
} }
@ -1063,7 +1065,10 @@ void FileViewController::dirListerRefreshItems(const KFileItemList& list) {
for (; *it!=0L; ++it) { for (; *it!=0L; ++it) {
updateViewItem(*it); updateViewItem(*it);
} }
loadMetaInfo(list, true);
if (FileViewConfig::loadMetadata()) {
loadMetaInfo(list, true);
}
} }
void FileViewController::updateViewItem(const KFileItem *item, bool metaDataOnly) { void FileViewController::updateViewItem(const KFileItem *item, bool metaDataOnly) {

@ -25,17 +25,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <tdefilemetainfo.h> #include <tdefilemetainfo.h>
#include <tdeglobal.h> #include <tdeglobal.h>
#include <tdelocale.h> #include <tdelocale.h>
// Local
#include "fileviewconfig.h"
namespace Gwenview { namespace Gwenview {
namespace TimeUtils { namespace TimeUtils {
time_t getTime(const KFileItem* item) { time_t getTime(const KFileItem* item) {
const KFileMetaInfo& info = item->metaInfo(/*autogen=*/false);
if (info.isValid()) { if (FileViewConfig::loadMetadata()) {
TQVariant value = info.value("Date/time"); const KFileMetaInfo& info = item->metaInfo(/*autogen=*/false);
TQDateTime dt = value.toDateTime(); if (info.isValid()) {
if (dt.isValid()) { TQDateTime dt = info.value("Date/time").toDateTime();
return dt.toTime_t(); if (dt.isValid()) {
return dt.toTime_t();
}
} }
} }
return item->time(TDEIO::UDS_MODIFICATION_TIME); return item->time(TDEIO::UDS_MODIFICATION_TIME);

@ -29,7 +29,8 @@ namespace Gwenview {
namespace TimeUtils { 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*); time_t getTime(const KFileItem*);

Loading…
Cancel
Save