Avogadro
1.1.0
|
Interface for adding extensions. More...
#include <avogadro/extension.h>
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 QDockWidget * | dockWidget () |
virtual QList< DockWidget * > | dockWidgets () const |
virtual int | numDockWidgets () const |
virtual QUndoCommand * | performAction (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 |
Interface for adding extensions.
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.
Avogadro::Extension::Extension | ( | QObject * | parent = 0 | ) |
Constructor.
Avogadro::Extension::~Extension | ( | ) | [virtual] |
Destructor.
virtual QList<QAction *> Avogadro::Extension::actions | ( | ) | const [pure virtual] |
Implemented in Avogadro::PythonExtension, and Avogadro::DockExtension.
void Avogadro::Extension::actionsChanged | ( | Extension * | ) | [signal] |
Can be used to notify the MainWindow to refresh the QActions for this extension.
QDockWidget * Avogadro::Extension::dockWidget | ( | ) | [virtual] |
Reimplemented in Avogadro::PythonExtension, and Avogadro::DockExtension.
References QList::first(), QList::isEmpty(), and m_dockWidgets.
QList< DockWidget * > Avogadro::Extension::dockWidgets | ( | ) | const [virtual] |
References m_dockWidgets.
QString Avogadro::Extension::menuPath | ( | QAction * | action | ) | const [virtual] |
Reimplemented in Avogadro::PythonExtension.
void Avogadro::Extension::message | ( | const QString & | m | ) | [signal] |
Can be used to add messages to the message pane.
m | the 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] |
References m_dockWidgets, and QList::size().
virtual QUndoCommand* Avogadro::Extension::performAction | ( | QAction * | action, |
GLWidget * | widget | ||
) | [pure virtual] |
action | the action that triggered the calls |
widget | the currently active GLWidget feedback to the user) |
Implemented in Avogadro::PythonExtension, and Avogadro::DockExtension.
void Avogadro::Extension::performCommand | ( | QUndoCommand * | ) | [signal] |
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
settings | settings variable to read settings from |
Reimplemented from Avogadro::Plugin.
Reimplemented in Avogadro::PythonExtension.
void Avogadro::Extension::setMolecule | ( | Molecule * | molecule | ) | [virtual, slot] |
Plugin::Type Avogadro::Extension::type | ( | ) | const [virtual] |
Plugin Type
Implements Avogadro::Plugin.
QString Avogadro::Extension::typeName | ( | ) | const |
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.
bool Avogadro::Extension::usesNetwork | ( | QAction * | action | ) | const [virtual] |
void Avogadro::Extension::writeSettings | ( | QSettings & | settings | ) | const [virtual] |
save settings for this extension
settings | settings variable to write settings to |
Reimplemented from Avogadro::Plugin.
Reimplemented in Avogadro::PythonExtension.
QList<DockWidget*> Avogadro::Extension::m_dockWidgets [protected] |
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().