File: qeditorcodecompletion.h

package info (click to toggle)
kdevelop3 4%3A3.2.0-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 58,220 kB
  • ctags: 33,997
  • sloc: cpp: 278,404; ansic: 48,238; sh: 23,721; tcl: 19,882; perl: 5,498; makefile: 4,717; ruby: 1,610; python: 1,549; awk: 1,484; xml: 563; java: 359; php: 20; asm: 14; ada: 5; pascal: 4; fortran: 4; haskell: 2; sql: 1
file content (127 lines) | stat: -rw-r--r-- 4,068 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/***************************************************************************
                          qeditorcodecompletion.h  -  description
                             -------------------
  begin      : Sun Nov 18 20:00 CET 2001
  copyright  : (C) 2001 Joseph Wenninger <jowenn@kde.org>
               (C) 2002 John Firebaugh <jfirebaugh@kde.org>
               (C) 2002 Roberto Raggi <roberto@kdevelop.org>

  taken from KDEVELOP:
  begin   : Sam Jul 14 18:20:00 CEST 2001
  copyright : (C) 2001 by Victor Rder <Victor_Roeder@GMX.de>
 ***************************************************************************/

/******** Partly based on the ArgHintWidget of Qt3 by Trolltech AS *********/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef __QEditorCodeCompletion_H__
#define __QEditorCodeCompletion_H__

#include <qvaluelist.h>
#include <qstringlist.h>
#include <qvbox.h>
#include <qlistbox.h>
#include <qlabel.h>

#include <ktexteditor/codecompletioninterface.h>

class QEditorArgHint;
class QEditorView;

class QEditorCodeCompletionCommentLabel : public QLabel
{
    Q_OBJECT
public:
    QEditorCodeCompletionCommentLabel( QWidget* parent, const QString& text) : QLabel( parent, "toolTipTip",
             WStyle_StaysOnTop | WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM )
    {
        setMargin(1);
        setIndent(0);
        setAutoMask( FALSE );
        setFrameStyle( QFrame::Plain | QFrame::Box );
        setLineWidth( 1 );
        setAlignment( AlignAuto | AlignTop );
        polish();
        setText(text);
        adjustSize();
    }
};

/**
 *This class is used for providing a codecompletionbox with the same size in all editorwindows.
 *Therefor the size is stored statically and provided over sizeHint().
 *@short Codecompletion-Listbox
 */
class CCListBox : public QListBox{
public:
    CCListBox(QWidget* parent = 0, const char* name = 0, WFlags f = 0):QListBox(parent, name, f){
    	resize(m_size);
	//resize the frame containing the listbox (bad "style" but i don't know a better way)
	if (parent)
		parent->resize(m_size +  QSize(2,2));
    };

    QSize sizeHint()  const {
	return m_size;
    };

protected:
   void resizeEvent(QResizeEvent* rev){
	m_size = rev->size();
	QListBox::resizeEvent(rev);
    };

private:
    static QSize m_size;
};

class QEditorCodeCompletion : public QObject
{
  Q_OBJECT

public:
  QEditorCodeCompletion(QEditorView *view);

  void showArgHint(
      QStringList functionList, const QString& strWrapping, const QString& strDelimiter );
  void showCompletionBox(
      QValueList<KTextEditor::CompletionEntry> entries, int offset = 0, bool casesensitive = true );
  bool eventFilter( QObject* o, QEvent* e );

public slots:
  void slotCursorPosChanged();
  void showComment();

signals:
  void completionAborted();
  void completionDone();
  void argHintHidden();
  void completionDone(KTextEditor::CompletionEntry);
  void filterInsertString(KTextEditor::CompletionEntry*,QString *);

private:
  void abortCompletion();
  void complete( KTextEditor::CompletionEntry );
  void updateBox( bool newCoordinate = false );

  QEditorArgHint*    m_pArgHint;
  QEditorView*       m_view;
  QVBox*          m_completionPopup;
  CCListBox*      m_completionListBox;
  QValueList<KTextEditor::CompletionEntry> m_complList;
  uint            m_lineCursor;
  uint            m_colCursor;
  int             m_offset;
  bool            m_caseSensitive;
  QEditorCodeCompletionCommentLabel* m_commentLabel;
};

#endif