GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
/* |
||
2 |
* The ManaPlus Client |
||
3 |
* Copyright (C) 2011-2019 The ManaPlus Developers |
||
4 |
* Copyright (C) 2009-2021 Andrei Karas |
||
5 |
* |
||
6 |
* This file is part of The ManaPlus Client. |
||
7 |
* |
||
8 |
* This program is free software; you can redistribute it and/or modify |
||
9 |
* it under the terms of the GNU General Public License as published by |
||
10 |
* the Free Software Foundation; either version 2 of the License, or |
||
11 |
* any later version. |
||
12 |
* |
||
13 |
* This program is distributed in the hope that it will be useful, |
||
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 |
* GNU General Public License for more details. |
||
17 |
* |
||
18 |
* You should have received a copy of the GNU General Public License |
||
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
20 |
*/ |
||
21 |
|||
22 |
#ifndef GUI_MODELS_LANGLISTMODEL_H |
||
23 |
#define GUI_MODELS_LANGLISTMODEL_H |
||
24 |
|||
25 |
#include "gui/models/extendedlistmodel.h" |
||
26 |
|||
27 |
#include "resources/loaders/imageloader.h" |
||
28 |
|||
29 |
#include "utils/gettext.h" |
||
30 |
|||
31 |
#include "localconsts.h" |
||
32 |
|||
33 |
88 |
struct Language final |
|
34 |
{ |
||
35 |
A_DEFAULT_COPY(Language) |
||
36 |
|||
37 |
std::string name; |
||
38 |
std::string value; |
||
39 |
std::string icon; |
||
40 |
}; |
||
41 |
|||
42 |
const int langs_count = 22; |
||
43 |
|||
44 |
✓✓ | 2 |
const Language LANG_NAME[langs_count] = |
45 |
{ |
||
46 |
// TRANSLATORS: language |
||
47 |
{N_("(default)"), "", ""}, |
||
48 |
// TRANSLATORS: language |
||
49 |
{N_("Catalan"), "ca_ES", "ca.png"}, |
||
50 |
// TRANSLATORS: language |
||
51 |
{N_("Chinese (China)"), "zh_CN", "cn.png"}, |
||
52 |
// TRANSLATORS: language |
||
53 |
{N_("Chinese (Hong Kong)"), "zh_HK", "hk.png"}, |
||
54 |
// TRANSLATORS: language |
||
55 |
{N_("Czech"), "cs_CZ", "cz.png"}, |
||
56 |
// TRANSLATORS: language |
||
57 |
{N_("Dutch (Belgium/Flemish)"), "nl_BE", "nl_BE.png"}, |
||
58 |
// TRANSLATORS: language |
||
59 |
{N_("English"), "C", "en.png"}, |
||
60 |
// TRANSLATORS: language |
||
61 |
{N_("Finnish"), "fi_FI", "fi.png"}, |
||
62 |
// TRANSLATORS: language |
||
63 |
{N_("French"), "fr_FR", "fr.png"}, |
||
64 |
// TRANSLATORS: language |
||
65 |
{N_("German"), "de_DE", "de.png"}, |
||
66 |
// TRANSLATORS: language |
||
67 |
{N_("Indonesian"), "id_ID", "id.png"}, |
||
68 |
// TRANSLATORS: language |
||
69 |
{N_("Italian"), "it_IT", "it.png"}, |
||
70 |
// TRANSLATORS: language |
||
71 |
{N_("Japanese"), "ja_JP", "jp.png"}, |
||
72 |
// TRANSLATORS: language |
||
73 |
{N_("Polish"), "pl_PL", "pl.png"}, |
||
74 |
// TRANSLATORS: language |
||
75 |
{N_("Portuguese"), "pt_PT", "pt.png"}, |
||
76 |
// TRANSLATORS: language |
||
77 |
{N_("Portuguese (Brazilian)"), "pt_BR", "pt_BR.png"}, |
||
78 |
// TRANSLATORS: language |
||
79 |
{N_("Russian"), "ru_RU", "ru.png"}, |
||
80 |
// TRANSLATORS: language |
||
81 |
{N_("Spanish (Castilian)"), "es_ES", "es.png"}, |
||
82 |
// TRANSLATORS: language |
||
83 |
{N_("Swedish (Sweden)"), "sv_SE", "se.png"}, |
||
84 |
// TRANSLATORS: language |
||
85 |
{N_("Turkish"), "tr_TR", "tr.png"}, |
||
86 |
// TRANSLATORS: language |
||
87 |
{N_("Ukrainian"), "uk_UA", "ua.png"}, |
||
88 |
// TRANSLATORS: language |
||
89 |
{N_("Esperanto"), "eo", "eo.png"} |
||
90 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗ |
133 |
}; |
91 |
|||
92 |
class LangListModel final : public ExtendedListModel |
||
93 |
{ |
||
94 |
public: |
||
95 |
2 |
LangListModel() |
|
96 |
4 |
{ |
|
97 |
✓✓ | 46 |
for (int f = 0; f < langs_count; f ++) |
98 |
{ |
||
99 |
132 |
const std::string icon = LANG_NAME[f].icon; |
|
100 |
✓✓ | 44 |
if (!icon.empty()) |
101 |
{ |
||
102 |
✓✗ | 42 |
mIcons[f] = Loader::getImage("graphics/flags/" |
103 |
✓✗ | 84 |
+ icon); |
104 |
} |
||
105 |
else |
||
106 |
{ |
||
107 |
2 |
mIcons[f] = nullptr; |
|
108 |
} |
||
109 |
} |
||
110 |
2 |
} |
|
111 |
|||
112 |
A_DELETE_COPY(LangListModel) |
||
113 |
|||
114 |
2 |
~LangListModel() override final |
|
115 |
6 |
{ |
|
116 |
✓✓✗✗ |
46 |
for (int f = 0; f < langs_count; f ++) |
117 |
{ |
||
118 |
44 |
Image *const img = mIcons[f]; |
|
119 |
✓✓✗✗ |
44 |
if (img != nullptr) |
120 |
42 |
img->decRef(); |
|
121 |
} |
||
122 |
2 |
} |
|
123 |
|||
124 |
14 |
int getNumberOfElements() override final A_WARN_UNUSED |
|
125 |
14 |
{ return langs_count; } |
|
126 |
|||
127 |
std::string getElementAt(int i) override final A_WARN_UNUSED |
||
128 |
{ |
||
129 |
if (i >= getNumberOfElements() || i < 0) |
||
130 |
return "???"; |
||
131 |
|||
132 |
return gettext(LANG_NAME[i].name.c_str()); |
||
133 |
} |
||
134 |
|||
135 |
const Image *getImageAt(int i) override final A_WARN_UNUSED |
||
136 |
{ |
||
137 |
if (i >= getNumberOfElements() || i < 0) |
||
138 |
return nullptr; |
||
139 |
return mIcons[i]; |
||
140 |
} |
||
141 |
|||
142 |
Image *mIcons[langs_count] A_NONNULLPOINTER; |
||
143 |
}; |
||
144 |
|||
145 |
#endif // GUI_MODELS_LANGLISTMODEL_H |
Generated by: GCOVR (Version 3.3) |