File indexing completed on 2024-05-19 04:00:03

0001 /*
0002     SPDX-FileCopyrightText: 2001 Joseph Wenninger <jowenn@kde.org>
0003     SPDX-FileCopyrightText: 2013-2014 Dominik Haumann <dhaumann@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KTEXTEDITOR_TEXTHINTINTERFACE_H
0009 #define KTEXTEDITOR_TEXTHINTINTERFACE_H
0010 
0011 #include <QString>
0012 
0013 #include <ktexteditor_export.h>
0014 
0015 #include <ktexteditor/cursor.h>
0016 
0017 namespace KTextEditor
0018 {
0019 class TextHintProvider;
0020 class View;
0021 
0022 /**
0023  * \brief Class to provide text hints for a View.
0024  *
0025  * The class TextHintProvider is used in combination with TextHintInterface.
0026  * TextHintProvider allows to provide text hint information for text under
0027  * the mouse cursor.
0028  *
0029  * To use this class, derive your provider from TextHintProvider and register
0030  * it with TextHintInterface::registerTextHintProvider(). When not needed
0031  * anymore, make sure to remove your provider by calling
0032  * TextHintInterface::unregisterTextHintProvider(), otherwise the View will
0033  * contain a dangling pointer to your potentially deleted provider.
0034  *
0035  * Detailed information about how to use the TextHintInterface can be found
0036  * in the documentation about the TextHintInterface.
0037  *
0038  * \see TextHintInterface
0039  * \p since 5.0
0040  */
0041 class KTEXTEDITOR_EXPORT TextHintProvider
0042 {
0043 public:
0044     /**
0045      * Default constructor.
0046      */
0047     TextHintProvider();
0048 
0049     /**
0050      * Virtual destructor to allow inheritance.
0051      */
0052     virtual ~TextHintProvider();
0053 
0054     /**
0055      * This function is called whenever the users hovers over text such
0056      * that the text hint delay passes. Then, textHint() is called
0057      * for each registered TextHintProvider.
0058      *
0059      * Return the text hint (possibly Qt richtext) for @p view at @p position.
0060      *
0061      * If you do not have any contents to show, just return an empty QString().
0062      *
0063      * \param view the view that requests the text hint
0064      * \param position text cursor under the mouse position
0065      * \return text tool tip to be displayed, may be Qt richtext
0066      */
0067     virtual QString textHint(KTextEditor::View *view, const KTextEditor::Cursor &position) = 0;
0068 
0069 private:
0070     class TextHintProviderPrivate *const d = nullptr;
0071 };
0072 
0073 }
0074 
0075 #endif