QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RGuiAction Class Reference

Abstract base class for GUI action classes. More...

#include <RGuiAction.h>

Inheritance diagram for RGuiAction:
RFocusListener RTransactionListener RSelectionListener

List of all members.

Public Types

typedef void(* FactoryFunction )(RGuiAction *)

Public Slots

bool slotTrigger (const QString &command=QString::null)
 Called when the action is triggered (e.g.

Signals

void postTriggered ()

Public Member Functions

void addArgument (const QString &arg)
void addToMenu (QMenu *menu)
void addToToolBar (QToolBar *tb)
void clearArguments ()
void disableIcon ()
QStringList getArguments ()
QStringList getCommands ()
QStringList getDefaultCommands ()
QList< QKeySequence > getDefaultShortcuts ()
RDocumentInterfacegetDocumentInterface ()
QString getGroup ()
int getGroupSortOrder (const QWidget *w=NULL)
QString getMainCommand ()
bool getRequiresDocument ()
bool getRequiresRedoableTransaction ()
bool getRequiresSelection ()
bool getRequiresUndoableTransaction ()
QString getScriptClass () const
QString getScriptFile () const
QString getShortcutText ()
int getSortOrder (const QWidget *w=NULL)
QString getToolTip (const QString &text, const QString &shortcut)
QString getUniqueGroup ()
QStringList getWidgetNames () const
bool hasNoState ()
virtual void init ()
virtual void initTexts ()
 Initializes the GUI action texts (for menus, tooltips, ...).
virtual bool isChecked ()
bool isGroupDefault ()
bool isIconDisabled ()
bool isOverride ()
 RGuiAction (const QString &text, QObject *parent=0)
virtual void setChecked (bool on)
 Checks or unchecks this action.
void setCommands (const QStringList &cmds)
 Sets the command(s) that can trigger this action from a command line.
void setDefaultCommands (const QStringList &cmds)
void setDefaultShortcut (const QKeySequence &shortcut)
void setDefaultShortcuts (const QList< QKeySequence > &shortcuts)
void setDocumentInterface (RDocumentInterface *di)
virtual void setEnabled (bool on)
 Enables or disables the action.
virtual void setEnabledOverride (bool on, int override)
 Enables or disables the action.
void setFactory (FactoryFunction f)
virtual void setGroup (const QString &title)
void setGroupDefault (bool on)
void setGroupSortOrder (int sortOrder)
void setGroupSortOrderOverride (const QString &widgetName, int sortOrder)
virtual void setIcon (const QString &iconFile)
 Sets the action icon to the given icon file.
void setNoState (bool checkable=false)
void setOverride ()
void setRequiresDocument (bool on)
 If on is true, this action requires a document to be open.
void setRequiresRedoableTransaction (bool on)
void setRequiresSelection (bool on)
 If on is true, this action requires a selection to operate on.
void setRequiresUndoableTransaction (bool on)
void setScriptFile (const QString &sf, bool isSecondary=false)
 Sets the script file to be used for this action.
void setShortcut (const QKeySequence &shortcut)
 Sets the shortcut(s) for this action.
void setShortcuts (const QList< QKeySequence > &shortcuts)
void setShortcutText (const QString &text)
void setSortOrder (int sortOrder)
void setSortOrderOverride (const QString &widgetName, int sortOrder)
virtual void setStatusTip (const QString &tip)
 Sets the status tip of this action.
virtual void setToolTip (const QString &tip)
 Sets the tooltip for this action.
void setUniqueGroup (const QString &ug)
void setWidgetNames (const QStringList &widgetNames)
virtual void updateFocus (RDocumentInterface *documentInterface)
 Called by the document whenever the focus changed from one MDI to another.
virtual void updateSelectionListener (RDocumentInterface *documentInterface)
 Called by the document whenever the current clipboard changes.
virtual void updateTransactionListener (RDocument *document, RTransaction *transaction=NULL)
 Called by the document whenever the current transaction stack changes.
virtual ~RGuiAction ()
- Public Member Functions inherited from RFocusListener
virtual ~RFocusListener ()
- Public Member Functions inherited from RTransactionListener
virtual ~RTransactionListener ()
- Public Member Functions inherited from RSelectionListener
virtual ~RSelectionListener ()

Static Public Member Functions

static void addSeparatorToWidget (QAction *a, QWidget *w)
static void addToWidget (QAction *a, QWidget *w)
static void clear ()
 Cleans up all GUI action objects.
static void fixSeparators (const QWidget *w)
static QString formatToolTip (const QString &text, const QString &shortcut)
static QList< RGuiAction * > getActions ()
static QStringList getAvailableCommands (bool primaryOnly=false)
static QStringList getAvailableCommands (const QString &start, bool primaryOnly=false)
static RGuiActiongetByClassName (const QString &className)
static RGuiActiongetByScriptFile (const QString &scriptFile)
static int getGroupSortOrderStatic (const QAction *a, const QWidget *w=NULL)
static int getSortOrderStatic (const QAction *a, const QWidget *w=NULL)
static QStringList getWidgetNamesStatic (const QAction *a)
static void removeFromWidget (QAction *a, QWidget *w)
static void setGroupSortOrderOverrideStatic (QAction *a, const QString &widgetName, int sortOrder)
static void setGroupSortOrderStatic (QAction *a, int sortOrder)
static void setSortOrderOverrideStatic (QAction *a, const QString &widgetName, int sortOrder)
static void setSortOrderStatic (QAction *a, int sortOrder)
static void setWidgetNamesStatic (QAction *a, const QStringList &widgetNames)
static bool triggerByCommand (const QString &cmd)
 Triggers the first action in the list of actions that is registered to use the given command.
static bool triggerByScriptFile (const QString &scriptFile)
 Triggers the first action in the list of actions that is based on the given scriptFile.
static void triggerGroupDefault (const QString &group)
static void triggerGroupDefaults ()

Protected Attributes

QStringList arguments
QStringList commandList
QStringList defaultCommandList
QList< QKeySequence > defaultShortcuts
RDocumentInterfacedocumentInterface
int enabledOverride
FactoryFunction factory
QString group
bool groupDefault
bool iconDisabled
QString mainCommand
bool noState
bool override
bool requiresDocument
bool requiresRedoableTransaction
bool requiresSelection
bool requiresUndoableTransaction
QString scriptFile
QString shortcutText
QString toolTip
QString uniqueGroup

Static Protected Attributes

static QList< RGuiAction * > actions
static QMap< QString,
RGuiAction * > 
actionsByCommand
 Copyright (c) 2011-2014 by Andrew Mustun.
static QMultiMap< QString,
RGuiAction * > 
actionsByGroup
static QMap< QString,
RGuiAction * > 
actionsByPrimaryCommand
static QMap< QString,
RGuiAction * > 
actionsByScriptFile

Detailed Description

Abstract base class for GUI action classes.

Such classes represent a GUI action that can be used to start a tool. One GUI action class may be assigned to multiple GUI elements, for example a menu, a toolbutton and a context menu.

Each GUI action can have multiple commands assigned to it. These commands can be used to trigger the action from a command line.

Each GUI action can have multiple shortcuts assigned to it. Shortcuts are 'traditional' key combinations that can be used to trigger the action. e.g. Ctrl + Z, Ctrl + N, ...

Scriptable:
This class is wrapped for script environments.

Member Typedef Documentation

typedef void(* RGuiAction::FactoryFunction)(RGuiAction *)

Constructor & Destructor Documentation

RGuiAction::RGuiAction ( const QString &  text,
QObject *  parent = 0 
)
RGuiAction::~RGuiAction ( )
virtual

Member Function Documentation

void RGuiAction::addArgument ( const QString &  arg)
void RGuiAction::addSeparatorToWidget ( QAction *  a,
QWidget *  w 
)
static
void RGuiAction::addToMenu ( QMenu *  menu)
void RGuiAction::addToToolBar ( QToolBar *  tb)
void RGuiAction::addToWidget ( QAction *  a,
QWidget *  w 
)
static
void RGuiAction::clear ( )
static

Cleans up all GUI action objects.

void RGuiAction::clearArguments ( )
void RGuiAction::disableIcon ( )
void RGuiAction::fixSeparators ( const QWidget *  w)
static
QString RGuiAction::formatToolTip ( const QString &  text,
const QString &  shortcut 
)
static
static QList<RGuiAction*> RGuiAction::getActions ( )
inlinestatic
Returns:
List of all instantiated actions.
QStringList RGuiAction::getArguments ( )
QStringList RGuiAction::getAvailableCommands ( bool  primaryOnly = false)
static
Returns:
A list of available top level commands. These are commands that can be used to trigger actions.
Parameters:
primaryOnlyTrue: only include primary commands (e.g. 'point') False: also include secondary commands (e.g. 'po')
QStringList RGuiAction::getAvailableCommands ( const QString &  start,
bool  primaryOnly = false 
)
static
Returns:
List of available commands for triggering actions that start with start.

This is typically used when the user presses the Tab key in a command line to complete a started command. For example entering "li<tab>" will result in the command to be completed to "line".

Parameters:
primaryOnlyTrue: only include primary commands (e.g. 'point') False: also include secondary commands (e.g. 'po')
RGuiAction * RGuiAction::getByClassName ( const QString &  className)
static
Returns:
The first action in the list of actions that defines a class with the given name. Test is based on file name only.
RGuiAction * RGuiAction::getByScriptFile ( const QString &  scriptFile)
static
Returns:
The first action in the list of actions that is based on the given scriptFile.
QStringList RGuiAction::getCommands ( )
inline
Returns:
Complete list of commands that may be used to trigger this action.
QStringList RGuiAction::getDefaultCommands ( )
inline
QList< QKeySequence > RGuiAction::getDefaultShortcuts ( )
RDocumentInterface * RGuiAction::getDocumentInterface ( )
QString RGuiAction::getGroup ( )
int RGuiAction::getGroupSortOrder ( const QWidget *  w = NULL)
int RGuiAction::getGroupSortOrderStatic ( const QAction *  a,
const QWidget *  w = NULL 
)
static
QString RGuiAction::getMainCommand ( )
inline
Returns:
The main command used to trigger this action. This is typically the full command (e.g. "line") rather than one of the abbreviated commands such as "ln".
bool RGuiAction::getRequiresDocument ( )
inline
Return values:
trueThis action requires an open document to be started.
falseThis action does not require an open document to be started.
bool RGuiAction::getRequiresRedoableTransaction ( )
inline
bool RGuiAction::getRequiresSelection ( )
inline
Return values:
trueThis action requires an selection to be started.
falseThis action does not require a selection to be started.
bool RGuiAction::getRequiresUndoableTransaction ( )
inline
QString RGuiAction::getScriptClass ( ) const
inline
QString RGuiAction::getScriptFile ( ) const
inline
Returns:
Script file on which this action is based on.
QString RGuiAction::getShortcutText ( )
int RGuiAction::getSortOrder ( const QWidget *  w = NULL)
int RGuiAction::getSortOrderStatic ( const QAction *  a,
const QWidget *  w = NULL 
)
static
QString RGuiAction::getToolTip ( const QString &  text,
const QString &  shortcut 
)
QString RGuiAction::getUniqueGroup ( )
inline
QStringList RGuiAction::getWidgetNames ( ) const
QStringList RGuiAction::getWidgetNamesStatic ( const QAction *  a)
static
bool RGuiAction::hasNoState ( )
inline
void RGuiAction::init ( )
virtual
void RGuiAction::initTexts ( )
virtual

Initializes the GUI action texts (for menus, tooltips, ...).

This function is called whenever the text of the action changes.

bool RGuiAction::isChecked ( )
virtual
Returns:
True if this action is checked.
bool RGuiAction::isGroupDefault ( )
bool RGuiAction::isIconDisabled ( )
bool RGuiAction::isOverride ( )
inline
void RGuiAction::postTriggered ( )
signal
void RGuiAction::removeFromWidget ( QAction *  a,
QWidget *  w 
)
static
void RGuiAction::setChecked ( bool  on)
virtual

Checks or unchecks this action.

void RGuiAction::setCommands ( const QStringList &  cmds)

Sets the command(s) that can trigger this action from a command line.

Parameters:
cmdComma separated list of command(s) to set for this action. e.g. "mycommand", "mycommand,mycom,mc".
void RGuiAction::setDefaultCommands ( const QStringList &  cmds)
void RGuiAction::setDefaultShortcut ( const QKeySequence &  shortcut)
void RGuiAction::setDefaultShortcuts ( const QList< QKeySequence > &  shortcuts)
void RGuiAction::setDocumentInterface ( RDocumentInterface di)
void RGuiAction::setEnabled ( bool  on)
virtual

Enables or disables the action.

void RGuiAction::setEnabledOverride ( bool  on,
int  override 
)
virtual

Enables or disables the action.

Parameters:
override-1: don't set override (default), 1: true, 0: false
void RGuiAction::setFactory ( FactoryFunction  f)
   \par Non-Scriptable:

This function is not available in script environments.

void RGuiAction::setGroup ( const QString &  title)
virtual
void RGuiAction::setGroupDefault ( bool  on)
void RGuiAction::setGroupSortOrder ( int  sortOrder)
void RGuiAction::setGroupSortOrderOverride ( const QString &  widgetName,
int  sortOrder 
)
void RGuiAction::setGroupSortOrderOverrideStatic ( QAction *  a,
const QString &  widgetName,
int  sortOrder 
)
static
void RGuiAction::setGroupSortOrderStatic ( QAction *  a,
int  sortOrder 
)
static
void RGuiAction::setIcon ( const QString &  iconFile)
virtual

Sets the action icon to the given icon file.

void RGuiAction::setNoState ( bool  checkable = false)
inline
void RGuiAction::setOverride ( )
inline
void RGuiAction::setRequiresDocument ( bool  on)
inline

If on is true, this action requires a document to be open.

The GUI element(s) can for example be grayed out if no document is open.

void RGuiAction::setRequiresRedoableTransaction ( bool  on)
inline
void RGuiAction::setRequiresSelection ( bool  on)
inline

If on is true, this action requires a selection to operate on.

The GUI element(s) can for example be grayed out if no selection is present.

void RGuiAction::setRequiresUndoableTransaction ( bool  on)
inline
void RGuiAction::setScriptFile ( const QString &  sf,
bool  isSecondary = false 
)

Sets the script file to be used for this action.

This is only used for script based actions.

Parameters:
isSecondarytrue to avoid this action to be identified by the given script file when calling getByScriptFile. Used for example for recent file menu entries which all refer to the script OpenFile.js.
void RGuiAction::setShortcut ( const QKeySequence &  shortcut)

Sets the shortcut(s) for this action.

Parameters:
shortcutComma separated list of shortcuts (e.g. "Ctrl-Shift-Z,Ctrl-Y").
void RGuiAction::setShortcuts ( const QList< QKeySequence > &  shortcuts)
void RGuiAction::setShortcutText ( const QString &  text)
void RGuiAction::setSortOrder ( int  sortOrder)
void RGuiAction::setSortOrderOverride ( const QString &  widgetName,
int  sortOrder 
)
void RGuiAction::setSortOrderOverrideStatic ( QAction *  a,
const QString &  widgetName,
int  sortOrder 
)
static
void RGuiAction::setSortOrderStatic ( QAction *  a,
int  sortOrder 
)
static
void RGuiAction::setStatusTip ( const QString &  tip)
virtual

Sets the status tip of this action.

The status tip is shown in the status bar of the application when the mouse cursor hovers of a menu entry.

void RGuiAction::setToolTip ( const QString &  tip)
virtual

Sets the tooltip for this action.

Tooltips are shown when the mouse cursor hovers over a GUI element for some time.

void RGuiAction::setUniqueGroup ( const QString &  ug)
inline
void RGuiAction::setWidgetNames ( const QStringList &  widgetNames)
void RGuiAction::setWidgetNamesStatic ( QAction *  a,
const QStringList &  widgetNames 
)
static
bool RGuiAction::slotTrigger ( const QString &  command = QString::null)
slot

Called when the action is triggered (e.g.

This should be called when the action is triggered, i.e.

a button is pressed or a menu chosen).

a GUI element is activated (button pressed, menu selected, etc).

bool RGuiAction::triggerByCommand ( const QString &  cmd)
static

Triggers the first action in the list of actions that is registered to use the given command.

Parameters:
commandCommand that was launched (e.g. "line" or "ln").
bool RGuiAction::triggerByScriptFile ( const QString &  scriptFile)
static

Triggers the first action in the list of actions that is based on the given scriptFile.

void RGuiAction::triggerGroupDefault ( const QString &  group)
static

found &&

void RGuiAction::triggerGroupDefaults ( )
static
void RGuiAction::updateFocus ( RDocumentInterface di)
virtual

Called by the document whenever the focus changed from one MDI to another.

Parameters:
diThe document interface that has now the focus.

Implements RFocusListener.

void RGuiAction::updateSelectionListener ( RDocumentInterface documentInterface)
virtual

Called by the document whenever the current clipboard changes.

Implements RSelectionListener.

void RGuiAction::updateTransactionListener ( RDocument document,
RTransaction transaction = NULL 
)
virtual

Called by the document whenever the current transaction stack changes.

Implements RTransactionListener.


Member Data Documentation

QList< RGuiAction * > RGuiAction::actions
staticprotected
QMap< QString, RGuiAction * > RGuiAction::actionsByCommand
staticprotected

Copyright (c) 2011-2014 by Andrew Mustun.

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

QMultiMap< QString, RGuiAction * > RGuiAction::actionsByGroup
staticprotected
QMap< QString, RGuiAction * > RGuiAction::actionsByPrimaryCommand
staticprotected
QMap< QString, RGuiAction * > RGuiAction::actionsByScriptFile
staticprotected
QStringList RGuiAction::arguments
protected
QStringList RGuiAction::commandList
protected
QStringList RGuiAction::defaultCommandList
protected
QList<QKeySequence> RGuiAction::defaultShortcuts
protected
RDocumentInterface* RGuiAction::documentInterface
protected
int RGuiAction::enabledOverride
protected
FactoryFunction RGuiAction::factory
protected
QString RGuiAction::group
protected
bool RGuiAction::groupDefault
protected
bool RGuiAction::iconDisabled
protected
QString RGuiAction::mainCommand
protected
bool RGuiAction::noState
protected
bool RGuiAction::override
protected
bool RGuiAction::requiresDocument
protected
bool RGuiAction::requiresRedoableTransaction
protected
bool RGuiAction::requiresSelection
protected
bool RGuiAction::requiresUndoableTransaction
protected
QString RGuiAction::scriptFile
protected
QString RGuiAction::shortcutText
protected
QString RGuiAction::toolTip
protected
QString RGuiAction::uniqueGroup
protected

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