• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

interfaces

KDevelop::Context

KDevelop::Context Class Reference

#include <context.h>

Inheritance diagram for KDevelop::Context:

Inheritance graph
[legend]

List of all members.


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:

  1. Create a KMenu in context menu event handler:
     KMenu menu(this); 
    
  2. Create a context:
     FileContext context(list). 
    
  3. Ask PluginController to fill the menu:
     core()->pluginController()->buildContextMenu(&menu, context); 
    
  4. Show the popup menu:
     menu.exec(mapToGlobal(pos)); 
    

How to fill a context menu from a plugin:

  1. Implement the
     requestContextMenuActions(const Context &) 
    
    function in your plugin class.
  2. 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

enum KDevelop::Context::Type

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.

Enumerator:
EditorContext  Editor menu.

FileContext  File menu.

CodeContext  Code context menu.

ProjectItemContext  ProjectItem context menu.

Definition at line 93 of file context.h.


Constructor & Destructor Documentation

KDevelop::Context::Context (  )  [protected]

Constructor.

Definition at line 40 of file context.cpp.

KDevelop::Context::~Context (  )  [protected, virtual]

Destructor.

Definition at line 44 of file context.cpp.


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:
  • context.h
  • context.cpp

interfaces

Skip menu "interfaces"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal