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

List:       kde-core-devel
Subject:    KConfigBase & TODO
From:       Thomas Braxton <brax108 () cox ! net>
Date:       2005-12-13 8:22:46
Message-ID: 200512130222.46742.brax108 () cox ! net
[Download RAW message or body]

The TODO file has this entry
- KConfigBase: For all the read*Entry methods that take a QFont *, QPoint *,
  QSize *, etc. for the default value, add overloads that use a const
  reference, so that one can write
  resize( config->readSizeEntry( "Bleh", size() ); for example. Constructing a
  null QFont/QPoint/QSize is cheap enough to justify a consistent and usable
  API (IMHO) .
  Keep source compatibility.

I was wondering if this patch is correct and if so should I remove the item 
from the TODO file or just mark it as done when I commit?

["kconfigbase.diff" (text/x-diff)]

Index: kconfigbase.cpp
===================================================================
--- kconfigbase.cpp	(revision 488095)
+++ kconfigbase.cpp	(working copy)
@@ -805,6 +805,16 @@
   return readFontEntry(pKey.toUtf8().data(), pDefault);
 }
 
+QFont KConfigBase::readFontEntry( const QString& pKey, const QFont& pDefault ) const
+{
+  return readFontEntry(pKey.toUtf8().data(), &pDefault);
+}
+
+QFont KConfigBase::readFontEntry( const char *pKey, const QFont& pDefault ) const
+{
+  return readFontEntry(pKey, &pDefault);
+}
+
 QFont KConfigBase::readFontEntry( const char *pKey, const QFont* pDefault ) const
 {
   QFont aRetFont;
@@ -902,6 +912,16 @@
   return readRectEntry(pKey.toUtf8().data(), pDefault);
 }
 
+QRect KConfigBase::readRectEntry( const QString& pKey, const QRect& pDefault ) const
+{
+  return readRectEntry(pKey.toUtf8().data(), &pDefault);
+}
+
+QRect KConfigBase::readRectEntry( const char* pKey, const QRect& pDefault ) const
+{
+  return readRectEntry(pKey, &pDefault);
+}
+
 QRect KConfigBase::readRectEntry( const char *pKey, const QRect* pDefault ) const
 {
   QByteArray aValue = readEntryUtf8(pKey);
@@ -927,6 +947,18 @@
   return readPointEntry(pKey.toUtf8().data(), pDefault);
 }
 
+QPoint KConfigBase::readPointEntry( const QString& pKey,
+                                    const QPoint& pDefault ) const
+{
+  return readPointEntry(pKey.toUtf8().data(), &pDefault);
+}
+
+QPoint KConfigBase::readPointEntry( const char* pKey,
+                                    const QPoint& pDefault ) const
+{
+  return readPointEntry(pKey, &pDefault);
+}
+
 QPoint KConfigBase::readPointEntry( const char *pKey,
                                     const QPoint* pDefault ) const
 {
@@ -952,6 +984,18 @@
   return readSizeEntry(pKey.toUtf8().data(), pDefault);
 }
 
+QSize KConfigBase::readSizeEntry( const QString& pKey,
+                                  const QSize& pDefault ) const
+{
+  return readSizeEntry(pKey.toUtf8().data(), &pDefault);
+}
+
+QSize KConfigBase::readSizeEntry( const char* pKey,
+                                  const QSize& pDefault ) const
+{
+  return readSizeEntry(pKey, &pDefault);
+}
+
 QSize KConfigBase::readSizeEntry( const char *pKey,
                                   const QSize* pDefault ) const
 {
@@ -978,6 +1022,18 @@
   return readColorEntry(pKey.toUtf8().data(), pDefault);
 }
 
+QColor KConfigBase::readColorEntry( const QString& pKey,
+                                    const QColor& pDefault ) const
+{
+  return readColorEntry(pKey.toUtf8().data(), &pDefault);
+}
+
+QColor KConfigBase::readColorEntry( const char* pKey,
+                                    const QColor& pDefault ) const
+{
+  return readColorEntry(pKey, &pDefault);
+}
+
 QColor KConfigBase::readColorEntry( const char *pKey,
                                     const QColor* pDefault ) const
 {
@@ -1043,6 +1099,18 @@
   return readDateTimeEntry(pKey.toUtf8().data(), pDefault);
 }
 
+QDateTime KConfigBase::readDateTimeEntry( const QString& pKey,
+                                          const QDateTime& pDefault ) const
+{
+  return readDateTimeEntry(pKey.toUtf8().data(), &pDefault);
+}
+
+QDateTime KConfigBase::readDateTimeEntry( const char* pKey,
+                                          const QDateTime& pDefault ) const
+{
+  return readDateTimeEntry(pKey, &pDefault);
+}
+
 // ### currentDateTime() as fallback ? (Harri)
 QDateTime KConfigBase::readDateTimeEntry( const char *pKey,
                                           const QDateTime* pDefault ) const
Index: kconfigbase.h
===================================================================
--- kconfigbase.h	(revision 488095)
+++ kconfigbase.h	(working copy)
@@ -566,11 +566,36 @@
    * and interpret it as a font object.
    *
    * @param pKey The key to search for.
+   * @param pDefault A default value returned if the
+   * key was not found or if the read value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QFont readFontEntry( const QString& pKey, const QFont& pDefault ) const;
+
+  /**
+   * Reads a QFont value.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a font object.
+   *
+   * @param pKey The key to search for.
    * @param pDefault A default value (null QFont by default) returned if the
    * key was not found or if the read value cannot be interpreted.
    * @return The value for this key.
    */
   QFont readFontEntry( const char *pKey, const QFont* pDefault = 0L ) const;
