[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    KLocale patch
From:       "Nhuh Put" <nhuh.put () web ! de>
Date:       2007-08-24 0:05:27
Message-ID: 013b01c7e5e2$7b3be180$3301a8c0 () spika
[Download RAW message or body]

Hello
I'm trying to make KLocale independent form KConfigINIBackend internals.
This is the first patch out of two to reach this goal. This shouldn't break
anything, but I heard some bad stories about KLocale, so I wanted to ask
before committing.
I will remove the doFormatInit function before committing.

	PutHuhn

["klocale.patch" (text/x-patch)]

Index: klocale.cpp
===================================================================
--- klocale.cpp	(revision 704027)
+++ klocale.cpp	(working copy)
@@ -110,7 +110,7 @@
   /**
    * @internal Reads the format configuration from disk.
    */
-  void initFormat(KLocale *parent);
+  void initFormat(KConfig *config);
 
   /**
    * @internal The worker of the same-name KLocale API function.
@@ -199,7 +199,7 @@
   // Misc
   QString encoding;
   QTextCodec * codecForEncoding;
-  KSharedConfig::Ptr config;
+  //KSharedConfig::Ptr config;
   int pageSize;
   KLocale::MeasureSystem measureSystem;
   KConfigBase * languages;
@@ -221,7 +221,7 @@
 KLocale::KLocale( const QString & catalog, KSharedConfig::Ptr config )
 	: d(new KLocalePrivate)
 {
-  d->config = config;
+//  d->config = config;
   d->languages = 0;
   d->calendar = 0;
   d->formatInited = false;
@@ -229,17 +229,19 @@
   d->initEncoding(0);
   d->initFileNameEncoding(0);
 
-  KSharedConfig::Ptr cfg = d->config;
+  KSharedConfig::Ptr cfg = config;
   this_klocale = this;
   if (!cfg) cfg = KGlobal::config();
   this_klocale = 0;
-  Q_ASSERT( cfg );
+  Q_ASSERT( cfg ); 
 
   d->appName = catalog;
   d->initLanguageList(cfg.data(), !config);
   d->initMainCatalogs(catalog);
 
   d->useTranscript = false;
+
+  d->initFormat(cfg.data());
 }
 
 QString KLocale::_initLanguage(KConfigBase *config)
@@ -347,28 +349,20 @@
 
 void KLocalePrivate::doFormatInit(const KLocale *parent)
 {
+/* to be removed
   if ( formatInited ) return;
 
   initFormat(const_cast<KLocale *>(parent));
 
-  formatInited = true;
+  formatInited = true;*/
 }
 
-void KLocalePrivate::initFormat(KLocale *parent)
+void KLocalePrivate::initFormat(KConfig *config)
 {
-    if (!config) {
-        config = KGlobal::config();
-    }
-    Q_ASSERT(config);
+  Q_ASSERT(config);
 
-  kDebug(173) << "KLocale::initFormat";
+  kDebug(173) << "KLocalePrivate::KLocalePrivate";
 
-  // make sure the config files are read using the correct locale
-  // ### Why not add a KConfigBase::setLocale( const KLocale * )?
-  // ### Then we could remove this hack
-  KLocale *lsave = KGlobal::locale();
-  KGlobal::setLocale(parent);
-
   KConfigGroup cg(config, "Locale");
 
   KConfig entryFile(KStandardDirs::locate("locale",
@@ -441,9 +435,6 @@
   read3ConfigBoolEntry("NounDeclension", false, nounDeclension);
   read3ConfigBoolEntry("DateMonthNamePossessive", false,
 		       dateMonthNamePossessive);
-
-  // end of hack
-  KGlobal::setLocale(lsave);
 }
 
 bool KLocale::setCountry(const QString & aCountry)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic