From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- lib/interfaces/kdevcore.h | 387 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 lib/interfaces/kdevcore.h (limited to 'lib/interfaces/kdevcore.h') diff --git a/lib/interfaces/kdevcore.h b/lib/interfaces/kdevcore.h new file mode 100644 index 00000000..cdc5ca87 --- /dev/null +++ b/lib/interfaces/kdevcore.h @@ -0,0 +1,387 @@ +/* This file is part of the KDE project + Copyright (C) 2001-2002 Matthias Hoelzer-Kluepfel + Copyright (C) 2001-2002 Bernd Gehrmann + Copyright (C) 2001 Sandy Meier + Copyright (C) 2002 Daniel Engelschalt + Copyright (C) 2002 Simon Hausmann + Copyright (C) 2002-2003 Roberto Raggi + Copyright (C) 2003 Mario Scalas + Copyright (C) 2003 Harald Fernengel + Copyright (C) 2003 Hamish Rodda + Copyright (C) 2004 Alexander Dymo + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +#ifndef KDEVCORE_H +#define KDEVCORE_H + +/** +@file kdevcore.h +The interface to the application core and context menu classes. +*/ + +#include +#include +#include + +#include + +class KDialogBase; +class KDevPlugin; +class CodeModelItem; +class ProjectModelItem; + +namespace KParts +{ + class Part; +} + +class QStatusBar; +class QPopupMenu; + +/** +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: +-# Create a popup menu in context menu event handler: @code KPopupMenu menu(this); @endcode +-# Create a context: @code MyContext context(param). @endcode +-# Fill a context menu: @code core()->fillContextMenu(&menu, &context); @endcode +-# Show the popup menu: @code menu.exec(event->globalPos()); @endcode +. +In this example @em event is an object of QContextMenuEvent class which you have access +to if you reimplement QWidget::contextMenuEvent method. + +How to fill context menu from a plugin: +-# Create a @code contextMenu(QPopupMenu *, const Context *) @endcode slot in your plugin class. +-# Connect KDevCore::contextMenu(QPopupMenu *, const Context *) signal to that slot in +the constructor of your plugin:\n +@code +connect(core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)), + this, SLOT(contextMenu(QPopupMenu *, const Context *))); +@endcode +-# Fill the menu in the slot you created, for example:\n +@code +if (context->hasType(Context::EditorContext)) +{ + const EditorContext *econtext = static_cast(context); + int id = popup->insertItem(i18n("My Menu Item 1"), this, SLOT(myMenuAction1())); + popup->setWhatsThis(id, i18n("What's this for my menu item 1")); +} +else if context->hasType(MyContext)) +{ + int id = popup->insertItem(... + ... +} +... +@endcode +*/ +class Context +{ +public: + /**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 kdevelop official context types.*/ + enum Type + { + EditorContext, /**