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