Context Class

class Core::Context

The Context class implements a list of context IDs. More...

Header: #include <coreplugin/icontext.h>

Public Types

Public Functions

Context()
Context(Utils::Id c1)
Context(Utils::Id c1, Utils::Id c2)
Context(Utils::Id c1, Utils::Id c2, Utils::Id c3)
void add(Utils::Id c)
void add(const Core::Context &c)
Utils::Id at(int i) const
Core::Context::const_iterator begin() const
bool contains(Utils::Id c) const
Core::Context::const_iterator end() const
int indexOf(Utils::Id c) const
bool isEmpty() const
void prepend(Utils::Id c)
void removeAt(int i)
int size() const

Detailed Description

Contexts are used for registering actions with Core::ActionManager, and when creating UI elements that provide a context for actions.

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

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

Member Type Documentation

[alias] Context::const_iterator

The Context::const_iterator provides an STL-style const interator for Context.

Member Function Documentation

[constexpr noexcept] Context::Context()

Creates a context list that represents the global context.

[explicit] Context::Context(Utils::Id c1)

Creates a context list with a single ID c1.

Context::Context(Utils::Id c1, Utils::Id c2)

Creates a context list with IDs c1 and c2.

Context::Context(Utils::Id c1, Utils::Id c2, Utils::Id c3)

Creates a context list with IDs c1, c2 and c3.

void Context::add(Utils::Id c)

Adds the ID c at the end of the context list.

void Context::add(const Core::Context &c)

Adds the context list c at the end of this context list.

Utils::Id Context::at(int i) const

Returns the ID at index i in the context list.

Core::Context::const_iterator Context::begin() const

Returns an STL-style iterator pointing to the first ID in the context list.

bool Context::contains(Utils::Id c) const

Returns whether this context list contains the ID c.

Core::Context::const_iterator Context::end() const

Returns an STL-style iterator pointing to the imaginary item after the last ID in the context list.

int Context::indexOf(Utils::Id c) const

Returns the index position of the ID c in the context list. Returns -1 if no item matched.

bool Context::isEmpty() const

Returns whether this context list is empty and therefore default constructed.

void Context::prepend(Utils::Id c)

Adds the ID c as the first item to the context list.

void Context::removeAt(int i)

Removes the ID at index i from the context list.

int Context::size() const

Returns the number of IDs in the context list.