ip2ccountry.cpp
1 //------------------------------------------------------------------------------
2 // ip2ccountry.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2021 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "ip2ccountry.h"
24 
25 #include <QHash>
26 #include <QObject>
27 
28 IP2CCountry::IP2CCountry()
29  :flag(nullptr)
30 {}
31 
32 IP2CCountry::IP2CCountry(QString name)
33  :flag(nullptr), name(name)
34 {
35 }
36 
37 IP2CCountry::IP2CCountry(const QPixmap *flag, QString name)
38  :flag(flag), name(name)
39 {
40 }
41 
42 bool IP2CCountry::isValid() const
43 {
44  return !name.isEmpty();
45 }
46 
47 namespace
48 {
49 class IP2CCountryTr : public QObject
50 {
51  Q_OBJECT
52 
53 public:
54  static QHash<QString, IP2CCountry> all()
55  {
56  QHash<QString, IP2CCountry> map;
57  map.insert("ABW", IP2CCountry(tr("Aruba")));
58  map.insert("AFG", IP2CCountry(tr("Afghanistan")));
59  map.insert("AGO", IP2CCountry(tr("Angola")));
60  map.insert("AIA", IP2CCountry(tr("Anguilla")));
61  map.insert("ALB", IP2CCountry(tr("Albania")));
62  map.insert("AND", IP2CCountry(tr("Andorra")));
63  map.insert("ANT", IP2CCountry(tr("Netherlands Antilles")));
64  map.insert("ARE", IP2CCountry(tr("United Arab Emirates")));
65  map.insert("ARG", IP2CCountry(tr("Argentina")));
66  map.insert("ARM", IP2CCountry(tr("Armenia")));
67  map.insert("ASM", IP2CCountry(tr("American Samoa")));
68  map.insert("ATA", IP2CCountry(tr("Antarctica")));
69  map.insert("ATF", IP2CCountry(tr("French Southern Territories")));
70  map.insert("ATG", IP2CCountry(tr("Antigua and Barbuda")));
71  map.insert("AUS", IP2CCountry(tr("Australia")));
72  map.insert("AUT", IP2CCountry(tr("Austria")));
73  map.insert("AZE", IP2CCountry(tr("Azerbaijan")));
74  map.insert("BDI", IP2CCountry(tr("Burundi")));
75  map.insert("BEL", IP2CCountry(tr("Belgium")));
76  map.insert("BEN", IP2CCountry(tr("Benin")));
77  map.insert("BFA", IP2CCountry(tr("Burkina Faso")));
78  map.insert("BGD", IP2CCountry(tr("Bangladesh")));
79  map.insert("BGR", IP2CCountry(tr("Bulgaria")));
80  map.insert("BHR", IP2CCountry(tr("Bahrain")));
81  map.insert("BHS", IP2CCountry(tr("Bahamas")));
82  map.insert("BIH", IP2CCountry(tr("Bosnia and Herzegovina")));
83  map.insert("BLR", IP2CCountry(tr("Belarus")));
84  map.insert("BLZ", IP2CCountry(tr("Belize")));
85  map.insert("BMU", IP2CCountry(tr("Bermuda")));
86  map.insert("BOL", IP2CCountry(tr("Bolivia")));
87  map.insert("BRA", IP2CCountry(tr("Brazil")));
88  map.insert("BRB", IP2CCountry(tr("Barbados")));
89  map.insert("BRN", IP2CCountry(tr("Brunei")));
90  map.insert("BTN", IP2CCountry(tr("Bhutan")));
91  map.insert("BVT", IP2CCountry(tr("Bouvet Island")));
92  map.insert("BWA", IP2CCountry(tr("Botswana")));
93  map.insert("CAF", IP2CCountry(tr("Central African Republic")));
94  map.insert("CAN", IP2CCountry(tr("Canada")));
95  map.insert("CCK", IP2CCountry(tr("Cocos (Keeling) Islands")));
96  map.insert("CHE", IP2CCountry(tr("Switzerland")));
97  map.insert("CHL", IP2CCountry(tr("Chile")));
98  map.insert("CHN", IP2CCountry(tr("China")));
99  map.insert("CIV", IP2CCountry(tr("Ivory Coast")));
100  map.insert("CMR", IP2CCountry(tr("Cameroon")));
101  map.insert("COD", IP2CCountry(tr("Congo, the Democratic Republic of the")));
102  map.insert("COG", IP2CCountry(tr("Congo")));
103  map.insert("COK", IP2CCountry(tr("Cook Islands")));
104  map.insert("COL", IP2CCountry(tr("Colombia")));
105  map.insert("COM", IP2CCountry(tr("Comoros")));
106  map.insert("CPV", IP2CCountry(tr("Cape Verde")));
107  map.insert("CRI", IP2CCountry(tr("Costa Rica")));
108  map.insert("CUB", IP2CCountry(tr("Cuba")));
109  map.insert("CXR", IP2CCountry(tr("Christmas Island")));
110  map.insert("CYM", IP2CCountry(tr("Cayman Islands")));
111  map.insert("CYP", IP2CCountry(tr("Cyprus")));
112  map.insert("CZE", IP2CCountry(tr("Czech Republic")));
113  map.insert("DEU", IP2CCountry(tr("Germany")));
114  map.insert("DJI", IP2CCountry(tr("Djibouti")));
115  map.insert("DMA", IP2CCountry(tr("Dominica")));
116  map.insert("DNK", IP2CCountry(tr("Denmark")));
117  map.insert("DOM", IP2CCountry(tr("Dominican Republic")));
118  map.insert("DZA", IP2CCountry(tr("Algeria")));
119  map.insert("ECU", IP2CCountry(tr("Ecuador")));
120  map.insert("EGY", IP2CCountry(tr("Egypt")));
121  map.insert("ERI", IP2CCountry(tr("Eritrea")));
122  map.insert("ESH", IP2CCountry(tr("Western Sahara")));
123  map.insert("ESP", IP2CCountry(tr("Spain")));
124  map.insert("EST", IP2CCountry(tr("Estonia")));
125  map.insert("ETH", IP2CCountry(tr("Ethiopia")));
126  map.insert("EU", IP2CCountry(tr("European Union")));
127  map.insert("FIN", IP2CCountry(tr("Finland")));
128  map.insert("FJI", IP2CCountry(tr("Fiji")));
129  map.insert("FLK", IP2CCountry(tr("Falkland Islands (Malvinas)")));
130  map.insert("FRA", IP2CCountry(tr("France")));
131  map.insert("FRO", IP2CCountry(tr("Faroe Islands")));
132  map.insert("FSM", IP2CCountry(tr("Micronesia, Federated States of")));
133  map.insert("GAB", IP2CCountry(tr("Gabon")));
134  map.insert("GBR", IP2CCountry(tr("United Kingdom")));
135  map.insert("GEO", IP2CCountry(tr("Georgia")));
136  map.insert("GGY", IP2CCountry(tr("Guernsey")));
137  map.insert("GHA", IP2CCountry(tr("Ghana")));
138  map.insert("GIB", IP2CCountry(tr("Gibraltar")));
139  map.insert("GIN", IP2CCountry(tr("Guinea")));
140  map.insert("GLP", IP2CCountry(tr("Guadeloupe")));
141  map.insert("GMB", IP2CCountry(tr("Gambia")));
142  map.insert("GNB", IP2CCountry(tr("Guinea-Bissau")));
143  map.insert("GNQ", IP2CCountry(tr("Equatorial Guinea")));
144  map.insert("GRC", IP2CCountry(tr("Greece")));
145  map.insert("GRD", IP2CCountry(tr("Grenada")));
146  map.insert("GRL", IP2CCountry(tr("Greenland")));
147  map.insert("GTM", IP2CCountry(tr("Guatemala")));
148  map.insert("GUF", IP2CCountry(tr("French Guiana")));
149  map.insert("GUM", IP2CCountry(tr("Guam")));
150  map.insert("GUY", IP2CCountry(tr("Guyana")));
151  map.insert("HKG", IP2CCountry(tr("Hong Kong")));
152  map.insert("HMD", IP2CCountry(tr("Heard Island and McDonald Islands")));
153  map.insert("HND", IP2CCountry(tr("Honduras")));
154  map.insert("HRV", IP2CCountry(tr("Croatia")));
155  map.insert("HTI", IP2CCountry(tr("Haiti")));
156  map.insert("HUN", IP2CCountry(tr("Hungary")));
157  map.insert("IDN", IP2CCountry(tr("Indonesia")));
158  map.insert("IMN", IP2CCountry(tr("Isle of Man")));
159  map.insert("IND", IP2CCountry(tr("India")));
160  map.insert("IOT", IP2CCountry(tr("British Indian Ocean Territory")));
161  map.insert("IRL", IP2CCountry(tr("Ireland")));
162  map.insert("IRN", IP2CCountry(tr("Iran, Islamic Republic of")));
163  map.insert("IRQ", IP2CCountry(tr("Iraq")));
164  map.insert("ISL", IP2CCountry(tr("Iceland")));
165  map.insert("ISR", IP2CCountry(tr("Israel")));
166  map.insert("ITA", IP2CCountry(tr("Italy")));
167  map.insert("JAM", IP2CCountry(tr("Jamaica")));
168  map.insert("JEY", IP2CCountry(tr("Jersey")));
169  map.insert("JOR", IP2CCountry(tr("Jordan")));
170  map.insert("JPN", IP2CCountry(tr("Japan")));
171  map.insert("KAZ", IP2CCountry(tr("Kazakhstan")));
172  map.insert("KEN", IP2CCountry(tr("Kenya")));
173  map.insert("KGZ", IP2CCountry(tr("Kyrgyzstan")));
174  map.insert("KHM", IP2CCountry(tr("Cambodia")));
175  map.insert("KIR", IP2CCountry(tr("Kiribati")));
176  map.insert("KNA", IP2CCountry(tr("Saint Kitts and Nevis")));
177  map.insert("KOR", IP2CCountry(tr("South Korea")));
178  map.insert("KWT", IP2CCountry(tr("Kuwait")));
179  map.insert("LAO", IP2CCountry(tr("Lao People's Democratic Republic")));
180  map.insert("LBN", IP2CCountry(tr("Lebanon")));
181  map.insert("LBR", IP2CCountry(tr("Liberia")));
182  map.insert("LBY", IP2CCountry(tr("Libya")));
183  map.insert("LCA", IP2CCountry(tr("Saint Lucia")));
184  map.insert("LIE", IP2CCountry(tr("Liechtenstein")));
185  map.insert("LKA", IP2CCountry(tr("Sri Lanka")));
186  map.insert("LSO", IP2CCountry(tr("Lesotho")));
187  map.insert("LTU", IP2CCountry(tr("Lithuania")));
188  map.insert("LUX", IP2CCountry(tr("Luxembourg")));
189  map.insert("LVA", IP2CCountry(tr("Latvia")));
190  map.insert("MAC", IP2CCountry(tr("Macao")));
191  map.insert("MAR", IP2CCountry(tr("Morocco")));
192  map.insert("MCO", IP2CCountry(tr("Monaco")));
193  map.insert("MDA", IP2CCountry(tr("Moldova, Republic of")));
194  map.insert("MDG", IP2CCountry(tr("Madagascar")));
195  map.insert("MDV", IP2CCountry(tr("Maldives")));
196  map.insert("MEX", IP2CCountry(tr("Mexico")));
197  map.insert("MHL", IP2CCountry(tr("Marshall Islands")));
198  map.insert("MKD", IP2CCountry(tr("Macedonia, the former Yugoslav Republic of")));
199  map.insert("MLI", IP2CCountry(tr("Mali")));
200  map.insert("MLT", IP2CCountry(tr("Malta")));
201  map.insert("MMR", IP2CCountry(tr("Myanmar")));
202  map.insert("MNE", IP2CCountry(tr("Montenegro")));
203  map.insert("MNG", IP2CCountry(tr("Mongolia")));
204  map.insert("MNP", IP2CCountry(tr("Northern Mariana Islands")));
205  map.insert("MOZ", IP2CCountry(tr("Mozambique")));
206  map.insert("MRT", IP2CCountry(tr("Mauritania")));
207  map.insert("MSR", IP2CCountry(tr("Montserrat")));
208  map.insert("MTQ", IP2CCountry(tr("Martinique")));
209  map.insert("MUS", IP2CCountry(tr("Mauritius")));
210  map.insert("MWI", IP2CCountry(tr("Malawi")));
211  map.insert("MYS", IP2CCountry(tr("Malaysia")));
212  map.insert("MYT", IP2CCountry(tr("Mayotte")));
213  map.insert("NAM", IP2CCountry(tr("Namibia")));
214  map.insert("NCL", IP2CCountry(tr("New Caledonia")));
215  map.insert("NER", IP2CCountry(tr("Niger")));
216  map.insert("NFK", IP2CCountry(tr("Norfolk Island")));
217  map.insert("NGA", IP2CCountry(tr("Nigeria")));
218  map.insert("NIC", IP2CCountry(tr("Nicaragua")));
219  map.insert("NIU", IP2CCountry(tr("Niue")));
220  map.insert("NLD", IP2CCountry(tr("Netherlands")));
221  map.insert("NOR", IP2CCountry(tr("Norway")));
222  map.insert("NPL", IP2CCountry(tr("Nepal")));
223  map.insert("NRU", IP2CCountry(tr("Nauru")));
224  map.insert("NZL", IP2CCountry(tr("New Zealand")));
225  map.insert("OMN", IP2CCountry(tr("Oman")));
226  map.insert("PAK", IP2CCountry(tr("Pakistan")));
227  map.insert("PAN", IP2CCountry(tr("Panama")));
228  map.insert("PCN", IP2CCountry(tr("Pitcairn")));
229  map.insert("PER", IP2CCountry(tr("Peru")));
230  map.insert("PHL", IP2CCountry(tr("Philippines")));
231  map.insert("PLW", IP2CCountry(tr("Palau")));
232  map.insert("PNG", IP2CCountry(tr("Papua New Guinea")));
233  map.insert("POL", IP2CCountry(tr("Poland")));
234  map.insert("PRI", IP2CCountry(tr("Puerto Rico")));
235  map.insert("PRK", IP2CCountry(tr("Korea, Democratic People's Republic of")));
236  map.insert("PRT", IP2CCountry(tr("Portugal")));
237  map.insert("PRY", IP2CCountry(tr("Paraguay")));
238  map.insert("PSE", IP2CCountry(tr("Palestinian Territory, Occupied")));
239  map.insert("PYF", IP2CCountry(tr("French Polynesia")));
240  map.insert("QAT", IP2CCountry(tr("Qatar")));
241  map.insert("REU", IP2CCountry(tr("RĂ©union")));
242  map.insert("ROU", IP2CCountry(tr("Romania")));
243  map.insert("RUS", IP2CCountry(tr("Russian Federation")));
244  map.insert("RWA", IP2CCountry(tr("Rwanda")));
245  map.insert("SAU", IP2CCountry(tr("Saudi Arabia")));
246  map.insert("SDN", IP2CCountry(tr("Sudan")));
247  map.insert("SEN", IP2CCountry(tr("Senegal")));
248  map.insert("SGP", IP2CCountry(tr("Singapore")));
249  map.insert("SGS", IP2CCountry(tr("South Georgia and the South Sandwich Islands")));
250  map.insert("SHN", IP2CCountry(tr("Saint Helena, Ascension and Tristan da Cunha")));
251  map.insert("SJM", IP2CCountry(tr("Svalbard and Jan Mayen")));
252  map.insert("SLB", IP2CCountry(tr("Solomon Islands")));
253  map.insert("SLE", IP2CCountry(tr("Sierra Leone")));
254  map.insert("SLV", IP2CCountry(tr("El Salvador")));
255  map.insert("SMR", IP2CCountry(tr("San Marino")));
256  map.insert("SOM", IP2CCountry(tr("Somalia")));
257  map.insert("SPM", IP2CCountry(tr("Saint Pierre and Miquelon")));
258  map.insert("SRB", IP2CCountry(tr("Serbia")));
259  map.insert("SSD", IP2CCountry(tr("South Sudan")));
260  map.insert("STP", IP2CCountry(tr("Sao Tome and Principe")));
261  map.insert("SUR", IP2CCountry(tr("Suriname")));
262  map.insert("SVK", IP2CCountry(tr("Slovakia")));
263  map.insert("SVN", IP2CCountry(tr("Slovenia")));
264  map.insert("SWE", IP2CCountry(tr("Sweden")));
265  map.insert("SWZ", IP2CCountry(tr("Swaziland")));
266  map.insert("SYC", IP2CCountry(tr("Seychelles")));
267  map.insert("SYR", IP2CCountry(tr("Syrian Arab Republic")));
268  map.insert("TCA", IP2CCountry(tr("Turks and Caicos Islands")));
269  map.insert("TCD", IP2CCountry(tr("Chad")));
270  map.insert("TGO", IP2CCountry(tr("Togo")));
271  map.insert("THA", IP2CCountry(tr("Thailand")));
272  map.insert("TJK", IP2CCountry(tr("Tajikistan")));
273  map.insert("TKL", IP2CCountry(tr("Tokelau")));
274  map.insert("TKM", IP2CCountry(tr("Turkmenistan")));
275  map.insert("TLS", IP2CCountry(tr("Timor-Leste")));
276  map.insert("TON", IP2CCountry(tr("Tonga")));
277  map.insert("TTO", IP2CCountry(tr("Trinidad and Tobago")));
278  map.insert("TUN", IP2CCountry(tr("Tunisia")));
279  map.insert("TUR", IP2CCountry(tr("Turkey")));
280  map.insert("TUV", IP2CCountry(tr("Tuvalu")));
281  map.insert("TWN", IP2CCountry(tr("Taiwan")));
282  map.insert("TZA", IP2CCountry(tr("Tanzania, United Republic of")));
283  map.insert("UGA", IP2CCountry(tr("Uganda")));
284  map.insert("UKR", IP2CCountry(tr("Ukraine")));
285  map.insert("UMI", IP2CCountry(tr("United States Minor Outlying Islands")));
286  map.insert("URY", IP2CCountry(tr("Uruguay")));
287  map.insert("USA", IP2CCountry(tr("United States")));
288  map.insert("UZB", IP2CCountry(tr("Uzbekistan")));
289  map.insert("VAT", IP2CCountry(tr("Holy See (Vatican City State)")));
290  map.insert("VCT", IP2CCountry(tr("Saint Vincent and the Grenadines")));
291  map.insert("VEN", IP2CCountry(tr("Venezuela")));
292  map.insert("VGB", IP2CCountry(tr("Virgin Islands, British")));
293  map.insert("VIR", IP2CCountry(tr("Virgin Islands, U.S.")));
294  map.insert("VNM", IP2CCountry(tr("Vietnam")));
295  map.insert("VUT", IP2CCountry(tr("Vanuatu")));
296  map.insert("WLF", IP2CCountry(tr("Wallis and Futuna")));
297  map.insert("WSM", IP2CCountry(tr("Samoa")));
298  map.insert("YEM", IP2CCountry(tr("Yemen")));
299  map.insert("ZAF", IP2CCountry(tr("South Africa")));
300  map.insert("ZMB", IP2CCountry(tr("Zambia")));
301  map.insert("ZWE", IP2CCountry(tr("Zimbabwe")));
302  return map;
303  }
304 };
305 }
306 
307 QHash<QString, IP2CCountry> IP2CCountry::all()
308 {
309  return IP2CCountryTr::all();
310 }
311 
312 #include "ip2ccountry.moc"