当前位置: 首页>>代码示例>>Python>>正文


Python QSettings.remove方法代码示例

本文整理汇总了Python中PyQt.QtCore.QSettings.remove方法的典型用法代码示例。如果您正苦于以下问题:Python QSettings.remove方法的具体用法?Python QSettings.remove怎么用?Python QSettings.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt.QtCore.QSettings的用法示例。


在下文中一共展示了QSettings.remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: NewConnectionDialog

# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import remove [as 别名]
class NewConnectionDialog(QDialog, BASE_CLASS):

    """Dialogue to add a new CSW entry"""

    def __init__(self, conn_name=None):
        """init"""

        QDialog.__init__(self)
        self.setupUi(self)
        self.settings = QSettings()
        self.conn_name = None
        self.conn_name_orig = conn_name

    def accept(self):
        """add CSW entry"""

        conn_name = self.leName.text().strip()
        conn_url = self.leURL.text().strip()

        if any([conn_name == '', conn_url == '']):
            QMessageBox.warning(self, self.tr('Save connection'),
                                self.tr('Both Name and URL must be provided'))
            return

        if '/' in conn_name:
            QMessageBox.warning(self, self.tr('Save connection'),
                                self.tr('Name cannot contain \'/\''))
            return

        if conn_name is not None:
            key = '/MetaSearch/%s' % conn_name
            keyurl = '%s/url' % key
            key_orig = '/MetaSearch/%s' % self.conn_name_orig

            # warn if entry was renamed to an existing connection
            if all([self.conn_name_orig != conn_name,
                    self.settings.contains(keyurl)]):
                res = QMessageBox.warning(self, self.tr('Save connection'),
                                          self.tr('Overwrite %s?') % conn_name,
                                          QMessageBox.Ok | QMessageBox.Cancel)
                if res == QMessageBox.Cancel:
                    return

            # on rename delete original entry first
            if all([self.conn_name_orig is not None,
                    self.conn_name_orig != conn_name]):
                self.settings.remove(key_orig)

            self.settings.setValue(keyurl, conn_url)
            self.settings.setValue('/MetaSearch/selected', conn_name)

            QDialog.accept(self)

    def reject(self):
        """back out of dialogue"""

        QDialog.reject(self)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:59,代码来源:newconnectiondialog.py

示例2: remove

# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import remove [as 别名]
 def remove(self):
     settings = QSettings()
     settings.beginGroup(u"/%s/%s" % (self.connectionSettingsKey(), self.connectionName()))
     settings.remove("")
     self.deleted.emit()
     return True
开发者ID:dwadler,项目名称:QGIS,代码行数:8,代码来源:plugin.py

示例3: MetaSearchDialog

# 需要导入模块: from PyQt.QtCore import QSettings [as 别名]
# 或者: from PyQt.QtCore.QSettings import remove [as 别名]

#.........这里部分代码省略.........
        """add new service"""

        conn_new = NewConnectionDialog()
        conn_new.setWindowTitle(self.tr('New Catalogue service'))
        if conn_new.exec_() == QDialog.Accepted:  # add to service list
            self.populate_connection_list()
        self.textMetadata.clear()

    def edit_connection(self):
        """modify existing connection"""

        current_text = self.cmbConnectionsServices.currentText()

        url = self.settings.value('/MetaSearch/%s/url' % current_text)

        conn_edit = NewConnectionDialog(current_text)
        conn_edit.setWindowTitle(self.tr('Edit Catalogue service'))
        conn_edit.leName.setText(current_text)
        conn_edit.leURL.setText(url)
        if conn_edit.exec_() == QDialog.Accepted:  # update service list
            self.populate_connection_list()

    def delete_connection(self):
        """delete connection"""

        current_text = self.cmbConnectionsServices.currentText()

        key = '/MetaSearch/%s' % current_text

        msg = self.tr('Remove service %s?') % current_text

        result = QMessageBox.information(self, self.tr('Confirm delete'), msg,
                                         QMessageBox.Ok | QMessageBox.Cancel)
        if result == QMessageBox.Ok:  # remove service from list
            self.settings.remove(key)
            index_to_delete = self.cmbConnectionsServices.currentIndex()
            self.cmbConnectionsServices.removeItem(index_to_delete)
            self.cmbConnectionsSearch.removeItem(index_to_delete)
            self.set_connection_list_position()

    def load_connections(self):
        """load services from list"""

        ManageConnectionsDialog(1).exec_()
        self.populate_connection_list()

    def add_default_connections(self):
        """add default connections"""

        filename = os.path.join(self.context.ppath,
                                'resources', 'connections-default.xml')
        doc = get_connections_from_file(self, filename)
        if doc is None:
            return

        self.settings.beginGroup('/MetaSearch/')
        keys = self.settings.childGroups()
        self.settings.endGroup()

        for server in doc.findall('csw'):
            name = server.attrib.get('name')
            # check for duplicates
            if name in keys:
                msg = self.tr('%s exists.  Overwrite?') % name
                res = QMessageBox.warning(self,
                                          self.tr('Loading connections'), msg,
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:70,代码来源:maindialog.py


注:本文中的PyQt.QtCore.QSettings.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。