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

List:       kde-devel
Subject:    KDE/kdelibs
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2007-05-27 23:57:48
Message-ID: 1180310268.647811.12596.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 668875 by apaku:

As discussed with David Faure and Laurent Montel KDevelop4 needs to fully
override write/readConfig and set/useDefaults. This is the patch that makes it possible.

Virtualize read/writeConfig and set/useDefaults 
Along the way properly revert the changes that Adam Treat did to
use/setDefaults, Laurent Montel already reverted read/writeConfig.
remove the static writeConfig from .kcfg generated classes

kconfig_compiler change needs a re-creation of all .kcfg generated classes,
thus I'm CC'ing kde-devel. All usages of the static writeConfig method in
trunk/KDE, trunk/koffice and trunk/extragear/multimedia have been ported
already.
CCMAIL:kde-devel@kde.org


 M  +0 -8      kdecore/kconfig_compiler/kconfig_compiler.cpp  
 M  +15 -16    kdeui/config/kconfigskeleton.cpp  
 M  +20 -8     kdeui/config/kconfigskeleton.h  


--- trunk/KDE/kdelibs/kdecore/kconfig_compiler/kconfig_compiler.cpp #668874:668875
@@ -1532,14 +1532,6 @@
     h << endl;
   }
 
-  // Static writeConfig method for singleton
-  if ( singleton ) {
-    h << "    static" << endl;
-    h << "    void writeConfig()" << endl;
-    h << "    {" << endl;
-    h << "      static_cast<KConfigSkeleton*>(self())->writeConfig();" << endl;
-    h << "    }" << endl;
-  }
 
   // Signal definition.
   if( hasSignals ) {
--- trunk/KDE/kdelibs/kdeui/config/kconfigskeleton.cpp #668874:668875
@@ -976,11 +976,25 @@
 
 bool KConfigSkeleton::useDefaults(bool b)
 {
-  return usrUseDefaults(b);
+  if (b == mUseDefaults)
+    return mUseDefaults;
+
+  mUseDefaults = b;
+  KConfigSkeletonItem::List::ConstIterator it;
+  for( it = mItems.begin(); it != mItems.end(); ++it )
+  {
+    (*it)->swapDefault();
+  }
+  usrUseDefaults(b);
+  return !mUseDefaults;
 }
 
 void KConfigSkeleton::setDefaults()
 {
+  KConfigSkeletonItem::List::ConstIterator it;
+  for( it = mItems.begin(); it != mItems.end(); ++it ) {
+    (*it)->setDefault();
+  }
   usrSetDefaults();
 }
 
@@ -1011,29 +1025,14 @@
   readConfig();
 
   emit configChanged();
-
 }
 
 bool KConfigSkeleton::usrUseDefaults(bool b)
 {
-  if (b == mUseDefaults)
-     return mUseDefaults;
-
-  mUseDefaults = b;
-  KConfigSkeletonItem::List::ConstIterator it;
-  for( it = mItems.begin(); it != mItems.end(); ++it )
-  {
-    (*it)->swapDefault();
-  }
-  return !mUseDefaults;
 }
 
 void KConfigSkeleton::usrSetDefaults()
 {
-  KConfigSkeletonItem::List::ConstIterator it;
-  for( it = mItems.begin(); it != mItems.end(); ++it ) {
-    (*it)->setDefault();
-  }
 }
 
 void KConfigSkeleton::usrReadConfig()
--- trunk/KDE/kdelibs/kdeui/config/kconfigskeleton.h #668874:668875
@@ -937,26 +937,35 @@
 
   /**
    * Set all registered items to their default values.
-   * This method is implemented by usrSetDefaults(), which can be overridden
-   * in derived classes if you have special requirements.
+   * This method calls usrSetDefaults() after setting the defaults for the
+   * registered items. You can overridde usrSetDefaults() in derived classes
+   * if you have special requirements.
+   * If you need more fine-grained control of setting the default values of
+   * the registered items you can override setDefaults() in a derived class.
    */
-  void setDefaults();
+  virtual void setDefaults();
 
   /**
    * Read preferences from config file. All registered items are set to the
    * values read from disk.
-   * This method is implemented by usrReadConfig(), which can be overridden
+   * This method calls usrReadConfig() after reading the settings of the
+   * registered items from the KConfig. You can overridde usrReadConfig()
    * in derived classes if you have special requirements.
+   * If you need more fine-grained control of storing the settings from
+   * the registered items you can override readConfig() in a derived class.
    */
-  void readConfig();
+  virtual void readConfig();
 
   /**
    * Write preferences to config file. The values of all registered items are
    * written to disk.
-   * This method is implemented by usrWriteConfig(), which can be overridden
+   * This method calls usrWriteConfig() after writing the settings from the
+   * registered items to the KConfig. You can overridde usrWriteConfig()
    * in derived classes if you have special requirements.
+   * If you need more fine-grained control of storing the settings from
+   * the registered items you can override writeConfig() in a derived class.
    */
-  void writeConfig();
+  virtual void writeConfig();
 
   /**
    * Set the config file group for subsequent addItem() calls. It is valid
@@ -1295,7 +1304,10 @@
    * Specify whether this object should reflect the actual values or the
    * default values.
    * This method is implemented by usrUseDefaults(), which can be overridden
-   * in derived classes if you have special requirements.
+   * in derived classes if you have special requirements and can call
+   * usrUseDefaults() directly.
+   * If you don't have control wether useDefaults() or usrUseDefaults() is
+   * called override useDefaults() directly.
    * @param b true to make this object reflect the default values,
    *          false to make it reflect the actual values.
    * @return The state prior to this call
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

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