Exemple #1
0
void Zone::readZoneList(TDEListView *listView )
{
  const KTimezones::ZoneMap zones = m_zoneDb.allZones();
  TQMap<TQString, TQListViewItem*> KontinentMap;

  listView->setRootIsDecorated(true);
  for (KTimezones::ZoneMap::ConstIterator it = zones.begin(); it != zones.end(); ++it)
  {
    const KTimezone *zone = it.data();
    TQString tzName = zone->name();
    TQString comment = zone->comment();
    if (!comment.isEmpty())
      comment = i18n(comment.utf8());

    const TQStringList KontCity = TQStringList::split("/", i18n(tzName.utf8()).replace("_", " "));
    TQListViewItem* Kontinent = KontinentMap[KontCity[0]];
    if (!Kontinent) {
	KontinentMap[KontCity[0]] = new TQListViewItem(listView, KontCity[0]);
	Kontinent = KontinentMap[KontCity[0]];
	Kontinent->setExpandable(true);
    }

    TQCheckListItem *li = new TQCheckListItem(Kontinent, KontCity[1], TQCheckListItem::CheckBox);
    li->setText(1, comment);
    li->setText(2, tzName); /* store complete path in ListView */

    if (_remotezonelist.findIndex(tzName) != -1)
       li->setOn(true);

    // locate the flag from /l10n/%1/flag.png
    // if not available select default "C" flag
    TQString flag = locate( "locale", TQString("l10n/%1/flag.png").arg(zone->countryCode().lower()) );
    if (!TQFile::exists(flag))
       flag = locate( "locale", "l10n/C/flag.png" );
    if (TQFile::exists(flag))
       li->setPixmap(0, TQPixmap(flag));
  }
}