Quark  0.1
RecentFileTableModelMenuAdapter Class Reference

An implementation of BasicTableModelMenuAdapter for RecentFile objects. More...

#include <RecentFileTableModelMenuAdapter.h++>

Inheritance diagram for RecentFileTableModelMenuAdapter:

Public Types

enum  Option { InsertAtTop = 1 << 0, Checkable = 1 << 1, Exclusive = 1 << 2 }
 Item model menu adapter options. More...
 

Signals

void recentFileSelected (const QString &path)
 Emitted when a menu item is selected. More...
 

Public Member Functions

 RecentFileTableModelMenuAdapter (RecentFileTableModel *model, QMenu *menu)
 Constructs a new RecentFileTableModelMenuAdapter for the given model and menu. More...
 
virtual ~RecentFileTableModelMenuAdapter ()
 Destructor. More...
 
void setSelectedItem (const RecentFile *item)
 Selects the (checkable) menu item corresponding to the given model item. More...
 
 Q_DECLARE_FLAGS (Options, Option)
 
void sync ()
 Synchronizes the menu with the model. More...
 

Protected Member Functions

QString getMenuLabelForItem (const RecentFile &item) const
 Returns the menu item label that should be used for the given item in the model. More...
 
void handleItemSelection (const RecentFile *item)
 Called when a checkable menu item has been selected. More...
 

Detailed Description

An implementation of BasicTableModelMenuAdapter for RecentFile objects.

May be used to implement a "recently opened documents" menu.

Author
Mark Lindner

Member Enumeration Documentation

◆ Option

enum Option
inherited

Item model menu adapter options.

Enumerator
InsertAtTop 

An option indicating that the menu items should be inserted above any menu items that existed in the menu at the time of this adapter's construction.

By default, items are added below existing items.

Checkable 

An option indicating that the menu items created by this adapter are checkable.

Exclusive 

An option indicating that the menu items created by this adapter are mutually exclusive; that is, only one may be checked at any given time.

This option is only meaningful if the Checkable option is also set.

Constructor & Destructor Documentation

◆ RecentFileTableModelMenuAdapter()

RecentFileTableModelMenuAdapter ( RecentFileTableModel model,
QMenu *  menu 
)

Constructs a new RecentFileTableModelMenuAdapter for the given model and menu.

◆ ~RecentFileTableModelMenuAdapter()

virtual ~RecentFileTableModelMenuAdapter ( )
virtual

Destructor.

Member Function Documentation

◆ getMenuLabelForItem()

QString getMenuLabelForItem ( const RecentFile item) const
protectedvirtual

Returns the menu item label that should be used for the given item in the model.

Parameters
itemThe model item.
Returns
The menu item label.

Implements BasicTableModelMenuAdapter< RecentFile >.

◆ handleItemSelection()

void handleItemSelection ( const RecentFile item)
protectedvirtual

Called when a checkable menu item has been selected.

Parameters
itemThe model item corresponding to the menu item that was selected.

Implements BasicTableModelMenuAdapter< RecentFile >.

◆ Q_DECLARE_FLAGS()

Q_DECLARE_FLAGS ( Options  ,
Option   
)
inherited

◆ recentFileSelected

void recentFileSelected ( const QString &  path)
signal

Emitted when a menu item is selected.

Parameters
pathThe path of the RecentFile that was selected.

◆ setSelectedItem()

void setSelectedItem ( const RecentFile item)
inherited

Selects the (checkable) menu item corresponding to the given model item.

Parameters
itemThe model item.

◆ sync()

void sync ( )
inherited

Synchronizes the menu with the model.

This method must be called at least once to populate the menu with any items that may exist in the model.


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