[KPhotoAlbum] Fwd: Patch for loading only one version of a file into the DB.

Andreas Neustifter andreas.neustifter at gmail.com
Sun Jun 5 11:39:04 BST 2011


Forgot mailing list. (Again...)


---------- Forwarded message ----------
From: Andreas Neustifter <andreas.neustifter at gmail.com>
Date: 5 June 2011 09:31
Subject: Re: [KPhotoAlbum] Patch for loading only one version of a
file into the DB.
To: "Jesper K. Pedersen" <blackie at kde.org>


Hi all!

[Since this patch has some history this EMail is longish, if anyone is
interested in a shorter version, please say so!]

This patch is still pending, anyone willing to have a look at it? I
would really like to see this go into KPA:

https://github.com/astifter/kphotoalbum-fork/commit/7bccdfc3078e628edfa111e3cff394a36120f183

Since digging through the archives is a little time consuming I have
prepared the relevant excerpts, first me explaining what the patch is
all about:

On 12 December 2010 21:38, Andreas Neustifter
<andreas.neustifter at gmail.com> wrote:
> [...]
> There are some strings and regexes that are constant throughout the
> NewImageFinder::loadExtraFiles() loop, this patch pulls them out and
> creates them only once.
>
> This patch creates support for several regexes for the original file
> version detection. Those regexes are separated with semicolons and
> processes from left to right. The first regex that matches an existing
> file is used as original file.
>
> When used with e.g. "(.*)/(.{8})(.*)" as modifiedFileComponent and
> "\\1/\\2.JPG;\\1/\\2.CR2;\\1/\\2.CRW" as originalFileComponent this
> stacks all files with the same 8 characters onto each other.
>
> This does not prevent the loading of multiple files but merely stacks
> them on top of each other.

Then Jan Kundrát gave some feedback:

> On 20 December 2010 00:56, Jan Kundrát <jkt at gentoo.org> wrote:
>> On 12/12/10 21:38, Andreas Neustifter wrote:
>>> There are some strings and regexes that are constant throughout the
>>> NewImageFinder::loadExtraFiles() loop, this patch pulls them out and
>>> creates them only once.
>>
>> Obligatory question -- what's the overhead of a QRegExp() constructor?
>> I'm asking because QSettings() is documented to have very low overhead,
>> and it's really good to have optimizations backed up by measurements.
>
> This is only in a small part intended as a runtime optimisation but
> also as a readability optimisation because
> NewImageFinder::loadExtraFile now is easier and simpler to read. In
> generall I find it good to move loop invariant code out of the loop
> for readability purpose.
>
>>> This patch creates support for several regexes for the original file
>>> version detection. Those regexes are separated with semicolons and
>>> processes from left to right. The first regex that matches an existing
>>> file is used as original file.
>>
>> If you allow entering multiple strings, please also make the GUI look
>> intuitive. Separating regular expression by semicolon isn't intuitive. I
>> can't think of anything better that a QTextEdit; I don't believe you'd
>> like me to suggest using a QListWidget with some delegate for editing
>> the regular expressions, although I'm sure Jesper would be glad to see
>> it integrated with the KRegExpEditor :). If you find something
>> reasonable, please go ahead and use that.
>
> I thought a little about this and I have not found another (equally
> easy to implement) solution. Is it possible to use it like this for
> the time being and maybe design a better GUI afterwards?

Finally the point was raised if stacking is the appropriate way to
handle multiple versions of a file. I have use the patch for some time
now and I really works fine, and I do not want to add another way to
"combine" images together.

Cheers, Andi



More information about the Kphotoalbum mailing list