+  /**
+   * Reads a QFont value.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a font object.
+   *
+   * @param pKey The key to search for.
+   * @param pDefault A default value returned if the
+   * key was not found or if the read value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QFont readFontEntry( const char *pKey, const QFont& pDefault ) const;
 
   /**
    * Reads a boolean entry.
@@ -618,6 +643,19 @@
    * and interpret it as a QRect object.
    *
    * @param pKey The key to search for
+   * @param pDefault A default value returned if the
+   * key was not found or if the read value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QRect readRectEntry( const QString& pKey, const QRect& pDefault ) const;
+
+  /**
+   * Reads a QRect entry.
+   *
+   * Read the value of an entry specified by pKey in the current group
+   * and interpret it as a QRect object.
+   *
+   * @param pKey The key to search for
    * @param pDefault A default value (null QRect by default) returned if the
    * key was not found or if the read value cannot be interpreted.
    * @return The value for this key.
@@ -625,6 +663,19 @@
   QRect readRectEntry( const char *pKey, const QRect* pDefault = 0L ) const;
 
   /**
+   * Reads a QRect entry.
+   *
+   * Read the value of an entry specified by pKey in the current group
+   * and interpret it as a QRect object.
+   *
+   * @param pKey The key to search for
+   * @param pDefault A default value returned if the
+   * key was not found or if the read value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QRect readRectEntry( const char *pKey, const QRect& pDefault ) const;
+
+  /**
    * Reads a QPoint entry.
    *
    * Read the value of an entry specified by @p pKey in the current group
@@ -644,6 +695,19 @@
    * and interpret it as a QPoint object.
    *
    * @param pKey The key to search for
+   * @param pDefault A default value returned if the
+   * key was not found or if the read value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QPoint readPointEntry( const QString& pKey, const QPoint& pDefault ) const;
+
+  /**
+   * Reads a QPoint entry.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a QPoint object.
+   *
+   * @param pKey The key to search for
    * @param pDefault A default value (null QPoint by default) returned if the
    * key was not found or if the read value cannot be interpreted.
    * @return The value for this key.
@@ -651,6 +715,19 @@
   QPoint readPointEntry( const char *pKey, const QPoint* pDefault = 0L ) const;
 
   /**
+   * Reads a QPoint entry.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a QPoint object.
+   *
+   * @param pKey The key to search for
+   * @param pDefault A default value returned if the
+   * key was not found or if the read value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QPoint readPointEntry( const char *pKey, const QPoint& pDefault ) const;
+
+  /**
    * Reads a QSize entry.
    *
    * Read the value of an entry specified by @p pKey in the current group
@@ -670,12 +747,37 @@
    * and interpret it as a QSize object.
    *
    * @param pKey The key to search for
+   * @param pDefault A default value returned if the
+   * key was not found or if the read value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QSize readSizeEntry( const QString& pKey, const QSize& pDefault ) const;
+
+  /**
+   * Reads a QSize entry.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a QSize object.
+   *
+   * @param pKey The key to search for
    * @param pDefault A default value (null QSize by default) returned if the
    * key was not found or if the read value cannot be interpreted.
    * @return The value for this key.
    */
   QSize readSizeEntry( const char *pKey, const QSize* pDefault = 0L ) const;
 
+  /**
+   * Reads a QSize entry.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a QSize object.
+   *
+   * @param pKey The key to search for
+   * @param pDefault A default value returned if the
+   * key was not found or if the read value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QSize readSizeEntry( const char *pKey, const QSize& pDefault ) const;
 
   /**
    * Reads a QColor entry.
@@ -697,6 +799,19 @@
    * and interpret it as a color.
    *
    * @param pKey The key to search for.
+   * @param pDefault A default value returned if the
+   * key was not found or if the value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QColor readColorEntry( const QString& pKey, const QColor& pDefault ) const;
+
+  /**
+   * Reads a QColor entry.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a color.
+   *
+   * @param pKey The key to search for.
    * @param pDefault A default value (null QColor by default) returned if the
    * key was not found or if the value cannot be interpreted.
    * @return The value for this key.
@@ -704,6 +819,19 @@
   QColor readColorEntry( const char *pKey, const QColor* pDefault = 0L ) const;
 
   /**
+   * Reads a QColor entry.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a color.
+   *
+   * @param pKey The key to search for.
+   * @param pDefault A default value returned if the
+   * key was not found or if the value cannot be interpreted.
+   * @return The value for this key.
+   */
+  QColor readColorEntry( const char *pKey, const QColor& pDefault ) const;
+
+  /**
    * Reads a QDateTime entry.
    *
    * Read the value of an entry specified by @p pKey in the current group
@@ -729,9 +857,37 @@
    * interpreted.
    * @return The value for this key.
    */
+  QDateTime readDateTimeEntry( const QString& pKey, const QDateTime& pDefault ) const;
+
+  /**
+   * Reads a QDateTime entry.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a date and time.
+   *
+   * @param pKey The key to search for.
+   * @param pDefault A default value ( currentDateTime() by default)
+   * returned if the key was not found or if the read value cannot be
+   * interpreted.
+   * @return The value for this key.
+   */
   QDateTime readDateTimeEntry( const char *pKey, const QDateTime* pDefault = 0L ) const;
 
   /**
+   * Reads a QDateTime entry.
+   *
+   * Read the value of an entry specified by @p pKey in the current group
+   * and interpret it as a date and time.
+   *
+   * @param pKey The key to search for.
+   * @param pDefault A default value ( currentDateTime() by default)
+   * returned if the key was not found or if the read value cannot be
+   * interpreted.
+   * @return The value for this key.
+   */
+  QDateTime readDateTimeEntry( const char *pKey, const QDateTime& pDefault ) const;
+
+  /**
    * Reads the value of an entry specified by @p pKey in the current group.
    * The untranslated entry is returned, you normally do not need this.
    *


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

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