KTextEditor.VariableInterface

KDE 4.9 PyKDE API Reference

- KDE's Python API

# VariableInterface Class Reference

`from PyKDE4.ktexteditor import *`

Namespace: KTextEditor

## Detailed Description

Variable/Modeline extension interface for the Document.

Introduction

The VariableInterface is designed to provide access to so called "document variables" (also called modelines), for example variables defined in files like "kate: variable value;" or the emacs style "-*- variable: value -*-".

The idea is to allow KTextEditor plugins and applications to use document variables. A document implementing this interface should return values for variables that it does not otherwise know how to use, since they could be of interest for plugins. A Document implementing this interface must emit the signal variableChanged() whenever a variable/value pair was set, changed or removed.

Note:
  Implementations should check the document variables whenever the document was saved or loaded.

Accessing the VariableInterface

The VariableInterface is an extension interface for a Document, i.e. the Document inherits the interface provided that the used KTextEditor library implements the interface. Use qobject_cast to access the interface:

     // doc is of type KTextEditor.Document*
     KTextEditor.VariableInterface *iface =
         qobject_cast<KTextEditor.VariableInterface*>( doc );

     if( iface ) {
         // the implementation supports the interface
         // do stuff
     }

See also:
  KTextEditor.Document, KTextEditor.Plugin

Author:
  Anders Lund <anders@alweb.dk>

## Methods
| __init__ (self)
QString | variable (self, QString name)
| variableChanged (self, KTextEditor.Document document, QString variable, QString value)

## Method Documentation

__init__ | ( |  | self ) |

QString variable | ( | self, |
|  | QString | name
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Get the value of the variable name.

Returns:
  the value or an empty string if the variable is not set or has no value.

variableChanged | ( | self, |
|  | KTextEditor.Document | document,
|  | QString | variable,
|  | QString | value
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

The document emits this signal whenever the value of the variable changed, this includes when a variable was initially set.

Parameters:

  | document | document that emitted the signal

Parameters:

  | variable | variable that changed

Parameters:

  | value | new value for variable

See also:
  variable()