KParts::PartManager Class

Header: #include <PartManager>
CMake: find_package(KF6 REQUIRED COMPONENTS Parts)
target_link_libraries(mytarget PRIVATE KF6::Parts)

Public Types

enum Reason { ReasonLeftClick, ReasonMidClick, ReasonRightClick, NoReason }

Public Functions

PartManager(QWidget *parent)
PartManager(QWidget *topLevel, QObject *parent)
short activationButtonMask() const
virtual KParts::Part *activePart() const
virtual QWidget *activeWidget() const
void addManagedTopLevelWidget(const QWidget *topLevel)
virtual void addPart(KParts::Part *part, bool setActive = true)
bool allowNestedParts() const
bool ignoreScrollBars() const
const QList<KParts::Part *> parts() const
int reason() const
void removeManagedTopLevelWidget(const QWidget *topLevel)
virtual void removePart(KParts::Part *part)
virtual void replacePart(KParts::Part *oldPart, KParts::Part *newPart, bool setActive = true)
KParts::PartManager::SelectionPolicy selectionPolicy() const
void setActivationButtonMask(short buttonMask)
virtual void setActivePart(KParts::Part *part, QWidget *widget = nullptr)
void setAllowNestedParts(bool allow)
void setIgnoreScrollBars(bool ignore)
void setSelectionPolicy(KParts::PartManager::SelectionPolicy policy)

Reimplemented Public Functions

virtual bool eventFilter(QObject *obj, QEvent *ev) override

Signals

void activePartChanged(KParts::Part *newPart)
void partAdded(KParts::Part *part)
void partRemoved(KParts::Part *part)

Protected Functions

Protected Slots

Detailed Description

@class PartManager partmanager.h <KParts/PartManager>

@short 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().

Member Type Documentation

enum PartManager::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 @ref setActivePart.

Member Function Documentation

PartManager::PartManager(QWidget *parent)

Constructs a part manager.

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

PartManager::PartManager(QWidget *topLevel, QObject *parent)

Constructs a part manager.

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

short PartManager::activationButtonMask() const

@see setActivationButtonMask

See also setActivationButtonMask().

[virtual] KParts::Part *PartManager::activePart() const

Returns the active part.

See also setActivePart().

[signal] void PartManager::activePartChanged(KParts::Part *newPart)

Emitted when the active part has changed. @see setActivePart()

[virtual] QWidget *PartManager::activeWidget() const

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

void PartManager::addManagedTopLevelWidget(const QWidget *topLevel)

Adds the @p 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.

[virtual] void PartManager::addPart(KParts::Part *part, bool setActive = true)

Adds a part to the manager.

Sets it to the active part automatically if @p setActive is true (default).

bool PartManager::allowNestedParts() const

@see setAllowNestedParts

Note: Getter function for property allowNestedParts.

See also setAllowNestedParts().

[override virtual] bool PartManager::eventFilter(QObject *obj, QEvent *ev)

@internal

bool PartManager::ignoreScrollBars() const

@see setIgnoreScrollBars

Note: Getter function for property ignoreScrollBars.

See also setIgnoreScrollBars().

[signal] void PartManager::partAdded(KParts::Part *part)

Emitted when a new part has been added. @see addPart()

[signal] void PartManager::partRemoved(KParts::Part *part)

Emitted when a part has been removed. @see removePart()

const QList<KParts::Part *> PartManager::parts() const

Returns the list of parts being managed by the partmanager.

int PartManager::reason() const

@return the reason for the last activePartChanged signal emitted. @see Reason

void PartManager::removeManagedTopLevelWidget(const QWidget *topLevel)

Removes the @p topLevel widget from the list of managed toplevel widgets. @see addManagedTopLevelWidget

[virtual] void PartManager::removePart(KParts::Part *part)

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

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

[virtual] void PartManager::replacePart(KParts::Part *oldPart, KParts::Part *newPart, bool setActive = true)

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

KParts::PartManager::SelectionPolicy PartManager::selectionPolicy() const

Returns the current selection policy.

Note: Getter function for property selectionPolicy.

See also setSelectionPolicy().

void PartManager::setActivationButtonMask(short buttonMask)

Specifies which mouse buttons the partmanager should react upon. By default it reacts on all mouse buttons (LMB/MMB/RMB). @param buttonMask a combination of Qt::ButtonState values e.g. Qt::LeftButton | Qt::MiddleButton

See also activationButtonMask().

[virtual] void PartManager::setActivePart(KParts::Part *part, QWidget *widget = nullptr)

Sets the active part.

The active part receives activation events.

@p 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 .

See also activePart().

void PartManager::setAllowNestedParts(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.

Note: Setter function for property allowNestedParts.

See also allowNestedParts().

[protected] void PartManager::setIgnoreExplictFocusRequests(bool)

Sets whether the PartManager ignores explicit set focus requests from the part.

By default this option is set to false. Set it to true to prevent the part from sending explicit set focus requests to the client application.

@since 4.10

void PartManager::setIgnoreScrollBars(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).

Note: Setter function for property ignoreScrollBars.

See also ignoreScrollBars().

void PartManager::setSelectionPolicy(KParts::PartManager::SelectionPolicy policy)

Sets the selection policy of the partmanager.

Note: Setter function for property selectionPolicy.

See also selectionPolicy().

[protected slot] void PartManager::slotManagedTopLevelWidgetDestroyed()

@internal

[protected slot] void PartManager::slotObjectDestroyed()

Removes a part when it is destroyed.

[protected slot] void PartManager::slotWidgetDestroyed()

@internal