~ubuntu-branches/ubuntu/vivid/kate/vivid-updates

« back to all changes in this revision

Viewing changes to addons/project/kateprojectcompletion.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-12-04 16:49:41 UTC
  • mfrom: (1.6.6)
  • Revision ID: package-import@ubuntu.com-20141204164941-l3qbvsly83hhlw2v
Tags: 4:14.11.97-0ubuntu1
* New upstream release
* Update build-deps and use pkg-kde v3 for Qt 5 build
* kate-data now kate5-data for co-installability

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the Kate project.
 
2
 *
 
3
 *  Copyright (C) 2010 Christoph Cullmann <cullmann@kde.org>
 
4
 *  Copyright (C) 2003 Anders Lund <anders.lund@lund.tdcadsl.dk>
 
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 KATE_PROJECT_COMPLETION_H
 
23
#define KATE_PROJECT_COMPLETION_H
 
24
 
 
25
#include <ktexteditor/view.h>
 
26
#include <ktexteditor/codecompletionmodel.h>
 
27
#include <ktexteditor/codecompletionmodelcontrollerinterface.h>
 
28
 
 
29
#include <QStandardItemModel>
 
30
 
 
31
/**
 
32
 * Project wide completion support.
 
33
 */
 
34
class KateProjectCompletion : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface
 
35
{
 
36
    Q_OBJECT
 
37
 
 
38
    Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface)
 
39
 
 
40
public:
 
41
    /**
 
42
     * Construct project completion.
 
43
     * @param plugin our plugin
 
44
     */
 
45
    KateProjectCompletion(class KateProjectPlugin *plugin);
 
46
 
 
47
    /**
 
48
     * Deconstruct project completion.
 
49
     */
 
50
    ~KateProjectCompletion();
 
51
 
 
52
    /**
 
53
     * This function is responsible to generating / updating the list of current
 
54
     * completions. The default implementation does nothing.
 
55
     *
 
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
 
61
     * */
 
62
    void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType);
 
63
 
 
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 &currentCompletion);
 
66
 
 
67
    void saveMatches(KTextEditor::View *view,
 
68
                     const KTextEditor::Range &range);
 
69
 
 
70
    int rowCount(const QModelIndex &parent) const;
 
71
 
 
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);
 
76
 
 
77
    virtual KTextEditor::Range completionRange(KTextEditor::View *view, const KTextEditor::Cursor &position);
 
78
 
 
79
    void allMatches(QStandardItemModel &model, KTextEditor::View *view, const KTextEditor::Range &range) const;
 
80
 
 
81
private:
 
82
    /**
 
83
     * our plugin view
 
84
     */
 
85
    KateProjectPlugin *m_plugin;
 
86
 
 
87
    /**
 
88
     * model with matching data
 
89
     */
 
90
    QStandardItemModel m_matches;
 
91
 
 
92
    /**
 
93
     * automatic invocation?
 
94
     */
 
95
    bool m_automatic;
 
96
};
 
97
 
 
98
#endif
 
99