Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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. 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...
 
QActionmyClear
 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...
 

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

void QtxMRUAction::activated ( const QString &  link)
signal
Parameters
linkselected MRU item
void QtxMRUAction::clear ( )
slot

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.

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

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.

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

References myHistoryCount.

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.

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

References myInsertMode.

bool QtxMRUAction::isClearPossible ( ) const

References myClear.

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

References 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::linkType ( ) const
Returns
link type (QtxMRUAction::LinkType)

References myLinkType.

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::onAboutToShow ( )
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().

void QtxMRUAction::onActivated ( )
privateslot

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

References activated(), and myLinks.

void QtxMRUAction::onCleared ( bool  )
privateslot

References clear().

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::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::setClearPossible ( const bool  on)

References myClear.

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::setInsertMode ( const int  mode)
Parameters
modeinsertion policy (QtxMRUAction::InsertionMode)

References myInsertMode.

void QtxMRUAction::setLinkType ( const int  type)
Parameters
linktype (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.

Parameters
numvisible MRU items number

References myVisCount.

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

References myVisCount.

Member Data Documentation

QAction* QtxMRUAction::myClear
private
int QtxMRUAction::myHistoryCount
private
int QtxMRUAction::myInsertMode
private
QStringList QtxMRUAction::myLinks
private
int QtxMRUAction::myLinkType
private
int QtxMRUAction::myVisCount
private

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