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. More... | |
Signals | |
void | activated (const QString &) |
Emitted when user selects any MRU item in the menu. More... | |
Public Member Functions | |
QtxMRUAction (QObject *=0) | |
Constructor. More... | |
QtxMRUAction (const QString &, const QString &, QObject *=0) | |
Constructor. More... | |
QtxMRUAction (const QString &, const QIcon &, const QString &, QObject *=0) | |
Constructor. More... | |
virtual | ~QtxMRUAction () |
Destructor. More... | |
int | insertMode () const |
Get items insertion policy. More... | |
void | setInsertMode (const int) |
Set items insertion policy. More... | |
int | linkType () const |
Get the type of link menu name. More... | |
void | setLinkType (const int) |
Set the type of link menu name. More... | |
int | count () const |
Get number of MRU items. More... | |
bool | isEmpty () const |
Check if the MRU items list is empty. More... | |
int | visibleCount () const |
Get number of visible MRU items. More... | |
void | setVisibleCount (const int) |
Set number of visible MRU items. More... | |
bool | isClearPossible () const |
Return visible status of the menu item which clear all MRU items. More... | |
void | setClearPossible (const bool) |
Set visible the menu item which clear all MRU items. More... | |
int | historyCount () const |
Get number of totally stored MRU items. More... | |
void | setHistoryCount (const int) |
Set number of totally stored MRU items. More... | |
void | remove (const int) |
Remove MRU item. More... | |
void | remove (const QString &) |
Remove MRU item. More... | |
void | insert (const QString &) |
Insert MRU item. More... | |
QString | item (const int) const |
Get MRU item. More... | |
int | find (const QString &) const |
Get MRU item index. More... | |
bool | contains (const QString &) const |
Check if MRU item is in the list. More... | |
virtual void | loadLinks (QtxResourceMgr *, const QString &, const bool=true) |
Load the MRU items from specified resources section. More... | |
virtual void | saveLinks (QtxResourceMgr *, const QString &, const bool=true) const |
Save the MRU items to specified resources section. More... | |
Public Member Functions inherited from QtxAction | |
QtxAction (QObject *=0, bool=false, const QString &=QString()) | |
Constructor. More... | |
QtxAction (const QString &, const QString &, int, QObject *, bool=false, const QString &=QString()) | |
Constructor. More... | |
QtxAction (const QString &, const QString &, const QKeySequence &, QObject *, bool=false, const QString &=QString()) | |
Constructor. More... | |
QtxAction (const QString &, const QIcon &, const QString &, int, QObject *, bool=false, const QString &=QString()) | |
Constructor. More... | |
QtxAction (const QString &, const QIcon &, const QString &, const QKeySequence &, QObject *, bool=false, const QString &=QString()) | |
Constructor. More... | |
virtual | ~QtxAction () |
Destructor. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Customize action events. More... | |
QString | shortcutActionName () const |
Return shortcut action name for the action. More... | |
void | setShortcutActionName (const QString &) |
Set shortcut action name to the action. More... | |
Private Slots | |
void | onActivated () |
Called when any MRU item is selected by the user. More... | |
void | onAboutToShow () |
Prepare MRU items popup menu. More... | |
void | onCleared (bool) |
Private Member Functions | |
void | updateMenu () |
Update MRU items popup menu. More... | |
Private Attributes | |
QStringList | myLinks |
most recent used items More... | |
QAction * | myClear |
clear item More... | |
int | myVisCount |
number of visible MRU items More... | |
int | myHistoryCount |
number of stored MRU items More... | |
int | myLinkType |
type of link names in menu More... | |
int | myInsertMode |
items insertion policy More... | |
Additional Inherited Members | |
Protected Member Functions inherited from QtxAction | |
virtual void | addedTo (QWidget *) |
Called when the action is added to the widget. More... | |
virtual void | removedFrom (QWidget *) |
Called when the action is removed from the widget. More... | |
virtual void | customEvent (QEvent *) |
Process notification events. More... | |
QtxMRUAction::QtxMRUAction | ( | QObject * | parent = 0 | ) |
parent | parent object |
References myClear, onAboutToShow(), and onCleared().
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().
|
virtual |
|
signal |
link | selected MRU item |
|
slot |
References myLinks.
bool QtxMRUAction::contains | ( | const QString & | link | ) | const |
link | MRU item |
true
if specified item is already added to the list References myLinks.
int QtxMRUAction::count | ( | ) | const |
References myLinks.
int QtxMRUAction::find | ( | const QString & | link | ) | const |
int QtxMRUAction::historyCount | ( | ) | const |
References myHistoryCount.
void QtxMRUAction::insert | ( | const QString & | link | ) |
int QtxMRUAction::insertMode | ( | ) | const |
References myInsertMode.
bool QtxMRUAction::isClearPossible | ( | ) | const |
References myClear.
bool QtxMRUAction::isEmpty | ( | ) | const |
true
if there are no MRU items References myLinks.
QString QtxMRUAction::item | ( | const int | idx | ) | const |
idx | MRU item index |
References myLinks.
int QtxMRUAction::linkType | ( | ) | const |
References myLinkType.
|
virtual |
resMgr | resources manager |
section | resources section |
clear | if true , previous MRU items list is cleared |
References myLinks, QtxResourceMgr::parameters(), and QtxResourceMgr::stringValue().
|
privateslot |
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().
|
privateslot |
Emits signal activated(const QString&) passing selected MRU item as parameter.
References activated(), and myLinks.
|
privateslot |
References clear().
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.
|
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::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::setInsertMode | ( | const int | mode | ) |
mode | insertion policy (QtxMRUAction::InsertionMode) |
References myInsertMode.
void QtxMRUAction::setLinkType | ( | const int | type | ) |
link | type (QtxMRUAction::LinkType) |
References myLinkType.
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.
|
private |
References AddLast, count(), Qtx::file(), insertMode(), isClearPossible(), LinkAuto, LinkFull, LinkShort, linkType(), MoveLast, myClear, myLinks, onActivated(), and visibleCount().
int QtxMRUAction::visibleCount | ( | ) | const |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |