Create a new temp table for style items to be inserted into history.

This is only to get a proper ROWNUM (not supported by SQLite) for the
select results.
(cherry picked from commit f65cf51590226908c74c05de9be20e18ee4583e1)
Fix order of style items recorded into the style and when applied to image.
(cherry picked from commit 8477b4fed193e6d4b57064a7604e1e31ca8f38e2)
When apply a style to a duplicate make sure the collected images are updated.

Now that the collected images into the lighttable are stored separately
into a memory table, we want to ensure that this collection is properly
updated when applying a style to a duplicate. we were not doing this
and the duplicated image was not visible until some filters were changed.
(cherry picked from commit 1a1bdc4217f4edc1fc93f69a47918f08f5f8fe00)