Version: 6.3.1
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes

QtxMRUAction Class Reference

Menu action which provides most recent used items support.

#include <QtxMRUAction.h>

Inheritance diagram for QtxMRUAction:
Inheritance graph

Public Types

enum  InsertionMode { MoveFirst, MoveLast, AddFirst, AddLast }
 

Items insertion policy.

More...
enum  LinkType { LinkAuto, LinkShort, LinkFull }

Public Slots

void clear ()
 Remove all MRU items.

Signals

void activated (const QString &)
 Emitted when user selects any MRU item in the menu.

Public Member Functions

 QtxMRUAction (QObject *=0)
 Constructor.
 QtxMRUAction (const QString &, const QString &, QObject *=0)
 Constructor.
 QtxMRUAction (const QString &, const QIcon &, const QString &, QObject *=0)
 Constructor.
virtual ~QtxMRUAction ()
 Destructor.
int insertMode () const
 Get items insertion policy.
void setInsertMode (const int)
 Set items insertion policy.
int linkType () const
 Get the type of link menu name.
void setLinkType (const int)
 Set the type of link menu name.
int count () const
 Get number of MRU items.
bool isEmpty () const
 Check if the MRU items list is empty.
int visibleCount () const
 Get number of visible MRU items.
void setVisibleCount (const int)
 Set number of visible MRU items.
bool isClearPossible () const
 Return visible status of the menu item which clear all MRU items.
void setClearPossible (const bool)
 Set visible the menu item which clear all MRU items.
int historyCount () const
 Get number of totally stored MRU items.
void setHistoryCount (const int)
 Set number of totally stored MRU items.
void remove (const int)
 Remove MRU item.
void remove (const QString &)
 Remove MRU item.
void insert (const QString &)
 Insert MRU item.
QString item (const int) const
 Get MRU item.
int find (const QString &) const
 Get MRU item index.
bool contains (const QString &) const
 Check if MRU item is in the list.
virtual void loadLinks (QtxResourceMgr *, const QString &, const bool=true)
 Load the MRU items from specified resources section.
virtual void saveLinks (QtxResourceMgr *, const QString &, const bool=true) const
 Save the MRU items to specified resources section.
virtual bool eventFilter (QObject *, QEvent *)
 Customize action events.
QString shortcutActionName () const
 Return shortcut action name for the action.
void setShortcutActionName (const QString &)
 Set shortcut action name to the action.

Protected Member Functions

virtual void addedTo (QWidget *)
 Called when the action is added to the widget.
virtual void removedFrom (QWidget *)
 Called when the action is removed from the widget.
virtual void customEvent (QEvent *)
 Process notification events.

Private Slots

void onActivated ()
 Called when any MRU item is selected by the user.
void onAboutToShow ()
 Prepare MRU items popup menu.
void onCleared (bool)

Private Member Functions

void updateMenu ()
 Update MRU items popup menu.

Private Attributes

QStringList myLinks
 most recent used items
QActionmyClear
 clear item
int myVisCount
 number of visible MRU items
int myHistoryCount
 number of stored MRU items
int myLinkType
 type of link names in menu
int myInsertMode
 items insertion policy

Member Enumeration Documentation

Enumerator:
MoveFirst 

put the specified item to the beginning

MoveLast 

put the specified item to the end

AddFirst 

if specified item doesn't exist, add it to the beginning

AddLast 

if specified item doesn't exist, add it to the end

Enumerator:
LinkAuto 

put the full path of link into the menu if link file names of severals link are same

LinkShort 

put the only file name of link into the menu

LinkFull 

put the full path of link into the menu


Constructor & Destructor Documentation

QtxMRUAction::QtxMRUAction ( QObject parent = 0)
Parameters:
parentparent object

References myClear, onAboutToShow(), and onCleared().

QtxMRUAction::QtxMRUAction ( const QString &  text,
const QString &  menuText,
QObject parent = 0 
)
Parameters:
description(tooltip) text
menuTextmenu text
parentparent object

References myClear, onAboutToShow(), and onCleared().

QtxMRUAction::QtxMRUAction ( const QString &  text,
const QIcon &  icon,
const QString &  menuText,
QObject parent = 0 
)
Parameters:
description(tooltip) text
iconaction icon
menuTextmenu text
parentparent object

References myClear, onAboutToShow(), and onCleared().

QtxMRUAction::~QtxMRUAction ( ) [virtual]

Member Function Documentation

int QtxMRUAction::insertMode ( ) const
Returns:
insertion policy (QtxMRUAction.InsertionMode)

References myInsertMode.

void QtxMRUAction::setInsertMode ( const int  mode)
Parameters:
modeinsertion policy (QtxMRUAction.InsertionMode)

References myInsertMode.

int QtxMRUAction::linkType ( ) const
Returns:
link type (QtxMRUAction.LinkType)

References myLinkType.

void QtxMRUAction::setLinkType ( const int  type)
Parameters:
linktype (QtxMRUAction.LinkType)

References myLinkType.

int QtxMRUAction::count ( ) const
Returns:
number of MRU items

References myLinks.

bool QtxMRUAction::isEmpty ( ) const
Returns:
true if there are no MRU items

References myLinks.

int QtxMRUAction::visibleCount ( ) const
Returns:
visible MRU items number
See also:
setVisibleCount()

References myVisCount.

void QtxMRUAction::setVisibleCount ( const int  num)

