itom
Loading...
Searching...
No Matches
wordHoverTooltip.h
1
2
3/* ********************************************************************
4 itom software
5 URL: http://www.uni-stuttgart.de/ito
6 Copyright (C) 2020, Institut für Technische Optik (ITO),
7 Universität Stuttgart, Germany
8
9 This file is part of itom.
10
11 itom is free software; you can redistribute it and/or modify it
12 under the terms of the GNU Library General Public Licence as published by
13 the Free Software Foundation; either version 2 of the Licence, or (at
14 your option) any later version.
15
16 itom is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
19 General Public Licence for more details.
20
21 You should have received a copy of the GNU Library General Public License
22 along with itom. If not, see <http://www.gnu.org/licenses/>.
23
24 Further hints:
25 ------------------------
26
27 This file belongs to the code editor of itom. The code editor is
28 in major parts a fork / rewritten version of the python-based source
29 code editor PyQode from Colin Duquesnoy and others
30 (see https://github.com/pyQode). PyQode itself is licensed under
31 the MIT License (MIT).
32
33 Some parts of the code editor of itom are also inspired by the
34 source code editor of the Spyder IDE (https://github.com/spyder-ide),
35 also licensed under the MIT License and developed by the Spyder Project
36 Contributors.
37
38*********************************************************************** */
39
40#pragma once
41
42/*
43This module contains the WordHoverTooltipMode
44*/
45
46#include "../mode.h"
47#include "../textDecoration.h"
48#include "../delayJobRunner.h"
49#include "../../python/pythonJedi.h"
50#include <qobject.h>
51#include <qstring.h>
52#include <qtextcursor.h>
53#include <qevent.h>
54#include <qvector.h>
55#include <qpair.h>
56
57namespace ito {
58
59/*
60Adds support for tooltips when hovering words in a script.
61
62
63*/
64class WordHoverTooltipMode : public QObject, public Mode
65{
66 Q_OBJECT
67public:
68 WordHoverTooltipMode(const QString &name = "WordHoverTooltipMode", const QString &description = "", QObject *parent = nullptr);
69 virtual ~WordHoverTooltipMode();
70
71 virtual void onStateChanged(bool state);
72
73 void hideTooltip();
74
75protected:
76 QTextCursor m_cursor;
77
78 void emitWordHover(QTextCursor cursor);
79
80 /*
81 \returns (stringlist os signatures, docstring)
82 */
83 QPair<QStringList, QString> parseTooltipDocstring(const QString &docstring) const;
84
85private:
86 DelayJobRunnerBase *m_pTimer;
87 QObject *m_pPythonEngine;
88 int m_requestCount;
89 int m_tooltipsMaxLength;
90 bool m_tooltipVisible;
91
92private slots:
93 void onMouseMoved(QMouseEvent *e);
94 void onJediGetHelpResultAvailable(QVector<ito::JediGetHelp> helps);
95
96};
97
98} //end namespace ito
Definition delayJobRunner.h:55
Definition mode.h:70
Definition wordHoverTooltip.h:65
Definition apiFunctionsGraph.cpp:40