本文整理汇总了Python中PyQt.QtCore.QSettings.childGroups方法的典型用法代码示例。如果您正苦于以下问题:Python QSettings.childGroups方法的具体用法?Python QSettings.childGroups怎么用?Python QSettings.childGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt.QtCore.QSettings
的用法示例。
在下文中一共展示了QSettings.childGroups方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import childGroups [as 别名]
def load(self):
""" populate the mRepositories dict"""
self.mRepositories = {}
settings = QSettings()
settings.beginGroup(reposGroup)
# first, update repositories in QSettings if needed
officialRepoPresent = False
for key in settings.childGroups():
url = settings.value(key + "/url", "", type=unicode)
if url == officialRepo[1]:
officialRepoPresent = True
if url == officialRepo[2]:
settings.setValue(key + "/url", officialRepo[1]) # correct a depreciated url
officialRepoPresent = True
if not officialRepoPresent:
settings.setValue(officialRepo[0] + "/url", officialRepo[1])
for key in settings.childGroups():
self.mRepositories[key] = {}
self.mRepositories[key]["url"] = settings.value(key + "/url", "", type=unicode)
self.mRepositories[key]["authcfg"] = settings.value(key + "/authcfg", "", type=unicode)
self.mRepositories[key]["enabled"] = settings.value(key + "/enabled", True, type=bool)
self.mRepositories[key]["valid"] = settings.value(key + "/valid", True, type=bool)
self.mRepositories[key]["Relay"] = Relay(key)
self.mRepositories[key]["xmlData"] = None
self.mRepositories[key]["state"] = 0
self.mRepositories[key]["error"] = ""
settings.endGroup()
示例2: __init__
# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import childGroups [as 别名]
def __init__(self, parent, tablename):
super(PostgisTableSelector, self).__init__(parent)
self.connection = None
self.table = None
self.schema = None
self.setupUi(self)
settings = QSettings()
settings.beginGroup('/PostgreSQL/connections/')
names = settings.childGroups()
settings.endGroup()
for n in names:
item = ConnectionItem(n)
self.treeConnections.addTopLevelItem(item)
def itemExpanded(item):
try:
item.populateSchemas()
except:
pass
self.treeConnections.itemExpanded.connect(itemExpanded)
self.textTableName.setText(tablename)
self.buttonBox.accepted.connect(self.okPressed)
self.buttonBox.rejected.connect(self.cancelPressed)
示例3: connections
# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import childGroups [as 别名]
def connections(self):
# get the list of connections
conn_list = []
settings = QSettings()
settings.beginGroup(self.connectionSettingsKey())
for name in settings.childGroups():
conn_list.append(createDbPlugin(self.typeName(), name))
settings.endGroup()
return conn_list
示例4: selectOutput
# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import childGroups [as 别名]
def selectOutput(self):
if isinstance(self.output, OutputDirectory):
self.selectDirectory()
else:
popupMenu = QMenu()
actionSaveToTempFile = QAction(
self.tr('Save to a temporary file'), self.btnSelect)
actionSaveToTempFile.triggered.connect(self.saveToTemporaryFile)
popupMenu.addAction(actionSaveToTempFile)
actionSaveToFile = QAction(
self.tr('Save to file...'), self.btnSelect)
actionSaveToFile.triggered.connect(self.selectFile)
popupMenu.addAction(actionSaveToFile)
if isinstance(self.output, OutputVector) \
and self.alg.provider.supportsNonFileBasedOutput():
actionSaveToMemory = QAction(
self.tr('Save to memory layer'), self.btnSelect)
actionSaveToMemory.triggered.connect(self.saveToMemory)
popupMenu.addAction(actionSaveToMemory)
actionSaveToSpatialite = QAction(
self.tr('Save to Spatialite table...'), self.btnSelect)
actionSaveToSpatialite.triggered.connect(self.saveToSpatialite)
popupMenu.addAction(actionSaveToSpatialite)
actionSaveToPostGIS = QAction(
self.tr('Save to PostGIS table...'), self.btnSelect)
actionSaveToPostGIS.triggered.connect(self.saveToPostGIS)
settings = QSettings()
settings.beginGroup('/PostgreSQL/connections/')
names = settings.childGroups()
settings.endGroup()
actionSaveToPostGIS.setEnabled(bool(names))
popupMenu.addAction(actionSaveToPostGIS)
popupMenu.exec_(QCursor.pos())
示例5: ManageConnectionsDialog
# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import childGroups [as 别名]
class ManageConnectionsDialog(QDialog, BASE_CLASS):
"""manage connections"""
def __init__(self, mode):
"""init dialog"""
QDialog.__init__(self)
self.setupUi(self)
self.settings = QSettings()
self.filename = None
self.mode = mode # 0 - save, 1 - load
self.btnBrowse.clicked.connect(self.select_file)
self.manage_gui()
def manage_gui(self):
"""manage interface"""
if self.mode == 1:
self.label.setText(self.tr('Load from file'))
self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr('Load'))
else:
self.label.setText(self.tr('Save to file'))
self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr('Save'))
self.populate()
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
def select_file(self):
"""select file ops"""
label = self.tr('eXtensible Markup Language (*.xml *.XML)')
if self.mode == 0:
slabel = self.tr('Save connections')
self.filename = QFileDialog.getSaveFileName(self, slabel,
'.', label)
else:
slabel = self.tr('Load connections')
self.filename = QFileDialog.getOpenFileName(self, slabel,
'.', label)
if not self.filename:
return
# ensure the user never omitted the extension from the file name
if not self.filename.lower().endswith('.xml'):
self.filename = '%s.xml' % self.filename
self.leFileName.setText(self.filename)
if self.mode == 1:
self.populate()
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
def populate(self):
"""populate connections list from settings"""
if self.mode == 0:
self.settings.beginGroup('/MetaSearch/')
keys = self.settings.childGroups()
for key in keys:
item = QListWidgetItem(self.listConnections)
item.setText(key)
self.settings.endGroup()
else: # populate connections list from file
doc = get_connections_from_file(self, self.filename)
if doc is None:
self.filename = None
self.leFileName.clear()
self.listConnections.clear()
return
for csw in doc.findall('csw'):
item = QListWidgetItem(self.listConnections)
item.setText(csw.attrib.get('name'))
def save(self, connections):
"""save connections ops"""
doc = etree.Element('qgsCSWConnections')
doc.attrib['version'] = '1.0'
for conn in connections:
url = self.settings.value('/MetaSearch/%s/url' % conn)
if url is not None:
connection = etree.SubElement(doc, 'csw')
connection.attrib['name'] = conn
connection.attrib['url'] = url
# write to disk
with open(self.filename, 'w') as fileobj:
fileobj.write(prettify_xml(etree.tostring(doc)))
QMessageBox.information(self, self.tr('Save Connections'),
self.tr('Saved to %s') % self.filename)
self.reject()
def load(self, items):
#.........这里部分代码省略.........
示例6: dbConnectionNames
# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import childGroups [as 别名]
def dbConnectionNames(self):
settings = QSettings()
settings.beginGroup('/PostgreSQL/connections/')
return settings.childGroups()
示例7: MetaSearchDialog
# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import childGroups [as 别名]
#.........这里部分代码省略.........
self.tabWidget.setCurrentIndex(0)
self.populate_connection_list()
self.btnCapabilities.setEnabled(False)
self.spnRecords.setValue(
self.settings.value('/MetaSearch/returnRecords', 10, int))
key = '/MetaSearch/%s' % self.cmbConnectionsSearch.currentText()
self.catalog_url = self.settings.value('%s/url' % key)
self.set_bbox_global()
self.reset_buttons()
# get preferred connection save strategy from settings and set it
save_strat = self.settings.value('/MetaSearch/ows_save_strategy',
'title_ask')
if save_strat == 'temp_name':
self.radioTempName.setChecked(True)
elif save_strat == 'title_no_ask':
self.radioTitleNoAsk.setChecked(True)
else:
self.radioTitleAsk.setChecked(True)
# install proxy handler if specified in QGIS settings
self.install_proxy()
# Servers tab
def populate_connection_list(self):
"""populate select box with connections"""
self.settings.beginGroup('/MetaSearch/')
self.cmbConnectionsServices.clear()
self.cmbConnectionsServices.addItems(self.settings.childGroups())
self.cmbConnectionsSearch.clear()
self.cmbConnectionsSearch.addItems(self.settings.childGroups())
self.settings.endGroup()
self.set_connection_list_position()
if self.cmbConnectionsServices.count() == 0:
# no connections - disable various buttons
state_disabled = False
self.btnSave.setEnabled(state_disabled)
# and start with connection tab open
self.tabWidget.setCurrentIndex(1)
# tell the user to add services
msg = self.tr('No services/connections defined. To get '
'started with MetaSearch, create a new '
'connection by clicking \'New\' or click '
'\'Add default services\'.')
self.textMetadata.setHtml('<p><h3>%s</h3></p>' % msg)
else:
# connections - enable various buttons
state_disabled = True
self.btnServerInfo.setEnabled(state_disabled)
self.btnEdit.setEnabled(state_disabled)
self.btnDelete.setEnabled(state_disabled)
def set_connection_list_position(self):
"""set the current index to the selected connection"""
to_select = self.settings.value('/MetaSearch/selected')
conn_count = self.cmbConnectionsServices.count()
if conn_count == 0: