You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
202 lines
8.9 KiB
202 lines
8.9 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
11 years ago
|
Copyright (C) 1999-2001 Bernd Gehrmann <bernd@kdevelop.org>
|
||
|
Copyright (C) 2004 Alexander Dymo <adymo@kdevelop.org>
|
||
15 years ago
|
|
||
|
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
|
||
15 years ago
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
15 years ago
|
*/
|
||
11 years ago
|
#ifndef TDEVPLUGIN_H
|
||
|
#define TDEVPLUGIN_H
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqobject.h>
|
||
15 years ago
|
#include <kxmlguiclient.h>
|
||
11 years ago
|
#include "tdevapi.h"
|
||
|
|
||
|
class TDevCore;
|
||
|
class TDevProject;
|
||
|
class TDevVersionControl;
|
||
|
class TDevLanguageSupport;
|
||
|
class TDevPartController;
|
||
|
class TDevMainWindow;
|
||
|
class TDevCodeRepository;
|
||
15 years ago
|
class CodeModel;
|
||
11 years ago
|
class TDevPluginInfo;
|
||
15 years ago
|
class TQDomElement;
|
||
15 years ago
|
|
||
|
/**
|
||
11 years ago
|
@file tdevplugin.h
|
||
13 years ago
|
TDevelop plugin interface.
|
||
15 years ago
|
*/
|
||
|
|
||
13 years ago
|
/**Current TDevelop plugin interface version. Interfaces declare plugin version to make sure
|
||
15 years ago
|
old source (or binary) incompatible plugins are not loaded. Increase this if
|
||
|
it is necessary that old plugins stop working.*/
|
||
13 years ago
|
#define TDEVELOP_PLUGIN_VERSION 5
|
||
15 years ago
|
|
||
|
/**
|
||
13 years ago
|
The base class for all TDevelop plugins.
|
||
|
Plugin is a component which is loaded into TDevelop shell at startup or by request.
|
||
15 years ago
|
Each plugin should have corresponding .desktop file with a description.
|
||
|
.desktop file template looks like:
|
||
|
@code
|
||
|
[Desktop Entry]
|
||
|
Encoding=UTF-8
|
||
|
Type=Service
|
||
|
Name=
|
||
|
GenericName=
|
||
|
Comment=
|
||
|
Icon=
|
||
13 years ago
|
X-TDevelop-Plugin-Version=
|
||
|
X-TDevelop-Plugin-Homepage=
|
||
|
X-TDevelop-Plugin-BugsEmailAddress=
|
||
|
X-TDevelop-Plugin-Copyright=
|
||
13 years ago
|
X-TDE-Library=
|
||
13 years ago
|
X-TDevelop-Version=
|
||
|
X-TDevelop-Scope=
|
||
|
X-TDevelop-Properties=
|
||
|
X-TDevelop-Args=
|
||
15 years ago
|
@endcode
|
||
|
<b>Description of parameters in .desktop file:</b>
|
||
12 years ago
|
- <i>Name</i> is a non-translatable name of a plugin, it is used in TDETrader queries
|
||
15 years ago
|
to search for a plugin (required);
|
||
|
- <i>GenericName</i> is a translatable name of a plugin, it is used to show
|
||
|
plugin names in GUI (required);
|
||
|
- <i>Comment</i> is a short description about the plugin (optional);
|
||
|
- <i>Icon</i> is a plugin icon (preferred);
|
||
13 years ago
|
- <i>X-TDevelop-Plugin-Version</i> is a version of a plugin (optional);
|
||
|
- <i>X-TDevelop-Plugin-Homepage</i> is a home page of a plugin (optional);
|
||
|
- <i>X-TDevelop-Plugin-License</i> is a license (optional). can be: GPL, LGPL, BSD, Artistic,
|
||
14 years ago
|
TQPL or Custom. If this property is not set, license is considered as unknown;
|
||
13 years ago
|
- <i>X-TDevelop-Plugin-BugsEmailAddress</i> is an email address for bug reports (optional);
|
||
|
- <i>X-TDevelop-Plugin-Copyright</i> is a copyright statement (optional);
|
||
13 years ago
|
- <i>X-TDE-Library</i> is a name of library which contains the plugin (required);
|
||
13 years ago
|
- <i>X-TDevelop-Version</i> is a version of TDevelop interfaces which is supported by the plugin (required);
|
||
|
- <i>X-TDevelop-Scope</i> is a scope of a plugin (see below for explanation) (required);
|
||
|
- <i>X-TDevelop-Args</i> is a list of additional arguments passed to plugins constructor (optional);
|
||
|
- <i>X-TDevelop-Properties</i> is a list of properties which this plugin supports, see @ref Profile class documentation for explanation (required to work with shells that support profiles).
|
||
15 years ago
|
.
|
||
|
Plugin scope can be either:
|
||
|
- Core
|
||
|
- Global
|
||
|
- Project
|
||
|
.
|
||
11 years ago
|
Global plugins are plugins which require only shell to be loaded and do not operate on @ref TDevProject interface and/or do not use project wide information.\n
|
||
15 years ago
|
Core plugins are global plugins which offer some important "core" functionality and thus
|
||
|
are not selectable by user in plugin configuration pages.\n
|
||
|
Project plugins require a project to be loaded and are usually loaded/unloaded among with the project.
|
||
11 years ago
|
If your plugin use @ref TDevProject interface and/or operate on project-related information then this is the project plugin.
|
||
15 years ago
|
|
||
11 years ago
|
@sa TDevGenericFactory class documentation for an information about plugin instantiation
|
||
15 years ago
|
and writing factories for plugins.
|
||
|
|
||
11 years ago
|
@sa TDevCore class documentation for an information about features which are available to plugins
|
||
15 years ago
|
from shell applications.
|
||
|
*/
|
||
11 years ago
|
class TDevPlugin: public TQObject, public KXMLGUIClient
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
|
||
|
public:
|
||
|
/**Constructs a plugin.
|
||
|
@param info Important information about the plugin - plugin internal and generic
|
||
|
(GUI) name, description, a list of authors, etc. That information is used to show
|
||
|
plugin information in various places like "about application" dialog, plugin selector
|
||
|
dialog, etc. Plugin does not take ownership on info object, also its lifetime should
|
||
|
be equal to the lifetime of the plugin.
|
||
11 years ago
|
@param parent The parent object for the plugin. Parent object must implement @ref TDevApi
|
||
15 years ago
|
interface. Otherwise the plugin will not be constructed.
|
||
|
@param name The internal name which identifies the plugin.*/
|
||
11 years ago
|
TDevPlugin(const TDevPluginInfo *info, TQObject *parent, const char *name = 0);
|
||
15 years ago
|
|
||
|
/**Destructs a plugin.*/
|
||
11 years ago
|
virtual ~TDevPlugin();
|
||
15 years ago
|
|
||
|
/**Provides an information about the plugin.
|
||
12 years ago
|
@return TDEAboutData object which was initialized in the constructor.*/
|
||
11 years ago
|
const TDevPluginInfo* info();
|
||
15 years ago
|
|
||
|
/**@return A reference to the toplevel widget.*/
|
||
11 years ago
|
TDevMainWindow *mainWindow();
|
||
15 years ago
|
|
||
|
/**@return A reference to the application core - an object which provides
|
||
|
basic functionalities for inter-parts communications / cooperation.*/
|
||
11 years ago
|
TDevCore *core() const;
|
||
15 years ago
|
|
||
|
/**@return A reference to the current project component or 0 if no project is loaded.*/
|
||
11 years ago
|
TDevProject *project() const;
|
||
15 years ago
|
|
||
|
/**@return A reference to the language support component or 0 if no support available.*/
|
||
11 years ago
|
TDevLanguageSupport *languageSupport() const;
|
||
15 years ago
|
|
||
|
/**@return A reference to the memory symbol store.*/
|
||
|
CodeModel *codeModel() const;
|
||
|
|
||
|
/**@return A reference to the DOM tree that represents the project file or 0 if no project is loaded.*/
|
||
15 years ago
|
TQDomDocument *projectDom() const;
|
||
15 years ago
|
|
||
|
/**@return A reference to the part controller which is used to manipulate loaded KParts.*/
|
||
11 years ago
|
TDevPartController *partController() const;
|
||
15 years ago
|
|
||
|
/**@return A reference to the plugin controller which is used to manipulate loaded plugin.*/
|
||
11 years ago
|
virtual TDevPluginController *pluginController() const;
|
||
15 years ago
|
|
||
|
/**@return A reference to the code repository (accessor to persistent symbol stores).*/
|
||
11 years ago
|
TDevCodeRepository* codeRepository() const;
|
||
15 years ago
|
|
||
|
/**Queries for the plugin which supports given service type (such plugins are called extensions in KDevelop).
|
||
|
All already loaded plugins will be queried and the <b>first loaded one</b> to support
|
||
|
the service type will be returned. Any plugin can be an extension, only "ServiceTypes=..."
|
||
|
entry is required in .desktop file for that plugin.
|
||
|
|
||
|
Template argument is used as a type to cast the result to. This is done because extension
|
||
11 years ago
|
is usually derived from a certain base class and not directly from TDevPlugin.
|
||
13 years ago
|
@param serviceType The service type of an extension (like "TDevelop/SourceFormatter").
|
||
15 years ago
|
@param constraint The constraint which is applied when quering for the service. This
|
||
12 years ago
|
constraint is a usual TDETrader constraint statement (like "[X-TDevelop-Foo]=='MyFoo'").
|
||
15 years ago
|
@return A KDevelop extension plugin for given service type or 0 if no plugin supports it*/
|
||
|
template <class Extension>
|
||
15 years ago
|
Extension *extension(const TQString &serviceType, const TQString &constraint = "")
|
||
15 years ago
|
{
|
||
|
return static_cast<Extension*>(extension_internal(serviceType, constraint));
|
||
|
}
|
||
|
|
||
|
/**Override this base class method to restore any settings which differs from project to project.
|
||
|
Data can be read from a certain subtree of the project session file.
|
||
|
During project loading, respectively project session (.kdevses) loading,
|
||
|
this method will be called to give a chance to adapt the plugin to
|
||
|
the newly loaded project. For instance, the debugger plugin might restore the
|
||
|
list of breakpoints from the previous debug session for the certain project.
|
||
|
@note Take attention to the difference to common not-project-related session stuff.
|
||
13 years ago
|
They belong to the application rc file (tdeveloprc)
|
||
15 years ago
|
@note Project session file is useful for settings which cannot be shared between
|
||
|
developers. If a setting should be shared, modify projectDom instead.
|
||
14 years ago
|
@param el The parent DOM element for plugins session settings.*/
|
||
15 years ago
|
virtual void restorePartialProjectSession(const TQDomElement* el);
|
||
15 years ago
|
|
||
|
/**Saves session settings.
|
||
|
@sa restorePartialProjectSession - this is the other way round, the same just for saving.*/
|
||
15 years ago
|
virtual void savePartialProjectSession(TQDomElement* el);
|
||
15 years ago
|
|
||
|
private:
|
||
11 years ago
|
TDevPlugin *extension_internal(const TQString &serviceType, const TQString &constraint = "");
|
||
15 years ago
|
|
||
11 years ago
|
TDevApi *m_api;
|
||
15 years ago
|
class Private;
|
||
|
Private *d;
|
||
|
};
|
||
|
|
||
|
#endif
|