QString WeatherPlugin::forecastReplace(const QString &text) { if (*getDay(m_day) == 0) return ""; QString res = text; QString temp; int minT = atol(getMinT(m_day)); int maxT = atol(getMaxT(m_day)); temp += QString::number(minT); temp += QChar((unsigned short)176); temp += getUT(); if ((strcmp(getMaxT(m_day), "N/A")) && (maxT != -255)) { temp += "/"; temp += QString::number(maxT); temp += QChar((unsigned short)176); temp += getUT(); } string dd = getDay(m_day); string mon = getToken(dd, ' '); QString day = dd.c_str(); day += ". "; day += i18n(mon.c_str()); res = res.replace(QRegExp("\\%n"), getDayIcon(m_day)); res = res.replace(QRegExp("\\%t"), temp); res = res.replace(QRegExp("\\%c"), i18n_conditions(getDayConditions(m_day))); res = res.replace(QRegExp("\\%w"), i18n(getWDay(m_day))); res = res.replace(QRegExp("\\%d"), day); return res; }
QString WeatherPlugin::forecastReplace(const QString &text) { if (*getDay(m_day) == 0) return ""; QString res = text; QString temp; int minT = atol(getMinT(m_day)); int maxT = atol(getMaxT(m_day)); if ((minT < 0) && (maxT < 0)){ int r = minT; minT = maxT; maxT = r; } if (minT < 0){ temp += "-"; minT = -minT; }else if (minT > 0){ temp += "+"; } temp += number((unsigned)minT).c_str(); temp += QChar((unsigned short)176); temp += getUT(); if (maxT < 0){ temp += "-"; maxT = -maxT; }else if (maxT >= 0){ temp += "+"; } temp += number((unsigned)maxT).c_str(); temp += QChar((unsigned short)176); temp += getUT(); string dd = getDay(m_day); string mon = getToken(dd, ' '); QString day = dd.c_str(); day += " "; day += i18n(mon.c_str()); res = res.replace(QRegExp("\\%n"), number(m_day).c_str()); res = res.replace(QRegExp("\\%t"), temp); res = res.replace(QRegExp("\\%c"), i18n_conditions(getDayConditions(m_day))); res = res.replace(QRegExp("\\%w"), i18n(getWDay(m_day))); res = res.replace(QRegExp("\\%d"), day); return res; }