A model adapter that populates a QMenu with items that correspond to items in an AbstractTableModel.
More...
#include <BasicTableModelMenuAdapter.h++>
|
virtual QString | getMenuLabelForItem (const T &item) const =0 |
| Returns the menu item label that should be used for the given item in the model. More...
|
|
virtual void | handleItemSelection (const T *item)=0 |
| Called when a checkable menu item has been selected. More...
|
|
template<class T>
class quark::gui::BasicTableModelMenuAdapter< T >
A model adapter that populates a QMenu with items that correspond to items in an AbstractTableModel.
The adapter automatically keeps the menu up to date with respect to the model; as items are added to or removed from the model, the corresponding menu items will be added to or removed from the menu.
This is an abstract class; subclasses must implement getMenuLabelForItem() and handleItemSelection().
- Author
- Mark Lindner
◆ Option
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.
|
◆ BasicTableModelMenuAdapter()
Constructs a new BasicTableModelMenuAdapter for the given model and menu.
- Parameters
-
model | The model. |
menu | The menu |
options | Options for the adapter. |
◆ ~BasicTableModelMenuAdapter()
◆ getMenuLabelForItem()
virtual QString getMenuLabelForItem |
( |
const T & |
item | ) |
const |
|
protectedpure virtual |
Returns the menu item label that should be used for the given item in the model.
- Parameters
-
- Returns
- The menu item label.
Implemented in RecentFileTableModelMenuAdapter.
◆ handleItemSelection()
virtual void handleItemSelection |
( |
const T * |
item | ) |
|
|
protectedpure virtual |
Called when a checkable menu item has been selected.
- Parameters
-
item | The model item corresponding to the menu item that was selected. |
Implemented in RecentFileTableModelMenuAdapter.
◆ Q_DECLARE_FLAGS()
Q_DECLARE_FLAGS |
( |
Options |
, |
|
|
Option |
|
|
) |
| |
|
inherited |
◆ setSelectedItem()
void setSelectedItem |
( |
const T * |
item | ) |
|
Selects the (checkable) menu item corresponding to the given model item.
- Parameters
-
◆ sync()
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: