OpenMS
RecentFilesMenu Class Reference

Manages recent files opened by the user and provides a QMenu to go with it. More...

#include <OpenMS/VISUAL/RecentFilesMenu.h>

Inheritance diagram for RecentFilesMenu:
[legend]
Collaboration diagram for RecentFilesMenu:
[legend]

Public Slots

void add (const String &filename)
 put a new recent file at the top (removing any duplicates in other positions); will update the QMenu More...
 

Signals

void recentFileClicked (const String &filename)
 when a recent file action item from the getMenu() was clicked More...
 

Public Member Functions

 RecentFilesMenu (int max_entries=15)
 C'tor. More...
 
void set (const QStringList &initial)
 sets a list of recent files (up to max_entries many – see C'tor) More...
 
unsigned setFromParam (const Param &filenames)
 Extracts all values from all elements in the param object and tries to interpret them as filenames If they exist, they will be used in the list of recent files. The name of the param items is ignored. More...
 
Param getAsParam () const
 Convert current file list to Param. Their names are just numbers, starting at "0". The values are the filenames. More...
 
QMenu * getMenu ()
 get a menu-pointer to an internal member which always contains the up-to-date recent items More...
 
const QStringList & get () const
 current list of recent files (most recent first) More...
 

Private Slots

void itemClicked_ ()
 invoked by the QAction when it was clicked; emits recentFileClicked(String filename) More...
 

Private Member Functions

void sync_ ()
 updates the menu by synching text and and visibility of actions using the current list of recent files More...
 

Private Attributes

QMenu recent_menu_
 holds the menu and the filenames (as QActions) More...
 
int max_entries_
 maximum of entries; adding more will delete the oldest one More...
 
QStringList recent_files_
 list of the recently opened files actions (menu entries) More...
 
std::vector< QAction * > recent_actions_
 .. and the actions to go with it More...
 

Detailed Description

Manages recent files opened by the user and provides a QMenu to go with it.

Constructor & Destructor Documentation

◆ RecentFilesMenu()

RecentFilesMenu ( int  max_entries = 15)

C'tor.

Member Function Documentation

◆ add

void add ( const String filename)
slot

put a new recent file at the top (removing any duplicates in other positions); will update the QMenu

Referenced by TOPPViewBase::addRecentFile_(), and TOPPASBase::addTOPPASFile().

◆ get()

const QStringList& get ( ) const

current list of recent files (most recent first)

◆ getAsParam()

Param getAsParam ( ) const

Convert current file list to Param. Their names are just numbers, starting at "0". The values are the filenames.

Returns
Param object with name:value pairs

Referenced by TOPPASBase::savePreferences(), and TOPPViewBase::savePreferences().

◆ getMenu()

QMenu* getMenu ( )

get a menu-pointer to an internal member which always contains the up-to-date recent items

Referenced by TOPPASBase::TOPPASBase().

◆ itemClicked_

void itemClicked_ ( )
privateslot

invoked by the QAction when it was clicked; emits recentFileClicked(String filename)

◆ recentFileClicked

void recentFileClicked ( const String filename)
signal

when a recent file action item from the getMenu() was clicked

Referenced by TOPPASBase::TOPPASBase(), and TOPPViewBase::TOPPViewBase().

◆ set()

void set ( const QStringList &  initial)

sets a list of recent files (up to max_entries many – see C'tor)

◆ setFromParam()

unsigned setFromParam ( const Param filenames)

Extracts all values from all elements in the param object and tries to interpret them as filenames If they exist, they will be used in the list of recent files. The name of the param items is ignored.

Parameters
filenamesA Param object of which all values will be tested for being a filename
Returns
The number of items which were successfully interpreted as filenames

Referenced by TOPPASBase::loadPreferences(), and TOPPViewBase::loadPreferences().

◆ sync_()

void sync_ ( )
private

updates the menu by synching text and and visibility of actions using the current list of recent files

Member Data Documentation

◆ max_entries_

int max_entries_
private

maximum of entries; adding more will delete the oldest one

◆ recent_actions_

std::vector<QAction*> recent_actions_
private

.. and the actions to go with it

◆ recent_files_

QStringList recent_files_
private

list of the recently opened files actions (menu entries)

◆ recent_menu_

QMenu recent_menu_
private

holds the menu and the filenames (as QActions)