settings_proxy.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 QMutex, QMutexLocker, QObject
00032 
00033 
00034 class SettingsProxy(QObject):
00035 
00036     """Wrapper of a QSettings instance simplifying access of grouped data."""
00037 
00038     def __init__(self, qsettings):
00039         super(SettingsProxy, self).__init__()
00040         self.setObjectName('SettingsProxy')
00041 
00042         self._qsettings = qsettings
00043         self._mutex = QMutex(QMutex.Recursive)
00044 
00045     def all_keys(self, group):
00046         locker = QMutexLocker(self._mutex)  # @UnusedVariable
00047         self._qsettings.beginGroup(group)
00048         keys = self._qsettings.allKeys()
00049         self._qsettings.endGroup()
00050         return keys
00051 
00052 #    def begin_read_array(self, group):
00053 
00054 #    def begin_write_array(self, group):
00055 
00056     def child_groups(self, group):
00057         locker = QMutexLocker(self._mutex)  # @UnusedVariable
00058         self._qsettings.beginGroup(group)
00059         groups = self._qsettings.childGroups()
00060         self._qsettings.endGroup()
00061         return groups
00062 
00063     def child_keys(self, group):
00064         locker = QMutexLocker(self._mutex)  # @UnusedVariable
00065         self._qsettings.beginGroup(group)
00066         keys = self._qsettings.childKeys()
00067         self._qsettings.endGroup()
00068         return keys
00069 
00070     def contains(self, group, key):
00071         locker = QMutexLocker(self._mutex)  # @UnusedVariable
00072         self._qsettings.beginGroup(group)
00073         key_exists = self._qsettings.contains(key)
00074         self._qsettings.endGroup()
00075         return key_exists
00076 
00077 #    def end_array(self):
00078 
00079     def remove(self, group, key):
00080         locker = QMutexLocker(self._mutex)  # @UnusedVariable
00081         self._qsettings.beginGroup(group)
00082         self._qsettings.remove(key)
00083         self._qsettings.endGroup()
00084 
00085 #    def set_array_index(self, i):
00086 
00087     def set_value(self, group, key, value):
00088         locker = QMutexLocker(self._mutex)  # @UnusedVariable
00089         self._qsettings.beginGroup(group)
00090         self._qsettings.setValue(key, value)
00091         self._qsettings.endGroup()
00092 
00093     def value(self, group, key, default_value=None):
00094         locker = QMutexLocker(self._mutex)  # @UnusedVariable
00095         self._qsettings.beginGroup(group)
00096         v = self._qsettings.value(key, default_value)
00097         self._qsettings.endGroup()
00098         return v


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