1
/* This file is part of the Kate project.
3
* Copyright (C) 2010 Christoph Cullmann <cullmann@kde.org>
4
* Copyright (C) 2003 Anders Lund <anders.lund@lund.tdcadsl.dk>
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.
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.
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.
22
#ifndef KATE_PROJECT_COMPLETION_H
23
#define KATE_PROJECT_COMPLETION_H
25
#include <ktexteditor/view.h>
26
#include <ktexteditor/codecompletionmodel.h>
27
#include <ktexteditor/codecompletionmodelcontrollerinterface.h>
29
#include <QStandardItemModel>
32
* Project wide completion support.
34
class KateProjectCompletion : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface
38
Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface)
42
* Construct project completion.
43
* @param plugin our plugin
45
KateProjectCompletion(class KateProjectPlugin *plugin);
48
* Deconstruct project completion.
50
~KateProjectCompletion();
53
* This function is responsible to generating / updating the list of current
54
* completions. The default implementation does nothing.
56
* When implementing this function, remember to call setRowCount() (or implement
57
* rowCount()), and to generate the appropriate change notifications (for instance
58
* by calling QAbstractItemModel::reset()).
59
* @param view The view to generate completions for
60
* @param range The range of text to generate completions for
62
void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType);
64
bool shouldStartCompletion(KTextEditor::View *view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position);
65
bool shouldAbortCompletion(KTextEditor::View *view, const KTextEditor::Range &range, const QString ¤tCompletion);
67
void saveMatches(KTextEditor::View *view,
68
const KTextEditor::Range &range);
70
int rowCount(const QModelIndex &parent) const;
72
QVariant data(const QModelIndex &index, int role) const;
73
virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
74
virtual QModelIndex parent(const QModelIndex &index) const;
75
virtual MatchReaction matchingItem(const QModelIndex &matched);
77
virtual KTextEditor::Range completionRange(KTextEditor::View *view, const KTextEditor::Cursor &position);
79
void allMatches(QStandardItemModel &model, KTextEditor::View *view, const KTextEditor::Range &range) const;
85
KateProjectPlugin *m_plugin;
88
* model with matching data
90
QStandardItemModel m_matches;
93
* automatic invocation?