QCodeEdit
2.2
|
00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr> 00004 ** 00005 ** This file is part of the Edyuk project <http://edyuk.org> 00006 ** 00007 ** This file may be used under the terms of the GNU General Public License 00008 ** version 3 as published by the Free Software Foundation and appearing in the 00009 ** file GPL.txt included in the packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ****************************************************************************/ 00015 00016 #ifndef _QCOMPLETION_ENGINE_H_ 00017 #define _QCOMPLETION_ENGINE_H_ 00018 00019 #include "qce-config.h" 00020 00026 #include "qdocumentcursor.h" 00027 00028 #include <QObject> 00029 #include <QPointer> 00030 #include <QStringList> 00031 00032 class QEditor; 00033 class QAction; 00034 class QKeyEvent; 00035 class QCodeModel; 00036 class QCodeStream; 00037 00038 class QCE_EXPORT QCodeCompletionEngine : public QObject 00039 { 00040 Q_OBJECT 00041 00042 public: 00043 QCodeCompletionEngine(QObject *p = 0); 00044 virtual ~QCodeCompletionEngine(); 00045 00046 virtual QCodeCompletionEngine* clone() = 0; 00047 00048 virtual QString language() const = 0; 00049 virtual QStringList extensions() const = 0; 00050 00051 QAction* triggerAction() const; 00052 00053 QEditor* editor() const; 00054 void setEditor(QEditor *e); 00055 00056 QStringList triggers() const; 00057 00058 void addTrigger(const QString& s); 00059 void removeTrigger(const QString& s); 00060 00061 virtual void setCodeModel(QCodeModel *m); 00062 00063 virtual void retranslate(); 00064 00065 signals: 00066 void popup(); 00067 void cloned(QCodeCompletionEngine *e); 00068 void completionTriggered(const QString& s); 00069 00070 public slots: 00071 void complete(); 00072 void textEdited(QKeyEvent *e); 00073 00074 protected: 00075 virtual void run(); 00076 virtual bool eventFilter(QObject *o, QEvent *e); 00077 00078 virtual void complete(QCodeStream *s, const QString& trigger); 00079 virtual void complete(const QDocumentCursor& c, const QString& trigger); 00080 00081 private: 00082 int m_max; 00083 QString m_trig; 00084 QDocumentCursor m_cur; 00085 QAction *pForcedTrigger; 00086 00087 QStringList m_triggers; 00088 00089 QPointer<QEditor> pEdit; 00090 }; 00091 00092 #endif // _QCOMPLETION_ENGINE_H_