KParts.PartManager

KDE 4.7 PyKDE API Reference

- KDE's Python API

# PartManager Class Reference

`from PyKDE4.kparts import *`

Inherits: QObject
Namespace: KParts

## Detailed Description

The part manager is an object which knows about a collection of parts (even nested ones) and handles activation/deactivation.

Applications that want to embed parts without merging GUIs only use a KParts.PartManager. Those who want to merge GUIs use a KParts.MainWindow for example, in addition to a part manager.

Parts know about the part manager to add nested parts to it. See also KParts.Part.manager() and KParts.Part.setManager().

## Enumerations
Reason | { ReasonLeftClick, ReasonMidClick, ReasonRightClick, NoReason }
SelectionPolicy | { Direct, TriState }
## Signals
| activePartChanged (KParts.Part newPart)
| partAdded (KParts.Part part)
| partRemoved (KParts.Part part)
## Methods
| __init__ (self, QWidget parent)
| __init__ (self, QWidget topLevel, QObject parent)
int | activationButtonMask (self)
KParts.Part | activePart (self)
QWidget | activeWidget (self)
| addManagedTopLevelWidget (self, QWidget topLevel)
| addPart (self, KParts.Part part, bool setActive=1)
bool | allowNestedParts (self)
bool | eventFilter (self, QObject obj, QEvent ev)
bool | ignoreScrollBars (self)
[KParts.Part] | parts (self)
int | reason (self)
| removeManagedTopLevelWidget (self, QWidget topLevel)
| removePart (self, KParts.Part part)
| replacePart (self, KParts.Part oldPart, KParts.Part newPart, bool setActive=1)
KParts.Part | selectedPart (self)
QWidget | selectedWidget (self)
KParts.PartManager.SelectionPolicy | selectionPolicy (self)
| setActivationButtonMask (self, int buttonMask)
| setActiveComponent (self, KComponentData instance)
| setActivePart (self, KParts.Part part, QWidget widget=0)
| setAllowNestedParts (self, bool allow)
| setIgnoreScrollBars (self, bool ignore)
| setSelectedPart (self, KParts.Part part, QWidget widget=0)
| setSelectionPolicy (self, KParts.PartManager.SelectionPolicy policy)
| slotManagedTopLevelWidgetDestroyed (self)
| slotObjectDestroyed (self)
| slotWidgetDestroyed (self)

## Signal Documentation

activePartChanged | ( | KParts.Part | newPart
| ) |  |  |

Emitted when the active part has changed.

See also:
  setActivePart()

Signal syntax:
  `QObject.connect(source, SIGNAL("activePartChanged(KParts::Part*)"), target_slot)`

partAdded | ( | KParts.Part | part
| ) |  |  |

Emitted when a new part has been added.

See also:
  addPart()

Signal syntax:
  `QObject.connect(source, SIGNAL("partAdded(KParts::Part*)"), target_slot)`

partRemoved | ( | KParts.Part | part
| ) |  |  |

Emitted when a part has been removed.

See also:
  removePart()

