By invoking saveHistory after each change we ensure that the clipboard
doesn't lose data in case klipper (or in dataengine mode plasmashell)
crashes.
To not cause stalls, the saving is performed in a thread using
QtConcurrentRun. As klipper itself is not thread save a Mutex is
used to lock changes in the HistoryModel.
To not overload the system the save operations are delayed and queued.
Each save is delayed by five seconds since the last clipboard change.
So if the clipboard is changed multiple times in a short interval it
doesn't get synced to the disk till the interaction has settled.
BUG: 343333
FIXED-IN: 5.3.0
REVIEW: 122382
The UuidRole is mapped to a new data role which provides the item's
uuid base64 encoded. This is needed as the uuid will be passed through
the data engine and needs to be string convertable.
The HistoryModel provides the needed functionality to be hooked into
History. It's not setting up the chaining (that's implicit in a model)
and uses shared pointer. Both needs further adjustments in Klipper.