File indexing completed on 2024-06-23 05:18:35
0001 /* 0002 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "messagecomposer_export.h" 0010 #include <PimCommon/CustomToolsViewInterface> 0011 #include <QDebug> 0012 0013 namespace KPIMTextEdit 0014 { 0015 class RichTextComposer; 0016 } 0017 namespace MessageComposer 0018 { 0019 class PluginEditorGrammarCustomToolsViewInterfacePrivate; 0020 /** 0021 * @brief The PluginGrammarAction class 0022 * @author Laurent Montel <montel@kde.org> 0023 */ 0024 class MESSAGECOMPOSER_EXPORT PluginGrammarAction 0025 { 0026 public: 0027 PluginGrammarAction(); 0028 0029 [[nodiscard]] QString replacement() const; 0030 void setReplacement(const QString &replacement); 0031 0032 [[nodiscard]] int start() const; 0033 void setStart(int start); 0034 0035 [[nodiscard]] int length() const; 0036 void setLength(int length); 0037 0038 [[nodiscard]] QStringList suggestions() const; 0039 void setSuggestions(const QStringList &suggestions); 0040 0041 [[nodiscard]] int blockId() const; 0042 void setBlockId(int blockId); 0043 0044 [[nodiscard]] QStringList infoUrls() const; 0045 void setInfoUrls(const QStringList &urls); 0046 0047 private: 0048 QStringList mSuggestions; 0049 QStringList mInfoUrls; 0050 QString mReplacement; 0051 int mStart = -1; 0052 int mLength = -1; 0053 int mBlockId = -1; 0054 }; 0055 0056 /** 0057 * @brief The PluginEditorGrammarCustomToolsViewInterface class 0058 * @author Laurent Montel <montel@kde.org> 0059 */ 0060 class MESSAGECOMPOSER_EXPORT PluginEditorGrammarCustomToolsViewInterface : public PimCommon::CustomToolsViewInterface 0061 { 0062 Q_OBJECT 0063 public: 0064 explicit PluginEditorGrammarCustomToolsViewInterface(QWidget *parent = nullptr); 0065 ~PluginEditorGrammarCustomToolsViewInterface() override; 0066 0067 void setParentWidget(QWidget *parent); 0068 [[nodiscard]] QWidget *parentWidget() const; 0069 0070 [[nodiscard]] KPIMTextEdit::RichTextComposer *richTextEditor() const; 0071 void setRichTextEditor(KPIMTextEdit::RichTextComposer *richTextEditor); 0072 0073 Q_SIGNALS: 0074 void replaceText(const MessageComposer::PluginGrammarAction &act); 0075 0076 private: 0077 std::unique_ptr<PluginEditorGrammarCustomToolsViewInterfacePrivate> const d; 0078 }; 0079 } 0080 Q_DECLARE_METATYPE(MessageComposer::PluginGrammarAction) 0081 MESSAGECOMPOSER_EXPORT QDebug operator<<(QDebug d, const MessageComposer::PluginGrammarAction &t);