1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
23 #include "uisupport-export.h"
25 #include "networkmodelcontroller.h"
27 class UISUPPORT_EXPORT ContextMenuActionProvider : public NetworkModelController
32 ContextMenuActionProvider(QObject *parent = nullptr);
33 virtual ~ContextMenuActionProvider();
35 //! Provide a list of actions applying to the given item
37 * Note that this list ist not persistent, hence it should only be used immediately after
38 * calling this function (e.g. in a context menu). Optionally one can provide a QObject and a slot
39 * (that should take a QAction * as parameter) that is invoked for actions that require external
41 * @param index The item index in the NetworkModel
42 * @param receiver The optional object that is notified for actions that need to be handled externally.
43 * The action type will be stored in the QAction's data().
44 * @param slot The receiving slot name; should be "mySlot" rather than SLOT(mySlot(QAction *))
45 * @return A list of actions applying to the given item
47 void addActions(QMenu *, const QModelIndex &index, QObject *receiver = nullptr, const char *slot = nullptr, bool allowBufferHide = false);
48 void addActions(QMenu *, const QList<QModelIndex> &indexList, QObject *receiver = nullptr, const char *slot = nullptr, bool allowBufferHide = false);
49 void addActions(QMenu *, BufferId id, QObject *receiver = nullptr, const char *slot = nullptr);
50 void addActions(QMenu *, MessageFilter *filter, BufferId msgBuffer, QObject *receiver = nullptr, const char *slot = nullptr);
51 void addActions(QMenu *, MessageFilter *filter, BufferId msgBuffer, const QString &chanOrNick, QObject *receiver = nullptr, const char *slot = nullptr);
55 void addActions(QMenu *, const QList<QModelIndex> &indexList, MessageFilter *filter, const QString &chanOrNick,
56 QObject *receiver, const char *slot, bool allowBufferHide);
58 Action *addAction(ActionType, QMenu *, bool condition = true);
59 Action *addAction(Action *, QMenu *, bool condition = true);
60 Action *addAction(ActionType, QMenu *, const QModelIndex &index, ItemActiveStates requiredActiveState = QFlags<ItemActiveState>(ActiveState | InactiveState));
61 Action *addAction(Action *, QMenu *, const QModelIndex &index, ItemActiveStates requiredActiveState = QFlags<ItemActiveState>(ActiveState | InactiveState));
63 void addHideEventsMenu(QMenu *, BufferId bufferId);
64 void addHideEventsMenu(QMenu *, MessageFilter *msgFilter);
65 void addHideEventsMenu(QMenu *, int filter = -1);
66 void addIgnoreMenu(QMenu *menu, const QString &hostmask, const QMap<QString, bool> &ignoreMap);
68 void addNetworkItemActions(QMenu *, const QModelIndex &);
69 void addBufferItemActions(QMenu *, const QModelIndex &, bool isCustomBufferView = false);
70 void addIrcUserActions(QMenu *, const QModelIndex &);
72 Action *_hideEventsMenuAction;
73 Action *_nickCtcpMenuAction;
74 Action *_nickModeMenuAction;
75 Action *_nickIgnoreMenuAction;
76 QList<QAction *> _ignoreDescriptions;