Messagelib

composerviewinterface.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "composerviewinterface.h"
8#include "composerviewbase.h"
9#include "snippet/convertsnippetvariablesutil.h"
10#include <KIO/Global>
11#include <MessageComposer/AttachmentModel>
12using namespace MessageComposer;
13ComposerViewInterface::ComposerViewInterface(ComposerViewBase *composerView)
14 : mComposerView(composerView)
15{
16}
17
18ComposerViewInterface::~ComposerViewInterface() = default;
19
20QString ComposerViewInterface::subject() const
21{
22 if (mComposerView) {
23 return mComposerView->subject();
24 }
25 return {};
26}
27
28QString ComposerViewInterface::to() const
29{
30 if (mComposerView) {
31 return mComposerView->to();
32 }
33 return {};
34}
35
36QString ComposerViewInterface::cc() const
37{
38 if (mComposerView) {
39 return mComposerView->cc();
40 }
41 return {};
42}
43
44QString ComposerViewInterface::bcc() const
45{
46 if (mComposerView) {
47 return mComposerView->bcc();
48 }
49 return {};
50}
51
52QString ComposerViewInterface::from() const
53{
54 if (mComposerView) {
55 return mComposerView->from();
56 }
57 return {};
58}
59
60QString ComposerViewInterface::replyTo() const
61{
62 if (mComposerView) {
63 return mComposerView->replyTo();
64 }
65 return {};
66}
67
68MessageComposer::ComposerAttachmentInterface ComposerViewInterface::attachments() const
69{
71 if (mComposerView) {
72 const int countElement = mComposerView->attachmentModel()->attachments().count();
73 attachmentInterface.setCount(countElement);
75 QStringList nameAndSize;
76 QStringList names;
77
78 fileNames.reserve(countElement);
79 nameAndSize.reserve(countElement);
80 names.reserve(countElement);
81 const auto attachments = mComposerView->attachmentModel()->attachments();
82 for (const MessageCore::AttachmentPart::Ptr &attachment : attachments) {
83 fileNames.append(attachment->fileName());
84 names.append(attachment->name());
85 nameAndSize.append(QStringLiteral("%1 (%2)").arg(attachment->name(), KIO::convertSize(attachment->size())));
86 }
87 attachmentInterface.setNames(names);
88 attachmentInterface.setNamesAndSize(nameAndSize);
89 attachmentInterface.setFileNames(fileNames);
90 }
91 return attachmentInterface;
92}
93
94QString ComposerViewInterface::shortDate() const
95{
96 return MessageComposer::ConvertSnippetVariablesUtil::shortDate();
97}
98
99QString ComposerViewInterface::longDate() const
100{
101 return MessageComposer::ConvertSnippetVariablesUtil::longDate();
102}
103
104QString ComposerViewInterface::shortTime() const
105{
106 return MessageComposer::ConvertSnippetVariablesUtil::shortTime();
107}
108
109QString ComposerViewInterface::longTime() const
110{
111 return MessageComposer::ConvertSnippetVariablesUtil::longTime();
112}
113
114QString ComposerViewInterface::insertDayOfWeek() const
115{
116 return MessageComposer::ConvertSnippetVariablesUtil::insertDayOfWeek();
117}
The ComposerViewBase class.
QString to() const
Header fields in recipients editor.
KIOCORE_EXPORT QString convertSize(KIO::filesize_t size)
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
KEDUVOCDOCUMENT_EXPORT QStringList fileNames(const QString &language=QString())
void append(QList< T > &&value)
qsizetype count() const const
void reserve(qsizetype size)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.