Add AlertAction type

This commit is contained in:
Dan Paulat 2023-05-02 22:13:11 -05:00
parent 9019aa5e33
commit 411a949be9
3 changed files with 74 additions and 2 deletions

View file

@ -129,12 +129,14 @@ set(SRC_SETTINGS source/scwx/qt/settings/general_settings.cpp
source/scwx/qt/settings/settings_interface_base.cpp
source/scwx/qt/settings/settings_variable.cpp
source/scwx/qt/settings/settings_variable_base.cpp)
set(HDR_TYPES source/scwx/qt/types/font_types.hpp
set(HDR_TYPES source/scwx/qt/types/alert_types.hpp
source/scwx/qt/types/font_types.hpp
source/scwx/qt/types/github_types.hpp
source/scwx/qt/types/qt_types.hpp
source/scwx/qt/types/radar_product_record.hpp
source/scwx/qt/types/text_event_key.hpp)
set(SRC_TYPES source/scwx/qt/types/github_types.cpp
set(SRC_TYPES source/scwx/qt/types/alert_types.cpp
source/scwx/qt/types/github_types.cpp
source/scwx/qt/types/radar_product_record.cpp
source/scwx/qt/types/text_event_key.cpp)
set(HDR_UI source/scwx/qt/ui/about_dialog.hpp

View file

@ -0,0 +1,42 @@
#include <scwx/qt/types/alert_types.hpp>
#include <boost/algorithm/string.hpp>
namespace scwx
{
namespace qt
{
namespace types
{
static const std::unordered_map<AlertAction, std::string> alertActionName_ {
{AlertAction::Go, "Go"},
{AlertAction::View, "View"},
{AlertAction::Unknown, "?"}};
AlertAction GetAlertAction(const std::string& name)
{
auto result =
std::find_if(alertActionName_.cbegin(),
alertActionName_.cend(),
[&](const std::pair<AlertAction, std::string>& pair) -> bool
{ return boost::iequals(pair.second, name); });
if (result != alertActionName_.cend())
{
return result->first;
}
else
{
return AlertAction::Unknown;
}
}
std::string GetAlertActionName(AlertAction alertAction)
{
return alertActionName_.at(alertAction);
}
} // namespace types
} // namespace qt
} // namespace scwx

View file

@ -0,0 +1,28 @@
#pragma once
#include <scwx/util/iterator.hpp>
#include <string>
namespace scwx
{
namespace qt
{
namespace types
{
enum class AlertAction
{
Go,
View,
Unknown
};
typedef scwx::util::Iterator<AlertAction, AlertAction::Go, AlertAction::View>
AlertActionIterator;
AlertAction GetAlertAction(const std::string& name);
std::string GetAlertActionName(AlertAction alertAction);
} // namespace types
} // namespace qt
} // namespace scwx