X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fcontextmenuactionprovider.h;h=5a1a18a74eed4c99bb8475966de6493c5b4bd7b2;hp=112d33177baa78d0c80cb3ffe6a6450c3c50fba1;hb=a95ad2de573027f9bee36db972bcae4195168d0c;hpb=9fc57dc2c000e80fb8bd746a090e2e8210e1278e diff --git a/src/uisupport/contextmenuactionprovider.h b/src/uisupport/contextmenuactionprovider.h index 112d3317..5a1a18a7 100644 --- a/src/uisupport/contextmenuactionprovider.h +++ b/src/uisupport/contextmenuactionprovider.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,18 +18,21 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef CONTEXTMENUACTIONPROVIDER_H -#define CONTEXTMENUACTIONPROVIDER_H +#pragma once + +#include "uisupport-export.h" + +#include #include "networkmodelcontroller.h" -class ContextMenuActionProvider : public NetworkModelController +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 /** @@ -40,40 +43,75 @@ 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); - void addActions(QMenu *, const QList &indexList, MessageFilter *filter, const QString &chanOrNick, - QObject *receiver, const char *slot, bool allowBufferHide); + 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 = {}); - Action *addAction(ActionType, QMenu *, bool condition = true); - Action *addAction(Action *, QMenu *, bool condition = true); - Action *addAction(ActionType, QMenu *, const QModelIndex &index, ItemActiveStates requiredActiveState = QFlags(ActiveState | InactiveState)); - Action *addAction(Action *, QMenu *, const QModelIndex &index, ItemActiveStates requiredActiveState = QFlags(ActiveState | InactiveState)); + 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 = {}); - void addHideEventsMenu(QMenu *, BufferId bufferId); - void addHideEventsMenu(QMenu *, MessageFilter *msgFilter); - void addHideEventsMenu(QMenu *, int filter = -1); - void addIgnoreMenu(QMenu *menu, const QString &hostmask, const QMap &ignoreMap); + 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 = {}); - void addNetworkItemActions(QMenu *, const QModelIndex &); - void addBufferItemActions(QMenu *, const QModelIndex &, bool isCustomBufferView = false); - void addIrcUserActions(QMenu *, const QModelIndex &); +private: + void addActions(QMenu* menu, + const QList& indexList, + MessageFilter* filter, + const QString& chanOrNick, + ActionSlot actionSlot, + bool isCustomBufferView); - Action *_hideEventsMenuAction; - Action *_nickCtcpMenuAction; - Action *_nickModeMenuAction; - Action *_nickIgnoreMenuAction; - QList _ignoreDescriptions; -}; + Action* addAction(ActionType, QMenu*, bool condition = true); + Action* addAction(Action*, QMenu*, bool condition = true); + Action* addAction(ActionType, + QMenu*, + const QModelIndex& index, + ItemActiveStates requiredActiveState = QFlags(ActiveState | InactiveState)); + Action* addAction(Action*, + QMenu*, + const QModelIndex& index, + ItemActiveStates requiredActiveState = QFlags(ActiveState | InactiveState)); + + void addHideEventsMenu(QMenu*, BufferId bufferId); + void addHideEventsMenu(QMenu*, MessageFilter* msgFilter); + void addHideEventsMenu(QMenu*, int filter = -1); + void addIgnoreMenu(QMenu* menu, const QString& hostmask, const QMap& ignoreMap); + void addNetworkItemActions(QMenu*, const QModelIndex&); + void addBufferItemActions(QMenu*, const QModelIndex&, bool isCustomBufferView = false); + void addIrcUserActions(QMenu*, const QModelIndex&); -#endif + Action* _hideEventsMenuAction; + Action* _nickCtcpMenuAction; + Action* _nickModeMenuAction; + Action* _nickIgnoreMenuAction; + QList _ignoreDescriptions; +};