From 5038ae0a0099c2a5c6ffdd08734b597d92edac70 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 May 2017 20:02:34 +0900 Subject: Code cleanup and tweaking (partially driven by clang-tidy) Mainly it's about const-ification (in particular, passing const-refs instead of values) and deleting unneeded declarations/#includes. Since the changes alter the external interface, this is submitted as a PR for peer review. One of unneeded declarations/definitions is a virtual destructor in BaseJob descendants. Since a job object should be deleted through QObject::deleteLater() anyway (and it's the only correct way of disposing of the object), all deletions will call the stack of destructors through virtual QObject::~QObject(). Therefore even BaseJob could get on with a non-virtual destructor but for the sake of clarity BaseJob::~BaseJob() is still declared virtual. --- events/receiptevent.h | 2 -- events/roommemberevent.h | 5 ++--- events/roommessageevent.h | 4 ++-- events/roomnameevent.cpp | 4 ++-- events/roomnameevent.h | 24 +++++++++++------------- events/roomtopicevent.h | 2 -- events/typingevent.h | 4 ++-- 7 files changed, 19 insertions(+), 26 deletions(-) (limited to 'events') diff --git a/events/receiptevent.h b/events/receiptevent.h index a7e1debf..40c0384f 100644 --- a/events/receiptevent.h +++ b/events/receiptevent.h @@ -20,8 +20,6 @@ #include "event.h" -#include - namespace QMatrixClient { class Receipt diff --git a/events/roommemberevent.h b/events/roommemberevent.h index f37cdc04..a33c2982 100644 --- a/events/roommemberevent.h +++ b/events/roommemberevent.h @@ -18,11 +18,10 @@ #pragma once -#include -#include - #include "event.h" +#include + namespace QMatrixClient { enum class MembershipType {Invite, Join, Knock, Leave, Ban}; diff --git a/events/roommessageevent.h b/events/roommessageevent.h index 67789ef7..5d5336aa 100644 --- a/events/roommessageevent.h +++ b/events/roommessageevent.h @@ -18,12 +18,12 @@ #pragma once +#include "event.h" + #include #include #include -#include "event.h" - namespace QMatrixClient { enum class MessageEventType diff --git a/events/roomnameevent.cpp b/events/roomnameevent.cpp index c5bcf011..c94cb2c3 100644 --- a/events/roomnameevent.cpp +++ b/events/roomnameevent.cpp @@ -22,8 +22,8 @@ using namespace QMatrixClient; class RoomNameEvent::Private { -public: - QString name; + public: + QString name; }; RoomNameEvent::RoomNameEvent() : diff --git a/events/roomnameevent.h b/events/roomnameevent.h index 0997ad9c..8748c4be 100644 --- a/events/roomnameevent.h +++ b/events/roomnameevent.h @@ -22,20 +22,18 @@ namespace QMatrixClient { + class RoomNameEvent : public Event + { + public: + RoomNameEvent(); + virtual ~RoomNameEvent(); -class RoomNameEvent : public Event -{ -public: - RoomNameEvent(); - virtual ~RoomNameEvent(); - - QString name() const; - - static RoomNameEvent* fromJson(const QJsonObject& obj); + QString name() const; -private: - class Private; - Private *d; -}; + static RoomNameEvent* fromJson(const QJsonObject& obj); + private: + class Private; + Private *d; + }; } diff --git a/events/roomtopicevent.h b/events/roomtopicevent.h index d4347953..4b0a24b0 100644 --- a/events/roomtopicevent.h +++ b/events/roomtopicevent.h @@ -18,8 +18,6 @@ #pragma once -#include - #include "event.h" namespace QMatrixClient diff --git a/events/typingevent.h b/events/typingevent.h index 5a8b045c..da57a389 100644 --- a/events/typingevent.h +++ b/events/typingevent.h @@ -18,10 +18,10 @@ #pragma once -#include - #include "event.h" +#include + namespace QMatrixClient { class TypingEvent: public Event -- cgit v1.2.3 From 63db311d5a64b9942dc69e1b13b4570a548554c0 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 13 May 2017 15:10:07 +0900 Subject: Refactored logging enhancements logging.h/logging.cpp is now a full-fledged pair for all things logging. Two more categories added, EPHEMERAL and SYNCJOB, that control logging for ephemeral events and SyncJob, respectively (in particular, switching off EPHEMERAL greatly reduces the logspam about moving read markers and how many users have read up to which event). --- events/event.cpp | 5 ++--- events/receiptevent.cpp | 8 ++++---- events/roomaliasesevent.cpp | 4 ++-- events/roommemberevent.cpp | 3 +-- events/roommessageevent.cpp | 3 ++- events/typingevent.cpp | 6 +++--- events/unknownevent.cpp | 5 ++--- 7 files changed, 16 insertions(+), 18 deletions(-) (limited to 'events') diff --git a/events/event.cpp b/events/event.cpp index b3f75ca9..07649b02 100644 --- a/events/event.cpp +++ b/events/event.cpp @@ -20,10 +20,7 @@ #include #include -#include -#include -#include "util.h" #include "roommessageevent.h" #include "roomnameevent.h" #include "roomaliasesevent.h" @@ -33,6 +30,8 @@ #include "typingevent.h" #include "receiptevent.h" #include "unknownevent.h" +#include "logging.h" +#include "util.h" using namespace QMatrixClient; diff --git a/events/receiptevent.cpp b/events/receiptevent.cpp index 5d11a0dd..c163424f 100644 --- a/events/receiptevent.cpp +++ b/events/receiptevent.cpp @@ -34,10 +34,10 @@ Example of a Receipt Event: */ #include "receiptevent.h" -#include "util.h" + +#include "logging.h" #include -#include using namespace QMatrixClient; @@ -73,8 +73,8 @@ ReceiptEvent* ReceiptEvent::fromJson(const QJsonObject& obj) { if (eventIt.key().isEmpty()) { - qCWarning(EVENTS) << "ReceiptEvent has an empty event id, skipping"; - qCDebug(EVENTS) << "ReceiptEvent content follows:\n" << contents; + qCWarning(EPHEMERAL) << "ReceiptEvent has an empty event id, skipping"; + qCDebug(EPHEMERAL) << "ReceiptEvent content follows:\n" << contents; continue; } const QJsonObject reads = eventIt.value().toObject().value("m.read").toObject(); diff --git a/events/roomaliasesevent.cpp b/events/roomaliasesevent.cpp index e0dbdb38..ab414498 100644 --- a/events/roomaliasesevent.cpp +++ b/events/roomaliasesevent.cpp @@ -33,10 +33,10 @@ // } #include "roomaliasesevent.h" -#include "util.h" + +#include "logging.h" #include -#include using namespace QMatrixClient; diff --git a/events/roommemberevent.cpp b/events/roommemberevent.cpp index 0dafd303..51dbbbab 100644 --- a/events/roommemberevent.cpp +++ b/events/roommemberevent.cpp @@ -17,9 +17,8 @@ */ #include "roommemberevent.h" -#include "util.h" -#include +#include "logging.h" using namespace QMatrixClient; diff --git a/events/roommessageevent.cpp b/events/roommessageevent.cpp index fd6de464..677bb79f 100644 --- a/events/roommessageevent.cpp +++ b/events/roommessageevent.cpp @@ -17,10 +17,11 @@ */ #include "roommessageevent.h" + +#include "logging.h" #include "util.h" #include -#include using namespace QMatrixClient; diff --git a/events/typingevent.cpp b/events/typingevent.cpp index 11c3a565..009059af 100644 --- a/events/typingevent.cpp +++ b/events/typingevent.cpp @@ -17,10 +17,10 @@ */ #include "typingevent.h" -#include "util.h" + +#include "logging.h" #include -#include using namespace QMatrixClient; @@ -55,6 +55,6 @@ TypingEvent* TypingEvent::fromJson(const QJsonObject& obj) { e->d->users << user.toString(); } - qCDebug(EVENTS) << "Typing:" << e->d->users; + qCDebug(EPHEMERAL) << "Typing:" << e->d->users; return e; } diff --git a/events/unknownevent.cpp b/events/unknownevent.cpp index b2947bf7..1670ff1d 100644 --- a/events/unknownevent.cpp +++ b/events/unknownevent.cpp @@ -18,10 +18,9 @@ #include "unknownevent.h" -#include -#include +#include "logging.h" -#include "util.h" +#include using namespace QMatrixClient; -- cgit v1.2.3