X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fnetworkmodelcontroller.h;h=1d691f7097fd36c52696de1ba975ce41365a808f;hp=3f1b29fc2b7be9bdff24bd201bef43fd21ebff27;hb=2c8434f74c68194d56f2084f637419123e61d18b;hpb=1cb02004ee5973b89368bd84f234d4652794690d diff --git a/src/uisupport/networkmodelcontroller.h b/src/uisupport/networkmodelcontroller.h index 3f1b29fc..1d691f70 100644 --- a/src/uisupport/networkmodelcontroller.h +++ b/src/uisupport/networkmodelcontroller.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,8 +18,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef NETWORKMODELCONTROLLER_H_ -#define NETWORKMODELCONTROLLER_H_ +#pragma once + +#include "uisupport-export.h" + +#include +#include #include @@ -31,13 +35,12 @@ class QComboBox; class QDialogButtonBox; class QLineEdit; -class NetworkModelController : public QObject +class UISUPPORT_EXPORT NetworkModelController : public QObject { Q_OBJECT public: - NetworkModelController(QObject *parent = 0); - virtual ~NetworkModelController(); + NetworkModelController(QObject *parent = nullptr); // don't change enums without doublechecking masks etc. in code enum ActionType { @@ -45,8 +48,10 @@ public: NetworkMask = 0x0f, NetworkConnect = 0x01, NetworkDisconnect = 0x02, - NetworkConnectAll = 0x03, - NetworkDisconnectAll = 0x04, + NetworkConnectAllWithDropdown = 0x03, + NetworkDisconnectAllWithDropdown = 0x04, + NetworkConnectAll = 0x05, + NetworkDisconnectAll = 0x06, // Buffer actions BufferMask = 0xf0, @@ -64,6 +69,7 @@ public: HideMode = 0x0500, HideDayChange = 0x0600, HideTopic = 0x0700, + HideJoinPartQuit = 0xd00, HideUseDefaults = 0xe00, HideApplyToAll = 0xf00, @@ -72,6 +78,7 @@ public: JoinChannel = 0x1000, ShowChannelList = 0x2000, ShowIgnoreList = 0x3000, + ShowNetworkConfig = 0x4000, // Nick actions NickMask = 0xff0000, @@ -128,14 +135,24 @@ protected: inline QList indexList() const; inline MessageFilter *messageFilter() const; inline QString contextItem() const; ///< Channel name or nick to provide context menu for - inline QObject *receiver() const; - inline const char *method() const; void setIndexList(const QModelIndex &); void setIndexList(const QList &); void setMessageFilter(MessageFilter *); void setContextItem(const QString &); - void setSlot(QObject *receiver, const char *method); + + using ActionSlot = std::function; + + template + ActionSlot buildActionSlot(Receiver *receiver, Slot slot) + { + static_assert(!std::is_same::value, "Old-style slots not supported"); + return [receiver, slot = std::move(slot)](QAction *action) { + (receiver->*slot)(action); + }; + } + + void setSlot(ActionSlot slot); Action *registerAction(ActionType type, const QString &text, bool checkable = false); Action *registerAction(NetworkModelController::ActionType type, const QIcon &icon, const QString &text, bool checkable = false); @@ -150,7 +167,17 @@ protected slots: virtual void actionTriggered(QAction *); signals: - void showChannelList(NetworkId); + /** + * Request to show the channel list dialog for the network, optionally searching by channel name + * + * @see MainWin::showChannelList() + * + * @param networkId Network ID for associated network + * @param channelFilters Partial channel name to search for, or empty to show all + * @param listImmediately If true, immediately list channels, otherwise just show dialog + */ + void showChannelList(NetworkId, const QString &, bool); + void showNetworkConfig(NetworkId); void showIgnoreList(QString); protected: @@ -170,10 +197,9 @@ private: QHash _actionByType; QList _indexList; - MessageFilter *_messageFilter; + MessageFilter *_messageFilter{nullptr}; QString _contextItem; ///< Channel name or nick to provide context menu for - QObject *_receiver; - const char *_method; + ActionSlot _actionSlot; }; @@ -183,7 +209,7 @@ class NetworkModelController::JoinDlg : public QDialog Q_OBJECT public: - JoinDlg(const QModelIndex &index, QWidget *parent = 0); + JoinDlg(const QModelIndex &index, QWidget *parent = nullptr); QString channelName() const; QString channelPassword() const; @@ -206,7 +232,3 @@ Action *NetworkModelController::action(ActionType type) const { return _actionBy QList NetworkModelController::indexList() const { return _indexList; } MessageFilter *NetworkModelController::messageFilter() const { return _messageFilter; } QString NetworkModelController::contextItem() const { return _contextItem; } -QObject *NetworkModelController::receiver() const { return _receiver; } -const char *NetworkModelController::method() const { return _method; } - -#endif