From a4e9794b13c69ac82b9f3a0f7c286fc10edf504c Mon Sep 17 00:00:00 2001 From: James Graham Date: Sat, 5 Oct 2024 15:51:19 +0000 Subject: [PATCH] MessageComponent It feels weird to have anything that needs MessageComponent have to depend on all of MessageContentModel and pull in it's dependencies. This moves MessageComponent into its own header. --- autotests/texthandlertest.cpp | 2 -- src/CMakeLists.txt | 1 + src/messagecomponent.h | 22 ++++++++++++++++++++++ src/models/messagecontentmodel.h | 17 +---------------- src/texthandler.cpp | 1 - src/texthandler.h | 2 +- 6 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 src/messagecomponent.h diff --git a/autotests/texthandlertest.cpp b/autotests/texthandlertest.cpp index 9c0fe26da..dbe0ee98b 100644 --- a/autotests/texthandlertest.cpp +++ b/autotests/texthandlertest.cpp @@ -12,9 +12,7 @@ #include "enums/messagecomponenttype.h" #include "models/customemojimodel.h" -#include "models/messagecontentmodel.h" #include "neochatconnection.h" -#include "utils.h" #include "testutils.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bf17a841b..354b8202e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,6 +195,7 @@ add_library(neochat STATIC models/threadmodel.cpp models/threadmodel.h enums/messagetype.h + messagecomponent.h ) set_source_files_properties(qml/OsmLocationPlugin.qml PROPERTIES diff --git a/src/messagecomponent.h b/src/messagecomponent.h new file mode 100644 index 000000000..463a22bf4 --- /dev/null +++ b/src/messagecomponent.h @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2024 James Graham +// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL + +#pragma once + +#include "enums/messagecomponenttype.h" + +struct MessageComponent { + MessageComponentType::Type type = MessageComponentType::Other; + QString content; + QVariantMap attributes; + + int operator==(const MessageComponent &right) const + { + return type == right.type && content == right.content && attributes == right.attributes; + } + + bool isEmpty() const + { + return type == MessageComponentType::Other; + } +}; diff --git a/src/models/messagecontentmodel.h b/src/models/messagecontentmodel.h index 6c005e63d..d07e7e79e 100644 --- a/src/models/messagecontentmodel.h +++ b/src/models/messagecontentmodel.h @@ -11,24 +11,9 @@ #include "enums/messagecomponenttype.h" #include "itinerarymodel.h" +#include "messagecomponent.h" #include "neochatroommember.h" -struct MessageComponent { - MessageComponentType::Type type = MessageComponentType::Other; - QString content; - QVariantMap attributes; - - int operator==(const MessageComponent &right) const - { - return type == right.type && content == right.content && attributes == right.attributes; - } - - bool isEmpty() const - { - return type == MessageComponentType::Other; - } -}; - /** * @class MessageContentModel * diff --git a/src/texthandler.cpp b/src/texthandler.cpp index 3c45545a9..4fc6004d1 100644 --- a/src/texthandler.cpp +++ b/src/texthandler.cpp @@ -17,7 +17,6 @@ #include #include "messagecomponenttype.h" -#include "messagecontentmodel.h" #include "models/customemojimodel.h" #include "utils.h" diff --git a/src/texthandler.h b/src/texthandler.h index ae392110f..a4329044f 100644 --- a/src/texthandler.h +++ b/src/texthandler.h @@ -6,7 +6,7 @@ #include #include -#include "models/messagecontentmodel.h" +#include "messagecomponent.h" #include "neochatroom.h" namespace Quotient