[Digikam-devel] [Bug 96388] show number of images in the album

Gilles Caulier caulier.gilles at gmail.com
Mon Dec 10 14:56:10 GMT 2007

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
caulier.gilles gmail com changed:

           What    |Removed                     |Added
  Attachment #22442|0                           |1
        is obsolete|                            |

------- Additional Comments From caulier.gilles gmail com  2007-12-10 15:56 -------
Created an attachment (id=22453)
 --> (http://bugs.kde.org/attachment.cgi?id=22453&action=view)
patch version 21

new version of the patch witch include more speed up improvement in digikamtags
kio-slave and several improvment in timeline widget.

Code is not optimum yet. We need to find a simple query to DB outside the loop
witch count items in tags albums.

Marcel, code sound like below :

// --------------------------------------
QMap<int, int> tagsStatMap;
int	       tagID, imageID;
QStringList    values, fileNames;

m_db.execSql(QString("SELECT tagid, imageid FROM ImageTags"), &values);

for ( QStringList::iterator it = values.begin(); it != values.end(); )
   tagID = (*it).toInt();
   imageID = (*it).toInt();
   m_db.execSql(QString("SELECT name FROM Images WHERE id=%1").arg(imageID),

   if ( matchFilterList( regex, fileNames.first() ) )
      QMap<int, int>::iterator it2 = tagsStatMap.find(tagID);
      if ( it2 == tagsStatMap.end() )
	 tagsStatMap.insert(tagID, 1);
	 tagsStatMap.replace(tagID, it2.data() + 1);

QDataStream os(ba, IO_WriteOnly);
os << tagsStatMap;

// --------------------------------------


- The first DB query outside the loop get the complete list of tags/images IDs.

- The second one inside the loop get the filename associed to the image ID to
check mime type in items count.

It would be nice if we can get the list of tagsIDs/imageFilenames directly
outside the loop using only one query. This will limit DB access and speedup
the process...

But it's complex to do because tagsIDs/imageIds and imageIds/imageFilenames
lists are stored in separate DB tables. 

I need help from an SQL guru here (:=)))...


More information about the Digikam-devel mailing list