Eneboo - Documentación para desarrolladores
|
00001 /********************************************************************** 00002 ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved. 00003 ** 00004 ** This file is part of Qt Designer. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00012 ** licenses may use this file in accordance with the Qt Commercial License 00013 ** Agreement provided with the Software. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00020 ** information about Qt Commercial License Agreements. 00021 ** 00022 ** Contact info@trolltech.com if any conditions of this licensing are 00023 ** not clear to you. 00024 ** 00025 **********************************************************************/ 00026 00027 #ifndef COMPLETION_H 00028 #define COMPLETION_H 00029 00030 #include <qstring.h> 00031 #include <qstringlist.h> 00032 #include <qobject.h> 00033 #include <qmap.h> 00034 00035 class QTextDocument; 00036 class Editor; 00037 class QVBox; 00038 class QListBox; 00039 class ArgHintWidget; 00040 00041 struct CompletionEntry 00042 { 00043 QString type; 00044 QString text; 00045 QString postfix; 00046 QString prefix; 00047 QString postfix2; 00048 00049 bool operator==( const CompletionEntry &c ) const { 00050 return ( c.type == type && 00051 c.text == text && 00052 c.postfix == postfix && 00053 c.prefix == prefix && 00054 c.postfix2 == postfix2 ); 00055 } 00056 }; 00057 00058 class EditorCompletion : public QObject 00059 { 00060 Q_OBJECT 00061 00062 public: 00063 EditorCompletion( Editor *e ); 00064 ~EditorCompletion(); 00065 00066 virtual void addCompletionEntry( const QString &s, QTextDocument *doc, bool strict ); 00067 virtual QValueList<CompletionEntry> completionList( const QString &s, QTextDocument *doc ) const; 00068 virtual void updateCompletionMap( QTextDocument *doc ); 00069 00070 bool eventFilter( QObject *o, QEvent *e ); 00071 virtual void setCurrentEdior( Editor *e ); 00072 virtual bool doCompletion(); 00073 virtual bool doObjectCompletion(); 00074 virtual bool doObjectCompletion( const QString &object ); 00075 virtual bool doArgumentHint( bool useIndex ); 00076 00077 virtual void addEditor( Editor *e ); 00078 virtual QValueList<QStringList> functionParameters( const QString &func, QChar &, QString &prefix, QString &postfix ); 00079 00080 virtual void setContext( QObject *this_ ); 00081 00082 void setEnabled( bool b ) { enabled = b; } 00083 00084 protected: 00085 virtual bool continueComplete(); 00086 virtual void showCompletion( const QValueList<CompletionEntry> &lst ); 00087 virtual void completeCompletion(); 00088 00089 protected: 00090 QVBox *completionPopup; 00091 QListBox *completionListBox; 00092 ArgHintWidget *functionLabel; 00093 int completionOffset; 00094 Editor *curEditor; 00095 QString searchString; 00096 QValueList<CompletionEntry> cList; 00097 QMap<QChar, QStringList> completionMap; 00098 bool enabled; 00099 QTextDocument *lastDoc; 00100 00101 }; 00102 00103 #endif