Signal syntax:
  `QObject.connect(source, SIGNAL("partRemoved(KParts::Part*)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent
| ) |  |  |

Constructs a part manager.

Parameters:

  | parent | The toplevel widget (window / dialog) the partmanager should monitor for activation/selection events

__init__ | ( | self, |
|  | QWidget | topLevel,
|  | QObject | parent
| ) |  |  |

Constructs a part manager.

Parameters:

  | topLevel | The toplevel widget (window / dialog ) the partmanager should monitor for activation/selection events
  | parent | The parent QObject.

int activationButtonMask | ( |  | self ) |

See also:
  setActivationButtonMask

KParts.Part activePart | ( |  | self ) |

Returns the active part.

QWidget activeWidget | ( |  | self ) |

Returns the active widget of the current active part (see activePart ).

addManagedTopLevelWidget | ( | self, |
|  | QWidget | topLevel
| ) |  |  |

Adds the topLevel widget to the list of managed toplevel widgets. Usually a PartManager only listens for events (for activation/selection) for one toplevel widget (and its children) , the one specified in the constructor. Sometimes however (like for example when using the KDE dockwidget library) , it is necessary to extend this.

addPart | ( | self, |
|  | KParts.Part | part,
|  | bool | setActive=1
| ) |  |  |

Adds a part to the manager.

Sets it to the active part automatically if setActive is true (default ). Behavior fix in KDE3.4: the part's widget is shown only if setActive is true, it used to be shown in all cases before.

bool allowNestedParts | ( |  | self ) |

See also:
  setAllowNestedParts

bool eventFilter | ( | self, |
|  | QObject | obj,
|  | QEvent | ev
| ) |  |  |

Internal:

bool ignoreScrollBars | ( |  | self ) |

See also:
  setIgnoreScrollBars

[KParts.Part] parts | ( |  | self ) |

Returns the list of parts being managed by the partmanager.

int reason | ( |  | self ) |

Returns:
  the reason for the last activePartChanged signal emitted.

See also:
  Reason

removeManagedTopLevelWidget | ( | self, |
|  | QWidget | topLevel
| ) |  |  |

Removes the topLevel widget from the list of managed toplevel widgets.

See also:
  addManagedTopLevelWidget

removePart | ( | self, |
|  | KParts.Part | part
| ) |  |  |

Removes a part from the manager (this does not delete the object) .

Sets the active part to 0 if part is the activePart() .

replacePart | ( | self, |
|  | KParts.Part | oldPart,
|  | KParts.Part | newPart,
|  | bool | setActive=1
| ) |  |  |

Replaces oldPart with newPart, and sets newPart as active if setActive is true. This is an optimised version of removePart + addPart

KParts.Part selectedPart | ( |  | self ) |

Returns the current selected part.

QWidget selectedWidget | ( |  | self ) |

Returns the selected widget of the current selected part (see selectedPart ).

KParts.PartManager.SelectionPolicy selectionPolicy | ( |  | self ) |

Returns the current selection policy.

setActivationButtonMask | ( | self, |
|  | int | buttonMask
| ) |  |  |

Specifies which mouse buttons the partmanager should react upon. By default it reacts on all mouse buttons (LMB/MMB/RMB).

Parameters:

  | buttonMask | a combination of Qt.ButtonState values e.g. Qt.LeftButton | Qt.MidButton

setActiveComponent | ( | self, |
|  | KComponentData | instance
| ) |  |  |

Changes the active instance when the active part changes. The active instance is used by KBugReport and KAboutDialog. Override if you really need to - usually you don't need to.

setActivePart | ( | self, |
|  | KParts.Part | part,
|  | QWidget | widget=0
| ) |  |  |

Sets the active part.

The active part receives activation events.

widget can be used to specify which widget was responsible for the activation. This is important if you have multiple views for a document/part , like in KOffice .

setAllowNestedParts | ( | self, |
|  | bool | allow
| ) |  |  |

Specifies whether the partmanager should handle/allow nested parts or not.

This is a property the shell has to set/specify. Per default we assume that the shell cannot handle nested parts. However in case of a KOffice shell for example we allow nested parts. A Part is nested (a child part) if its parent object inherits KParts.Part. If a child part is activated and nested parts are not allowed/handled, then the top parent part in the tree is activated.

setIgnoreScrollBars | ( | self, |
|  | bool | ignore
| ) |  |  |

Specifies whether the partmanager should ignore mouse click events for scrollbars or not. If the partmanager ignores them, then clicking on the scrollbars of a non-active/non-selected part will not change the selection or activation state.

The default value is false (read: scrollbars are NOT ignored).

setSelectedPart | ( | self, |
|  | KParts.Part | part,
|  | QWidget | widget=0
| ) |  |  |

Sets the selected part.

The selected part receives selection events.

widget can be used to specify which widget was responsible for the selection. This is important if you have multiple views for a document/part , like in KOffice .

setSelectionPolicy | ( | self, |
|  | KParts.PartManager.SelectionPolicy | policy
| ) |  |  |

Sets the selection policy of the partmanager.

slotManagedTopLevelWidgetDestroyed | ( |  | self ) |

Internal:

slotObjectDestroyed | ( |  | self ) |

Removes a part when it is destroyed.

slotWidgetDestroyed | ( |  | self ) |

Internal:

## Enumeration Documentation

Reason

This extends QFocusEvent.Reason with the non-focus-event reasons for partmanager to activate a part. To test for "any focusin reason", use < ReasonLeftClick NoReason usually means: explicit activation with setActivePart.

Enumerator:

  ReasonLeftClick = 100 |
  ReasonMidClick |
  ReasonRightClick |
  NoReason |

SelectionPolicy

Enumerator:

  Direct |
  TriState |