[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/graphics/digikam/utilities/advancedrename/parser/options
From:       Andi Clemens <andi.clemens () gmx ! net>
Date:       2010-06-03 19:54:04
Message-ID: 20100603200036.27FFEAC8C9 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1134267 by aclemens:

Tripple-check datetime information in the parser. It should have been set already be \
the calling instance, but somehow it fails for CameraUI now.

BUG:231585

 M  +28 -3     dateoption.cpp  


--- trunk/extragear/graphics/digikam/utilities/advancedrename/parser/options/dateoption.cpp \
#1134266:1134267 @@ -34,6 +34,7 @@
 
 #include <kiconloader.h>
 #include <klocale.h>
+#include <kdebug.h>
 
 // Local includes
 
@@ -249,20 +250,44 @@
         token.remove(0, 1);
     }
 
+    QDateTime dateTime = settings.dateTime;
+    if (dateTime.isNull() || !dateTime.isValid())
+    {
+        // lets try to re-read the file information
+        ImageInfo info(settings.fileUrl);
+        if (!info.isNull())
+        {
+            dateTime = info.dateTime();
+        }
+
+        if (dateTime.isNull() || !dateTime.isValid())
+        {
+            // still no date info, use Qt file information
+            QFileInfo fileInfo(settings.fileUrl.path());
+            dateTime = fileInfo.created();
+        }
+    }
+
+    // do we have a valid date?
+    if (dateTime.isNull())
+    {
+        return QString();
+    }
+
     QVariant v = df.formatType(token);
     if (v.isNull())
     {
-        result = settings.dateTime.toString(token);
+        result = dateTime.toString(token);
     }
     else
     {
         if (v.type() == QVariant::String)
         {
-            result = settings.dateTime.toString(v.toString());
+            result = dateTime.toString(v.toString());
         }
         else
         {
-            result = settings.dateTime.toString((Qt::DateFormat)v.toInt());
+            result = dateTime.toString((Qt::DateFormat)v.toInt());
         }
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic