Workspace 6.21.5
Public Slots | Signals | Public Member Functions | List of all members
RecentFilesMenuView Class Reference

Menu-item based view for a RecentFilesModel. More...

#include <Workspace/Presentation/recentfilesmenuview.h>

Inherits QObject.

Public Slots

bool selectFile (int index)
 
bool selectMostRecentFile ()
 

Signals

void fileSelected (QString fileName)
 

Public Member Functions

 RecentFilesMenuView (QMenu &parent, QAction *before=nullptr)
 
 ~RecentFilesMenuView () override
 
void setModel (RecentFilesModel *model)
 

Detailed Description

Presents the list of files as selectable menu items under a parent menu. Other menu items can also exist in the same menu - the view will make sure to track items it creates and where they are in the menu.

See also
RecentFilesModel

Constructor & Destructor Documentation

◆ RecentFilesMenuView()

RecentFilesMenuView ( QMenu &  parent,
QAction *  before = nullptr 
)
explicit
Parameters
parentThe menu into which the recent files menu items are to be inserted.
beforeThe existing action in the menu parent before which all items are to be inserted. If 0 is specified, actions will be appended to the menu.

◆ ~RecentFilesMenuView()

~RecentFilesMenuView ( )
override

Member Function Documentation

◆ fileSelected

void fileSelected ( QString  fileName)
signal

◆ selectFile

bool selectFile ( int  index)
slot
Parameters
indexIndex of the file to select in the recent files list.
Returns
True if index was within range of recent files, false otherwise.

If successful, emits the signal fileSelected with the filename at the given index in the recent files list.

◆ selectMostRecentFile

bool selectMostRecentFile ( )
slot
Returns
True if at least one recent file exists, false otherwise.

If successful, emits the signal fileSelected with the first filename listed in the recent files list.

◆ setModel()

void setModel ( RecentFilesModel model)
Parameters
modelThe model that this view is to observe and reflect its contents. An empty model can be assigned - this will result in the view being cleared.

Sets the model used by the view. This will result in the views contents being reconstructed to match the model.