StelLocaleMgr.cpp   StelLocaleMgr.cpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <config.h> #include <config.h>
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "TextEntryDateTimeValidator.hpp"
#include <QLocale> #include <QLocale>
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
#include <QString> #include <QString>
#include <QFile> #include <QFile>
QMap<QString, QString> StelLocaleMgr::countryCodeToStringMap; QMap<QString, QString> StelLocaleMgr::countryCodeToStringMap;
skipping to change at line 93 skipping to change at line 92
QFile file("countryCodes.dat"); QFile file("countryCodes.dat");
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
QDataStream out(&file); // save the data serialized to the file QDataStream out(&file); // save the data serialized to the file
out << countryCodeToStringMap; out << countryCodeToStringMap;
file.close(); file.close();
} }
void StelLocaleMgr::init() void StelLocaleMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
assert(conf); Q_ASSERT(conf);
setSkyLanguage(conf->value("localization/sky_locale", "system").toSt ring()); setSkyLanguage(conf->value("localization/sky_locale", "system").toSt ring());
setAppLanguage(conf->value("localization/app_locale", "system").toSt ring()); setAppLanguage(conf->value("localization/app_locale", "system").toSt ring());
timeFormat = stringToSTimeFormat(conf->value("localization/time_disp lay_format", "system_default").toString()); timeFormat = stringToSTimeFormat(conf->value("localization/time_disp lay_format", "system_default").toString());
dateFormat = stringToSDateFormat(conf->value("localization/date_disp lay_format", "system_default").toString()); dateFormat = stringToSDateFormat(conf->value("localization/date_disp lay_format", "system_default").toString());
// time_zone used to be in init_location section of config, // time_zone used to be in init_location section of config,
// so use that as fallback when reading config - Rob // so use that as fallback when reading config - Rob
QString tzstr = conf->value("localization/time_zone", conf->value("i nit_location/time_zone", "system_default").toString()).toString(); QString tzstr = conf->value("localization/time_zone", conf->value("i nit_location/time_zone", "system_default").toString()).toString();
if (tzstr == "system_default") if (tzstr == "system_default")
skipping to change at line 131 skipping to change at line 130
} }
} }
} }
/************************************************************************* /*************************************************************************
Set the application locale. This apply to GUI, console messages etc.. Set the application locale. This apply to GUI, console messages etc..
*************************************************************************/ *************************************************************************/
void StelLocaleMgr::setAppLanguage(const QString& newAppLanguageName) void StelLocaleMgr::setAppLanguage(const QString& newAppLanguageName)
{ {
// Update the translator with new locale name // Update the translator with new locale name
Translator::globalTranslator = Translator(PACKAGE_NAME, StelApp::get StelTranslator::globalTranslator = StelTranslator(PACKAGE_NAME, Stel
Instance().getFileMgr().getLocaleDir(), newAppLanguageName); App::getInstance().getFileMgr().getLocaleDir(), newAppLanguageName);
qDebug() << "Application language is " << Translator::globalTranslat qDebug() << "Application language is " << StelTranslator::globalTran
or.getTrueLocaleName(); slator.getTrueLocaleName();
StelApp::getInstance().updateI18n(); StelApp::getInstance().updateI18n();
} }
/************************************************************************* /*************************************************************************
Set the sky language. Set the sky language.
*************************************************************************/ *************************************************************************/
void StelLocaleMgr::setSkyLanguage(const QString& newSkyLanguageName) void StelLocaleMgr::setSkyLanguage(const QString& newSkyLanguageName)
{ {
// Update the translator with new locale name // Update the translator with new locale name
skyTranslator = Translator(PACKAGE_NAME, StelApp::getInstance().getF ileMgr().getLocaleDir(), newSkyLanguageName); skyTranslator = StelTranslator(PACKAGE_NAME, StelApp::getInstance(). getFileMgr().getLocaleDir(), newSkyLanguageName);
qDebug() << "Sky language is " << skyTranslator.getTrueLocaleName(); qDebug() << "Sky language is " << skyTranslator.getTrueLocaleName();
StelApp::getInstance().updateI18n(); StelApp::getInstance().updateI18n();
} }
/************************************************************************* /*************************************************************************
Get the language currently used for sky objects.. Get the language currently used for sky objects..
*************************************************************************/ *************************************************************************/
QString StelLocaleMgr::getSkyLanguage() const QString StelLocaleMgr::getSkyLanguage() const
{ {
return skyTranslator.getTrueLocaleName(); return skyTranslator.getTrueLocaleName();
} }
// Get the Translator currently used for sky objects. // Get the StelTranslator currently used for sky objects.
Translator& StelLocaleMgr::getSkyTranslator() StelTranslator& StelLocaleMgr::getSkyTranslator()
{ {
return skyTranslator; return skyTranslator;
} }
// Return the time in ISO 8601 format that is : %Y-%m-%d %H:%M:%S // Return the time in ISO 8601 format that is : %Y-%m-%d %H:%M:%S
QString StelLocaleMgr::getISO8601TimeLocal(double JD) const QString StelLocaleMgr::getISO8601TimeLocal(double JD) const
{ {
double shift = 0.0; double shift = 0.0;
if (timeZoneMode == STzGMTShift) if (timeZoneMode == STzGMTShift)
{ {
skipping to change at line 180 skipping to change at line 179
{ {
shift = StelUtils::getGMTShiftFromQT(JD)*0.041666666666; shift = StelUtils::getGMTShiftFromQT(JD)*0.041666666666;
} }
return StelUtils::jdToIsoString(JD + shift); return StelUtils::jdToIsoString(JD + shift);
} }
//! get the six ints from an ISO8601 date time, understood to be local time , make a jdate out //! get the six ints from an ISO8601 date time, understood to be local time , make a jdate out
//! of them. //! of them.
double StelLocaleMgr::getJdFromISO8601TimeLocal(const QString& t) const double StelLocaleMgr::getJdFromISO8601TimeLocal(const QString& t) const
{ {
vector<int> numbers = TextEntryDateTimeValidator::getIntsFromISO8601 String(t); QList<int> numbers = StelUtils::getIntsFromISO8601String(t);
if (numbers.size() == 6) if (numbers.size() == 6)
{ {
int y = numbers[0]; int y = numbers[0];
int m = numbers[1]; int m = numbers[1];
int d = numbers[2]; int d = numbers[2];
int h = numbers[3]; int h = numbers[3];
int mn = numbers[4]; int mn = numbers[4];
int s = numbers[5]; int s = numbers[5];
double jd; double jd;
 End of changes. 6 change blocks. 
10 lines changed or deleted 9 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/