• 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
katewordcompletion.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) 2003 Anders Lund <anders.lund@lund.tdcadsl.dk>
4  * Copyright (C) 2010 Christoph Cullmann <cullmann@kde.org>
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 _KateWordCompletion_h_
23 #define _KateWordCompletion_h_
24 
25 #include <ktexteditor/plugin.h>
26 #include <ktexteditor/view.h>
27 #include <ktexteditor/codecompletioninterface.h>
28 #include <ktexteditor/codecompletionmodel.h>
29 #include <ktexteditor/configpage.h>
30 #include "codecompletionmodelcontrollerinterfacev4.h"
31 #include <kxmlguiclient.h>
32 
33 #include <QtCore/QEvent>
34 #include <QtCore/QObject>
35 #include <QtCore/QList>
36 
37 #include <kdebug.h>
38 
39 class KATEPART_TESTS_EXPORT KateWordCompletionModel : public KTextEditor::CodeCompletionModel2, public KTextEditor::CodeCompletionModelControllerInterface4
40 {
41  Q_OBJECT
42  Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface4)
43  public:
44  KateWordCompletionModel( QObject *parent );
45  ~KateWordCompletionModel();
46 
57  void completionInvoked(KTextEditor::View* view, const KTextEditor::Range& range, InvocationType invocationType);
58 
59  bool shouldStartCompletion(KTextEditor::View* view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position);
60  bool shouldAbortCompletion(KTextEditor::View* view, const KTextEditor::Range &range, const QString &currentCompletion);
61 
62  void saveMatches( KTextEditor::View* view,
63  const KTextEditor::Range& range);
64 
65  int rowCount ( const QModelIndex & parent ) const;
66 
67  QVariant data(const QModelIndex& index, int role) const;
68  virtual QModelIndex index(int row, int column, const QModelIndex& parent=QModelIndex()) const;
69  virtual QModelIndex parent(const QModelIndex& index) const;
70  virtual MatchReaction matchingItem(const QModelIndex& matched);
71 
72  virtual KTextEditor::Range completionRange(KTextEditor::View* view, const KTextEditor::Cursor &position);
73 
74  virtual bool shouldHideItemsWithEqualNames() const;
75 
76  QStringList allMatches( KTextEditor::View *view, const KTextEditor::Range &range ) const;
77 
78  virtual void executeCompletionItem2(KTextEditor::Document* document, const KTextEditor::Range& word, const QModelIndex& index) const;
79 
80  private:
81  QStringList m_matches;
82  bool m_automatic;
83 };
84 
85 class KateWordCompletionView : public QObject
86 {
87  Q_OBJECT
88 
89  public:
90  KateWordCompletionView(KTextEditor::View *view, KActionCollection* ac );
91  ~KateWordCompletionView();
92 
93  private Q_SLOTS:
94  void completeBackwards();
95  void completeForwards();
96  void slotCursorMoved();
97 
98  void shellComplete();
99 
100  void popupCompletionList();
101 
102  private:
103  void complete( bool fw=true );
104 
105  QString word() const;
106  KTextEditor::Range range() const;
107 
108  QString findLongestUnique( const QStringList &matches, int lead ) const;
109 
110  KTextEditor::View *m_view;
111  KateWordCompletionModel *m_dWCompletionModel;
112  struct KateWordCompletionViewPrivate *d;
113 };
114 
115 #endif // _DocWordCompletionPlugin_h_
116 
117 // kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
QModelIndex
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
KateWordCompletionView::~KateWordCompletionView
~KateWordCompletionView()
Definition: katewordcompletion.cpp:364
codecompletionmodelcontrollerinterfacev4.h
QObject
QString
QStringList
KTextEditor::CodeCompletionModelControllerInterface4
Extension of CodeCompletionModelControllerInterface3.
Definition: codecompletionmodelcontrollerinterfacev4.h:32
KateWordCompletionView
Definition: katewordcompletion.h:85
KateWordCompletionModel
Definition: katewordcompletion.h:39
KateWordCompletionView::KateWordCompletionView
KateWordCompletionView(KTextEditor::View *view, KActionCollection *ac)
Definition: katewordcompletion.cpp:322
KTextEditor::CodeCompletionModelControllerInterface4::shouldHideItemsWithEqualNames
virtual bool shouldHideItemsWithEqualNames() const
When multiple completion models are used at the same time, it may happen that multiple models add ite...
Definition: codecompletionmodelcontrollerinterfacev4.cpp:25
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:59 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