OpenMS
Loading...
Searching...
No Matches
RecentFilesMenu.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Chris Bielow $
6// $Authors: Chris Bielow $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11// OpenMS_GUI config
12#include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13
15
16#include <QMenu>
17#include <QStringList>
18
19#include <vector>
20
21class QAction;
22
23namespace OpenMS
24{
25 class Param;
26
33 : public QObject
34 {
35 Q_OBJECT
36
37 signals:
39 void recentFileClicked(const std::string& filename);
40
41 public:
43 RecentFilesMenu(int max_entries = 15);
44
46 void set(const QStringList& initial);
47
56 unsigned setFromParam(const Param& filenames);
57
63
65 QMenu* getMenu();
66
68 const QStringList& get() const;
69
70 public slots:
72 void add(const std::string& filename);
73
74 private slots:
77
78 private:
80 void sync_();
81
87 QStringList recent_files_;
89 std::vector<QAction*> recent_actions_;
90 };
91
92} //namespace
93
Management and storage of parameters / INI files.
Definition Param.h:46
Manages recent files opened by the user and provides a QMenu to go with it.
Definition RecentFilesMenu.h:34
void recentFileClicked(const std::string &filename)
when a recent file action item from the getMenu() was clicked
Param getAsParam() const
Convert current file list to Param. Their names are just numbers, starting at "0"....
RecentFilesMenu(int max_entries=15)
C'tor.
std::vector< QAction * > recent_actions_
.. and the actions to go with it
Definition RecentFilesMenu.h:89
QStringList recent_files_
list of the recently opened files actions (menu entries)
Definition RecentFilesMenu.h:87
unsigned setFromParam(const Param &filenames)
Extracts all values from all elements in the param object and tries to interpret them as filenames If...
const QStringList & get() const
current list of recent files (most recent first)
void itemClicked_()
invoked by the QAction when it was clicked; emits recentFileClicked(std::string filename)
void add(const std::string &filename)
put a new recent file at the top (removing any duplicates in other positions); will update the QMenu
void sync_()
updates the menu by synching text and and visibility of actions using the current list of recent file...
QMenu recent_menu_
holds the menu and the filenames (as QActions)
Definition RecentFilesMenu.h:83
int max_entries_
maximum of entries; adding more will delete the oldest one
Definition RecentFilesMenu.h:85
void set(const QStringList &initial)
sets a list of recent files (up to max_entries many – see C'tor)
QMenu * getMenu()
get a menu-pointer to an internal member which always contains the up-to-date recent items
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19