From 7ec9e05510a24811c945b765bb6c03e38dbd42f9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 27 Jan 2023 14:37:01 +0400 Subject: [PATCH] Allow appending TextWithEntnties by const-ref. --- ui/text/text_entity.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui/text/text_entity.h b/ui/text/text_entity.h index 3756539..07e281c 100644 --- a/ui/text/text_entity.h +++ b/ui/text/text_entity.h @@ -152,6 +152,16 @@ struct TextWithEntities { entities.append(other.entities); return *this; } + TextWithEntities &append(const TextWithEntities &other) { + const auto shift = text.size(); + text.append(other.text); + entities.reserve(entities.size() + other.entities.size()); + for (auto entity : other.entities) { + entity.shiftRight(shift); + entities.append(entity); + } + return *this; + } TextWithEntities &append(const QString &other) { text.append(other); return *this;