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