/usr/include/ktexteditor/codecompletionmodelcontrollerinterface.h is in kdelibs5-dev 4:4.13.3-0ubuntu0.5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | /* This file is part of the KDE libraries
Copyright (C) 2008 Niko Sams <niko.sams@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KDELIBS_KTEXTEDITOR_CODECOMPLETIONMODELCONTROLLERINTERFACE_H
#define KDELIBS_KTEXTEDITOR_CODECOMPLETIONMODELCONTROLLERINTERFACE_H
#include <ktexteditor/ktexteditor_export.h>
#include <ktexteditor/smartrange.h>
#include <ktexteditor/cursor.h>
#include "codecompletionmodel.h"
class QModelIndex;
namespace KTextEditor {
class View;
/**
* \short Controller interface for a CodeCompletionModel
*
* \ingroup kte_group_ccmodel_extensions
*
* The CodeCompletionModelControllerInterface gives an CodeCompletionModel better
* control over the completion.
*
* By implementing methods defined in this interface you can:
* - control when automatic completion should start (shouldStartCompletion())
* - define a custom completion range (that will be replaced when the completion
* is executed) (completionRange())
* - dynamically modify the completion range during completion (updateCompletionRange())
* - specify the string used for filtering the completion (filterString())
* - control when completion should stop (shouldAbortCompletion())
*
* When the interface is not implemented, or no methods are overridden the
* default behaviour is used, which will be correct in many situations.
*
*
* \section markext_access Implemeting the Interface
* To use this class implement it in your CodeCompletionModel.
*
* \code
* class MyCodeCompletion : public KTextEditor::CodeCompletionTestModel,
public KTextEditor::CodeCompletionModelControllerInterface
* {
* Q_OBJECT
* Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface)
* public:
* KTextEditor::Range completionRange(KTextEditor::View* view, const KTextEditor::Cursor &position);
* };
* \endcode
*
* \see CodeCompletionModel
* \author Niko Sams \<niko.sams@gmail.com\>
* \since 4.2
*/
class KTEXTEDITOR_EXPORT_DEPRECATED CodeCompletionModelControllerInterface
{
public:
CodeCompletionModelControllerInterface();
virtual ~CodeCompletionModelControllerInterface();
/**
* This function decides if the automatic completion should be started when
* the user entered some text.
*
* The default implementation will return true if the last character in
* \p insertedText is a letter, a number, '.', '_' or '\>'
*
* \param view The view to generate completions for
* \param insertedText The text that was inserted by the user
* \param userInsertion Whether the the text was inserted by the user using typing.
* If false, it may have been inserted for example by code-completion.
* \param position Current cursor position
* \return \e true, if the completion should be started, otherwise \e false
*/
virtual bool shouldStartCompletion(View* view, const QString &insertedText, bool userInsertion, const Cursor &position);
/**
* This function returns the completion range that will be used for the
* current completion.
*
* This range will be used for filtering the completion list and will get
* replaced when executing the completion
*
* The default implementation will work for most languages that don't have
* special chars in identifiers.
*
* \param view The view to generate completions for
* \param position Current cursor position
* \return the completion range
*/
virtual Range completionRange(View* view, const Cursor &position);
/**
* This function lets the CompletionModel dynamically modify the range.
* Called after every change to the range (eg. when user entered text)
*
* The default implementation does nothing.
*
* The smart-mutex is not locked when this is called.
* @warning Make sure you lock it before you change the range
*
* \param view The view to generate completions for
* \param range Reference to the current range
*/
virtual void updateCompletionRange(View* view, SmartRange& range);
/**
* This function returns the filter-text used for the current completion.
* Can return an empty string to disable filtering.
*
* The default implementation will return the text from \p range start to
* the cursor \p position.
*
* The smart-mutex is not locked when this is called.
*
* \param view The view to generate completions for
* \param range The completion range
* \param position Current cursor position
* \return the string used for filtering the completion list
*/
virtual QString filterString(View* view, const SmartRange& range, const Cursor &position);
/**
* This function decides if the completion should be aborted.
* Called after every change to the range (eg. when user entered text)
*
* The default implementation will return true when any special character was entered, or when the range is empty.
*
* The smart-mutex is not locked when this is called.
*
* \param view The view to generate completions for
* \param range The completion range
* \param currentCompletion The text typed so far
* \return \e true, if the completion should be aborted, otherwise \e false
*/
virtual bool shouldAbortCompletion(View* view, const SmartRange& range, const QString ¤tCompletion);
/**
* When an item within this model is currently selected in the completion-list, and the user inserted the given character,
* should the completion-item be executed? This can be used to execute items from other inputs than the return-key.
* For example a function item could be executed by typing '(', or variable items by typing '.'.
* \param selected The currently selected index
* \param inserted The character that was inserted by tue user
*/
virtual bool shouldExecute(const QModelIndex& selected, QChar inserted);
/**
* Notification that completion for this model has been aborted.
* \param view The view in which the completion for this model was aborted
*/
virtual void aborted(View* view);
};
///Extension of CodeCompletionModelControllerInterface
class KTEXTEDITOR_EXPORT_DEPRECATED CodeCompletionModelControllerInterface2 : public CodeCompletionModelControllerInterface {
public:
enum MatchReaction {
None,
HideListIfAutomaticInvocation /** If this is returned, the completion-list is hidden if it was invoked automatically */
};
/**
* Called whenever an item in the completion-list perfectly matches the current filter text.
* \param The index that is matched
* \return Whether the completion-list should be hidden on this event. The default-implementation always returns HideListIfAutomaticInvocation
*/
virtual MatchReaction matchingItem(const QModelIndex& matched);
};
//BEGIN V3
/**
* \short Controller interface for a CodeCompletionModel
*
* \ingroup kte_group_ccmodel_extensions
*
* The CodeCompletionModelControllerInterface3 gives an CodeCompletionModel better
* control over the completion.
*
* By implementing methods defined in this interface you can:
* - control when automatic completion should start (shouldStartCompletion())
* - define a custom completion range (that will be replaced when the completion
* is executed) (completionRange())
* - dynamically modify the completion range during completion (updateCompletionRange())
* - specify the string used for filtering the completion (filterString())
* - control when completion should stop (shouldAbortCompletion())
*
* When the interface is not implemented, or no methods are overridden the
* default behaviour is used, which will be correct in many situations.
*
*
* \section markext_access Implemeting the Interface
* To use this class implement it in your CodeCompletionModel.
*
* \code
* class MyCodeCompletion : public KTextEditor::CodeCompletionTestModel,
public KTextEditor::CodeCompletionModelControllerInterface3
* {
* Q_OBJECT
* Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface3)
* public:
* KTextEditor::Range completionRange(KTextEditor::View* view, const KTextEditor::Cursor &position);
* };
* \endcode
*
* \see CodeCompletionModel
* \author Niko Sams \<niko.sams@gmail.com\>
* \author Joseph Wenninger
* \since 4.5
*/
class KTEXTEDITOR_EXPORT CodeCompletionModelControllerInterface3
{
public:
CodeCompletionModelControllerInterface3();
virtual ~CodeCompletionModelControllerInterface3();
/**
* This function decides if the automatic completion should be started when
* the user entered some text.
*
* The default implementation will return true if the last character in
* \p insertedText is a letter, a number, '.', '_' or '\>'
*
* \param view The view to generate completions for
* \param insertedText The text that was inserted by the user
* \param userInsertion Whether the the text was inserted by the user using typing.
* If false, it may have been inserted for example by code-completion.
* \param position Current cursor position
* \return \e true, if the completion should be started, otherwise \e false
*/
virtual bool shouldStartCompletion(View* view, const QString &insertedText, bool userInsertion, const Cursor &position);
/**
* This function returns the completion range that will be used for the
* current completion.
*
* This range will be used for filtering the completion list and will get
* replaced when executing the completion
*
* The default implementation will work for most languages that don't have
* special chars in identifiers.
*
* \param view The view to generate completions for
* \param position Current cursor position
* \return the completion range
*/
virtual Range completionRange(View* view, const Cursor &position);
/**
* This function lets the CompletionModel dynamically modify the range.
* Called after every change to the range (eg. when user entered text)
*
* The default implementation does nothing.
*
* The smart-mutex is not locked when this is called.
* @warning Make sure you lock it before you change the range
*
* \param view The view to generate completions for
* \param range Reference to the current range
* \returns the modified range
*/
virtual Range updateCompletionRange(View* view, const Range& range);
/**
* This function returns the filter-text used for the current completion.
* Can return an empty string to disable filtering.
*
* The default implementation will return the text from \p range start to
* the cursor \p position.
*
* The smart-mutex is not locked when this is called.
*
* \param view The view to generate completions for
* \param range The completion range
* \param position Current cursor position
* \return the string used for filtering the completion list
*/
virtual QString filterString(View* view, const Range& range, const Cursor &position);
/**
* This function decides if the completion should be aborted.
* Called after every change to the range (eg. when user entered text)
*
* The default implementation will return true when any special character was entered, or when the range is empty.
*
* The smart-mutex is not locked when this is called.
*
* \param view The view to generate completions for
* \param range The completion range
* \param currentCompletion The text typed so far
* \return \e true, if the completion should be aborted, otherwise \e false
*/
virtual bool shouldAbortCompletion(View* view, const Range& range, const QString ¤tCompletion);
/**
* When an item within this model is currently selected in the completion-list, and the user inserted the given character,
* should the completion-item be executed? This can be used to execute items from other inputs than the return-key.
* For example a function item could be executed by typing '(', or variable items by typing '.'.
* \param selected The currently selected index
* \param inserted The character that was inserted by tue user
*/
virtual bool shouldExecute(const QModelIndex& selected, QChar inserted);
/**
* Notification that completion for this model has been aborted.
* \param view The view in which the completion for this model was aborted
*/
virtual void aborted(View* view);
public:
enum MatchReaction {
None=0,
HideListIfAutomaticInvocation=1, /** If this is returned, the completion-list is hidden if it was invoked automatically */
ForExtension=0xffff
};
/**
* Called whenever an item in the completion-list perfectly matches the current filter text.
* \param The index that is matched
* \return Whether the completion-list should be hidden on this event. The default-implementation always returns HideListIfAutomaticInvocation
*/
virtual MatchReaction matchingItem(const QModelIndex& matched);
};
//END V3
}
#ifndef KTEXTEDITOR_NO_DEPRECATED
Q_DECLARE_INTERFACE(KTextEditor::CodeCompletionModelControllerInterface, "org.kde.KTextEditor.CodeCompletionModelControllerInterface")
Q_DECLARE_INTERFACE(KTextEditor::CodeCompletionModelControllerInterface2, "org.kde.KTextEditor.CodeCompletionModelControllerInterface2")
#endif
Q_DECLARE_INTERFACE(KTextEditor::CodeCompletionModelControllerInterface3, "org.kde.KTextEditor.CodeCompletionModelControllerInterface3")
#endif // KDELIBS_KTEXTEDITOR_CODECOMPLETIONMODELCONTROLLERINTERFACE_H
|