vsettings.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file vsettings.h
00013 ** \version $Id: vsettings.h 2362 2008-02-29 04:30:11Z edmanm $
00014 ** \brief Stores and retrieves settings from Vidalia's configuration file.
00015 */
00016 
00017 #ifndef _VSETTINGS_H
00018 #define _VSETTINGS_H
00019 
00020 #include <QHash>
00021 #include <QSettings>
00022 
00023 
00024 class VSettings : public QSettings
00025 {
00026   Q_OBJECT
00027 
00028 public:
00029   /** Default constructor. The optional parameter <b>group</b> can be used to
00030    * set a prefix that will be prepended to keys specified to VSettings in
00031    * value() and setValue(). */
00032   VSettings(const QString group = QString());
00033 
00034   /** Resets all of Vidalia's settings. */
00035   static void reset();
00036 
00037   /** Returns the saved value associated with <b>key</b>. If no value has been
00038    * set, the default value is returned.
00039    * \sa setDefault
00040    */
00041   virtual QVariant value(const QString &key,
00042                          const QVariant &defaultVal = QVariant()) const;
00043   /** Sets the value associated with <b>key</b> to <b>val</b>. */
00044   virtual void setValue(const QString &key, const QVariant &val);
00045 
00046 protected:
00047   /** Sets the default setting for <b>key</b> to <b>val</b>. */
00048   void setDefault(const QString &key, const QVariant &val);
00049   /** Returns the default setting value associated with <b>key</b>. If
00050    * <b>key</b> has no default value, then an empty QVariant is returned. */
00051   QVariant defaultValue(const QString &key) const;
00052   /** Returns a map of all currently saved settings at the last apply()
00053    * point. */
00054   QMap<QString, QVariant> allSettings() const;
00055 
00056 private:
00057   /** Association of setting key names to default setting values. */
00058   QHash<QString, QVariant> _defaults; 
00059 };
00060 
00061 #endif
00062 

Generated on Tue Jul 7 16:58:11 2009 for Vidalia by  doxygen 1.4.7