[Digikam-devel] extragear/graphics/digikam/libs/database

Andi Clemens andi.clemens at gmx.net
Thu May 28 09:28:05 BST 2009


SVN commit 973925 by aclemens:

Only fetch statistics for active elements.

Marcel, Gilles,

there is some query in the function that doesn't seem to do anything. Is
this old code? I have commented it for now.

Statistics seems to work fine for images now, but somehow I get 12
movies more in another test database, as when I recursively display the
movie folder.

Need to check if it is a problem with my DB.

Andi

CCMAIL::digikam-devel at kde.org

 M  +10 -3     albumdb.cpp  


--- trunk/extragear/graphics/digikam/libs/database/albumdb.cpp #973924:973925
@@ -2043,13 +2043,20 @@
     QList<QVariant> values, allFormats;
     QMap<QString, int>  map;
 
-    d->db->execSql("SELECT DISTINCT format FROM ImageInformation;", &allFormats);
+    //    d->db->execSql("SELECT DISTINCT format FROM ImageInformation;", &allFormats);
+    d->db->execSql("SELECT DISTINCT II.format "
+                   "    FROM ImageInformation AS II, Images "
+                   "    WHERE Images.id == II.imageid AND Images.status == 1;", &allFormats);
 
-    QSqlQuery query = d->db->prepareQuery( QString("SELECT count() FROM ImageInformation WHERE format=?;") );
+    // FIXME: What is this for? Old code?
+    //        I disabled it for now because it seems to do nothing.
+    //    QSqlQuery query = d->db->prepareQuery( QString("SELECT count() FROM ImageInformation WHERE format=?;") );
 
     foreach (const QVariant &format, allFormats)
     {
-        d->db->execSql("SELECT count() FROM ImageInformation WHERE format=?;", format, &values);
+        d->db->execSql("SELECT count() FROM ImageInformation AS II, Images "
+                       "    WHERE II.imageid == Images.id AND Images.status== 1 "
+                       "        AND format=?;", format, &values);
         map[format.toString()] = values.isEmpty() ? 0 : values.first().toInt();
     }
 



More information about the Digikam-devel mailing list