modernize: Use override instead of virtual
[quassel.git] / src / common / ctcpevent.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #pragma once
22
23 #include "common-export.h"
24
25 #include "ircevent.h"
26
27 #include <QUuid>
28
29 class COMMON_EXPORT CtcpEvent : public IrcEvent
30 {
31 public:
32     enum CtcpType {
33         Query,
34         Reply
35     };
36
37     explicit CtcpEvent(EventManager::EventType type, Network *network, const QString &prefix, const QString &target,
38         CtcpType ctcpType, const QString &ctcpCmd, const QString &param,
39         const QDateTime &timestamp = QDateTime(), const QUuid &uuid = QUuid())
40         : IrcEvent(type, network, prefix),
41         _ctcpType(ctcpType),
42         _ctcpCmd(ctcpCmd),
43         _target(target),
44         _param(param),
45         _uuid(uuid)
46     {
47         setTimestamp(timestamp);
48     }
49
50
51     inline CtcpType ctcpType() const { return _ctcpType; }
52     inline void setCtcpType(CtcpType type) { _ctcpType = type; }
53
54     inline QString ctcpCmd() const { return _ctcpCmd; }
55     inline void setCtcpCmd(const QString &ctcpCmd) { _ctcpCmd = ctcpCmd; }
56
57     inline QString target() const { return _target; }
58     inline void setTarget(const QString &target) { _target = target; }
59
60     inline QString param() const { return _param; }
61     inline void setParam(const QString &param) { _param = param; }
62
63     inline QString reply() const { return _reply; }
64     inline void setReply(const QString &reply) { _reply = reply; }
65
66     inline QUuid uuid() const { return _uuid; }
67     inline void setUuid(const QUuid &uuid) { _uuid = uuid; }
68
69     static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
70
71 protected:
72     explicit CtcpEvent(EventManager::EventType type, QVariantMap &map, Network *network);
73     void toVariantMap(QVariantMap &map) const override;
74
75     inline QString className() const override { return "CtcpEvent"; }
76     inline void debugInfo(QDebug &dbg) const override
77     {
78         NetworkEvent::debugInfo(dbg);
79         dbg << ", prefix = " << qPrintable(prefix())
80             << ", target = " << qPrintable(target())
81             << ", ctcptype = " << (ctcpType() == Query ? "query" : "reply")
82             << ", cmd = " << qPrintable(ctcpCmd())
83             << ", param = " << qPrintable(param())
84             << ", reply = " << qPrintable(reply());
85     }
86
87
88 private:
89     CtcpType _ctcpType;
90     QString _ctcpCmd;
91     QString _target, _param, _reply;
92     QUuid _uuid;
93 };