modernize: Prefer default member init over ctor init
[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 #include <utility>
29
30 class COMMON_EXPORT CtcpEvent : public IrcEvent
31 {
32 public:
33     enum CtcpType {
34         Query,
35         Reply
36     };
37
38     explicit CtcpEvent(EventManager::EventType type, Network *network, const QString &prefix, QString target,
39         CtcpType ctcpType, QString ctcpCmd, QString param,
40         const QDateTime &timestamp = QDateTime(), const QUuid &uuid = QUuid())
41         : IrcEvent(type, network, prefix),
42         _ctcpType(ctcpType),
43         _ctcpCmd(std::move(ctcpCmd)),
44         _target(std::move(target)),
45         _param(std::move(param)),
46         _uuid(uuid)
47     {
48         setTimestamp(timestamp);
49     }
50
51
52     inline CtcpType ctcpType() const { return _ctcpType; }
53     inline void setCtcpType(CtcpType type) { _ctcpType = type; }
54
55     inline QString ctcpCmd() const { return _ctcpCmd; }
56     inline void setCtcpCmd(const QString &ctcpCmd) { _ctcpCmd = ctcpCmd; }
57
58     inline QString target() const { return _target; }
59     inline void setTarget(const QString &target) { _target = target; }
60
61     inline QString param() const { return _param; }
62     inline void setParam(const QString &param) { _param = param; }
63
64     inline QString reply() const { return _reply; }
65     inline void setReply(const QString &reply) { _reply = reply; }
66
67     inline QUuid uuid() const { return _uuid; }
68     inline void setUuid(const QUuid &uuid) { _uuid = uuid; }
69
70     static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
71
72 protected:
73     explicit CtcpEvent(EventManager::EventType type, QVariantMap &map, Network *network);
74     void toVariantMap(QVariantMap &map) const override;
75
76     inline QString className() const override { return "CtcpEvent"; }
77     inline void debugInfo(QDebug &dbg) const override
78     {
79         NetworkEvent::debugInfo(dbg);
80         dbg << ", prefix = " << qPrintable(prefix())
81             << ", target = " << qPrintable(target())
82             << ", ctcptype = " << (ctcpType() == Query ? "query" : "reply")
83             << ", cmd = " << qPrintable(ctcpCmd())
84             << ", param = " << qPrintable(param())
85             << ", reply = " << qPrintable(reply());
86     }
87
88
89 private:
90     CtcpType _ctcpType;
91     QString _ctcpCmd;
92     QString _target, _param, _reply;
93     QUuid _uuid;
94 };