Stellarium 0.11.4
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/StelLocaleMgr.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2006 Fabien Chereau
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
00018  */
00019 
00020 #ifndef _STELLOCALEMGR_HPP_
00021 #define _STELLOCALEMGR_HPP_
00022 
00023 #include "StelTranslator.hpp"
00024 
00028 class StelLocaleMgr
00029 {
00030 public:
00031     StelLocaleMgr();
00032     ~StelLocaleMgr();
00033 
00038     void init();
00039     
00041     // MESSAGES TRANSLATIONS
00046     QString getAppLanguage() const { return StelTranslator::globalTranslator.getTrueLocaleName(); }
00047     
00051     void setAppLanguage(const QString& newAppLangName);
00052     
00054     StelTranslator& getAppStelTranslator() const;
00055     
00059     QString getSkyLanguage() const;
00060     
00065     void setSkyLanguage(const QString& newSkyLangName);
00066     
00068     StelTranslator& getSkyTranslator();
00069     
00071     // DATE & TIME LOCALIZATION
00080     QString getTimeFormatStr(void) const {return sTimeFormatToString(timeFormat);}
00083     void setTimeFormatStr(const QString& tf) {timeFormat=stringToSTimeFormat(tf);}
00092     QString getDateFormatStr(void) const {return sDateFormatToString(dateFormat);}
00093     void setDateFormatStr(const QString& df) {dateFormat=stringToSDateFormat(df);}
00094     
00098     void setCustomTimezone(QString tZ) { setCustomTzName(tZ); }
00099 
00102     enum STimeFormat {
00103         STime24h,       
00104         STime12h,       
00105         STimeSystemDefault  
00106     };
00107     
00110     enum SDateFormat {
00111         SDateMMDDYYYY,  
00112         SDateDDMMYYYY,  
00113         SDateSystemDefault, 
00114         SDateYYYYMMDD       
00115     };
00116     
00118     QString getPrintableDateLocal(double JD) const;
00119     
00121     QString getPrintableTimeLocal(double JD) const;
00122     
00124     enum STzFormat
00125     {
00126         STzCustom,      
00127         STzGMTShift,        
00128         STzSystemDefault    
00129     };
00130     
00132     void setGMTShift(int t)
00133     {
00134         GMTShift=t;
00135     }
00137     float getGMTShift(double JD = 0) const;
00139     void setCustomTzName(const QString& tzname);
00141     QString getCustomTzName(void) const
00142     {
00143         return customTzName;
00144     }
00146     STzFormat getTzFormat(void) const
00147     {
00148         return timeZoneMode;
00149     }
00150     
00153     QString getISO8601TimeLocal(double JD) const;
00154 
00160     double getJdFromISO8601TimeLocal(const QString& str, bool* ok) const;
00161 
00163     static QString countryCodeToString(const QString& countryCode);
00164     
00166     static QStringList getAllCountryNames();
00167     
00168 private:
00169     // The translator used for astronomical object naming
00170     StelTranslator skyTranslator;
00171     
00172     // Date and time variables
00173     STimeFormat timeFormat;
00174     SDateFormat dateFormat;
00175     STzFormat timeZoneMode;     // Can be the system default or a user defined value
00176     
00177     QString customTzName;           // Something like "Europe/Paris"
00178     float GMTShift;             // Time shift between GMT time and local time in hour. (positive for Est of GMT)
00179     
00180     // Convert the time format enum to its associated string and reverse
00181     STimeFormat stringToSTimeFormat(const QString&) const;
00182     QString sTimeFormatToString(STimeFormat) const;
00183     
00184     // Convert the date format enum to its associated string and reverse
00185     SDateFormat stringToSDateFormat(const QString& df) const;
00186     QString sDateFormatToString(SDateFormat df) const;
00187     
00188     static QMap<QString, QString> countryCodeToStringMap;
00189     
00190     static void generateCountryList();
00191 };
00192 
00193 #endif // _STELLOCALEMGR_HPP_
Generated on Sat Aug 25 22:13:29 2012 for Stellarium by  doxygen 1.6.3