Menu action which provides most recent used items support.
#include <QtxMRUAction.h>

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 | |
| QAction * | myClear |
| 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 | |
| QtxMRUAction::QtxMRUAction | ( | QObject * | parent = 0 | ) |
| parent | parent object |
References myClear, onAboutToShow(), and onCleared().
| QtxMRUAction::QtxMRUAction | ( | const QString & | text, |
| const QString & | menuText, | ||
| QObject * | parent = 0 |
||
| ) |
| description | (tooltip) text |
| menuText | menu text |
| parent | parent object |
References myClear, onAboutToShow(), and onCleared().
| QtxMRUAction::QtxMRUAction | ( | const QString & | text, |
| const QIcon & | icon, | ||
| const QString & | menuText, | ||
| QObject * | parent = 0 |
||
| ) |
| description | (tooltip) text |
| icon | action icon |
| menuText | menu text |
| parent | parent object |
References myClear, onAboutToShow(), and onCleared().
| QtxMRUAction::~QtxMRUAction | ( | ) | [virtual] |
| int QtxMRUAction::insertMode | ( | ) | const |
References myInsertMode.
| void QtxMRUAction::setInsertMode | ( | const int | mode | ) |
| mode | insertion policy (QtxMRUAction.InsertionMode) |
References myInsertMode.
| int QtxMRUAction::linkType | ( | ) | const |
References myLinkType.
| void QtxMRUAction::setLinkType | ( | const int | type | ) |
| link | type (QtxMRUAction.LinkType) |
References myLinkType.
| int QtxMRUAction::count | ( | ) | const |
References myLinks.
| bool QtxMRUAction::isEmpty | ( | ) | const |
true if there are no MRU items References myLinks.
| int QtxMRUAction::visibleCount | ( | ) | const |
| 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.
| num | visible MRU items number |
References myVisCount.
| bool QtxMRUAction::isClearPossible | ( | ) | const |
References myClear.
| void QtxMRUAction::setClearPossible | ( | const bool | on | ) |
References myClear.
| int QtxMRUAction::historyCount | ( | ) | const |
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.
References myHistoryCount.
| void QtxMRUAction::remove | ( | const int | idx | ) |
| void QtxMRUAction::remove | ( | const QString & | link | ) |
Does nothing if there is no speicified item in the list.
| link | MRU item to be removed |
References myLinks.
| void QtxMRUAction::insert | ( | const QString & | link | ) |
| QString QtxMRUAction::item | ( | const int | idx | ) | const |
| idx | MRU item index |
References myLinks.
| int QtxMRUAction::find | ( | const QString & | link | ) | const |
| bool QtxMRUAction::contains | ( | const QString & | link | ) | const |
| link | MRU item |
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] |
| resMgr | resources manager |
| section | resources section |
| clear | if 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] |
| resMgr | resources manager |
| section | resources section |
| clear | if 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] |
| link | selected 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] |
References AddLast, count(), Qtx.file(), insertMode(), isClearPossible(), LinkAuto, LinkFull, LinkShort, linkType(), MoveLast, myClear, myLinks, onActivated(), and visibleCount().
Sends a notification event to the action when it is added to the widget or removed from it in order to perform custom processing.
| o | object |
| e | event |
true if further event processing should be stopped | QString QtxAction::shortcutActionName | ( | ) | const [inherited] |
References QtxAction.myShortcutActionName.
| void QtxAction::setShortcutActionName | ( | const QString & | shortcutAction | ) | [inherited] |
Shortcut action name is used for shortcuts customization.
| shortcutAction | shortcut action name |
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.
| w | widget (should be menu or toolbar) |
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.
| w | widget (should be menu or toolbar) |
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.
| e | noification event |
References QtxAction.addedTo(), QtxAction.ActionNotify.isAdded(), QtxAction.removedFrom(), and QtxAction.ActionNotify.widget().
QStringList QtxMRUAction.myLinks [private] |
QAction* QtxMRUAction.myClear [private] |
int QtxMRUAction.myVisCount [private] |
int QtxMRUAction.myHistoryCount [private] |
int QtxMRUAction.myLinkType [private] |
int QtxMRUAction.myInsertMode [private] |