IContext Class

(Core::IContext)

The IContext class associates a widget with a context list and context help. More...

Header: #include <coreplugin/icontext.h>
Inherited By:

Core::IEditor and Core::IMode

Public Types

typedef HelpCallback

Public Functions

IContext(QObject *parent = nullptr)
virtual Core::Context context() const
virtual void contextHelp(const Core::IContext::HelpCallback &callback) const
virtual void setContext(const Core::Context &context)
virtual void setContextHelp(const Core::HelpItem &id)
virtual void setWidget(QWidget *widget)
virtual QWidget *widget() const

Static Public Members

const QMetaObject staticMetaObject

Protected Variables

Core::Context m_context
Core::HelpItem m_contextHelp
QPointer<QWidget> m_widget

Detailed Description

The IContext class associates a widget with a context list and context help.

An instance of IContext must be registered with Core::ICore::addContextObject() to have an effect. For many subclasses of IContext, like Core::IEditor and Core::IMode, this is done automatically. But instances of IContext can be created manually to associate a context and context help for an arbitrary widget, too. IContext instances are automatically unregistered when they are deleted. Use Core::ICore::removeContextObject() if you need to unregister an IContext instance manually.

Whenever the widget is part of the application wide focus widget's parent chain, the associated context list is made active. This makes actions active that were registered for any of the included context IDs. If the user requests context help, the top-most IContext instance in the focus widget's parent hierarchy is asked to provide it.

See The Action Manager and Commands for an overview of how contexts are used for managing actions.

See also Core::ICore, Core::Context, Core::ActionManager, and The Action Manager and Commands.

Member Type Documentation

typedef IContext::HelpCallback

The HelpCallback class defines the callback function that is used to report the help item to show when the user requests context help.

Member Function Documentation

IContext::IContext(QObject *parent = nullptr)

Default constructs an instance of IContext.

[virtual] Core::Context IContext::context() const

See also setContext().

[virtual] void IContext::contextHelp(const Core::IContext::HelpCallback &callback) const

See also setContextHelp().

[virtual] void IContext::setContext(const Core::Context &context)

See also context().

[virtual] void IContext::setContextHelp(const Core::HelpItem &id)

See also contextHelp().

[virtual] void IContext::setWidget(QWidget *widget)

See also widget().

[virtual] QWidget *IContext::widget() const

See also setWidget().