File indexing completed on 2025-04-27 03:58:36
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-07-07 0007 * Description : country selector combo-box. 0008 * 0009 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "countryselector.h" 0016 0017 // Qt includes 0018 0019 #include <QMap> 0020 0021 // KDE includes 0022 0023 #include <klocalizedstring.h> 0024 0025 // Local includes 0026 0027 #include "digikam_debug.h" 0028 0029 namespace Digikam 0030 { 0031 0032 class Q_DECL_HIDDEN CountrySelector::Private 0033 { 0034 public: 0035 0036 explicit Private() 0037 { 0038 /** 0039 * NOTE: We cannot use KLocale::allCountriesList() here because KDE only 0040 * support 2 characters country codes. XMP require 3 characters country 0041 * following ISO 3166 (userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html) 0042 */ 0043 0044 // Standard ISO 3166 country codes. 0045 0046 countryCodeMap.insert(QLatin1String("AFG"), i18nc("@info: country code", "Afghanistan")); 0047 countryCodeMap.insert(QLatin1String("ALB"), i18nc("@info: country code", "Albania")); 0048 countryCodeMap.insert(QLatin1String("DZA"), i18nc("@info: country code", "Algeria")); 0049 countryCodeMap.insert(QLatin1String("ASM"), i18nc("@info: country code", "American Samoa")); 0050 countryCodeMap.insert(QLatin1String("AND"), i18nc("@info: country code", "Andorra")); 0051 countryCodeMap.insert(QLatin1String("AGO"), i18nc("@info: country code", "Angola")); 0052 countryCodeMap.insert(QLatin1String("AIA"), i18nc("@info: country code", "Anguilla")); 0053 countryCodeMap.insert(QLatin1String("AGO"), i18nc("@info: country code", "Angola")); 0054 countryCodeMap.insert(QLatin1String("ATA"), i18nc("@info: country code", "Antarctica")); 0055 countryCodeMap.insert(QLatin1String("ATG"), i18nc("@info: country code", "Antigua and Barbuda")); 0056 countryCodeMap.insert(QLatin1String("ARG"), i18nc("@info: country code", "Argentina")); 0057 countryCodeMap.insert(QLatin1String("ARM"), i18nc("@info: country code", "Armenia")); 0058 countryCodeMap.insert(QLatin1String("ABW"), i18nc("@info: country code", "Aruba")); 0059 countryCodeMap.insert(QLatin1String("AUS"), i18nc("@info: country code", "Australia")); 0060 countryCodeMap.insert(QLatin1String("AUT"), i18nc("@info: country code", "Austria")); 0061 countryCodeMap.insert(QLatin1String("AZE"), i18nc("@info: country code", "Azerbaijan")); 0062 countryCodeMap.insert(QLatin1String("BHS"), i18nc("@info: country code", "Bahamas")); 0063 countryCodeMap.insert(QLatin1String("BHR"), i18nc("@info: country code", "Bahrain")); 0064 countryCodeMap.insert(QLatin1String("BGD"), i18nc("@info: country code", "Bangladesh")); 0065 countryCodeMap.insert(QLatin1String("BRB"), i18nc("@info: country code", "Barbados")); 0066 countryCodeMap.insert(QLatin1String("BLR"), i18nc("@info: country code", "Belarus")); 0067 countryCodeMap.insert(QLatin1String("BEL"), i18nc("@info: country code", "Belgium")); 0068 countryCodeMap.insert(QLatin1String("BLZ"), i18nc("@info: country code", "Belize")); 0069 countryCodeMap.insert(QLatin1String("BEN"), i18nc("@info: country code", "Benin")); 0070 countryCodeMap.insert(QLatin1String("BMU"), i18nc("@info: country code", "Bermuda")); 0071 countryCodeMap.insert(QLatin1String("BTN"), i18nc("@info: country code", "Bhutan")); 0072 countryCodeMap.insert(QLatin1String("BOL"), i18nc("@info: country code", "Bolivia")); 0073 countryCodeMap.insert(QLatin1String("BIH"), i18nc("@info: country code", "Bosnia and Herzegovina")); 0074 countryCodeMap.insert(QLatin1String("BWA"), i18nc("@info: country code", "Botswana")); 0075 countryCodeMap.insert(QLatin1String("BVT"), i18nc("@info: country code", "Bouvet Island")); 0076 countryCodeMap.insert(QLatin1String("BRA"), i18nc("@info: country code", "Brazil")); 0077 countryCodeMap.insert(QLatin1String("IOT"), i18nc("@info: country code", "British Indian Ocean Territory")); 0078 countryCodeMap.insert(QLatin1String("VGB"), i18nc("@info: country code", "British Virgin Islands")); 0079 countryCodeMap.insert(QLatin1String("BRN"), i18nc("@info: country code", "Brunei Darussalam")); 0080 countryCodeMap.insert(QLatin1String("BGR"), i18nc("@info: country code", "Bulgaria")); 0081 countryCodeMap.insert(QLatin1String("BFA"), i18nc("@info: country code", "Burkina Faso")); 0082 countryCodeMap.insert(QLatin1String("BDI"), i18nc("@info: country code", "Burundi")); 0083 countryCodeMap.insert(QLatin1String("KHM"), i18nc("@info: country code", "Cambodia")); 0084 countryCodeMap.insert(QLatin1String("CMR"), i18nc("@info: country code", "Cameroon")); 0085 countryCodeMap.insert(QLatin1String("CAN"), i18nc("@info: country code", "Canada")); 0086 countryCodeMap.insert(QLatin1String("CPV"), i18nc("@info: country code", "Cape Verde")); 0087 countryCodeMap.insert(QLatin1String("CYM"), i18nc("@info: country code", "Cayman Islands")); 0088 countryCodeMap.insert(QLatin1String("CAF"), i18nc("@info: country code", "Central African Republic")); 0089 countryCodeMap.insert(QLatin1String("TCD"), i18nc("@info: country code", "Chad")); 0090 countryCodeMap.insert(QLatin1String("CHL"), i18nc("@info: country code", "Chile")); 0091 countryCodeMap.insert(QLatin1String("CHN"), i18nc("@info: country code", "China")); 0092 countryCodeMap.insert(QLatin1String("CXR"), i18nc("@info: country code", "Christmas Island ")); 0093 countryCodeMap.insert(QLatin1String("CCK"), i18nc("@info: country code", "Cocos Islands")); 0094 countryCodeMap.insert(QLatin1String("COL"), i18nc("@info: country code", "Colombia")); 0095 countryCodeMap.insert(QLatin1String("COM"), i18nc("@info: country code", "Comoros")); 0096 countryCodeMap.insert(QLatin1String("COD"), i18nc("@info: country code", "Zaire")); 0097 countryCodeMap.insert(QLatin1String("COG"), i18nc("@info: country code", "Congo")); 0098 countryCodeMap.insert(QLatin1String("COK"), i18nc("@info: country code", "Cook Islands")); 0099 countryCodeMap.insert(QLatin1String("CRI"), i18nc("@info: country code", "Costa Rica")); 0100 countryCodeMap.insert(QLatin1String("CIV"), i18nc("@info: country code", "Ivory Coast")); 0101 countryCodeMap.insert(QLatin1String("CUB"), i18nc("@info: country code", "Cuba")); 0102 countryCodeMap.insert(QLatin1String("CYP"), i18nc("@info: country code", "Cyprus")); 0103 countryCodeMap.insert(QLatin1String("CZE"), i18nc("@info: country code", "Czechia")); 0104 countryCodeMap.insert(QLatin1String("DNK"), i18nc("@info: country code", "Denmark")); 0105 countryCodeMap.insert(QLatin1String("DJI"), i18nc("@info: country code", "Djibouti")); 0106 countryCodeMap.insert(QLatin1String("DMA"), i18nc("@info: country code", "Dominica")); 0107 countryCodeMap.insert(QLatin1String("DOM"), i18nc("@info: country code", "Dominican Republic")); 0108 countryCodeMap.insert(QLatin1String("ECU"), i18nc("@info: country code", "Ecuador")); 0109 countryCodeMap.insert(QLatin1String("EGY"), i18nc("@info: country code", "Egypt")); 0110 countryCodeMap.insert(QLatin1String("SLV"), i18nc("@info: country code", "El Salvador")); 0111 countryCodeMap.insert(QLatin1String("GNQ"), i18nc("@info: country code", "Equatorial Guinea")); 0112 countryCodeMap.insert(QLatin1String("ERI"), i18nc("@info: country code", "Eritrea")); 0113 countryCodeMap.insert(QLatin1String("EST"), i18nc("@info: country code", "Estonia")); 0114 countryCodeMap.insert(QLatin1String("ETH"), i18nc("@info: country code", "Ethiopia")); 0115 countryCodeMap.insert(QLatin1String("FRO"), i18nc("@info: country code", "Faeroe Islands")); 0116 countryCodeMap.insert(QLatin1String("FLK"), i18nc("@info: country code", "Falkland Islands")); 0117 countryCodeMap.insert(QLatin1String("FJI"), i18nc("@info: country code", "Fiji Islands")); 0118 countryCodeMap.insert(QLatin1String("FIN"), i18nc("@info: country code", "Finland")); 0119 countryCodeMap.insert(QLatin1String("FRA"), i18nc("@info: country code", "France")); 0120 countryCodeMap.insert(QLatin1String("GUF"), i18nc("@info: country code", "French Guiana")); 0121 countryCodeMap.insert(QLatin1String("PYF"), i18nc("@info: country code", "French Polynesia")); 0122 countryCodeMap.insert(QLatin1String("ATF"), i18nc("@info: country code", "French Southern Territories")); 0123 countryCodeMap.insert(QLatin1String("GAB"), i18nc("@info: country code", "Gabon")); 0124 countryCodeMap.insert(QLatin1String("GMB"), i18nc("@info: country code", "Gambia")); 0125 countryCodeMap.insert(QLatin1String("GEO"), i18nc("@info: country code", "Georgia")); 0126 countryCodeMap.insert(QLatin1String("DEU"), i18nc("@info: country code", "Germany")); 0127 countryCodeMap.insert(QLatin1String("GHA"), i18nc("@info: country code", "Ghana")); 0128 countryCodeMap.insert(QLatin1String("GIB"), i18nc("@info: country code", "Gibraltar")); 0129 countryCodeMap.insert(QLatin1String("GRC"), i18nc("@info: country code", "Greece")); 0130 countryCodeMap.insert(QLatin1String("GRL"), i18nc("@info: country code", "Greenland")); 0131 countryCodeMap.insert(QLatin1String("GRD"), i18nc("@info: country code", "Grenada")); 0132 countryCodeMap.insert(QLatin1String("GLP"), i18nc("@info: country code", "Guadaloupe")); 0133 countryCodeMap.insert(QLatin1String("GUM"), i18nc("@info: country code", "Guam")); 0134 countryCodeMap.insert(QLatin1String("GTM"), i18nc("@info: country code", "Guatemala")); 0135 countryCodeMap.insert(QLatin1String("GIN"), i18nc("@info: country code", "Guinea")); 0136 countryCodeMap.insert(QLatin1String("GNB"), i18nc("@info: country code", "Guinea-Bissau")); 0137 countryCodeMap.insert(QLatin1String("GUY"), i18nc("@info: country code", "Guyana")); 0138 countryCodeMap.insert(QLatin1String("HTI"), i18nc("@info: country code", "Haiti")); 0139 countryCodeMap.insert(QLatin1String("HMD"), i18nc("@info: country code", "Heard and McDonald Islands")); 0140 countryCodeMap.insert(QLatin1String("VAT"), i18nc("@info: country code", "Vatican")); 0141 countryCodeMap.insert(QLatin1String("HND"), i18nc("@info: country code", "Honduras")); 0142 countryCodeMap.insert(QLatin1String("HKG"), i18nc("@info: country code", "Hong Kong")); 0143 countryCodeMap.insert(QLatin1String("HRV"), i18nc("@info: country code", "Croatia")); 0144 countryCodeMap.insert(QLatin1String("HUN"), i18nc("@info: country code", "Hungary")); 0145 countryCodeMap.insert(QLatin1String("ISL"), i18nc("@info: country code", "Iceland")); 0146 countryCodeMap.insert(QLatin1String("IND"), i18nc("@info: country code", "India")); 0147 countryCodeMap.insert(QLatin1String("IDN"), i18nc("@info: country code", "Indonesia")); 0148 countryCodeMap.insert(QLatin1String("IRN"), i18nc("@info: country code", "Iran")); 0149 countryCodeMap.insert(QLatin1String("IRQ"), i18nc("@info: country code", "Iraq")); 0150 countryCodeMap.insert(QLatin1String("IRL"), i18nc("@info: country code", "Ireland")); 0151 countryCodeMap.insert(QLatin1String("ISR"), i18nc("@info: country code", "Israel")); 0152 countryCodeMap.insert(QLatin1String("ITA"), i18nc("@info: country code", "Italy")); 0153 countryCodeMap.insert(QLatin1String("JAM"), i18nc("@info: country code", "Jamaica")); 0154 countryCodeMap.insert(QLatin1String("JPN"), i18nc("@info: country code", "Japan")); 0155 countryCodeMap.insert(QLatin1String("JOR"), i18nc("@info: country code", "Jordan")); 0156 countryCodeMap.insert(QLatin1String("KAZ"), i18nc("@info: country code", "Kazakhstan")); 0157 countryCodeMap.insert(QLatin1String("KEN"), i18nc("@info: country code", "Kenya")); 0158 countryCodeMap.insert(QLatin1String("KIR"), i18nc("@info: country code", "Kiribati")); 0159 countryCodeMap.insert(QLatin1String("PRK"), i18nc("@info: country code", "North-Korea")); 0160 countryCodeMap.insert(QLatin1String("KOR"), i18nc("@info: country code", "South-Korea")); 0161 countryCodeMap.insert(QLatin1String("KWT"), i18nc("@info: country code", "Kuwait")); 0162 countryCodeMap.insert(QLatin1String("KGZ"), i18nc("@info: country code", "Kyrgyz Republic")); 0163 countryCodeMap.insert(QLatin1String("LAO"), i18nc("@info: country code", "Lao")); 0164 countryCodeMap.insert(QLatin1String("LVA"), i18nc("@info: country code", "Latvia")); 0165 countryCodeMap.insert(QLatin1String("LBN"), i18nc("@info: country code", "Lebanon")); 0166 countryCodeMap.insert(QLatin1String("LSO"), i18nc("@info: country code", "Lesotho")); 0167 countryCodeMap.insert(QLatin1String("LBR"), i18nc("@info: country code", "Liberia")); 0168 countryCodeMap.insert(QLatin1String("LBY"), i18nc("@info: country code", "Libyan Arab Jamahiriya")); 0169 countryCodeMap.insert(QLatin1String("LIE"), i18nc("@info: country code", "Liechtenstein")); 0170 countryCodeMap.insert(QLatin1String("LTU"), i18nc("@info: country code", "Lithuania")); 0171 countryCodeMap.insert(QLatin1String("LUX"), i18nc("@info: country code", "Luxembourg")); 0172 countryCodeMap.insert(QLatin1String("MAC"), i18nc("@info: country code", "Macao")); 0173 countryCodeMap.insert(QLatin1String("MKD"), i18nc("@info: country code", "Macedonia")); 0174 countryCodeMap.insert(QLatin1String("MDG"), i18nc("@info: country code", "Madagascar")); 0175 countryCodeMap.insert(QLatin1String("MWI"), i18nc("@info: country code", "Malawi")); 0176 countryCodeMap.insert(QLatin1String("MYS"), i18nc("@info: country code", "Malaysia")); 0177 countryCodeMap.insert(QLatin1String("MDV"), i18nc("@info: country code", "Maldives")); 0178 countryCodeMap.insert(QLatin1String("MLI"), i18nc("@info: country code", "Mali")); 0179 countryCodeMap.insert(QLatin1String("MLT"), i18nc("@info: country code", "Malta")); 0180 countryCodeMap.insert(QLatin1String("MHL"), i18nc("@info: country code", "Marshall Islands")); 0181 countryCodeMap.insert(QLatin1String("MTQ"), i18nc("@info: country code", "Martinique")); 0182 countryCodeMap.insert(QLatin1String("MRT"), i18nc("@info: country code", "Mauritania")); 0183 countryCodeMap.insert(QLatin1String("MUS"), i18nc("@info: country code", "Mauritius")); 0184 countryCodeMap.insert(QLatin1String("MYT"), i18nc("@info: country code", "Mayotte")); 0185 countryCodeMap.insert(QLatin1String("MEX"), i18nc("@info: country code", "Mexico")); 0186 countryCodeMap.insert(QLatin1String("FSM"), i18nc("@info: country code", "Micronesia")); 0187 countryCodeMap.insert(QLatin1String("MDA"), i18nc("@info: country code", "Moldova")); 0188 countryCodeMap.insert(QLatin1String("MCO"), i18nc("@info: country code", "Monaco")); 0189 countryCodeMap.insert(QLatin1String("MNG"), i18nc("@info: country code", "Mongolia")); 0190 countryCodeMap.insert(QLatin1String("MSR"), i18nc("@info: country code", "Montserrat")); 0191 countryCodeMap.insert(QLatin1String("MAR"), i18nc("@info: country code", "Morocco")); 0192 countryCodeMap.insert(QLatin1String("MOZ"), i18nc("@info: country code", "Mozambique")); 0193 countryCodeMap.insert(QLatin1String("MMR"), i18nc("@info: country code", "Myanmar")); 0194 countryCodeMap.insert(QLatin1String("NAM"), i18nc("@info: country code", "Namibia")); 0195 countryCodeMap.insert(QLatin1String("NRU"), i18nc("@info: country code", "Nauru")); 0196 countryCodeMap.insert(QLatin1String("NPL"), i18nc("@info: country code", "Nepal")); 0197 countryCodeMap.insert(QLatin1String("ANT"), i18nc("@info: country code", "Netherlands Antilles")); 0198 countryCodeMap.insert(QLatin1String("NLD"), i18nc("@info: country code", "Netherlands")); 0199 countryCodeMap.insert(QLatin1String("NCL"), i18nc("@info: country code", "New Caledonia")); 0200 countryCodeMap.insert(QLatin1String("NZL"), i18nc("@info: country code", "New Zealand")); 0201 countryCodeMap.insert(QLatin1String("NIC"), i18nc("@info: country code", "Nicaragua")); 0202 countryCodeMap.insert(QLatin1String("NER"), i18nc("@info: country code", "Niger")); 0203 countryCodeMap.insert(QLatin1String("NGA"), i18nc("@info: country code", "Nigeria")); 0204 countryCodeMap.insert(QLatin1String("NIU"), i18nc("@info: country code", "Niue")); 0205 countryCodeMap.insert(QLatin1String("NFK"), i18nc("@info: country code", "Norfolk Island")); 0206 countryCodeMap.insert(QLatin1String("MNP"), i18nc("@info: country code", "Northern Mariana Islands")); 0207 countryCodeMap.insert(QLatin1String("NOR"), i18nc("@info: country code", "Norway")); 0208 countryCodeMap.insert(QLatin1String("OMN"), i18nc("@info: country code", "Oman")); 0209 countryCodeMap.insert(QLatin1String("PAK"), i18nc("@info: country code", "Pakistan")); 0210 countryCodeMap.insert(QLatin1String("PLW"), i18nc("@info: country code", "Palau")); 0211 countryCodeMap.insert(QLatin1String("PSE"), i18nc("@info: country code", "Palestinian Territory")); 0212 countryCodeMap.insert(QLatin1String("PAN"), i18nc("@info: country code", "Panama")); 0213 countryCodeMap.insert(QLatin1String("PNG"), i18nc("@info: country code", "Papua New Guinea")); 0214 countryCodeMap.insert(QLatin1String("PRY"), i18nc("@info: country code", "Paraguay")); 0215 countryCodeMap.insert(QLatin1String("PER"), i18nc("@info: country code", "Peru")); 0216 countryCodeMap.insert(QLatin1String("PHL"), i18nc("@info: country code", "Philippines")); 0217 countryCodeMap.insert(QLatin1String("PCN"), i18nc("@info: country code", "Pitcairn Island")); 0218 countryCodeMap.insert(QLatin1String("POL"), i18nc("@info: country code", "Poland")); 0219 countryCodeMap.insert(QLatin1String("PRT"), i18nc("@info: country code", "Portugal")); 0220 countryCodeMap.insert(QLatin1String("PRI"), i18nc("@info: country code", "Puerto Rico")); 0221 countryCodeMap.insert(QLatin1String("QAT"), i18nc("@info: country code", "Qatar")); 0222 countryCodeMap.insert(QLatin1String("REU"), i18nc("@info: country code", "Reunion")); 0223 countryCodeMap.insert(QLatin1String("ROU"), i18nc("@info: country code", "Romania")); 0224 countryCodeMap.insert(QLatin1String("RUS"), i18nc("@info: country code", "Russian Federation")); 0225 countryCodeMap.insert(QLatin1String("RWA"), i18nc("@info: country code", "Rwanda")); 0226 countryCodeMap.insert(QLatin1String("SHN"), i18nc("@info: country code", "St. Helena")); 0227 countryCodeMap.insert(QLatin1String("KNA"), i18nc("@info: country code", "St. Kitts and Nevis")); 0228 countryCodeMap.insert(QLatin1String("LCA"), i18nc("@info: country code", "St. Lucia")); 0229 countryCodeMap.insert(QLatin1String("SPM"), i18nc("@info: country code", "St. Pierre and Miquelon")); 0230 countryCodeMap.insert(QLatin1String("VCT"), i18nc("@info: country code", "St. Vincent and the Grenadines")); 0231 countryCodeMap.insert(QLatin1String("WSM"), i18nc("@info: country code", "Samoa")); 0232 countryCodeMap.insert(QLatin1String("SMR"), i18nc("@info: country code", "San Marino")); 0233 countryCodeMap.insert(QLatin1String("STP"), i18nc("@info: country code", "Sao Tome and Principe")); 0234 countryCodeMap.insert(QLatin1String("SAU"), i18nc("@info: country code", "Saudi Arabia")); 0235 countryCodeMap.insert(QLatin1String("SEN"), i18nc("@info: country code", "Senegal")); 0236 countryCodeMap.insert(QLatin1String("SCG"), i18nc("@info: country code", "Serbia")); 0237 countryCodeMap.insert(QLatin1String("SYC"), i18nc("@info: country code", "Seychelles")); 0238 countryCodeMap.insert(QLatin1String("SLE"), i18nc("@info: country code", "Sierra Leone")); 0239 countryCodeMap.insert(QLatin1String("SGP"), i18nc("@info: country code", "Singapore")); 0240 countryCodeMap.insert(QLatin1String("SVK"), i18nc("@info: country code", "Slovakia")); 0241 countryCodeMap.insert(QLatin1String("SVN"), i18nc("@info: country code", "Slovenia")); 0242 countryCodeMap.insert(QLatin1String("SLB"), i18nc("@info: country code", "Solomon Islands")); 0243 countryCodeMap.insert(QLatin1String("SOM"), i18nc("@info: country code", "Somalia")); 0244 countryCodeMap.insert(QLatin1String("ZAF"), i18nc("@info: country code", "South Africa")); 0245 countryCodeMap.insert(QLatin1String("SGS"), i18nc("@info: country code", "South Georgia and the South Sandwich Islands")); 0246 countryCodeMap.insert(QLatin1String("ESP"), i18nc("@info: country code", "Spain")); 0247 countryCodeMap.insert(QLatin1String("LKA"), i18nc("@info: country code", "Sri Lanka")); 0248 countryCodeMap.insert(QLatin1String("SDN"), i18nc("@info: country code", "Sudan")); 0249 countryCodeMap.insert(QLatin1String("SUR"), i18nc("@info: country code", "Suriname")); 0250 countryCodeMap.insert(QLatin1String("SJM"), i18nc("@info: country code", "Svalbard & Jan Mayen Islands")); 0251 countryCodeMap.insert(QLatin1String("SWZ"), i18nc("@info: country code", "Swaziland")); 0252 countryCodeMap.insert(QLatin1String("SWE"), i18nc("@info: country code", "Sweden")); 0253 countryCodeMap.insert(QLatin1String("CHE"), i18nc("@info: country code", "Switzerland")); 0254 countryCodeMap.insert(QLatin1String("SYR"), i18nc("@info: country code", "Syrian Arab Republic")); 0255 countryCodeMap.insert(QLatin1String("TWN"), i18nc("@info: country code", "Taiwan")); 0256 countryCodeMap.insert(QLatin1String("TJK"), i18nc("@info: country code", "Tajikistan")); 0257 countryCodeMap.insert(QLatin1String("TZA"), i18nc("@info: country code", "Tanzania")); 0258 countryCodeMap.insert(QLatin1String("THA"), i18nc("@info: country code", "Thailand")); 0259 countryCodeMap.insert(QLatin1String("TLS"), i18nc("@info: country code", "Timor-Leste")); 0260 countryCodeMap.insert(QLatin1String("TGO"), i18nc("@info: country code", "Togo")); 0261 countryCodeMap.insert(QLatin1String("TKL"), i18nc("@info: country code", "Tokelau Islands")); 0262 countryCodeMap.insert(QLatin1String("TON"), i18nc("@info: country code", "Tonga")); 0263 countryCodeMap.insert(QLatin1String("TTO"), i18nc("@info: country code", "Trinidad and Tobago")); 0264 countryCodeMap.insert(QLatin1String("TUN"), i18nc("@info: country code", "Tunisia")); 0265 countryCodeMap.insert(QLatin1String("TUR"), i18nc("@info: country code", "Turkey")); 0266 countryCodeMap.insert(QLatin1String("TKM"), i18nc("@info: country code", "Turkmenistan")); 0267 countryCodeMap.insert(QLatin1String("TCA"), i18nc("@info: country code", "Turks and Caicos Islands")); 0268 countryCodeMap.insert(QLatin1String("TUV"), i18nc("@info: country code", "Tuvalu")); 0269 countryCodeMap.insert(QLatin1String("VIR"), i18nc("@info: country code", "US Virgin Islands")); 0270 countryCodeMap.insert(QLatin1String("UGA"), i18nc("@info: country code", "Uganda")); 0271 countryCodeMap.insert(QLatin1String("UKR"), i18nc("@info: country code", "Ukraine")); 0272 countryCodeMap.insert(QLatin1String("ARE"), i18nc("@info: country code", "United Arab Emirates")); 0273 countryCodeMap.insert(QLatin1String("GBR"), i18nc("@info: country code", "United Kingdom")); 0274 countryCodeMap.insert(QLatin1String("UMI"), i18nc("@info: country code", "United States Minor Outlying Islands")); 0275 countryCodeMap.insert(QLatin1String("USA"), i18nc("@info: country code", "United States of America")); 0276 countryCodeMap.insert(QLatin1String("URY"), i18nc("@info: country code", "Uruguay, Eastern Republic of")); 0277 countryCodeMap.insert(QLatin1String("UZB"), i18nc("@info: country code", "Uzbekistan")); 0278 countryCodeMap.insert(QLatin1String("VUT"), i18nc("@info: country code", "Vanuatu")); 0279 countryCodeMap.insert(QLatin1String("VEN"), i18nc("@info: country code", "Venezuela")); 0280 countryCodeMap.insert(QLatin1String("VNM"), i18nc("@info: country code", "Viet Nam")); 0281 countryCodeMap.insert(QLatin1String("WLF"), i18nc("@info: country code", "Wallis and Futuna Islands ")); 0282 countryCodeMap.insert(QLatin1String("ESH"), i18nc("@info: country code", "Western Sahara")); 0283 countryCodeMap.insert(QLatin1String("YEM"), i18nc("@info: country code", "Yemen")); 0284 countryCodeMap.insert(QLatin1String("ZMB"), i18nc("@info: country code", "Zambia")); 0285 countryCodeMap.insert(QLatin1String("ZWE"), i18nc("@info: country code", "Zimbabwe")); 0286 // Supplemental IPTC/IIM country codes. 0287 countryCodeMap.insert(QLatin1String("XUN"), i18nc("@info: country code", "United Nations")); 0288 countryCodeMap.insert(QLatin1String("XEU"), i18nc("@info: country code", "European Union")); 0289 countryCodeMap.insert(QLatin1String("XSP"), i18nc("@info: country code", "Space")); 0290 countryCodeMap.insert(QLatin1String("XSE"), i18nc("@info: country code", "At Sea")); 0291 countryCodeMap.insert(QLatin1String("XIF"), i18nc("@info: country code", "In Flight")); 0292 countryCodeMap.insert(QLatin1String("XEN"), i18nc("@info: country code", "England")); 0293 countryCodeMap.insert(QLatin1String("XSC"), i18nc("@info: country code", "Scotland")); 0294 countryCodeMap.insert(QLatin1String("XNI"), i18nc("@info: country code", "Northern Ireland")); 0295 countryCodeMap.insert(QLatin1String("XWA"), i18nc("@info: country code", "Wales")); 0296 countryCodeMap.insert(QLatin1String("PSE"), i18nc("@info: country code", "Palestine")); 0297 countryCodeMap.insert(QLatin1String("GZA"), i18nc("@info: country code", "Gaza")); 0298 countryCodeMap.insert(QLatin1String("JRO"), i18nc("@info: country code", "Jericho")); 0299 } 0300 0301 typedef QMap<QString, QString> CountryCodeMap; 0302 0303 CountryCodeMap countryCodeMap; 0304 }; 0305 0306 CountrySelector::CountrySelector(QWidget* const parent) 0307 : QComboBox(parent), 0308 d (new Private) 0309 { 0310 for (Private::CountryCodeMap::Iterator it = d->countryCodeMap.begin() ; 0311 it != d->countryCodeMap.end() ; ++it) 0312 { 0313 addItem(QString::fromLatin1("%1 - %2").arg(it.key()).arg(it.value())); 0314 } 0315 0316 model()->sort(0); 0317 0318 insertSeparator(count()); 0319 addItem(i18nc("@item: unknown country", "Unknown")); 0320 } 0321 0322 CountrySelector::~CountrySelector() 0323 { 0324 delete d; 0325 } 0326 0327 void CountrySelector::setCountry(const QString& countryCode) 0328 { 0329 // NOTE: if countryCode is empty or do not matches code map, unknow is selected from the list. 0330 0331 int id = count()-1; 0332 0333 for (int i = 0 ; i < d->countryCodeMap.count() ; ++i) 0334 { 0335 if (itemText(i).left(3) == countryCode) 0336 { 0337 id = i; 0338 break; 0339 } 0340 } 0341 0342 setCurrentIndex(id); 0343 0344 qCDebug(DIGIKAM_WIDGETS_LOG) << count() << " :: " << id; 0345 } 0346 0347 bool CountrySelector::country(QString& countryCode, QString& countryName) const 0348 { 0349 // Unknow is selected ? 0350 0351 if (currentIndex() == count()-1) 0352 { 0353 return false; 0354 } 0355 0356 countryName = currentText().mid(6); 0357 countryCode = currentText().left(3); 0358 0359 return true; 0360 } 0361 0362 QString CountrySelector::countryForCode(const QString& countryCode) 0363 { 0364 Private priv; 0365 0366 return (priv.countryCodeMap[countryCode]); 0367 } 0368 0369 } // namespace Digikam 0370 0371 #include "moc_countryselector.cpp"