mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 03:21:29 +00:00
26f20b805d
When events are hidden in the profile, only hide events with the same name and the same severity (flags). From discussion in https://github.com/subsurface/libdc/pull/54. Signed-off-by: Michael Keller <github@ike.ch>
52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#include "eventname.h"
|
|
#include "subsurface-string.h"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
|
|
struct event_name {
|
|
std::string name;
|
|
bool plot;
|
|
};
|
|
|
|
static std::vector<event_name> event_names;
|
|
|
|
// Small helper so that we can compare events to C-strings
|
|
static bool operator==(const event_name &en, const char *s)
|
|
{
|
|
return en.name == s;
|
|
}
|
|
|
|
extern "C" void clear_event_names()
|
|
{
|
|
event_names.clear();
|
|
}
|
|
|
|
extern "C" void remember_event_name(const char *eventname)
|
|
{
|
|
if (empty_string(eventname))
|
|
return;
|
|
if (std::find(event_names.begin(), event_names.end(), eventname) != event_names.end())
|
|
return;
|
|
event_names.push_back({ eventname, true });
|
|
}
|
|
|
|
extern "C" bool is_event_hidden(const char *eventname)
|
|
{
|
|
auto it = std::find(event_names.begin(), event_names.end(), eventname);
|
|
return it != event_names.end() && !it->plot;
|
|
}
|
|
|
|
extern "C" void show_all_events()
|
|
{
|
|
for (event_name &en: event_names)
|
|
en.plot = true;
|
|
}
|
|
|
|
extern "C" bool any_events_hidden()
|
|
{
|
|
return std::any_of(event_names.begin(), event_names.end(),
|
|
[] (const event_name &en) { return !en.plot; });
|
|
}
|