1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
/* -*- C++ -*-
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2024 Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHOWTYPES_H
#define SHOWTYPES_H
#include <cstdint>
#include <QVariant>
enum class Severity : std::uint8_t;
/// @addtogroup GUI
/// @{
/**
* @brief A class for different show types we have.
* This class contains enum type for the different show types we have. Each
* show type presents one severity selectable in the GUI. In addition there
* are several supporting functions.
*
* Notice that the "visibility" settings are automatically loaded when the
* class is constructed and saved when the class is destroyed.
*/
class ShowTypes {
public:
/**
* @brief Show types we have (i.e. severities in the GUI).
*/
enum ShowType : std::uint8_t {
ShowStyle = 0,
ShowWarnings,
ShowPerformance,
ShowPortability,
ShowInformation,
ShowErrors, // Keep this as last real item
ShowNone
};
/**
* @brief Constructor.
* @note Loads visibility settings.
*/
ShowTypes();
/**
* @brief Destructor.
* @note Saves visibility settings.
*/
~ShowTypes();
/**
* @brief Load visibility settings from the platform's settings storage.
*/
void load();
/**
* @brief Save visibility settings to the platform's settings storage.
*/
void save() const;
/**
* @brief Is the showtype visible in the GUI?
* @param category Showtype to check.
* @return true if the showtype is visible.
*/
bool isShown(ShowTypes::ShowType category) const;
/**
* @brief Is the severity visible in the GUI?
* @param severity severity to check.
* @return true if the severity is visible.
*/
bool isShown(Severity severity) const;
/**
* @brief Show/hide the showtype.
* @param category Showtype whose visibility to set.
* @param showing true if the severity is set visible.
*/
void show(ShowTypes::ShowType category, bool showing);
/**
* @brief Convert severity string to ShowTypes value
* @param severity Error severity
* @return Severity converted to ShowTypes value
*/
static ShowTypes::ShowType SeverityToShowType(Severity severity);
/**
* @brief Convert ShowType to severity string
* @param type ShowType to convert
* @return ShowType converted to severity
*/
static Severity ShowTypeToSeverity(ShowTypes::ShowType type);
/**
* @brief Convert QVariant (that contains an int) to Showtypes value
*
* @param data QVariant (that contains an int) to be converted
* @return data converted to ShowTypes
*/
static ShowTypes::ShowType VariantToShowType(const QVariant &data);
bool mVisible[ShowNone];
};
/// @}
#endif // SHOWTYPES_H
|