interfaces
KDevelop::Context Class Reference
#include <context.h>

Detailed Description
Base class for every context.Think of a Context-based class as "useful information associated with a context menu".
When a context menu with a certain "context" associated appears, the platform's PluginController requests all plugins to return a list of QActions* they want to add to the context menu and a QString that should be used as the submenu entry. For example, a SVN plugin could add "commit" and "update" actions to the context menu of a document in a submenu called "Subversion".
The plugin that originally gets the contextmenu event shouldn't add its own actions directly to the menu but instead use the same mechanism.
How to show a context menu from a plugin:
- Create a KMenu in context menu event handler:
KMenu menu(this); - Create a context:
FileContext context(list).
- Ask PluginController to fill the menu:
core()->pluginController()->buildContextMenu(&menu, context);
- Show the popup menu:
menu.exec(mapToGlobal(pos));
How to fill a context menu from a plugin:
- Implement the function in your plugin class.
requestContextMenuActions(const Context &)
- Depending on the context return a pair of a submenu title and a list of actions that should appear in the menu:
QList<QAction*> actionlist; if (context->hasType(Context::EditorContext)) { actionlist << new QAction(...); } else if context->hasType(Context::FileContext)) { actionlist << new QAction(...); ... } return qMakePair("Subversion", actionlist);
Definition at line 87 of file context.h.
Public Types | |
| enum | Type { EditorContext, FileContext, CodeContext, ProjectItemContext } |
Public Member Functions | |
| bool | hasType (int type) const |
| virtual int | type () const =0 |
Protected Member Functions | |
| Context () | |
| virtual | ~Context () |
Member Enumeration Documentation
Pre-defined context types.
More may be added so it is possible to add custom contexts. We reserve enum values until 1000 (yeah, it is one thousand ) for kdevplatform official context types.
Constructor & Destructor Documentation
| KDevelop::Context::Context | ( | ) | [protected] |
| KDevelop::Context::~Context | ( | ) | [protected, virtual] |
Member Function Documentation
| bool KDevelop::Context::hasType | ( | int | type | ) | const |
- Returns:
- The type of this Context, so clients can discriminate between different file contexts.
Definition at line 47 of file context.cpp.
| virtual int KDevelop::Context::type | ( | ) | const [pure virtual] |
Implement this in the context so we can provide rtti.
Implemented in KDevelop::EditorContext, KDevelop::FileContext, and KDevelop::ProjectItemContext.
The documentation for this class was generated from the following files:
KDE 4.2 API Reference