source: trunk/tools/designer/editor/completion.h

Last change on this file was 197, checked in by rudi, 14 years ago

Added QtDesigner

File size: 3.1 KB
Line 
1 /**********************************************************************
2** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
3**
4** This file is part of Qt Designer.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12** licenses may use this file in accordance with the Qt Commercial License
13** Agreement provided with the Software.
14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17**
18** See http://www.trolltech.com/gpl/ for GPL licensing information.
19** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20** information about Qt Commercial License Agreements.
21**
22** Contact info@trolltech.com if any conditions of this licensing are
23** not clear to you.
24**
25**********************************************************************/
26
27#ifndef COMPLETION_H
28#define COMPLETION_H
29
30#include <qstring.h>
31#include <qstringlist.h>
32#include <qobject.h>
33#include <qmap.h>
34
35class QTextDocument;
36class Editor;
37class QVBox;
38class QListBox;
39class ArgHintWidget;
40
41struct CompletionEntry
42{
43 QString type;
44 QString text;
45 QString postfix;
46 QString prefix;
47 QString postfix2;
48
49 bool operator==( const CompletionEntry &c ) const {
50 return ( c.type == type &&
51 c.text == text &&
52 c.postfix == postfix &&
53 c.prefix == prefix &&
54 c.postfix2 == postfix2 );
55 }
56};
57
58class EditorCompletion : public QObject
59{
60 Q_OBJECT
61
62public:
63 EditorCompletion( Editor *e );
64 ~EditorCompletion();
65
66 virtual void addCompletionEntry( const QString &s, QTextDocument *doc, bool strict );
67 virtual QValueList<CompletionEntry> completionList( const QString &s, QTextDocument *doc ) const;
68 virtual void updateCompletionMap( QTextDocument *doc );
69
70 bool eventFilter( QObject *o, QEvent *e );
71 virtual void setCurrentEdior( Editor *e );
72 virtual bool doCompletion();
73 virtual bool doObjectCompletion();
74 virtual bool doObjectCompletion( const QString &object );
75 virtual bool doArgumentHint( bool useIndex );
76
77 virtual void addEditor( Editor *e );
78 virtual QValueList<QStringList> functionParameters( const QString &func, QChar &, QString &prefix, QString &postfix );
79
80 virtual void setContext( QObject *this_ );
81
82 void setEnabled( bool b ) { enabled = b; }
83
84protected:
85 virtual bool continueComplete();
86 virtual void showCompletion( const QValueList<CompletionEntry> &lst );
87 virtual void completeCompletion();
88
89protected:
90 QVBox *completionPopup;
91 QListBox *completionListBox;
92 ArgHintWidget *functionLabel;
93 int completionOffset;
94 Editor *curEditor;
95 QString searchString;
96 QValueList<CompletionEntry> cList;
97 QMap<QChar, QStringList> completionMap;
98 bool enabled;
99 QTextDocument *lastDoc;
100
101};
102
103#endif
Note: See TracBrowser for help on using the repository browser.