Avogadro  1.1.0
Public Types | Public Slots | Signals | Public Member Functions | Protected Attributes
Avogadro::Extension Class Reference

Interface for adding extensions. More...

#include <avogadro/extension.h>

Inheritance diagram for Avogadro::Extension:
Inheritance graph
[legend]

List of all members.

Public Types

enum  MoleculeChangedHint { KeepOld = 0x00, DeleteOld = 0x01, NewWindow = 0x02 }

Public Slots

virtual void setMolecule (Molecule *molecule)

Signals

void message (const QString &m)
void actionsChanged (Extension *)
void moleculeChanged (Molecule *, int)
void performCommand (QUndoCommand *)

Public Member Functions

 Extension (QObject *parent=0)
virtual ~Extension ()
Plugin::Type type () const
QString typeName () const
virtual QList< QAction * > actions () const =0
virtual QString menuPath (QAction *action) const
virtual bool usesNetwork (QAction *action) const
virtual QDockWidgetdockWidget ()
virtual QList< DockWidget * > dockWidgets () const
virtual int numDockWidgets () const
virtual QUndoCommandperformAction (QAction *action, GLWidget *widget)=0
virtual void writeSettings (QSettings &settings) const
virtual void readSettings (QSettings &settings)
virtual int usefulness () const

Protected Attributes

QList< DockWidget * > m_dockWidgets

Detailed Description

Interface for adding extensions.

Author:
Donald Ephraim Curtis

This is a template class used for adding extensions to Avogadro. Implementing the pure virutal functions provides a mechanism for more functionality. Extensions work by allowing each extension to have an unlimited number of possible actions (each represented by a QAction). To perform an action the extension should implement performAction and perform the correct action based on the action it receives. The actual action should will be performed by the parent object (usually MainWindow) as a result of a ::redo call on the returned QUndoCommand from the performAction function. Thus, to implement functionality you should subclass QUndoCommand accordingly based on the required functionality of the extension and return the command based on the action being peformed.

Append any dockwidgets the extension may use to the m_dockWidgets list and they will be put in place when the extension is loaded.


Member Enumeration Documentation

Enumerator:
DeleteOld 

Keeps the old Molecule.

NewWindow 

Deletes the old Molecule.


Constructor & Destructor Documentation

Constructor.

Destructor.


Member Function Documentation

virtual QList<QAction *> Avogadro::Extension::actions ( ) const [pure virtual]
Returns:
a list of actions which this widget can perform

Implemented in Avogadro::PythonExtension, and Avogadro::DockExtension.

Can be used to notify the MainWindow to refresh the QActions for this extension.

Returns:
A QDockWidget associated with this extension
Deprecated:
Use dockWidgets() instead. This function will return the first dockWidget in the dockWidgets() list or NULL in its default implementation.

Reimplemented in Avogadro::PythonExtension, and Avogadro::DockExtension.

References QList::first(), QList::isEmpty(), and m_dockWidgets.

Returns:
A list of DockWidget instances associated with this extension

References m_dockWidgets.

QString Avogadro::Extension::menuPath ( QAction action) const [virtual]
Returns:
the menu path for the specified action

Reimplemented in Avogadro::PythonExtension.

void Avogadro::Extension::message ( const QString m) [signal]

Can be used to add messages to the message pane.

Parameters:
mthe message to add to the message pane.
void Avogadro::Extension::moleculeChanged ( Molecule ,
int   
) [signal]

Can be used to notify the MainWindow to change the molecule to a new one. The MoleculeChangedHint allows the extension to specify how the new and old Molecule objects should be treated.

int Avogadro::Extension::numDockWidgets ( ) const [virtual]
Returns:
The number of DockWidget instances.

References m_dockWidgets, and QList::size().

virtual QUndoCommand* Avogadro::Extension::performAction ( QAction action,
GLWidget widget 
) [pure virtual]
Parameters:
actionthe action that triggered the calls
widgetthe currently active GLWidget feedback to the user)
Returns:
an undo command for this action

Implemented in Avogadro::PythonExtension, and Avogadro::DockExtension.

Can be used to notify the MainWindow of a delayed action. For example, if the Extension shows a window that alters a bond length or inserts a new framgent. The action should be added to the undo stack.

void Avogadro::Extension::readSettings ( QSettings settings) [virtual]

read settings for this extension

Parameters:
settingssettings variable to read settings from

Reimplemented from Avogadro::Plugin.

Reimplemented in Avogadro::PythonExtension.

void Avogadro::Extension::setMolecule ( Molecule molecule) [virtual, slot]

Slot to set the Molecule for the Extension - should be called whenever the active Molecule changes.

Plugin::Type Avogadro::Extension::type ( ) const [virtual]

Plugin Type

Implements Avogadro::Plugin.

Plugin Type Name (Extensions)

References QObject::tr().

int Avogadro::Extension::usefulness ( ) const [virtual]

Determines the ordering of the extensions. More useful extensions will be placed first in menus. It is up to the extension designer to be humble about their usefulness value.

Returns:
usefulness value
bool Avogadro::Extension::usesNetwork ( QAction action) const [virtual]
Returns:
whether the specified action requires the network
void Avogadro::Extension::writeSettings ( QSettings settings) const [virtual]

save settings for this extension

Parameters:
settingssettings variable to write settings to

Reimplemented from Avogadro::Plugin.

Reimplemented in Avogadro::PythonExtension.


Member Data Documentation

The list of DockWidget instances used in dockWidgets(). Append instances of Avogadro::DockWidget to this list to have them used.

Referenced by dockWidget(), dockWidgets(), and numDockWidgets().


The documentation for this class was generated from the following files: