--Boundary-00=_q7n/H+ICcxsLOk/ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, in light of the on-the-fly spell checking feature, I'd like to propose a spell checking interface for documents, which adds the possibility to set different languages for parts of a document and a function for obtaining document ranges that should be spell checked. A first interface proposal is attached. Michel --Boundary-00=_q7n/H+ICcxsLOk/ Content-Type: text/x-c++hdr; charset="us-ascii"; name="spellcheckinterface.h" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="spellcheckinterface.h" /* This file is part of the KDE libraries Copyright (C) 2008 Michel Ludwig This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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 KDELIBS_KTEXTEDITOR_SPELLCHECKINTERFACE_H #define KDELIBS_KTEXTEDITOR_SPELLCHECKINTERFACE_H #include class KConfigGroup; #include namespace KTextEditor { /** * \brief Spell checking extension for the Document. * * \ingroup kte_group_document_extensions * * \section spellcheck_intro Introduction * * The SpellcheckInterface is an extension for Documents which allows access to spell checking * related functionalities. * * \section spellcheck_support Adding Spell Checking Support * * To add support for spell checking a KTextEditor implementation has to derive the * Document class from SpellcheckInterface and reimplement the purely virtual methods defined * in this interfaces. * * \section spellcheck_access Accessing the SpellcheckInterface * * The SpellcheckInterface is supposed to be an extension interface for a Document, i.e. the * Document inherits the interface \e provided that it implements the interface. Use qobject_cast to * access the implementation: * \code * // object is of type KTextEditor::Document* * KTextEditor::SpellcheckInterface *iface = * qobject_cast( object ); * * if( iface ) { * // interface is supported * // do stuff * } * \endcode * * \since 4.1 * \see KTextEditor::Document, Sonnet::Speller * \author Michel Ludwig \ */ class KTEXTEDITOR_EXPORT SpellcheckInterface { public: /** * Constructor. */ SpellcheckInterface(); /** * Virtual destructor. */ virtual ~SpellcheckInterface() {} public: /** * Return the sub-ranges that contain text that should be spell checked within a given * document range. * * \param range Document range * \return Sub-ranges of \p range which contain text that should be spell checked * \since 4.1 */ virtual QList spellcheckableText(const KTextEditor::Range& range) const = 0; /** * Set the default language of the document, which is used when no other language is * set for a sub-range of the document. * * \param language Default language of the document * \since 4.1 */ virtual void setDefaultLanguage(const QString& language) = 0; /** * Get the default language of the document. * * \return Default language of the document * \since 4.1 */ virtual void defaultLanguage(const QString& language) const = 0; /** * Sets the language for a range in the document. Any existing language settings * for this range are overridden. * * \param range Range of the document for which the language is set * \param language New language for the given range * \since 4.1 */ virtual void changeLanguage(const KTextEditor::Range& range, const QString& language) = 0; /** * Sets the languages for specific ranges in the document. * * \param list List of range-language pairs; the ranges must be non-overlapping * \since 4.1 */ virtual void setDocumentLanguages(const QList >& list) = 0; /** * Clears the languages set for different document ranges. * \since 4.1 */ virtual void clearDocumentLanguages() = 0; /** * Returns the range-language pairs for the current document. * * \return List of range-language pairs * \since 4.1 */ virtual QList > documentLanguages() const = 0; /** * Returns the Speller object which is used for the spell checking. * * \return Speller object that is used for spell checking * \since 4.1 **/ virtual Sonnet::Speller speller() const = 0; /** * Sets the Speller object that is used for spell checking. * * \param speller Speller object that should be used for spell checking * \since 4.1 */ virtual void setSpeller(const Sonnet::Speller& speller) = 0; private: class SpellcheckInterfacePrivate* const d; }; } Q_DECLARE_INTERFACE(KTextEditor::SpellcheckInterface, "org.kde.KTextEditor.SpellcheckInterface") #endif // kate: space-indent on; indent-width 2; replace-tabs on; --Boundary-00=_q7n/H+ICcxsLOk/ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ KTextEditor-Devel mailing list KTextEditor-Devel@kde.org https://mail.kde.org/mailman/listinfo/ktexteditor-devel --Boundary-00=_q7n/H+ICcxsLOk/--