[KPhotoAlbum] Very experimental image-grouping patch

Paul Fleischer paul at xpg.dk
Thu Nov 29 08:20:39 GMT 2007


2007/11/29, Tero Tilus <tero at tilus.net>:
> 2007-11-29 00:11, Paul Fleischer:
> > I might be wrong here, but doesn't ImageDB::info() do exactly this?
>
> I might be wrong as well, but I'd say it does not.  I could not found
> ImageDB::info() btw, but afaik we are talking about this method.
>
>   DB::ImageInfoPtr XMLDB::Database::info( const QString& fileName ) const
>   {
>       static QMap<QString, DB::ImageInfoPtr > fileMap;
>
>       if ( fileMap.contains( fileName ) )
>           return fileMap[ fileName ];
>       else {
>           fileMap.clear();
>           for( DB::ImageInfoListConstIterator it = _images.constBegin(); it != _images.constEnd(); ++it ) {
>               fileMap.insert( (*it)->fileName(), *it );
>           }
>           if ( fileMap.contains( fileName ) )
>               return fileMap[ fileName ];
>       }
>       return DB::ImageInfoPtr();
>   }
>
> What I can tell it just looks up from fileMap and if fileName isn't
> there it (re)builds the whole map.

Yep, that's exactly the piece of code I was thinking about. What
happens is that the map is rebuild on the first call, and is reused on
following calls. But, of course you are correct that it would be more
efficient to have a map with less entries (namely parents).

[snip]

/Paul



More information about the Kphotoalbum mailing list