This method sets the maximum number of MRU items to be displayed in the popup menu (5 by default).

If num < 1, then all MRU items will be displayed.

Parameters:
numvisible MRU items number

References myVisCount.

bool QtxMRUAction::isClearPossible ( ) const

References myClear.

void QtxMRUAction::setClearPossible ( const bool  on)

References myClear.

int QtxMRUAction::historyCount ( ) const
Returns:
number of MRU items stored in the preferences
See also:
setHistoryCount(), saveLinks(), loadLinks()

References myHistoryCount.

void QtxMRUAction::setHistoryCount ( const int  num)

This option allows setting number of MRU items to be stored in the preferences file.

If num < 0, then number of stored MRU items is not limited.

Returns:
number of MRU items stored in the preferences
See also:
historyCount(), saveLinks(), loadLinks()

References myHistoryCount.

void QtxMRUAction::remove ( const int  idx)

Does nothing if idx is out of range.

Parameters:
idxMRU item index

References myLinks.

void QtxMRUAction::remove ( const QString &  link)

Does nothing if there is no speicified item in the list.

Parameters:
linkMRU item to be removed

References myLinks.

void QtxMRUAction::insert ( const QString &  link)

The item is inserted according to the current insertion policy.

Parameters:
linkMRU item to be added

References AddFirst, AddLast, insertMode(), MoveFirst, MoveLast, and myLinks.

QString QtxMRUAction::item ( const int  idx) const
Parameters:
idxMRU item index
Returns:
MRU item or null QString if idx is out of range

References myLinks.

int QtxMRUAction::find ( const QString &  link) const
Parameters:
linkMRU item
Returns:
MRU item index or -1 if item is not found

References myLinks.

bool QtxMRUAction::contains ( const QString &  link) const
Parameters:
linkMRU item
Returns:
true if specified item is already added to the list

References myLinks.

void QtxMRUAction::loadLinks ( QtxResourceMgr resMgr,
const QString &  section,
const bool  clear = true 
) [virtual]
Parameters:
resMgrresources manager
sectionresources section
clearif true, previous MRU items list is cleared

References myLinks, QtxResourceMgr.parameters(), and QtxResourceMgr.stringValue().

void QtxMRUAction::saveLinks ( QtxResourceMgr resMgr,
const QString &  section,
const bool  clear = true 
) const [virtual]
Parameters:
resMgrresources manager
sectionresources section
clearif true, the resources section is first cleared

References myHistoryCount, myLinks, QtxResourceMgr.parameters(), QtxResourceMgr.remove(), QtxResourceMgr.setValue(), and QtxResourceMgr.stringValue().

void QtxMRUAction::clear ( ) [slot]

References myLinks.

void QtxMRUAction::activated ( const QString &  link) [signal]
Parameters:
linkselected MRU item
void QtxMRUAction::onActivated ( ) [private, slot]

Emits signal activated(const QString&) passing selected MRU item as parameter.

References test_table.a, activated(), and myLinks.

void QtxMRUAction::onAboutToShow ( ) [private, slot]

This method is called when the parent menu is shown. Enables or disables sub menu item according to the number of MRU items.

References updateMenu().

void QtxMRUAction::onCleared ( bool  ) [private, slot]

References clear().

void QtxMRUAction::updateMenu ( ) [private]
bool QtxAction::eventFilter ( QObject o,
QEvent e 
) [virtual, inherited]

Sends a notification event to the action when it is added to the widget or removed from it in order to perform custom processing.

Parameters:
oobject
eevent
Returns:
true if further event processing should be stopped
See also:
customEvent(), addedTo(), removedFrom()
QString QtxAction::shortcutActionName ( ) const [inherited]
Returns:
shortcut action name
See also:
setShortcutActionName()

References QtxAction.myShortcutActionName.

void QtxAction::setShortcutActionName ( const QString &  shortcutAction) [inherited]

Shortcut action name is used for shortcuts customization.

Parameters:
shortcutActionshortcut action name
See also:
shortcutActionName()

References QtxAction.myShortcutActionName.

void QtxAction::addedTo ( QWidget ) [protected, virtual, inherited]

This method can be redefined in the subclasses to customize the action behavior. Base implementation does nothing.

Parameters:
wwidget (should be menu or toolbar)
See also:
removedFrom()

Reimplemented in LightApp_ModuleAction, QtxActionSet, QtxDockAction, QtxWorkspaceAction, and QtxWorkstackAction.

void QtxAction::removedFrom ( QWidget ) [protected, virtual, inherited]

This method can be redefined in the subclasses to customize the action behavior. Base implementation does nothing.

Parameters:
wwidget (should be menu or toolbar)
See also:
addedTo()

Reimplemented in LightApp_ModuleAction, QtxActionSet, QtxDockAction, QtxWorkspaceAction, and QtxWorkstackAction.

void QtxAction::customEvent ( QEvent e) [protected, virtual, inherited]

Calls addedTo() method when the action is added to the widget and removedFrom() when it is removed from the widget in order to perform custom processing.

Parameters:
enoification event
See also:
eventFilter(), addedTo(), removedFrom()

References QtxAction.addedTo(), QtxAction.ActionNotify.isAdded(), QtxAction.removedFrom(), and QtxAction.ActionNotify.widget().


Field Documentation

QStringList QtxMRUAction.myLinks [private]
int QtxMRUAction.myVisCount [private]
int QtxMRUAction.myLinkType [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS