David Faure faure at
Fri Sep 24 20:40:26 BST 2010

I just committed a KParts::TextExtension, so that kparts plugins (babelfish, 
kttsplugin etc.) or web browsers themselves can get information such as:
bool hasSelection(), QString selectedText(Format format), QString 
completeText(Format format) and signal selectionChanged(),
in a web-browser-engine independent way.

The api is below for post-commit review :-)
Now is a good time to ask for more virtual methods in there.

The reason I'm posting this here, is to let other kpart authors know about it.
For instance if katepart provides this extension then babelfish and text-to-
speech would also work with it (e.g. in konqueror).

I'll commit (kdebase) on Monday, 
it leads to a pretty nice cleanup of that code.

Question: when can I commit extragear/base/konq-plugins/babelfish, i.e. when 
can it depend on kdelibs trunk?

Question for webkit-devel: when can I commit the use of TextExtension to 


 * @short an extension for KParts that allows to retrieve text from the part.
 * For instance, the text-to-speech plugin uses this to speak the whole text
 * from the part or the selected text. The translation plugin uses it for
 * translating the selected text, and so on.
 * @since 4.6
class KPARTS_EXPORT TextExtension : public QObject
    TextExtension(KParts::ReadOnlyPart* parent);

     * Queries @p obj for a child object which inherits from this
     * TextExtension class.
    static TextExtension *childObject( QObject *obj );

    enum Format { PlainText, HTML };

     * Returns true if the user selected text in the part.
    virtual bool hasSelection() const;
     * Returns the selected text, in the requested format.
     * If the format is not supported, the part must return an empty string.
    virtual QString selectedText(Format format) const;
     * Returns the complete text shown in the part, in the requested format.
     * If the format is not supported, the part must return an empty string.
    virtual QString completeText(Format format) const;

    // future extensions can be made via slots

     * This signal is emitted when the selection changes.
    void selectionChanged();

    // for future extensions
    TextExtensionPrivate* const d;

David Faure, faure at,
Sponsored by Nokia to work on KDE, incl. Konqueror (

More information about the kde-core-devel mailing list