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 class String;
27
34 : public QObject
35 {
36 Q_OBJECT
37
38 signals:
40 void recentFileClicked(const String& filename);
41
42 public:
44 RecentFilesMenu(int max_entries = 15);
45
47 void set(const QStringList& initial);
48
57 unsigned setFromParam(const Param& filenames);
58
64
66 QMenu* getMenu();
67
69 const QStringList& get() const;
70
71 public slots:
73 void add(const String& filename);
74
75 private slots:
78
79 private:
81 void sync_();
82
88 QStringList recent_files_;
90 std::vector<QAction*> recent_actions_;
91 };
92
93} //namespace
94
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:35
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:90
QStringList recent_files_
list of the recently opened files actions (menu entries)
Definition RecentFilesMenu.h:88
unsigned setFromParam(const Param &filenames)
Extracts all values from all elements in the param object and tries to interpret them as filenames If...
void recentFileClicked(const String &filename)
when a recent file action item from the getMenu() was clicked
const QStringList & get() const
current list of recent files (most recent first)
void itemClicked_()
invoked by the QAction when it was clicked; emits recentFileClicked(String filename)
void add(const 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:84
int max_entries_
maximum of entries; adding more will delete the oldest one
Definition RecentFilesMenu.h:86
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
A more convenient string class.
Definition String.h:34
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19