Reuse QAction and QMenu items on updates
Summary:
When updating a menu we would always delete all the actions and recreate
them.
This caused a problem that we would also be deleting submenus and
recreating them, meaning when we update the applet's submenu before
showing it, our submenu will always be destroyed.
This patch uses the DBusMenuItem IDs to re-use existing QAction / QMenu
objects and only create new instances when needed. It should also be (in
theory) faster as there's a lot less object creation every update.
Also replace QSignalMapper with a lambda and replace replace QMap<int,
QPointer<QAction*> with QMap<int, QAction*> and a lambda to do cleanup
on deletion.
Test Plan:
Tweked the applet to update before showing
Original QMenu object used before showing still has all the items
Reviewers: Plasma
Subscribers: broulik, markg, plasma-devel
Tags: Plasma
Differential Revision: https://phabricator.kde.org/D4057