QCodeEdit  2.2
qcodecompletionengine.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
4 **
5 ** This file is part of the Edyuk project <http://edyuk.org>
6 **
7 ** This file may be used under the terms of the GNU General Public License
8 ** version 3 as published by the Free Software Foundation and appearing in the
9 ** file GPL.txt included in the packaging of this file.
10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 **
14 ****************************************************************************/
15 
16 #ifndef _QCOMPLETION_ENGINE_H_
17 #define _QCOMPLETION_ENGINE_H_
18 
19 #include "qce-config.h"
20 
26 #include "qdocumentcursor.h"
27 
28 #include <QObject>
29 #include <QPointer>
30 #include <QStringList>
31 
32 class QEditor;
33 class QAction;
34 class QKeyEvent;
35 class QCodeModel;
36 class QCodeStream;
37 
39 {
40  Q_OBJECT
41 
42  public:
44  virtual ~QCodeCompletionEngine();
45 
46  virtual QCodeCompletionEngine* clone() = 0;
47 
48  virtual QString language() const = 0;
49  virtual QStringList extensions() const = 0;
50 
51  QAction* triggerAction() const;
52 
53  QEditor* editor() const;
54  void setEditor(QEditor *e);
55 
56  QStringList triggers() const;
57 
58  void addTrigger(const QString& s);
59  void removeTrigger(const QString& s);
60 
61  virtual void setCodeModel(QCodeModel *m);
62 
63  virtual void retranslate();
64 
65  signals:
66  void popup();
67  void cloned(QCodeCompletionEngine *e);
68  void completionTriggered(const QString& s);
69 
70  public slots:
71  void complete();
72  void textEdited(QKeyEvent *e);
73 
74  protected:
75  virtual void run();
76  virtual bool eventFilter(QObject *o, QEvent *e);
77 
78  virtual void complete(QCodeStream *s, const QString& trigger);
79  virtual void complete(const QDocumentCursor& c, const QString& trigger);
80 
81  private:
82  int m_max;
83  QString m_trig;
84  QDocumentCursor m_cur;
85  QAction *pForcedTrigger;
86 
87  QStringList m_triggers;
88 
89  QPointer<QEditor> pEdit;
90 };
91 
92 #endif // _QCOMPLETION_ENGINE_H_