File indexing completed on 2024-06-23 05:18:38
0001 /* 0002 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "messagecomposer_export.h" 0010 #include <QObject> 0011 namespace MessageComposer 0012 { 0013 class ComposerViewInterface; 0014 /** 0015 * @brief The ConvertSnippetVariablesJob class 0016 * @author Laurent Montel <montel@kde.org> 0017 */ 0018 class MESSAGECOMPOSER_EXPORT ConvertSnippetVariablesJob : public QObject 0019 { 0020 Q_OBJECT 0021 public: 0022 explicit ConvertSnippetVariablesJob(QObject *parent = nullptr); 0023 ~ConvertSnippetVariablesJob() override; 0024 void start(); 0025 0026 void setText(const QString &str); 0027 [[nodiscard]] QString text() const; 0028 0029 MessageComposer::ComposerViewInterface *composerViewInterface() const; 0030 void setComposerViewInterface(MessageComposer::ComposerViewInterface *composerViewInterface); 0031 [[nodiscard]] static QString convertVariables(MessageComposer::ComposerViewInterface *composerView, const QString &text); 0032 0033 [[nodiscard]] bool canStart() const; 0034 Q_SIGNALS: 0035 void textConverted(const QString &str); 0036 0037 private: 0038 [[nodiscard]] static QString convertVariables(const QString &cmd, int &i, QChar c); 0039 [[nodiscard]] static QString getFirstNameFromEmail(const QString &address); 0040 [[nodiscard]] static QString getLastNameFromEmail(const QString &address); 0041 [[nodiscard]] static QString getNameFromEmail(const QString &address); 0042 QString mText; 0043 MessageComposer::ComposerViewInterface *mComposerViewInterface = nullptr; 0044 }; 0045 }