• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • TDevelop Interfaces Library
 

TDevelop Interfaces Library

Public Types | Public Member Functions | Protected Member Functions | List of all members
Context Class Referenceabstract

#include <kdevcore.h>

Inheritance diagram for Context:
CodeModelItemContext DocumentationContext EditorContext FileContext ProjectModelItemContext

Public Types

enum  Type {
  EditorContext, DocumentationContext, FileContext, ProjectModelItemContext,
  CodeModelItemContext
}
 

Public Member Functions

virtual int type () const =0
 
virtual bool hasType (int type) const
 

Protected Member Functions

 Context ()
 
virtual ~Context ()
 

Detailed Description

Base class for every context.

Think of a Context-based class as "useful info associated to a context menu". Several context menu can be defined, each defining different information: because of these context menus being used in many modules, they are defined here.

When context menu with a certain "context" associated appears, KDevelop core sends a notification signal and all plugins which receive this signal have the ability to add own items into the menu. For example, VCS plugin could add "commit" and "update" menu items to the context menu of a file.

How to use context from a plugin:

  1. Create a popup menu in context menu event handler:
    TDEPopupMenu menu(this);
  2. Create a context:
    MyContext context(param).
  3. Fill a context menu:
    core()->fillContextMenu(&menu, &context);
  4. Show the popup menu:
    menu.exec(event->globalPos());

In this example event is an object of TQContextMenuEvent class which you have access to if you reimplement TQWidget::contextMenuEvent method.

How to fill context menu from a plugin:

  1. Create a
    contextMenu(TQPopupMenu *, const Context *)
    slot in your plugin class.
  2. Connect KDevCore::contextMenu(TQPopupMenu *, const Context *) signal to that slot in the constructor of your plugin:
    connect(core(), TQT_SIGNAL(contextMenu(TQPopupMenu *, const Context *)),
    this, TQT_SLOT(contextMenu(TQPopupMenu *, const Context *)));
  3. Fill the menu in the slot you created, for example:
    if (context->hasType(Context::EditorContext))
    {
    const EditorContext *econtext = static_cast<const EditorContext*>(context);
    int id = popup->insertItem(i18n("My Menu Item 1"), this, TQT_SLOT(myMenuAction1()));
    popup->setWhatsThis(id, i18n("What's this for my menu item 1"));
    }
    else if context->hasType(MyContext))
    {
    int id = popup->insertItem(...
    ...
    }
    ...

Definition at line 100 of file kdevcore.h.

Member Enumeration Documentation

◆ Type

enum 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 tdevelop official context types.

Enumerator
EditorContext 

Editor context menu.

DocumentationContext 

Documentation browser context menu.

FileContext 

File context menu.

ProjectModelItemContext 

Project tree context menu.

CodeModelItemContext 

Class tree context menu.

Definition at line 106 of file kdevcore.h.

Constructor & Destructor Documentation

◆ Context()

Context::Context ( )
protected

Constructor.

Definition at line 33 of file kdevcore.cpp.

◆ ~Context()

Context::~Context ( )
protectedvirtual

Destructor.

Definition at line 37 of file kdevcore.cpp.

Member Function Documentation

◆ hasType()

bool Context::hasType ( int  type) const
virtual
Returns
The type of this Context, so clients can discriminate between different file contexts.

Definition at line 41 of file kdevcore.cpp.

◆ type()

virtual int Context::type ( ) const
pure virtual

Implement this in the context so we can provide rtti.

Implemented in ProjectModelItemContext, CodeModelItemContext, FileContext, DocumentationContext, and EditorContext.


The documentation for this class was generated from the following files:
  • kdevcore.h
  • kdevcore.cpp

TDevelop Interfaces Library

Skip menu "TDevelop Interfaces Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

TDevelop Interfaces Library

Skip menu "TDevelop Interfaces Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for TDevelop Interfaces Library by doxygen 1.8.13
This website is maintained by Timothy Pearson.