itom  4.1.0
pyCalltips.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 
22  Further hints:
23  ------------------------
24 
25  This file belongs to the code editor of itom. The code editor is
26  in major parts a fork / rewritten version of the python-based source
27  code editor PyQode from Colin Duquesnoy and others
28  (see https://github.com/pyQode). PyQode itself is licensed under
29  the MIT License (MIT).
30 
31  Some parts of the code editor of itom are also inspired by the
32  source code editor of the Spyder IDE (https://github.com/spyder-ide),
33  also licensed under the MIT License and developed by the Spyder Project
34  Contributors.
35 
36 *********************************************************************** */
37 
38 #ifndef PYCALLTIPS_H
39 #define PYCALLTIPS_H
40 
41 
42 #include "../../python/pythonJedi.h"
43 
44 #include "../utils/utils.h"
45 #include "../toolTip.h"
46 #include "../mode.h"
47 #include <qevent.h>
48 #include <qobject.h>
49 #include <qpair.h>
50 #include <qstring.h>
51 #include <qlist.h>
52 
53 namespace ito {
54 
55 /*
56 Contains the JediCompletionProvider class implementation.
57 */
58 
59 
60 /*
61 Shows function calltips.
62 
63 This mode shows function/method call tips in a QToolTip using
64 :meth:`jedi.Script.call_signatures`.
65 */
66 class PyCalltipsMode : public QObject, public Mode
67 {
68  Q_OBJECT
69 public:
70  PyCalltipsMode(const QString &name, const QString &description = "", QObject *parent = NULL);
71  virtual ~PyCalltipsMode();
72 
73  virtual void onStateChanged(bool state);
74 
75 private slots:
76  void onKeyReleased(QKeyEvent *e);
77  void onJediCalltipResultAvailable(QVector<ito::JediCalltip> calltips);
78 
79 signals:
80  //void jediCalltipRequested(const QString &source, int line, int col, const QString &path, const QString &encoding, QByteArray callbackFctName);
81 
82 protected:
83  void requestCalltip(const QString &source, int line, int col, const QString &encoding);
84  bool isLastChardEndOfWord() const;
85 
86 private:
87  QObject *m_pPythonEngine;
88  QList<int> m_disablingKeys;
89  int m_requestCount;
90 };
91 
92 } //end namespace ito
93 
94 #endif
Definition: apiFunctionsGraph.cpp:39
Definition: pyCalltips.h:66
Definition: mode.h:69