settings.py
Go to the documentation of this file.
00001 # Copyright (c) 2011, Dirk Thomas, Dorian Scholz, TU Darmstadt
00002 # All rights reserved.
00003 #
00004 # Redistribution and use in source and binary forms, with or without
00005 # modification, are permitted provided that the following conditions
00006 # are met:
00007 #
00008 #   * Redistributions of source code must retain the above copyright
00009 #     notice, this list of conditions and the following disclaimer.
00010 #   * Redistributions in binary form must reproduce the above
00011 #     copyright notice, this list of conditions and the following
00012 #     disclaimer in the documentation and/or other materials provided
00013 #     with the distribution.
00014 #   * Neither the name of the TU Darmstadt nor the names of its
00015 #     contributors may be used to endorse or promote products derived
00016 #     from this software without specific prior written permission.
00017 #
00018 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00022 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00023 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00024 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00026 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00028 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029 # POSSIBILITY OF SUCH DAMAGE.
00030 
00031 from python_qt_binding.QtCore import QObject, Slot
00032 
00033 
00034 class Settings(QObject):
00035 
00036     """Storage of key-value data with a QSettings-like interface."""
00037 
00038     def __init__(self, settings_proxy, group):
00039         super(Settings, self).__init__()
00040         self.setObjectName('Settings')
00041 
00042         self._settings_proxy = settings_proxy
00043         self._group = group
00044 
00045     def get_settings(self, group):
00046         prefix = self._group
00047         if prefix != '':
00048             prefix += '/'
00049         return Settings(self._settings_proxy, prefix + group)
00050 
00051     def all_keys(self):
00052         return self._settings_proxy.all_keys(self._group)
00053 
00054 #    def begin_read_array(self):
00055 
00056 #    def begin_write_array(self):
00057 
00058     def child_groups(self):
00059         return self._settings_proxy.child_groups(self._group)
00060 
00061     def child_keys(self):
00062         return self._settings_proxy.child_keys(self._group)
00063 
00064     @Slot(str, result=bool)
00065     def contains(self, key):
00066         return self._settings_proxy.contains(self._group, key)
00067 
00068 #    def end_array(self):
00069 
00070     @Slot(str)
00071     def remove(self, key):
00072         self._settings_proxy.remove(self._group, key)
00073 
00074 #    def set_array_index(self, i):
00075 
00076     @Slot(str, 'QVariant')
00077     def set_value(self, key, value):
00078         # work around for NoneType values via DBus
00079         if value is None:
00080             value = '__NoneType__'
00081         self._settings_proxy.set_value(self._group, key, value)
00082 
00083     @Slot(str, 'QVariant', result='QVariant')
00084     def value(self, key, default_value=None):
00085         # work around for passing NoneType (default_)values via DBus
00086         if default_value is None:
00087             default_value = '__NoneType__'
00088         value = self._settings_proxy.value(self._group, key, default_value)
00089         if value == '__NoneType__':
00090             value = None
00091         return value


qt_gui
Author(s): Dirk Thomas
autogenerated on Thu Jun 6 2019 18:07:34