X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fcontextmenuactionprovider.h;h=7d639fec9dc81d4c9fc4c6bba418c3e6b059a2b8;hp=a9c76bf04fdbfa4f4995b89c6968ffe12a21f4c3;hb=8f2ee00f4edef1693628d3af0bdee84d725eb754;hpb=92fc8c5b119111a35ab8423c3cbde5b2a022badf diff --git a/src/uisupport/contextmenuactionprovider.h b/src/uisupport/contextmenuactionprovider.h index a9c76bf0..7d639fec 100644 --- a/src/uisupport/contextmenuactionprovider.h +++ b/src/uisupport/contextmenuactionprovider.h @@ -22,6 +22,8 @@ #include "uisupport-export.h" +#include + #include "networkmodelcontroller.h" class UISUPPORT_EXPORT ContextMenuActionProvider : public NetworkModelController @@ -29,8 +31,8 @@ class UISUPPORT_EXPORT ContextMenuActionProvider : public NetworkModelController Q_OBJECT public: - ContextMenuActionProvider(QObject *parent = 0); - virtual ~ContextMenuActionProvider(); + ContextMenuActionProvider(QObject *parent = nullptr); + ~ContextMenuActionProvider() override; //! Provide a list of actions applying to the given item /** @@ -41,19 +43,46 @@ public: * @param index The item index in the NetworkModel * @param receiver The optional object that is notified for actions that need to be handled externally. * The action type will be stored in the QAction's data(). - * @param slot The receiving slot name; should be "mySlot" rather than SLOT(mySlot(QAction *)) + * @param slot The receiving slot * @return A list of actions applying to the given item */ - void addActions(QMenu *, const QModelIndex &index, QObject *receiver = 0, const char *slot = 0, bool allowBufferHide = false); - void addActions(QMenu *, const QList &indexList, QObject *receiver = 0, const char *slot = 0, bool allowBufferHide = false); - void addActions(QMenu *, BufferId id, QObject *receiver = 0, const char *slot = 0); - void addActions(QMenu *, MessageFilter *filter, BufferId msgBuffer, QObject *receiver = 0, const char *slot = 0); - void addActions(QMenu *, MessageFilter *filter, BufferId msgBuffer, const QString &chanOrNick, QObject *receiver = 0, const char *slot = 0); + template + void addActions(QMenu *menu, const QModelIndex &index, Receiver *receiver, Slot slot, bool isCustomBufferView = false) + { + addActions(menu, index, buildActionSlot(receiver, std::move(slot)), isCustomBufferView); + } + void addActions(QMenu *menu, const QModelIndex &index, ActionSlot = {}, bool isCustomBufferView = false); -private: + template + void addActions(QMenu *menu, const QList &indexList, Receiver *receiver, Slot slot, bool isCustomBufferView = false) + { + addActions(menu, indexList, buildActionSlot(receiver, std::move(slot)), isCustomBufferView); + } + void addActions(QMenu *menu, const QList &indexList, ActionSlot = {}, bool isCustomBufferView = false); + + template + void addActions(QMenu *menu, BufferId id, Receiver *receiver, Slot slot) + { + addActions(menu, id, buildActionSlot(receiver, std::move(slot))); + } + void addActions(QMenu *menu, BufferId id, ActionSlot = {}); - void addActions(QMenu *, const QList &indexList, MessageFilter *filter, const QString &chanOrNick, - QObject *receiver, const char *slot, bool allowBufferHide); + template + void addActions(QMenu *menu, MessageFilter *filter, BufferId msgBuffer, Receiver *receiver, Slot slot) + { + addActions(menu, filter, msgBuffer, buildActionSlot(receiver, std::move(slot))); + } + void addActions(QMenu *menu, MessageFilter *filter, BufferId msgBuffer, ActionSlot = {}); + + template + void addActions(QMenu *menu, MessageFilter *filter, BufferId msgBuffer, const QString &chanOrNick, Receiver *receiver, Slot slot) + { + addActions(menu, filter, msgBuffer, chanOrNick, buildActionSlot(receiver, std::move(slot))); + } + void addActions(QMenu *menu, MessageFilter *filter, BufferId msgBuffer, const QString &chanOrNick, ActionSlot = {}); + +private: + void addActions(QMenu *menu, const QList &indexList, MessageFilter *filter, const QString &chanOrNick, ActionSlot actionSlot, bool isCustomBufferView); Action *addAction(ActionType, QMenu *, bool condition = true); Action *addAction(Action *, QMenu *, bool condition = true);