qtmobileextensions/src/settingsmanager/xqsettingsmanager.cpp
branchRCL_3
changeset 10 cd2778e5acfe
parent 9 5d007b20cfd0
child 11 19a54be74e5e
equal deleted inserted replaced
9:5d007b20cfd0 10:cd2778e5acfe
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 * 
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not, 
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
       
    19 *
       
    20 */
       
    21 
       
    22 #include "xqsettingsmanager.h"
       
    23 #include "xqsettingsmanager_p.h"
       
    24 #include <QVariant>
       
    25 
       
    26 /*!
       
    27     \class XQSettingsManager
       
    28 
       
    29     \brief The XQSettingsManager class provides methods to handle settings items.
       
    30     The settings items can be targetted in Central Repository or Publish And Subscribe.
       
    31 */
       
    32 
       
    33 /*!
       
    34     Constructs an XQSettingsManager object with the given parent.
       
    35 */
       
    36 XQSettingsManager::XQSettingsManager(QObject* parent) 
       
    37     : QObject(parent), d(new XQSettingsManagerPrivate(this))
       
    38 {
       
    39 }
       
    40 
       
    41 /*!
       
    42     Destroys the XQSettingsManager object.
       
    43 */
       
    44 XQSettingsManager::~XQSettingsManager()
       
    45 {
       
    46     delete d;
       
    47 }
       
    48 
       
    49 /*!
       
    50     \enum XQSettingsManager::Type
       
    51 
       
    52     This enum defines the possible item types for an XQSettingsKey object.
       
    53 */
       
    54 /*! \var XQSettingsManager::TypeVariant XQSettingsManager::TypeVariant
       
    55     The item type is detected automatically.
       
    56 */
       
    57 /*! \var XQSettingsManager::TypeInt XQSettingsManager::TypeInt
       
    58     The item is treated as integer.
       
    59 */
       
    60 /*! \var XQSettingsManager::TypeDouble XQSettingsManager::TypeDouble
       
    61     The item is treated as double. NOTE: This is not supported in Publish And Subscribe.
       
    62 */
       
    63 /*! \var XQSettingsManager::TypeString XQSettingsManager::TypeString
       
    64     The item is treated as string.
       
    65 */
       
    66 /*! \var XQSettingsManager::TypeByteArray XQSettingsManager::TypeByteArray
       
    67     The item is treated as bytearray.
       
    68 */
       
    69 
       
    70 
       
    71 
       
    72 /*!
       
    73     \enum XQSettingsManager::Error
       
    74 
       
    75     This enum defines the possible errors for an XQSettingsManager object.
       
    76 */
       
    77 /*! \var XQSettingsManager::Error XQSettingsManager::NoError
       
    78     No error occured.
       
    79 */
       
    80 /*! \var XQSettingsManager::Error XQSettingsManager::OutOfMemoryError
       
    81     Not enough memory.
       
    82 */
       
    83 /*! \var XQSettingsManager::Error XQSettingsManager::NotFoundError
       
    84     Item not found error.
       
    85 */
       
    86 /*! \var XQSettingsManager::Error XQSettingsManager::AlreadyExistsError
       
    87     Item already exists error.
       
    88 */
       
    89 /*! \var XQSettingsManager::Error XQSettingsManager::NotSupportedError
       
    90     Operation with this kind of item type isn't supported error.
       
    91 */
       
    92 /*! \var XQSettingsManager::Error XQSettingsManager::PermissionDeniedError
       
    93     Permission denied.
       
    94 */
       
    95 /*! \var XQSettingsManager::Error XQSettingsManager::UnknownError
       
    96     Unknown error.
       
    97 */
       
    98 
       
    99 
       
   100 /*!
       
   101     Reads an item value.
       
   102     \param key XQSettingsKey where the value is read from
       
   103     \param type Value type. Default is TypeVariant which means that the type is
       
   104     tried to detect automatically.
       
   105     \return Settings value as QVariant or null object if an error has occurred.
       
   106     \sa error(), writeItemValue()
       
   107 */
       
   108 QVariant XQSettingsManager::readItemValue(const XQSettingsKey& key, XQSettingsManager::Type type)
       
   109 {
       
   110     return d->readItemValue(key, type);
       
   111 }
       
   112 
       
   113 /*!
       
   114     Writes an item value.
       
   115     \param key XQSettingsKey where the value is written to
       
   116     \param value Value to be written into the settings item. The type is determined with
       
   117     QVariant.type() and it must be either QVariant::Int, QVariant::Double, QVariant::String or
       
   118     QVariant::ByteArray.
       
   119     \return True if the item was written succesfully, otherwise return false.
       
   120     \sa error(), readItemValue()
       
   121 */
       
   122 bool XQSettingsManager::writeItemValue(const XQSettingsKey& key, const QVariant& value)
       
   123 {
       
   124     return d->writeItemValue(key, value);
       
   125 }
       
   126 
       
   127 /*!
       
   128     Starts monitoring a settings item.
       
   129     \param key XQSettingsKey of which changes are monitored.
       
   130     \param type Value type. Default is TypeVariant which means that the type is
       
   131     tried to detect automatically.
       
   132     \return True if monitoring was started succesfully, otherwise return false.
       
   133     \sa error(), stopMonitoring()
       
   134 */
       
   135 bool XQSettingsManager::startMonitoring(const XQSettingsKey& key, XQSettingsManager::Type type)
       
   136 {
       
   137     return d->startMonitoring(key, type);
       
   138 }
       
   139 
       
   140 /*!
       
   141     Stops monitoring a settings item.
       
   142     \param key XQSettingsKey of which changes are not monitored any more.
       
   143     \return True if monitoring was stopped succesfully, otherwise return false.
       
   144     \sa error(), startMonitoring()
       
   145 */
       
   146 bool XQSettingsManager::stopMonitoring(const XQSettingsKey& key)
       
   147 {
       
   148     return d->stopMonitoring(key);
       
   149 }
       
   150 
       
   151 /*!
       
   152     Returns the type of error that occurred if the latest function call failed. 
       
   153     Otherwise it returns NoError
       
   154     \return Error code
       
   155 */
       
   156 XQSettingsManager::Error XQSettingsManager::error() const
       
   157 {
       
   158     return d->error();
       
   159 }