QVariant TimezoneModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); if (role == Qt::DisplayRole) { const QTimeZone tz(m_ids.at(index.row())); switch (index.column()) { case TimezoneModelColumns::IanaIdColumn: return tz.id(); case TimezoneModelColumns::CountryColumn: return QLocale::countryToString(tz.country()); case TimezoneModelColumns::StandardDisplayNameColumn: return tz.displayName(QTimeZone::StandardTime); case TimezoneModelColumns::DSTColumn: return tz.hasDaylightTime(); case TimezoneModelColumns::WindowsIdColumn: return QTimeZone::ianaIdToWindowsId(tz.id()); } } else if (role == Qt::ToolTipRole && index.column() == 0) { const QTimeZone tz(m_ids.at(index.row())); return tz.comment(); } else if (role == TimezoneModelRoles::LocalZoneRole && index.column() == 0) { if (m_ids.at(index.row()) == QTimeZone::systemTimeZoneId()) return true; return QVariant(); } return QVariant(); }
void WorldTime::slotNewTz( const QTimeZone& zone ) { if( Qtopia::mousePreferred()) { changed = true; return; } QTimeZone curZone; int selButton = findCurrentButton(); if(selButton > -1 ) { strCityTz[selButton] = zone.id(); // qWarning()<< "slotNewTz"<<strCityTz[selButton]; listCities.at(selButton)->setText( zone.city()); listTimes.at(selButton)->setZone( zone.id()); if( !isEditMode) { changed = true; } } }
void WorldTime::selected() { if(!changed) { changed = true; } else { QTimeZone zone = frmMap->zone(); int selButton = findCurrentButton(); if(selButton != -1 ) { strCityTz[selButton] = zone.id(); // qWarning() << "selected" << strCityTz[selButton] << zone.id(); listCities.at(selButton)->setText( zone.city()); listTimes.at(selButton)->setZone( zone.id()); saveChanges(); changed = false; } viewMode(); } }
QString LXQtWorldClock::preformat(const QString &format, const QTimeZone &timeZone, const QDateTime &dateTime) { QString result = format; int from = 0; for (;;) { int apos = result.indexOf(QLatin1Char('\''), from); int tz = result.indexOf(QLatin1Char('T'), from); if ((apos != -1) && (tz != -1)) { if (apos > tz) apos = -1; else tz = -1; } if (apos != -1) { from = apos + 1; apos = result.indexOf(QLatin1Char('\''), from); if (apos == -1) // misformat break; from = apos + 1; } else if (tz != -1) { int length = 1; for (; result[tz + length] == QLatin1Char('T'); ++length); if (length > 6) length = 6; QString replacement; switch (length) { case 1: replacement = timeZone.displayName(dateTime, QTimeZone::OffsetName); if (replacement.startsWith(QLatin1String("UTC"))) replacement = replacement.mid(3); break; case 2: replacement = QString::fromLatin1(timeZone.id()); break; case 3: replacement = timeZone.abbreviation(dateTime); break; case 4: replacement = timeZone.displayName(dateTime, QTimeZone::ShortName); break; case 5: replacement = timeZone.displayName(dateTime, QTimeZone::LongName); break; case 6: replacement = mTimeZoneCustomNames[QString::fromLatin1(timeZone.id())]; } if ((tz > 0) && (result[tz - 1] == QLatin1Char('\''))) { --tz; ++length; } else replacement.prepend(QLatin1Char('\'')); if (result[tz + length] == QLatin1Char('\'')) ++length; else replacement.append(QLatin1Char('\'')); result.replace(tz, length, replacement); from = tz + replacement.length(); } else break; } return result; }
QString TClockForm::formatTimeZone(const QTimeZone &timeZone) { return timeZone.id(); }