• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • completion
katecompletionwidget.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries and the Kate part.
2  *
3  * Copyright (C) 2005-2006 Hamish Rodda <rodda@kde.org>
4  * Copyright (C) 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef KATECOMPLETIONWIDGET_H
23 #define KATECOMPLETIONWIDGET_H
24 
25 #include <QtGui/QFrame>
26 #include <QObject>
27 
28 #include "katepartprivate_export.h"
29 
30 #include <ktexteditor/movingrange.h>
31 #include <ktexteditor/codecompletioninterface.h>
32 #include <ktexteditor/codecompletionmodel.h>
33 
34 class QToolButton;
35 class QPushButton;
36 class QLabel;
37 class QTimer;
38 
39 class KateView;
40 class KateCompletionModel;
41 class KateCompletionTree;
42 class KateArgumentHintTree;
43 class KateArgumentHintModel;
44 
45 namespace KTextEditor {
46  class EmbeddedWidgetInterface;
47 }
48 
55 class KATEPART_TESTS_EXPORT KateCompletionWidget : public QFrame
56 {
57  Q_OBJECT
58 
59  public:
60  explicit KateCompletionWidget(KateView* parent);
61  ~KateCompletionWidget();
62 
63  KateView* view() const;
64  KateCompletionTree* treeView() const;
65 
66  bool isCompletionActive() const;
67  void startCompletion(KTextEditor::CodeCompletionModel::InvocationType invocationType, const QList<KTextEditor::CodeCompletionModel*>& models = QList<KTextEditor::CodeCompletionModel*>());
68  void startCompletion(const KTextEditor::Range& word, KTextEditor::CodeCompletionModel* model, KTextEditor::CodeCompletionModel::InvocationType invocationType = KTextEditor::CodeCompletionModel::ManualInvocation);
69  void startCompletion(const KTextEditor::Range& word, const QList<KTextEditor::CodeCompletionModel*>& models = QList<KTextEditor::CodeCompletionModel*>(), KTextEditor::CodeCompletionModel::InvocationType invocationType = KTextEditor::CodeCompletionModel::ManualInvocation);
70  void userInvokedCompletion();
71 
72  public Q_SLOTS:
73  //Executed when return is pressed while completion is active.
74  void execute();
75  void cursorDown();
76  void cursorUp();
77 
78  public:
79  void tab(bool shift);
80 
82  bool toggleExpanded(bool forceExpand = false, bool forceUnExpand = false);
83 
84  const KateCompletionModel* model() const;
85  KateCompletionModel* model();
86 
87  void registerCompletionModel(KTextEditor::CodeCompletionModel* model);
88  void unregisterCompletionModel(KTextEditor::CodeCompletionModel* model);
89 
90  int automaticInvocationDelay() const;
91  void setAutomaticInvocationDelay(int delay);
92 
93  struct CompletionRange{
94  CompletionRange() : range(0) {
95  }
96  CompletionRange(KTextEditor::MovingRange* r) : range(r) {
97  }
98 
99  bool operator==(const CompletionRange& rhs) const {
100  return range->toRange() == rhs.range->toRange();
101  }
102 
103  KTextEditor::MovingRange* range;
104  //Whenever the cursor goes before this position, the completion is stopped, unless it is invalid.
105  KTextEditor::Cursor leftBoundary;
106  };
107 
108  KTextEditor::MovingRange* completionRange(KTextEditor::CodeCompletionModel* model = 0) const;
109  QMap<KTextEditor::CodeCompletionModel*, CompletionRange> completionRanges( ) const;
110 
111  // Navigation
112  void pageDown();
113  void pageUp();
114  void top();
115  void bottom();
116 
117  QWidget* currentEmbeddedWidget();
118 
119  bool canExpandCurrentItem() const;
120 
121  bool canCollapseCurrentItem() const;
122 
123  void setCurrentItemExpanded( bool );
124 
125  //Returns true if a screen border has been hit
126  bool updatePosition(bool force = false);
127 
128  virtual bool eventFilter( QObject * watched, QEvent * event );
129 
130  KateArgumentHintTree* argumentHintTree() const;
131 
132  KateArgumentHintModel* argumentHintModel() const;
133 
135 
136  void updateHeight();
137 
138  public Q_SLOTS:
139  void waitForModelReset();
140 
141  void abortCompletion();
142  void showConfig();
143 /* void viewFocusIn();
144  void viewFocusOut();*/
145  void updatePositionSlot();
146  void automaticInvocation();
147 
148 /* void updateFocus();*/
149  void argumentHintsChanged(bool hasContent);
150 
151  bool navigateUp();
152  bool navigateDown();
153  bool navigateLeft();
154  bool navigateRight();
155  bool navigateAccept();
156  bool navigateBack();
157 
158  bool hadNavigation() const;
159  void resetHadNavigation();
160 
161  protected:
162  virtual void showEvent ( QShowEvent * event );
163  virtual void resizeEvent ( QResizeEvent * event );
164 // virtual void focusInEvent ( QFocusEvent * event );
165 
166  private Q_SLOTS:
167  void completionModelReset();
168  void modelDestroyed(QObject* model);
169  void modelContentChanged();
170  void cursorPositionChanged();
171  void modelReset();
172  void rowsInserted(const QModelIndex& parent, int row, int rowEnd);
173  void viewFocusOut();
174 
175  void wrapLine (const KTextEditor::Cursor &position);
176  void unwrapLine (int line);
177  void insertText (const KTextEditor::Cursor &position, const QString &text);
178  void removeText (const KTextEditor::Range &range);
179 
180  private:
181  void updateAndShow();
182  void updateArgumentHintGeometry();
183  QModelIndex selectedIndex() const;
184 
185  void clear();
186  //Switch cursor between argument-hint list / completion-list
187  void switchList();
188  KTextEditor::Range determineRange() const;
189  void completionRangeChanged(KTextEditor::CodeCompletionModel*, const KTextEditor::Range& word);
190 
191  void deleteCompletionRanges();
192 
193  QList<KTextEditor::CodeCompletionModel*> m_sourceModels;
194  KateCompletionModel* m_presentationModel;
195 
196  QMap<KTextEditor::CodeCompletionModel*, CompletionRange> m_completionRanges;
197  QSet<KTextEditor::CodeCompletionModel*> m_waitingForReset;
198 
199  KTextEditor::Cursor m_lastCursorPosition;
200 
201  KateCompletionTree* m_entryList;
202  KateArgumentHintModel* m_argumentHintModel;
203  KateArgumentHintTree* m_argumentHintTree;
204 
205  QTimer* m_automaticInvocationTimer;
206  //QTimer* m_updateFocusTimer;
207  QWidget* m_statusBar;
208  QToolButton* m_sortButton;
209  QLabel* m_sortText;
210  QToolButton* m_filterButton;
211  QLabel* m_filterText;
212  QPushButton* m_configButton;
213 
214  KTextEditor::Cursor m_automaticInvocationAt;
215  QString m_automaticInvocationLine;
216  int m_automaticInvocationDelay;
217  bool m_filterInstalled;
218 
219  class KateCompletionConfig* m_configWidget;
220  bool m_lastInsertionByUser;
221  bool m_inCompletionList; //Are we in the completion-list? If not, we're in the argument-hint list
222  bool m_isSuspended;
223  bool m_dontShowArgumentHints; //Used temporarily to prevent flashing
224  bool m_needShow;
225 
226  bool m_hadCompletionNavigation;
227 
228  bool m_haveExactMatch;
229 
230  bool m_noAutoHide;
231 
235  bool m_completionEditRunning;
236 
237  int m_expandedAddedHeightBase;
238  KTextEditor::CodeCompletionModel::InvocationType m_lastInvocationType;
239 };
240 
241 #endif
KateCompletionWidget::CompletionRange::CompletionRange
CompletionRange(KTextEditor::MovingRange *r)
Definition: katecompletionwidget.h:96
QModelIndex
QEvent
QResizeEvent
QWidget
KateArgumentHintModel
Definition: kateargumenthintmodel.h:30
QMap
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
KateCompletionModel
This class has the responsibility for filtering, sorting, and manipulating code completion data provi...
Definition: katecompletionmodel.h:48
KateCompletionWidget::CompletionRange::operator==
bool operator==(const CompletionRange &rhs) const
Definition: katecompletionwidget.h:99
KateArgumentHintTree
Definition: kateargumenthinttree.h:30
QWidget::showEvent
virtual void showEvent(QShowEvent *event)
KateCompletionWidget::CompletionRange::CompletionRange
CompletionRange()
Definition: katecompletionwidget.h:94
KateCompletionWidget
This is the code completion's main widget, and also contains the core interface logic.
Definition: katecompletionwidget.h:55
QTimer
QShowEvent
QObject
katepartprivate_export.h
QObject::eventFilter
virtual bool eventFilter(QObject *watched, QEvent *event)
QSet< KTextEditor::CodeCompletionModel * >
QString
QList< KTextEditor::CodeCompletionModel * >
KateView
Definition: kateview.h:77
QToolButton
QFrame
KateCompletionWidget::CompletionRange::leftBoundary
KTextEditor::Cursor leftBoundary
Definition: katecompletionwidget.h:105
KateCompletionWidget::CompletionRange::range
KTextEditor::MovingRange * range
Definition: katecompletionwidget.h:103
QPushButton
KateCompletionConfig
Definition: katecompletionconfig.h:36
QWidget::resizeEvent
virtual void resizeEvent(QResizeEvent *event)
KateCompletionTree
Definition: katecompletiontree.h:32
QLabel
KateCompletionWidget::CompletionRange
Definition: katecompletionwidget.h:93
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal