basehoverhandler.h 2.75 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
Leandro Melo's avatar
Leandro Melo committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
Leandro Melo's avatar
Leandro Melo committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
Leandro Melo's avatar
Leandro Melo committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
Leandro Melo's avatar
Leandro Melo committed
15 16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
Leandro Melo's avatar
Leandro Melo committed
29 30 31 32 33

#ifndef BASEHOVERHANDLER_H
#define BASEHOVERHANDLER_H

#include "texteditor_global.h"
34
#include "helpitem.h"
35
#include <texteditor/codeassist/keywordscompletionassist.h>
Leandro Melo's avatar
Leandro Melo committed
36

37
namespace Core { class IEditor; }
Leandro Melo's avatar
Leandro Melo committed
38 39 40

namespace TextEditor {

41
class BaseTextEditor;
42
class TextEditorWidget;
Leandro Melo's avatar
Leandro Melo committed
43 44 45 46

class TEXTEDITOR_EXPORT BaseHoverHandler : public QObject
{
    Q_OBJECT
hjk's avatar
hjk committed
47

Leandro Melo's avatar
Leandro Melo committed
48
public:
49
    BaseHoverHandler();
hjk's avatar
hjk committed
50
    ~BaseHoverHandler();
Leandro Melo's avatar
Leandro Melo committed
51

52 53 54
    QString contextHelpId(TextEditorWidget *widget, int pos);
    void showToolTip(TextEditorWidget *widget, const QPoint &point, int pos);

55 56 57
protected:
    void setToolTip(const QString &tooltip);
    void appendToolTip(const QString &extension);
58
    const QString &toolTip() const;
Leandro Melo's avatar
Leandro Melo committed
59

60
    void addF1ToToolTip();
Leandro Melo's avatar
Leandro Melo committed
61

62 63 64
    void setIsDiagnosticTooltip(bool isDiagnosticTooltip);
    bool isDiagnosticTooltip() const;

65 66
    void setLastHelpItemIdentified(const HelpItem &help);
    const HelpItem &lastHelpItemIdentified() const;
Leandro Melo's avatar
Leandro Melo committed
67 68

private:
69
    void clear();
70
    void process(TextEditorWidget *widget, int pos);
Leandro Melo's avatar
Leandro Melo committed
71

72
    virtual void identifyMatch(TextEditorWidget *editorWidget, int pos) = 0;
73
    virtual void decorateToolTip();
74
    virtual void operateTooltip(TextEditorWidget *editorWidget, const QPoint &point);
Leandro Melo's avatar
Leandro Melo committed
75

76
    bool m_diagnosticTooltip;
Leandro Melo's avatar
Leandro Melo committed
77
    QString m_toolTip;
78
    HelpItem m_lastHelpItemIdentified;
Leandro Melo's avatar
Leandro Melo committed
79 80 81 82 83
};

} // namespace TextEditor

#endif // BASEHOVERHANDLER_H