Let the timezone picker be searched by country
Finding a zone meant already knowing its name, which is the wrong way round when the thing you know is the country -- Ghana's zone is named after Accra, and nothing in the picker said so. Zones now carry the countries they cover, drawn from tzdata's own tables: zone1970.tab and zone.tab for the zone-to-country-code rows, iso3166.tab for the names. The picker already matched on description as well as label, so putting the countries there makes them searchable and shows them in the list. Those tables only name about 420 of the ~600 zones; the rest are backward-compatibility aliases like America/Buenos_Aires and US/Pacific, which tzdata ships as hard links to their canonical zone. Matching an alias to its canonical name by inode lifts coverage to 553, and the 45 left are the Etc/GMT pseudo-zones, which have no country by definition. The inherited countries are the union of every zone sharing the inode, not the first one found: those siblings are one clock under several countries' names, and each table names a different subset, so first-match made Africa/Asmera findable as Ethiopia but not as Eritrea. Joining is done in ClockModel against a fixture, so it does not depend on the host's tzdata version; the shell side only reads the files. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MhxtL7WzL5XmuTd8GHbcTY
This commit is contained in:
+7
-2
@@ -34,10 +34,15 @@ Item {
|
||||
readonly property color accent: Color.accent
|
||||
readonly property color urgent: Color.urgent
|
||||
|
||||
// The picker matches on label OR description, so putting the countries in
|
||||
// the description makes a zone findable by country without knowing that,
|
||||
// say, Ghana's zone is named after Accra. It shows there too, which is the
|
||||
// other half of the problem — recognising the right zone once you see it.
|
||||
readonly property var zoneOptions: {
|
||||
var list = root.zones ? root.zones.allZones : []
|
||||
var out = []
|
||||
for (var i = 0; i < list.length; i++) out.push({ value: list[i], label: list[i] })
|
||||
for (var i = 0; i < list.length; i++)
|
||||
out.push({ value: list[i].zone, label: list[i].zone, description: list[i].countries })
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -264,7 +269,7 @@ Item {
|
||||
showLabel: false
|
||||
value: row.modelData.timezone
|
||||
options: root.zoneOptions
|
||||
placeholderText: "Search timezones..."
|
||||
placeholderText: "Search by country or zone..."
|
||||
triggerLabel: row.modelData.timezone || "Choose a timezone"
|
||||
foreground: root.foreground
|
||||
accent: root.accent
|
||||
|
||||
Reference in New Issue
Block a user