diff --git a/src/composer-ng/klinkdialog_p.h b/src/composer-ng/klinkdialog_p.h index 12cda88..b6bb790 100644 --- a/src/composer-ng/klinkdialog_p.h +++ b/src/composer-ng/klinkdialog_p.h @@ -1,95 +1,95 @@ /** * klinkdialog * * Copyright 2008 Stephen Kelly * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ #ifndef KLINKDIALOG_H #define KLINKDIALOG_H //@cond PRIVATE #include class QDialogButtonBox; class QLabel; class QLineEdit; namespace KPIMTextEdit { /** @short Dialog to allow user to configure a hyperlink. @author Stephen Kelly @since 4.1 @internal This class provides a dialog to ask the user for a link target url and text. The size of the dialog is automatically saved to and restored from the global KDE config file. */ class KLinkDialog : public QDialog { Q_OBJECT public: /** * Create a link dialog. * @param parent Parent widget. */ explicit KLinkDialog(QWidget *parent = nullptr); /** * Destructor */ ~KLinkDialog(); /** * Returns the link text shown in the dialog * @param linkText The initial text */ void setLinkText(const QString &linkText); /** * Sets the target link url shown in the dialog * @param linkUrl The initial link target url */ void setLinkUrl(const QString &linkUrl); /** * Returns the link text entered by the user. * @return The link text */ - QString linkText() const; + Q_REQUIRED_RESULT QString linkText() const; /** * Returns the target link url entered by the user. * @return The link url */ - QString linkUrl() const; + Q_REQUIRED_RESULT QString linkUrl() const; private: void slotTextChanged(const QString &); QLabel *textLabel = nullptr; QLineEdit *textLineEdit = nullptr; QLabel *linkUrlLabel = nullptr; QLineEdit *linkUrlLineEdit = nullptr; QDialogButtonBox *buttonBox = nullptr; }; } //@endcond #endif diff --git a/src/composer-ng/richtextcomposer.h b/src/composer-ng/richtextcomposer.h index d299a16..41f1b9e 100644 --- a/src/composer-ng/richtextcomposer.h +++ b/src/composer-ng/richtextcomposer.h @@ -1,155 +1,155 @@ /* Copyright (C) 2015-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPIMTEXTEDITRICHTEXTCOMPOSER_H #define KPIMTEXTEDITRICHTEXTCOMPOSER_H #include "kpimtextedit_export.h" #include class KActionCollection; namespace KPIMTextEdit { class RichTextComposerControler; class RichTextComposerActions; class RichTextExternalComposer; class RichTextComposerEmailQuoteHighlighter; /** * @brief The RichTextComposer class * @author Laurent Montel */ class KPIMTEXTEDIT_EXPORT RichTextComposer : public KPIMTextEdit::RichTextEditor { Q_OBJECT public: explicit RichTextComposer(QWidget *parent = nullptr); ~RichTextComposer() override; enum Mode { Plain, ///< Plain text mode Rich ///< Rich text mode }; /** * @return The current text mode */ Q_REQUIRED_RESULT Mode textMode() const; /** * Enables word wrap. Words will be wrapped at the specified column. * * @param wrapColumn the column where words will be wrapped */ void enableWordWrap(int wrapColumn); /** * Disables word wrap. * Note that words are still wrapped at the end of the editor; no scrollbar * will appear. */ void disableWordWrap(); /** * @return the line number where the cursor is. This takes word-wrapping * into account. Line numbers start at 0. */ Q_REQUIRED_RESULT int linePosition() const; /** * @return the column number where the cursor is. */ Q_REQUIRED_RESULT int columnNumber() const; void forcePlainTextMarkup(bool force); void activateRichText(); void switchToPlainText(); void setTextOrHtml(const QString &text); Q_REQUIRED_RESULT QString textOrHtml() const; virtual void setHighlighterColors(KPIMTextEdit::RichTextComposerEmailQuoteHighlighter *highlighter); void setUseExternalEditor(bool use); void setExternalEditorPath(const QString &path); Q_REQUIRED_RESULT bool checkExternalEditorFinished(); void killExternalEditor(); //Redefine it for each apps virtual QString smartQuote(const QString &msg); //need by kmail void setQuotePrefixName(const QString "ePrefix); Q_REQUIRED_RESULT QString quotePrefixName() const; void setCursorPositionFromStart(unsigned int pos); Q_REQUIRED_RESULT int quoteLength(const QString &line, bool oneQuote = false) const; Q_REQUIRED_RESULT bool isLineQuoted(const QString &line) const; const QString defaultQuoteSign() const; void createActions(KActionCollection *ac); - QVector richTextActionList() const; + Q_REQUIRED_RESULT QVector richTextActionList() const; void setEnableActions(bool state); KPIMTextEdit::RichTextComposerControler *composerControler() const; KPIMTextEdit::RichTextExternalComposer *externalComposer() const; KPIMTextEdit::RichTextComposerActions *composerActions() const; void createHighlighter() override; virtual bool processModifyText(QKeyEvent *event); public Q_SLOTS: void insertPlainTextImplementation(); void slotChangeInsertMode(); Q_SIGNALS: void insertModeChanged(); /** * Emitted whenever the text mode is changed. * * @param mode The new text mode */ void textModeChanged(KPIMTextEdit::RichTextComposer::Mode mode); /** * Emitted when the user uses the up arrow in the first line. The application * should then put the focus on the widget above the text edit. */ void focusUp(); void externalEditorStarted(); void externalEditorClosed(); void insertEmoticon(const QString &str); protected: void keyPressEvent(QKeyEvent *event) override; Sonnet::SpellCheckDecorator *createSpellCheckDecorator() override; void insertFromMimeData(const QMimeData *source) override; bool canInsertFromMimeData(const QMimeData *source) const override; void mouseReleaseEvent(QMouseEvent *event) override; void clearDecorator() override; void updateHighLighter() override; bool processKeyEvent(QKeyEvent *e); private: void slotTextModeChanged(KPIMTextEdit::RichTextComposer::Mode mode); void evaluateListSupport(QKeyEvent *event); void evaluateReturnKeySupport(QKeyEvent *event); class RichTextComposerPrivate; RichTextComposerPrivate *const d; }; } #endif // RICHTEXTCOMPOSER_H diff --git a/src/composer-ng/richtextcomposercontroler.h b/src/composer-ng/richtextcomposercontroler.h index 650a509..2c8fb51 100644 --- a/src/composer-ng/richtextcomposercontroler.h +++ b/src/composer-ng/richtextcomposercontroler.h @@ -1,114 +1,114 @@ /* Copyright (C) 2015-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPIMTEXTEDITRICHTEXTCOMPOSERCONTROLER_H #define KPIMTEXTEDITRICHTEXTCOMPOSERCONTROLER_H #include #include "richtextcomposer.h" #include "kpimtextedit_export.h" namespace KPIMTextEdit { class RichTextComposer; class NestedListHelper; class RichTextComposerImages; /** * @brief The RichTextComposerControler class * @author Laurent Montel */ class KPIMTEXTEDIT_EXPORT RichTextComposerControler : public QObject { Q_OBJECT public: explicit RichTextComposerControler(RichTextComposer *richtextComposer, QObject *parent = nullptr); ~RichTextComposerControler(); Q_REQUIRED_RESULT RichTextComposer *richTextComposer() const; Q_REQUIRED_RESULT QString currentLinkUrl() const; Q_REQUIRED_RESULT QString currentLinkText() const; void selectLinkText() const; Q_REQUIRED_RESULT QString toCleanHtml() const; Q_REQUIRED_RESULT bool canIndentList() const; Q_REQUIRED_RESULT bool canDedentList() const; Q_REQUIRED_RESULT NestedListHelper *nestedListHelper() const; void insertLink(const QString &url); void setCursorPositionFromStart(unsigned int pos); void ensureCursorVisible(); RichTextComposerImages *composerImages() const; Q_REQUIRED_RESULT bool painterActive() const; void disablePainter(); - bool isFormattingUsed() const; + Q_REQUIRED_RESULT bool isFormattingUsed() const; void setFontForWholeText(const QFont &font); void textModeChanged(KPIMTextEdit::RichTextComposer::Mode mode); void updateLink(const QString &linkUrl, const QString &linkText); Q_REQUIRED_RESULT QString toWrappedPlainText(QTextDocument *doc) const; Q_REQUIRED_RESULT QString toWrappedPlainText() const; Q_REQUIRED_RESULT QString toCleanPlainText(const QString &plainText = QString()) const; void addQuotes(const QString &defaultQuote); public Q_SLOTS: #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) void addCheckbox(bool add = true); #endif void insertHorizontalRule(); void setHeadingLevel(int level); void alignLeft(); void alignCenter(); void alignRight(); void alignJustify(); void makeRightToLeft(); void makeLeftToRight(); void setTextBold(bool bold); void setTextItalic(bool italic); void setTextUnderline(bool underline); void setTextStrikeOut(bool strikeOut); void setTextForegroundColor(const QColor &color); void setTextBackgroundColor(const QColor &color); void setFontFamily(const QString &fontFamily); void setFontSize(int size); void setFont(const QFont &font); void setTextSuperScript(bool superscript); void setTextSubScript(bool subscript); void setChangeTextForegroundColor(); void setChangeTextBackgroundColor(); void manageLink(); void indentListMore(); void indentListLess(); void setListStyle(int styleIndex); void slotAddEmoticon(const QString &text); void slotInsertHtml(); void slotFormatReset(); void slotDeleteLine(); void slotPasteWithoutFormatting(); void slotPasteAsQuotation(); void slotRemoveQuotes(); void slotAddQuotes(); void slotAddImage(); void slotFormatPainter(bool active); void ensureCursorVisibleDelayed(); private: class RichTextComposerControlerPrivate; RichTextComposerControlerPrivate *const d; }; } #endif // RICHTEXTCOMPOSERCONTROLER_H diff --git a/src/composer-ng/richtextcomposeremailquotedecorator.h b/src/composer-ng/richtextcomposeremailquotedecorator.h index 96d344a..33de7cb 100644 --- a/src/composer-ng/richtextcomposeremailquotedecorator.h +++ b/src/composer-ng/richtextcomposeremailquotedecorator.h @@ -1,47 +1,47 @@ /* Copyright (C) 2015-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPIMTEXTEDITRICHTEXTCOMPOSEREMAILQUOTEDECORATOR_H #define KPIMTEXTEDITRICHTEXTCOMPOSEREMAILQUOTEDECORATOR_H #include #include "kpimtextedit_export.h" namespace KPIMTextEdit { class RichTextComposer; /** * @brief The RichTextComposerEmailQuoteDecorator class * @author Laurent Montel */ class KPIMTEXTEDIT_EXPORT RichTextComposerEmailQuoteDecorator : public Sonnet::SpellCheckDecorator { Q_OBJECT public: explicit RichTextComposerEmailQuoteDecorator(RichTextComposer *textEdit); ~RichTextComposerEmailQuoteDecorator() override; protected: - bool isSpellCheckingEnabledForBlock(const QString &blockText) const override; + Q_REQUIRED_RESULT bool isSpellCheckingEnabledForBlock(const QString &blockText) const override; private: class RichTextComposerEmailQuoteDecoratorPrivate; RichTextComposerEmailQuoteDecoratorPrivate *const d; }; } #endif // RICHTEXTCOMPOSEREMAILQUOTEDECORATOR_H diff --git a/src/emoticon/emoticonlistwidgetselector.h b/src/emoticon/emoticonlistwidgetselector.h index 2f80717..3b09a8d 100644 --- a/src/emoticon/emoticonlistwidgetselector.h +++ b/src/emoticon/emoticonlistwidgetselector.h @@ -1,55 +1,55 @@ /* Copyright (c) 2019-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef EMOTICONLISTWIDGETSELECTOR_H #define EMOTICONLISTWIDGETSELECTOR_H #include #include "kpimtextedit_private_export.h" namespace KPIMTextEdit { class KPIMTEXTEDIT_TESTS_EXPORT EmoticonTextEditItem : public QListWidgetItem { public: explicit EmoticonTextEditItem(const QString &emoticonText, QListWidget *parent); - QString text() const; + Q_REQUIRED_RESULT QString text() const; private: QString mText; }; class KPIMTEXTEDIT_TESTS_EXPORT EmoticonListWidgetSelector : public QListWidget { Q_OBJECT public: explicit EmoticonListWidgetSelector(QWidget *parent = nullptr); ~EmoticonListWidgetSelector(); void setEmoticons(const QList &lst); void setEmoticons(const QStringList &lst); Q_SIGNALS: void itemSelected(const QString &); private: void slotMouseOverItem(QListWidgetItem *item); void slotEmoticonClicked(QListWidgetItem *item); }; } #endif // EMOTICONLISTWIDGETSELECTOR_H diff --git a/src/grantleebuilder/abstractmarkupbuilder.h b/src/grantleebuilder/abstractmarkupbuilder.h index 95f040f..ede8985 100644 --- a/src/grantleebuilder/abstractmarkupbuilder.h +++ b/src/grantleebuilder/abstractmarkupbuilder.h @@ -1,275 +1,275 @@ /* Copyright (c) 2020 Montel Laurent Copyright (c) 2008,2010 Stephen Kelly This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef GRANTLEE_ABSTRACTMARKUPBUILDER_H #define GRANTLEE_ABSTRACTMARKUPBUILDER_H #include "kpimtextedit_export.h" #include #include class QBrush; namespace KPIMTextEdit { class AbstractMarkupBuilderPrivate; /// @headerfile abstractmarkupbuilder.h grantlee/abstractmarkupbuilder.h /** @brief Interface for creating marked-up text output. The **%AbstractMarkupBuilder** is used by a MarkupDirector to create marked-up output such as html or markdown. See PlainTextMarkupBuilder and TextHTMLBuilder for example implementations. This interface can be extended to handle custom format types in a QTextDocument. @see @ref custom_qtextobject @author Stephen Kelly */ class KPIMTEXTEDIT_EXPORT AbstractMarkupBuilder { public: /** Destructor */ virtual ~AbstractMarkupBuilder() {} /** Begin a bold element in the markup */ virtual void beginStrong() = 0; /** Close the bold element in the markup */ virtual void endStrong() = 0; /** Begin an emphasised element in the markup */ virtual void beginEmph() = 0; /** Close the emphasised element in the markup */ virtual void endEmph() = 0; /** Begin an underlined element in the markup */ virtual void beginUnderline() = 0; /** Close the underlined element in the markup */ virtual void endUnderline() = 0; /** Begin a struck out element in the markup */ virtual void beginStrikeout() = 0; /** Close the struck out element in the markup */ virtual void endStrikeout() = 0; /** Begin a decorarated foreground element in the markup (A text color) using @p brush */ virtual void beginForeground(const QBrush &brush) = 0; /** Close the decorarated foreground element in the markup */ virtual void endForeground() = 0; /** Begin a decorarated background element in the markup (A text background color) using @p brush */ virtual void beginBackground(const QBrush &brush) = 0; /** Close the decorarated background element in the markup */ virtual void endBackground() = 0; /** Begin a url anchor element in the markup @param href The href of the anchor. @param name The name of the anchor. */ virtual void beginAnchor(const QString &href = {}, const QString &name = {}) = 0; /** Close the anchor element */ virtual void endAnchor() = 0; /** Begin a new font familiy element in the markup @param family The name of the font family to begin. */ virtual void beginFontFamily(const QString &family) = 0; /** End font family element */ virtual void endFontFamily() = 0; /** Begin a new font point size element in the markup @param size The point size to begin. */ virtual void beginFontPointSize(int size) = 0; /** End font point size element */ virtual void endFontPointSize() = 0; /** Begin a new paragraph in the markup @param a The alignment of the new paragraph. @param top The top margin of the new paragraph. @param bottom The bottom margin of the new paragraph. @param left The left margin of the new paragraph. @param right The right margin of the new paragraph. */ virtual void beginParagraph(Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0, qreal bottom = 0.0, qreal left = 0.0, qreal right = 0.0) = 0; /** Close the paragraph in the markup. */ virtual void endParagraph() = 0; /** Add a newline to the markup. */ virtual void addNewline() = 0; /** Insert a horizontal rule into the markup. @param width The width of the rule. Default is full width. */ virtual void insertHorizontalRule(int width = -1) = 0; /** Insert a new image element into the markup. @param url The url of the image @param width The width of the image @param height The height of the image. */ virtual void insertImage(const QString &url, qreal width, qreal height) = 0; /** Begin a new list element in the markup. A list element contains list items, and may contain other lists. @param style The style of list to create. */ virtual void beginList(QTextListFormat::Style style) = 0; /** Close the list. */ virtual void endList() = 0; /** Begin a new list item in the markup */ virtual void beginListItem() = 0; /** End the list item */ virtual void endListItem() = 0; /** Begin a superscript element */ virtual void beginSuperscript() = 0; /** End superscript element */ virtual void endSuperscript() = 0; /** Begin a subscript element */ virtual void beginSubscript() = 0; /** End subscript element */ virtual void endSubscript() = 0; /** Begin a table element. @param cellpadding The padding attribute for the table. @param cellspacing The spacing attribute for the table. @param width The width of the table. May be either an integer, or a percentage value. */ virtual void beginTable(qreal cellpadding, qreal cellspacing, const QString &width) = 0; /** Begin a new table row */ virtual void beginTableRow() = 0; /** Begin a new table header cell. @param width The width of the cell. @param colSpan The column span of the cell. @param rowSpan The row span of the cell. */ virtual void beginTableHeaderCell(const QString &width, int colSpan, int rowSpan) = 0; /** Begin a new table cell. @param width The width of the cell. @param colSpan The column span of the cell. @param rowSpan The row span of the cell. */ virtual void beginTableCell(const QString &width, int colSpan, int rowSpan) = 0; /** End a table element */ virtual void endTable() = 0; /** End a table row */ virtual void endTableRow() = 0; /** End a table header cell */ virtual void endTableHeaderCell() = 0; /** End a table cell */ virtual void endTableCell() = 0; /** Begin a level @p level header @param level An integer between 1 and 6 */ virtual void beginHeader(int level) = 0; /** End a level @p level header @param level An integer between 1 and 6 */ virtual void endHeader(int level) = 0; /** Append the plain text @p text to the markup @param text The text to append. */ virtual void appendLiteralText(const QString &text) = 0; /** Append the raw text @p text to the markup. @p text is added unescaped */ virtual void appendRawText(const QString &text) = 0; /** Return the fully marked up result of the building process. This may contain metadata etc, such as a head element in html. @return The fully marked up text. */ - virtual QString getResult() = 0; + virtual Q_REQUIRED_RESULT QString getResult() = 0; virtual void addSingleBreakLine() = 0; }; } #endif diff --git a/src/grantleebuilder/markupdirector.h b/src/grantleebuilder/markupdirector.h index e1f1214..6ea5739 100644 --- a/src/grantleebuilder/markupdirector.h +++ b/src/grantleebuilder/markupdirector.h @@ -1,305 +1,305 @@ /* Copyright (c) 2019-2020 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MARKUPDIRECTOR_H #define MARKUPDIRECTOR_H #include "abstractmarkupbuilder.h" #include "kpimtextedit_export.h" #include #include class QTextTable; class QTextTableCell; class QTextList; class QTextCharFormat; namespace KPIMTextEdit { class MarkupDirectorPrivate; class AbstractMarkupBuilder; /// @headerfile markupdirector.h grantlee/markupdirector.h /** @brief Instructs a builder object to create markup output The **%MarkupDirector** is used with an implementation of AbstractMarkupBuilder to create a marked up document output. Usage can be quite simple. @code auto doc = editor->document(); // editor is a QTextEdit auto builder = new HTMLBuilder(); auto md = new MarkupDirector(builder); md->processDocument(doc); browser->setHtml(builder->getResult()); // browser is a QTextBrowser. @endcode Or with a different builder: @code auto builder = new PlainTextMarkupBuilder(); auto md = new MarkupDirector(builder); md->processDocument(doc); browser->setPlainText(builder->getResult()); @endcode The **%MarkupDirector** also provides API for processing just part of a QTextDocument, such as a QTextFrame or a QTextBlock. The appropriate method may then be called with an invalid iterator as appropriate. @code // ... Do some processing to get a QTextFrame. auto frame = getFrame(); auto builder = new PlainTextMarkupBuilder(); auto md = new MarkupDirector(builder); // Create output from only the frame. md->processFrame(QTextFrame::iterator(), frame); browser->setPlainText(builder->getResult()); @endcode The behaviour of the **%MarkupDirector** can be customized by subclassing. Support for custom types can also be added by implementing the @ref processCustomFragment method. @see @ref custom_qtextobject @author Stephen Kelly */ class KPIMTEXTEDIT_EXPORT MarkupDirector { public: /** Constructor */ explicit MarkupDirector(KPIMTextEdit::AbstractMarkupBuilder *builder); /** Destructor */ virtual ~MarkupDirector(); /** Constructs the output by directing the builder to create the markup. */ virtual void processDocument(QTextDocument *doc); /** Directs the builder to create output for the single @p frame. If calling this method directly, an invalid QTextFrame::iterator may be used. */ - virtual QTextFrame::iterator processFrame(QTextFrame::iterator it, + virtual Q_REQUIRED_RESULT QTextFrame::iterator processFrame(QTextFrame::iterator it, QTextFrame *frame); /** Directs the builder to create output for the single @p block. If calling this method directly, an invalid QTextFrame::iterator may be used. This method does not process the contents of the @p block, but uses the @ref processBlockContents method to do so. */ - virtual QTextFrame::iterator processBlock(QTextFrame::iterator it, + virtual Q_REQUIRED_RESULT QTextFrame::iterator processBlock(QTextFrame::iterator it, const QTextBlock &block); /** Directs the builder to create output for the single @p textObject. If calling this method directly, an invalid QTextFrame::iterator may be used. The block @p block is the container of the @p textObject. */ - virtual QTextFrame::iterator processObject(QTextFrame::iterator it, + virtual Q_REQUIRED_RESULT QTextFrame::iterator processObject(QTextFrame::iterator it, const QTextBlock &block, QTextObject *textObject); /** Directs the builder to create output for the single @p textBlockGroup. If calling this method directly, an invalid QTextFrame::iterator may be used. The block @p block is the first block in the @p textBlockGroup. */ - virtual QPair + virtual Q_REQUIRED_RESULT QPair processBlockGroup(const QTextFrame::iterator &it, const QTextBlock &block, QTextBlockGroup *textBlockGroup); /** Directs the builder to create output for the single @p textList. If calling this method directly, an invalid QTextFrame::iterator may be used. The block @p block is the first block in the @p textList. */ - virtual QPair + virtual Q_REQUIRED_RESULT QPair processList(QTextFrame::iterator it, const QTextBlock &block, QTextList *textList); /** Directs the builder to create output for the contents of the single @p block. If calling this method directly, an invalid QTextFrame::iterator may be used. */ - virtual QTextFrame::iterator processBlockContents(QTextFrame::iterator it, + virtual Q_REQUIRED_RESULT QTextFrame::iterator processBlockContents(QTextFrame::iterator it, const QTextBlock &block); /** Hook for instructing the builder to create output for the @p fragemnt with a custom type. @p doc is the document the fragment is in. */ virtual void processCustomFragment(const QTextFragment &fragment, QTextDocument const *doc); /** Directs the builder to create output for the contents of the single @p fragment. If calling this method directly, an invalid QTextBlock::iterator may be used. @p doc is the document the fragment is in. */ - virtual QTextBlock::iterator processFragment(QTextBlock::iterator it, + virtual Q_REQUIRED_RESULT QTextBlock::iterator processFragment(QTextBlock::iterator it, const QTextFragment &fragment, QTextDocument const *doc); /** Directs the builder to create output for the contents of the single @p textObject. The @p textObject is represented in the QTextDocument with the QTextFragment @p fragment. If calling this method directly, an invalid QTextBlock::iterator may be used. */ - virtual QTextBlock::iterator + virtual Q_REQUIRED_RESULT QTextBlock::iterator processCharTextObject(QTextBlock::iterator it, const QTextFragment &fragment, QTextObject *textObject); /** Directs the builder to create output for the image represented by the @p imageFormat. If calling this method directly, an invalid QTextBlock::iterator may be used. @p doc is the document the fragment is in. */ - virtual QTextBlock::iterator processImage(QTextBlock::iterator it, + virtual Q_REQUIRED_RESULT QTextBlock::iterator processImage(QTextBlock::iterator it, const QTextImageFormat &imageFormat, QTextDocument const *doc); /** Directs the builder to create output for the contents of the single @p table. If calling this method directly, an invalid QTextFrame::iterator may be used. */ - virtual QTextFrame::iterator processTable(QTextFrame::iterator it, + virtual Q_REQUIRED_RESULT QTextFrame::iterator processTable(QTextFrame::iterator it, QTextTable *table); /** Directs the builder to create output for the contents of the single @p tableCell. The tableCell is in the @p table. */ virtual void processTableCell(const QTextTableCell &tableCell, QTextTable *table); protected: /** Processes the document between @p begin and @p end */ void processDocumentContents(QTextFrame::iterator begin, const QTextFrame::iterator &end); /** Iterates the iterator @p it to the first block after @p blockGroup. @p _block is any block in the @p blockGroup. The return pair is the iterator pointing after the end of @p blockGroup and the first block after @p blockGroup. */ - QPair + Q_REQUIRED_RESULT QPair skipBlockGroup(QTextFrame::iterator it, const QTextBlock &_block, QTextBlockGroup *blockGroup); /** Returns a list of tags contained in @p openingTags sorted so they can be opened in order and will be closed in the correct order. @p openingTags should be a set of tags opened at the fragment pointed to by @p it. */ - QList sortOpeningOrder(QSet openingTags, + Q_REQUIRED_RESULT QList sortOpeningOrder(QSet openingTags, QTextBlock::iterator it) const; /** Directs the builder to close the appropriate tags at the position of @p it. */ virtual void processClosingElements(const QTextBlock::iterator &it); /** Directs the builder to open the appropriate tags at the position of @p it. */ virtual void processOpeningElements(const QTextBlock::iterator &it); /** Returns the tags that should be closed at the position of @p it. */ - virtual QSet getElementsToClose(const QTextBlock::iterator &it) const; + virtual Q_REQUIRED_RESULT QSet getElementsToClose(const QTextBlock::iterator &it) const; /** Returns the tags that should be opened at the position of @p it. */ - virtual QList getElementsToOpen(const QTextBlock::iterator &it); + virtual Q_REQUIRED_RESULT QList getElementsToOpen(const QTextBlock::iterator &it); /** Flags for the tags that may be open. */ enum OpenElementValues { None = 0x0, /// No tags are open SuperScript = 0x01, /// A superscript tag is open SubScript = 0x02, /// A subscript tag is open Anchor = 0x04, /// An anchor tag is open SpanForeground = 0x08, /// A foreground altering span tag is open. SpanBackground = 0x10, /// A background altering span tag is open. SpanFontFamily = 0x20, /// A font family altering span tag is open. SpanFontPointSize = 0x40, /// A font size altering span tag is open. Strong = 0x80, /// A strong tag is open. Emph = 0x100, /// A emphasis tag is open. Underline = 0x200, /// An underline tag is open. StrikeOut = 0x400 /// A strikeout tag is open. }; protected: #ifndef Q_QDOC MarkupDirectorPrivate *const d_ptr; #endif /** The builder this MarkupDirector is operating on. This is available when subclassing to customize behaviour. */ KPIMTextEdit::AbstractMarkupBuilder *m_builder; #ifndef Q_QDOC private: Q_DECLARE_PRIVATE(MarkupDirector) #endif }; } #endif diff --git a/src/grantleebuilder/plaintextmarkupbuilder.h b/src/grantleebuilder/plaintextmarkupbuilder.h index 9dd9912..e4d5aa6 100644 --- a/src/grantleebuilder/plaintextmarkupbuilder.h +++ b/src/grantleebuilder/plaintextmarkupbuilder.h @@ -1,136 +1,136 @@ /* Copyright (c) 2019-2020 Montel Laurent based on grantlee PlainTextMarkupBuilder This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PLAINTEXTMARKUPBUILDER_H #define PLAINTEXTMARKUPBUILDER_H #include "kpimtextedit_export.h" #include "abstractmarkupbuilder.h" #define LETTERSINALPHABET 26 #define DIGITSOFFSET 10 namespace KPIMTextEdit { class PlainTextMarkupBuilderPrivate; class KPIMTEXTEDIT_EXPORT PlainTextMarkupBuilder : virtual public KPIMTextEdit::AbstractMarkupBuilder { public: /** Construct a new PlainTextHTMLMarkupBuilder. */ PlainTextMarkupBuilder(); ~PlainTextMarkupBuilder() override; void setQuotePrefix(const QString &prefix); void beginStrong() override; void endStrong() override; void beginEmph() override; void endEmph() override; void beginUnderline() override; void endUnderline() override; void beginStrikeout() override; void endStrikeout() override; void beginAnchor(const QString &href = QString(), const QString &name = QString()) override; void endAnchor() override; void beginParagraph(Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0, qreal bottom = 0.0, qreal left = 0.0, qreal right = 0.0) override; void endParagraph() override; void addNewline() override; void insertHorizontalRule(int width = -1) override; void insertImage(const QString &src, qreal width, qreal height) override; void beginList(QTextListFormat::Style style) override; void endList() override; void beginListItem() override; void endListItem() override; void beginSuperscript() override; void endSuperscript() override; void beginSubscript() override; void endSubscript() override; void beginTable(qreal cellpadding, qreal cellspacing, const QString &width) override; void beginTableRow() override; void beginTableHeaderCell(const QString &width, int colSpan, int rowSpan) override; void beginTableCell(const QString &width, int colSpan, int rowSpan) override; void appendLiteralText(const QString &text) override; void appendRawText(const QString &text) override; /** Adds a reference to @p reference to the internal list of references in the document. */ - int addReference(const QString &reference); + Q_REQUIRED_RESULT int addReference(const QString &reference); /** Returns the finalised plain text markup, including references at the end. */ - QString getResult() override; + Q_REQUIRED_RESULT QString getResult() override; - bool isQuoteBlock(qreal top, qreal bottom, qreal left, qreal right) const; + Q_REQUIRED_RESULT bool isQuoteBlock(qreal top, qreal bottom, qreal left, qreal right) const; void beginForeground(const QBrush &brush) override; void endForeground() override; void beginBackground(const QBrush &brush) override; void endBackground() override; void beginFontFamily(const QString &family) override; void endFontFamily() override; void beginFontPointSize(int size) override; void endFontPointSize() override; void endTable() override; void endTableRow() override; void endTableHeaderCell() override; void endTableCell() override; void beginHeader(int level) override; void endHeader(int level) override; void addSingleBreakLine() override; private: PlainTextMarkupBuilderPrivate *const d_ptr; Q_DECLARE_PRIVATE(PlainTextMarkupBuilder) }; } #endif // PLAINTEXTMARKUPBUILDER_H diff --git a/src/texteditor/commonwidget/texteditfindbarbase.h b/src/texteditor/commonwidget/texteditfindbarbase.h index b7ac825..6ee6ff8 100644 --- a/src/texteditor/commonwidget/texteditfindbarbase.h +++ b/src/texteditor/commonwidget/texteditfindbarbase.h @@ -1,93 +1,93 @@ /* Copyright (C) 2013-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef TEXTEDITFINDBARBASE_H #define TEXTEDITFINDBARBASE_H #include "kpimtextedit_export.h" #include #include #include namespace KPIMTextEdit { class TextFindWidget; class TextReplaceWidget; /** * @brief The TextEditFindBarBase class * @author Laurent Montel */ class KPIMTEXTEDIT_EXPORT TextEditFindBarBase : public QWidget { Q_OBJECT public: explicit TextEditFindBarBase(QWidget *parent = nullptr); ~TextEditFindBarBase() override; Q_REQUIRED_RESULT QString text() const; void setText(const QString &text); void focusAndSetCursor(); void showReplace(); void showFind(); void setHideWhenClose(bool hide); Q_SIGNALS: void displayMessageIndicator(const QString &message); void hideFindBar(); protected: - virtual bool viewIsReadOnly() const = 0; - virtual bool documentIsEmpty() const = 0; - virtual bool searchInDocument(const QString &text, QTextDocument::FindFlags searchOptions) = 0; - virtual bool searchInDocument(const QRegularExpression ®Exp, QTextDocument::FindFlags searchOptions) = 0; + virtual Q_REQUIRED_RESULT bool viewIsReadOnly() const = 0; + virtual Q_REQUIRED_RESULT bool documentIsEmpty() const = 0; + virtual Q_REQUIRED_RESULT bool searchInDocument(const QString &text, QTextDocument::FindFlags searchOptions) = 0; + virtual Q_REQUIRED_RESULT bool searchInDocument(const QRegularExpression ®Exp, QTextDocument::FindFlags searchOptions) = 0; virtual void autoSearchMoveCursor() = 0; bool event(QEvent *e) override; void clearSelections(); void updateHighLight(bool); - bool searchText(bool backward, bool isAutoSearch); + Q_REQUIRED_RESULT bool searchText(bool backward, bool isAutoSearch); void updateSensitivity(bool); void setFoundMatch(bool match); void messageInfo(bool backward, bool isAutoSearch, bool found); public Q_SLOTS: void findNext(); void findPrev(); void autoSearch(const QString &str); virtual void slotSearchText(bool backward = false, bool isAutoSearch = true) = 0; void closeBar(); private Q_SLOTS: void slotClearSearch(); void slotUpdateSearchOptions(); virtual void slotReplaceText() = 0; virtual void slotReplaceAllText() = 0; protected: QString mLastSearchStr; QRegularExpression mLastSearchRegExp; TextFindWidget *mFindWidget = nullptr; TextReplaceWidget *mReplaceWidget = nullptr; bool mHideWhenClose = true; }; } #endif // TEXTEDITFINDBARBASE_H diff --git a/src/texteditor/commonwidget/textfindreplacewidget.h b/src/texteditor/commonwidget/textfindreplacewidget.h index 13926d8..7749b80 100644 --- a/src/texteditor/commonwidget/textfindreplacewidget.h +++ b/src/texteditor/commonwidget/textfindreplacewidget.h @@ -1,91 +1,91 @@ /* Copyright (C) 2013-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef TEXTFINDREPLACEWIDGET_H #define TEXTFINDREPLACEWIDGET_H #include #include class QAction; class QLineEdit; class QPushButton; namespace KPIMTextEdit { class TextFindWidget : public QWidget { Q_OBJECT public: explicit TextFindWidget(QWidget *parent = nullptr); ~TextFindWidget(); Q_REQUIRED_RESULT QTextDocument::FindFlags searchOptions() const; QLineEdit *searchLineEdit() const; void setFoundMatch(bool match); - bool isRegularExpression() const; + Q_REQUIRED_RESULT bool isRegularExpression() const; Q_REQUIRED_RESULT QRegularExpression searchRegExp() const; Q_REQUIRED_RESULT QString searchText() const; private Q_SLOTS: void slotAutoSearch(const QString &str); Q_SIGNALS: void findNext(); void findPrev(); void clearSearch(); void autoSearch(const QString &); void updateSearchOptions(); void searchStringEmpty(bool); private: QLineEdit *mSearch = nullptr; QAction *mCaseSensitiveAct = nullptr; QAction *mWholeWordAct = nullptr; QAction *mRegExpAct = nullptr; QPushButton *mFindPrevBtn = nullptr; QPushButton *mFindNextBtn = nullptr; }; class TextReplaceWidget : public QWidget { Q_OBJECT public: explicit TextReplaceWidget(QWidget *parent = nullptr); ~TextReplaceWidget(); QLineEdit *replaceLineEdit() const; public Q_SLOTS: void slotSearchStringEmpty(bool); Q_SIGNALS: void replaceText(); void replaceAllText(); private: QLineEdit *mReplace = nullptr; QPushButton *mReplaceBtn = nullptr; QPushButton *mReplaceAllBtn = nullptr; }; } #endif // TEXTFINDREPLACEWIDGET_H diff --git a/src/texteditor/plaintexteditor/plaintexteditfindbar.h b/src/texteditor/plaintexteditor/plaintexteditfindbar.h index cf7ed57..9e7264d 100644 --- a/src/texteditor/plaintexteditor/plaintexteditfindbar.h +++ b/src/texteditor/plaintexteditor/plaintexteditfindbar.h @@ -1,61 +1,61 @@ /* Copyright (C) 2012-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPIMTEXTEDIT_FINDBARBASE_H #define KPIMTEXTEDIT_FINDBARBASE_H #include "kpimtextedit_export.h" #include "kpimtextedit/texteditfindbarbase.h" #include class QPlainTextEdit; namespace KPIMTextEdit { class PlainTextEditFindBarPrivate; /** * @brief The PlainTextEditFindBar class * @author Laurent Montel */ class KPIMTEXTEDIT_EXPORT PlainTextEditFindBar : public TextEditFindBarBase { Q_OBJECT public: explicit PlainTextEditFindBar(QPlainTextEdit *view, QWidget *parent = nullptr); ~PlainTextEditFindBar() override; protected: - bool viewIsReadOnly() const override; - bool documentIsEmpty() const override; - bool searchInDocument(const QString &text, QTextDocument::FindFlags searchOptions) override; - bool searchInDocument(const QRegularExpression ®Exp, QTextDocument::FindFlags searchOptions) override; + Q_REQUIRED_RESULT bool viewIsReadOnly() const override; + Q_REQUIRED_RESULT bool documentIsEmpty() const override; + Q_REQUIRED_RESULT bool searchInDocument(const QString &text, QTextDocument::FindFlags searchOptions) override; + Q_REQUIRED_RESULT bool searchInDocument(const QRegularExpression ®Exp, QTextDocument::FindFlags searchOptions) override; void autoSearchMoveCursor() override; public Q_SLOTS: void slotSearchText(bool backward = false, bool isAutoSearch = true) override; private Q_SLOTS: void slotReplaceText() override; void slotReplaceAllText() override; private: PlainTextEditFindBarPrivate *const d; }; } #endif diff --git a/src/texteditor/plaintexteditor/plaintexteditor.h b/src/texteditor/plaintexteditor/plaintexteditor.h index f205252..de8c0d5 100644 --- a/src/texteditor/plaintexteditor/plaintexteditor.h +++ b/src/texteditor/plaintexteditor/plaintexteditor.h @@ -1,134 +1,134 @@ /* Copyright (C) 2013-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PLAINTEXTEDITOR_H #define PLAINTEXTEDITOR_H #include "kpimtextedit_export.h" #include namespace Sonnet { class Highlighter; class SpellCheckDecorator; } namespace KPIMTextEdit { /** * @brief The PlainTextEditor class * @author Laurent Montel */ class KPIMTEXTEDIT_EXPORT PlainTextEditor : public QPlainTextEdit { Q_OBJECT Q_PROPERTY(bool searchSupport READ searchSupport WRITE setSearchSupport) Q_PROPERTY(bool spellCheckingSupport READ spellCheckingSupport WRITE setSpellCheckingSupport) Q_PROPERTY(bool textToSpeechSupport READ textToSpeechSupport WRITE setTextToSpeechSupport) Q_PROPERTY(bool webShortcutSupport READ webShortcutSupport WRITE setWebShortcutSupport) public: explicit PlainTextEditor(QWidget *parent = nullptr); ~PlainTextEditor() override; enum SupportFeature { None = 0, Search = 1, SpellChecking = 2, TextToSpeech = 4, AllowWebShortcut = 8 }; Q_DECLARE_FLAGS(SupportFeatures, SupportFeature) void setSearchSupport(bool b); Q_REQUIRED_RESULT bool searchSupport() const; Q_REQUIRED_RESULT bool spellCheckingSupport() const; void setSpellCheckingSupport(bool check); virtual void setReadOnly(bool readOnly); void setTextToSpeechSupport(bool b); Q_REQUIRED_RESULT bool textToSpeechSupport() const; void setWebShortcutSupport(bool b); Q_REQUIRED_RESULT bool webShortcutSupport() const; virtual void createHighlighter(); void addIgnoreWords(const QStringList &lst); Q_REQUIRED_RESULT bool activateLanguageMenu() const; void setActivateLanguageMenu(bool activate); Q_REQUIRED_RESULT Sonnet::Highlighter *highlighter() const; bool checkSpellingEnabled() const; void setCheckSpellingEnabled(bool check); void setSpellCheckingConfigFileName(const QString &_fileName); Q_REQUIRED_RESULT QString spellCheckingConfigFileName() const; const QString &spellCheckingLanguage() const; void setSpellCheckingLanguage(const QString &_language); public Q_SLOTS: void slotDisplayMessageIndicator(const QString &message); void slotCheckSpelling(); void slotSpeakText(); void slotZoomReset(); private Q_SLOTS: void slotUndoableClear(); void slotSpellCheckerMisspelling(const QString &text, int pos); void slotSpellCheckerCorrected(const QString &, int, const QString &); void slotSpellCheckerAutoCorrect(const QString &, const QString &); void slotSpellCheckerCanceled(); void slotSpellCheckerFinished(); void slotLanguageSelected(); void slotToggleAutoSpellCheck(); protected: virtual void addExtraMenuEntry(QMenu *menu, QPoint pos); protected: void contextMenuEvent(QContextMenuEvent *event) override; - bool event(QEvent *ev) override; + Q_REQUIRED_RESULT bool event(QEvent *ev) override; void keyPressEvent(QKeyEvent *event) override; - bool overrideShortcut(QKeyEvent *event); - bool handleShortcut(QKeyEvent *event); + Q_REQUIRED_RESULT bool overrideShortcut(QKeyEvent *event); + Q_REQUIRED_RESULT bool handleShortcut(QKeyEvent *event); void wheelEvent(QWheelEvent *event) override; virtual Sonnet::SpellCheckDecorator *createSpellCheckDecorator(); void setHighlighter(Sonnet::Highlighter *_highLighter); void focusInEvent(QFocusEvent *event) override; virtual void updateHighLighter(); virtual void clearDecorator(); Q_SIGNALS: void findText(); void replaceText(); void spellCheckerAutoCorrect(const QString ¤tWord, const QString &autoCorrectWord); void checkSpellingChanged(bool); void languageChanged(const QString &); void spellCheckStatus(const QString &); void say(const QString &text); private: void addIgnoreWordsToHighLighter(); void deleteWordBack(); void deleteWordForward(); void highlightWord(int length, int pos); void deleteEndOfLine(); void moveLineUpDown(bool moveUp); class PlainTextEditorPrivate; PlainTextEditorPrivate *const d; }; } #endif // PLAINTEXTEDITOR_H diff --git a/src/texteditor/richtexteditor/richtexteditfindbar.h b/src/texteditor/richtexteditor/richtexteditfindbar.h index d0041e3..0125867 100644 --- a/src/texteditor/richtexteditor/richtexteditfindbar.h +++ b/src/texteditor/richtexteditor/richtexteditfindbar.h @@ -1,60 +1,60 @@ /* Copyright (C) 2013-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef RICHTEXTEDITFINDBAR_H #define RICHTEXTEDITFINDBAR_H #include "kpimtextedit_export.h" #include "kpimtextedit/texteditfindbarbase.h" #include class QTextEdit; namespace KPIMTextEdit { class RichTextEditFindBarPrivate; /** * @brief The RichTextEditFindBar class * @author Laurent Montel */ class KPIMTEXTEDIT_EXPORT RichTextEditFindBar : public TextEditFindBarBase { Q_OBJECT public: explicit RichTextEditFindBar(QTextEdit *view, QWidget *parent = nullptr); ~RichTextEditFindBar() override; protected: - bool viewIsReadOnly() const override; - bool documentIsEmpty() const override; - bool searchInDocument(const QString &text, QTextDocument::FindFlags searchOptions) override; - bool searchInDocument(const QRegularExpression ®Exp, QTextDocument::FindFlags searchOptions) override; + Q_REQUIRED_RESULT bool viewIsReadOnly() const override; + Q_REQUIRED_RESULT bool documentIsEmpty() const override; + Q_REQUIRED_RESULT bool searchInDocument(const QString &text, QTextDocument::FindFlags searchOptions) override; + Q_REQUIRED_RESULT bool searchInDocument(const QRegularExpression ®Exp, QTextDocument::FindFlags searchOptions) override; void autoSearchMoveCursor() override; public Q_SLOTS: void slotSearchText(bool backward = false, bool isAutoSearch = true) override; private Q_SLOTS: void slotReplaceText() override; void slotReplaceAllText() override; private: RichTextEditFindBarPrivate *const d; }; } #endif // RICHTEXTEDITFINDBAR_H diff --git a/src/texteditor/richtexteditor/richtexteditor.h b/src/texteditor/richtexteditor/richtexteditor.h index 18ce1f0..682c0b0 100644 --- a/src/texteditor/richtexteditor/richtexteditor.h +++ b/src/texteditor/richtexteditor/richtexteditor.h @@ -1,159 +1,159 @@ /* Copyright (C) 2013-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef RICHTEXTEDITOR_H #define RICHTEXTEDITOR_H #include "kpimtextedit_export.h" #include class QContextMenuEvent; class QMenu; namespace Sonnet { class Highlighter; class SpellCheckDecorator; } namespace KPIMTextEdit { /** * @brief The RichTextEditor class * @author Laurent Montel */ class KPIMTEXTEDIT_EXPORT RichTextEditor : public QTextEdit { Q_OBJECT Q_PROPERTY(bool searchSupport READ searchSupport WRITE setSearchSupport) Q_PROPERTY(bool spellCheckingSupport READ spellCheckingSupport WRITE setSpellCheckingSupport) Q_PROPERTY(bool textToSpeechSupport READ textToSpeechSupport WRITE setTextToSpeechSupport) Q_PROPERTY(bool activateLanguageMenu READ activateLanguageMenu WRITE setActivateLanguageMenu) Q_PROPERTY(bool tabSupport READ allowTabSupport WRITE setAllowTabSupport) Q_PROPERTY(bool webShortcutSupport READ webShortcutSupport WRITE setWebShortcutSupport) public: explicit RichTextEditor(QWidget *parent = nullptr); ~RichTextEditor() override; enum SupportFeature { None = 0, Search = 1, SpellChecking = 2, TextToSpeech = 4, AllowTab = 8, AllowWebShortcut = 16 }; Q_DECLARE_FLAGS(SupportFeatures, SupportFeature) void setSearchSupport(bool b); Q_REQUIRED_RESULT bool searchSupport() const; Q_REQUIRED_RESULT bool spellCheckingSupport() const; void setSpellCheckingSupport(bool check); void setSpellCheckingConfigFileName(const QString &_fileName); - bool checkSpellingEnabled() const; + Q_REQUIRED_RESULT bool checkSpellingEnabled() const; void setCheckSpellingEnabled(bool check); void setSpellCheckingLanguage(const QString &_language); const QString &spellCheckingLanguage() const; virtual void setReadOnly(bool readOnly); virtual void createHighlighter(); Q_REQUIRED_RESULT bool textToSpeechSupport() const; void setTextToSpeechSupport(bool b); Q_REQUIRED_RESULT Sonnet::Highlighter *highlighter() const; Q_REQUIRED_RESULT bool activateLanguageMenu() const; void setActivateLanguageMenu(bool activate); void setAllowTabSupport(bool b); Q_REQUIRED_RESULT bool allowTabSupport() const; void setShowAutoCorrectButton(bool b); Q_REQUIRED_RESULT bool showAutoCorrectButton() const; void forceSpellChecking(); Q_REQUIRED_RESULT QString spellCheckingConfigFileName() const; void setWebShortcutSupport(bool b); Q_REQUIRED_RESULT bool webShortcutSupport() const; void addIgnoreWords(const QStringList &lst); // Reimplement it in subclass virtual void forceAutoCorrection(bool selectedText = false); void setDefaultFontSize(int val); int zoomFactor() const; Q_SIGNALS: void say(const QString &text); public Q_SLOTS: void slotDisplayMessageIndicator(const QString &message); void slotSpeakText(); void slotCheckSpelling(); void slotZoomReset(); protected: virtual void addExtraMenuEntry(QMenu *menu, QPoint pos); void contextMenuEvent(QContextMenuEvent *event) override; void focusInEvent(QFocusEvent *event) override; bool event(QEvent *ev) override; void keyPressEvent(QKeyEvent *event) override; void wheelEvent(QWheelEvent *e) override; QMenu *mousePopupMenu(QPoint pos); virtual Sonnet::SpellCheckDecorator *createSpellCheckDecorator(); void setHighlighter(Sonnet::Highlighter *_highLighter); virtual void updateHighLighter(); virtual void clearDecorator(); Q_SIGNALS: void findText(); void replaceText(); void spellCheckerAutoCorrect(const QString ¤tWord, const QString &autoCorrectWord); void checkSpellingChanged(bool); void languageChanged(const QString &); void spellCheckStatus(const QString &); void spellCheckingFinished(); void spellCheckingCanceled(); private: void slotUndoableClear(); void slotSpellCheckerMisspelling(const QString &text, int pos); void slotSpellCheckerCorrected(const QString &, int, const QString &); void slotSpellCheckerAutoCorrect(const QString &, const QString &); void slotSpellCheckerCanceled(); void slotSpellCheckerFinished(); void slotToggleAutoSpellCheck(); void slotLanguageSelected(); void slotAllowTab(); void addIgnoreWordsToHighLighter(); bool handleShortcut(QKeyEvent *event); bool overrideShortcut(QKeyEvent *event); void deleteWordBack(); void deleteWordForward(); void highlightWord(int length, int pos); void checkSpelling(bool force); void moveLineUpDown(bool moveUp); class RichTextEditorPrivate; RichTextEditorPrivate *const d; }; } #endif // RICHTEXTEDITOR_H