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


Python QListWidgetItem.setCheckState方法代码示例

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


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

示例1: link_stylesheets

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
    def link_stylesheets(self, names):
        s = self.categories['styles']
        sheets = [unicode(s.child(i).data(0, NAME_ROLE).toString()) for i in xrange(s.childCount())]
        if not sheets:
            return error_dialog(self, _('No stylesheets'), _(
                'This book currently has no stylesheets. You must first create a stylesheet'
                ' before linking it.'), show=True)
        d = QDialog(self)
        d.l = l = QVBoxLayout(d)
        d.setLayout(l)
        d.setWindowTitle(_('Choose stylesheets'))
        d.la = la = QLabel(_('Choose the stylesheets to link. Drag and drop to re-arrange'))

        la.setWordWrap(True)
        l.addWidget(la)
        d.s = s = QListWidget(d)
        l.addWidget(s)
        s.setDragEnabled(True)
        s.setDropIndicatorShown(True)
        s.setDragDropMode(self.InternalMove)
        s.setAutoScroll(True)
        s.setDefaultDropAction(Qt.MoveAction)
        for name in sheets:
            i = QListWidgetItem(name, s)
            flags = Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled | Qt.ItemIsSelectable
            i.setFlags(flags)
            i.setCheckState(Qt.Checked)
        d.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        bb.accepted.connect(d.accept), bb.rejected.connect(d.reject)
        l.addWidget(bb)
        if d.exec_() == d.Accepted:
            sheets = [unicode(s.item(i).text()) for i in xrange(s.count()) if s.item(i).checkState() == Qt.Checked]
            if sheets:
                self.link_stylesheets_requested.emit(names, sheets)
开发者ID:CharlesSong,项目名称:calibre,代码行数:36,代码来源:file_list.py

示例2: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
 def __init__(self, parent, duplicates, loc):
     QDialog.__init__(self, parent)
     l = QVBoxLayout()
     self.setLayout(l)
     self.la = la = QLabel(_('Books with the same title and author as the following already exist in the library %s.'
                             ' Select which books you want copied anyway.') %
                           os.path.basename(loc))
     la.setWordWrap(True)
     l.addWidget(la)
     self.setWindowTitle(_('Duplicate books'))
     self.books = QListWidget(self)
     self.items = []
     for book_id, (title, authors) in duplicates.iteritems():
         i = QListWidgetItem(_('{0} by {1}').format(title, ' & '.join(authors[:3])), self.books)
         i.setData(Qt.UserRole, book_id)
         i.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
         i.setCheckState(Qt.Checked)
         self.items.append(i)
     l.addWidget(self.books)
     self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     bb.accepted.connect(self.accept)
     bb.rejected.connect(self.reject)
     self.a = b = bb.addButton(_('Select &all'), bb.ActionRole)
     b.clicked.connect(self.select_all), b.setIcon(QIcon(I('plus.png')))
     self.n = b = bb.addButton(_('Select &none'), bb.ActionRole)
     b.clicked.connect(self.select_none), b.setIcon(QIcon(I('minus.png')))
     self.ctc = b = bb.addButton(_('&Copy to clipboard'), bb.ActionRole)
     b.clicked.connect(self.copy_to_clipboard), b.setIcon(QIcon(I('edit-copy.png')))
     l.addWidget(bb)
     self.resize(600, 400)
开发者ID:BatteringRam,项目名称:calibre,代码行数:32,代码来源:copy_to_library.py

示例3: initialize

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
 def initialize(self):
     self.devices.blockSignals(True)
     self.devices.clear()
     for dev in self.gui.device_manager.devices:
         for d, name in dev.get_user_blacklisted_devices().iteritems():
             item = QListWidgetItem('%s [%s]'%(name, d), self.devices)
             item.setData(Qt.UserRole, (dev, d))
             item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
             item.setCheckState(Qt.Checked)
     self.devices.blockSignals(False)
开发者ID:yeyanchao,项目名称:calibre,代码行数:12,代码来源:ignored_devices.py

示例4: initialize

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
    def initialize(self, name):
        '''
        Retrieve plugin-specific settings from general prefs store
        Need to store order of all possible formats, enabled formats
        '''
        self.name = name

        # Supported, enabled formats
        all_formats = self.prefs.get('kindle_supported_formats', KINDLE_SUPPORTED_FORMATS)
        enabled_formats = self.prefs.get('kindle_enabled_formats', KINDLE_ENABLED_FORMATS)

        for format in all_formats:
            item = QListWidgetItem(format, self.columns)
            item.setData(Qt.UserRole, QVariant(format))
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked if format in enabled_formats else Qt.Unchecked)

        self.column_up.clicked.connect(self.up_column)
        self.column_down.clicked.connect(self.down_column)
开发者ID:r3act10n,项目名称:calibre-ios-reader-applications,代码行数:21,代码来源:kindle.py

示例5: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
    def __init__(self, dev, ignored_folders=None, parent=None):
        QDialog.__init__(self, parent)
        self.l = l = QVBoxLayout()
        self.setLayout(l)
        self.la = la = QLabel(
            "<p>"
            + _("<b>Scanned folders:</b>")
            + " "
            + _("You can select which top level folders calibre will " "scan when searching this device for books.")
        )
        la.setWordWrap(True)
        l.addWidget(la)
        self.tabs = QTabWidget(self)
        l.addWidget(self.tabs)
        self.widgets = []

        for storage in dev.filesystem_cache.entries:
            w = QListWidget(self)
            w.storage = storage
            self.tabs.addTab(w, storage.name)
            self.widgets.append(w)
            for child in sorted(storage.folders, key=attrgetter("name")):
                i = QListWidgetItem(child.name)
                i.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                i.setCheckState(
                    Qt.Unchecked
                    if dev.is_folder_ignored(storage, child.name, ignored_folders=ignored_folders)
                    else Qt.Checked
                )
                w.addItem(i)

        self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        self.sab = self.bb.addButton(_("Select &All"), self.bb.ActionRole)
        self.sab.clicked.connect(self.select_all)
        self.snb = self.bb.addButton(_("Select &None"), self.bb.ActionRole)
        self.snb.clicked.connect(self.select_none)
        l.addWidget(self.bb)
        self.setWindowTitle(_("Choose folders to scan"))
        self.setWindowIcon(QIcon(I("devices/tablet.png")))

        self.resize(500, 500)
开发者ID:bjhemens,项目名称:calibre,代码行数:45,代码来源:mtp_folder_browser.py

示例6: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
    def __init__(self, devs, blacklist):
        QWidget.__init__(self)
        self.l = l = QVBoxLayout()
        self.setLayout(l)
        self.la = la = QLabel('<p>'+_(
            '''Select the devices to be <b>ignored</b>. calibre <b>will not</b>
            connect to devices with a checkmark next to their names.'''))
        la.setWordWrap(True)
        l.addWidget(la)
        self.f = f = QListWidget(self)
        l.addWidget(f)

        devs = [(snum, (x[0], parse_date(x[1]))) for snum, x in
                devs.iteritems()]
        for dev, x in sorted(devs, key=lambda x:x[1][1], reverse=True):
            name = x[0]
            name = '%s [%s]'%(name, dev)
            item = QListWidgetItem(name, f)
            item.setData(Qt.UserRole, dev)
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked if dev in blacklist else Qt.Unchecked)
开发者ID:BobPyron,项目名称:calibre,代码行数:23,代码来源:mtp_config.py

示例7: init_columns

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
 def init_columns(self, defaults=False):
     # Set up columns
     self.opt_columns.blockSignals(True)
     model = self.gui.library_view.model()
     colmap = list(model.column_map)
     state = self.columns_state(defaults)
     hidden_cols = state['hidden_columns']
     positions = state['column_positions']
     colmap.sort(cmp=lambda x,y: cmp(positions[x], positions[y]))
     self.opt_columns.clear()
     for col in colmap:
         item = QListWidgetItem(model.headers[col], self.opt_columns)
         item.setData(Qt.UserRole, QVariant(col))
         flags = Qt.ItemIsEnabled|Qt.ItemIsSelectable
         if col != 'ondevice':
             flags |= Qt.ItemIsUserCheckable
         item.setFlags(flags)
         if col != 'ondevice':
             item.setCheckState(Qt.Unchecked if col in hidden_cols else
                     Qt.Checked)
     self.opt_columns.blockSignals(False)
开发者ID:Eksmo,项目名称:calibre,代码行数:23,代码来源:columns.py

示例8: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
    def __init__(self, all_formats, format_map):
        QWidget.__init__(self)
        self.l = l = QGridLayout()
        self.setLayout(l)

        self.f = f = QListWidget(self)
        l.addWidget(f, 0, 0, 3, 1)
        unchecked_formats = sorted(all_formats - set(format_map))
        for fmt in format_map + unchecked_formats:
            item = QListWidgetItem(fmt, f)
            item.setData(Qt.UserRole, fmt)
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked if fmt in format_map else Qt.Unchecked)

        self.button_up = b = QToolButton(self)
        b.setIcon(QIcon(I("arrow-up.png")))
        l.addWidget(b, 0, 1)
        b.clicked.connect(self.up)

        self.button_down = b = QToolButton(self)
        b.setIcon(QIcon(I("arrow-down.png")))
        l.addWidget(b, 2, 1)
        b.clicked.connect(self.down)
开发者ID:hashken,项目名称:calibre,代码行数:25,代码来源:mtp_config.py

示例9: create_item

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
 def create_item(self, alias, key, checked=False):
     i = QListWidgetItem(alias, self.recipients)
     i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
     i.setCheckState(Qt.Checked if checked else Qt.Unchecked)
     i.setData(Qt.UserRole, key)
     self.items.append(i)
开发者ID:fraga,项目名称:calibre,代码行数:8,代码来源:email.py

示例10: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]
    def __init__(self, settings, all_formats, supports_subdirs,
        must_read_metadata, supports_use_author_sort,
        extra_customization_message, device, extra_customization_choices=None):

        QWidget.__init__(self)
        Ui_ConfigWidget.__init__(self)
        self.setupUi(self)

        self.settings = settings

        all_formats = set(all_formats)
        self.calibre_known_formats = device.FORMATS
        try:
            self.device_name = device.get_gui_name()
        except TypeError:
            self.device_name = getattr(device, 'gui_name', None) or _('Device')
        if device.USER_CAN_ADD_NEW_FORMATS:
            all_formats = set(all_formats) | set(BOOK_EXTENSIONS)

        format_map = settings.format_map
        disabled_formats = list(set(all_formats).difference(format_map))
        for format in format_map + list(sorted(disabled_formats)):
            item = QListWidgetItem(format, self.columns)
            item.setData(Qt.UserRole, QVariant(format))
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked if format in format_map else Qt.Unchecked)

        self.column_up.clicked.connect(self.up_column)
        self.column_down.clicked.connect(self.down_column)

        if device.HIDE_FORMATS_CONFIG_BOX:
            self.groupBox.hide()

        if supports_subdirs:
            self.opt_use_subdirs.setChecked(self.settings.use_subdirs)
        else:
            self.opt_use_subdirs.hide()
        if not must_read_metadata:
            self.opt_read_metadata.setChecked(self.settings.read_metadata)
        else:
            self.opt_read_metadata.hide()
        if supports_use_author_sort:
            self.opt_use_author_sort.setChecked(self.settings.use_author_sort)
        else:
            self.opt_use_author_sort.hide()
        if extra_customization_message:
            extra_customization_choices = extra_customization_choices or {}
            def parse_msg(m):
                msg, _, tt = m.partition(':::') if m else ('', '', '')
                return msg.strip(), textwrap.fill(tt.strip(), 100)

            if isinstance(extra_customization_message, list):
                self.opt_extra_customization = []
                if len(extra_customization_message) > 6:
                    row_func = lambda x, y: ((x/2) * 2) + y
                    col_func = lambda x: x%2
                else:
                    row_func = lambda x, y: x*2 + y
                    col_func = lambda x: 0

                for i, m in enumerate(extra_customization_message):
                    label_text, tt = parse_msg(m)
                    if not label_text:
                        self.opt_extra_customization.append(None)
                        continue
                    if isinstance(settings.extra_customization[i], bool):
                        self.opt_extra_customization.append(QCheckBox(label_text))
                        self.opt_extra_customization[-1].setToolTip(tt)
                        self.opt_extra_customization[i].setChecked(bool(settings.extra_customization[i]))
                    elif i in extra_customization_choices:
                        cb = QComboBox(self)
                        self.opt_extra_customization.append(cb)
                        l = QLabel(label_text)
                        l.setToolTip(tt), cb.setToolTip(tt), l.setBuddy(cb), cb.setToolTip(tt)
                        for li in sorted(extra_customization_choices[i]):
                            self.opt_extra_customization[i].addItem(li)
                        cb.setCurrentIndex(max(0, cb.findText(settings.extra_customization[i])))
                    else:
                        self.opt_extra_customization.append(QLineEdit(self))
                        l = QLabel(label_text)
                        l.setToolTip(tt)
                        self.opt_extra_customization[i].setToolTip(tt)
                        l.setBuddy(self.opt_extra_customization[i])
                        l.setWordWrap(True)
                        self.opt_extra_customization[i].setText(settings.extra_customization[i])
                        self.opt_extra_customization[i].setCursorPosition(0)
                        self.extra_layout.addWidget(l, row_func(i, 0), col_func(i))
                    self.extra_layout.addWidget(self.opt_extra_customization[i],
                                                row_func(i, 1), col_func(i))
            else:
                self.opt_extra_customization = QLineEdit()
                label_text, tt = parse_msg(extra_customization_message)
                l = QLabel(label_text)
                l.setToolTip(tt)
                l.setBuddy(self.opt_extra_customization)
                l.setWordWrap(True)
                if settings.extra_customization:
                    self.opt_extra_customization.setText(settings.extra_customization)
                    self.opt_extra_customization.setCursorPosition(0)
                self.opt_extra_customization.setCursorPosition(0)
#.........这里部分代码省略.........
开发者ID:HaraldGustafsson,项目名称:calibre,代码行数:103,代码来源:configwidget.py

示例11: accept

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]

#.........这里部分代码省略.........
            return self.simple_error('', _('No column heading was provided'))

        db = self.parent.gui.library_view.model().db
        key = db.field_metadata.custom_field_prefix+col
        bad_col = False
        if key in self.parent.custcols:
            if not self.editing_col or \
                    self.parent.custcols[key]['colnum'] != self.orig_column_number:
                bad_col = True
        if bad_col:
            return self.simple_error('', _('The lookup name %s is already used')%col)

        bad_head = False
        for t in self.parent.custcols:
            if self.parent.custcols[t]['name'] == col_heading:
                if not self.editing_col or \
                        self.parent.custcols[t]['colnum'] != self.orig_column_number:
                    bad_head = True
        for t in self.standard_colheads:
            if self.standard_colheads[t] == col_heading:
                bad_head = True
        if bad_head:
            return self.simple_error('', _('The heading %s is already used')%col_heading)

        display_dict = {}

        if col_type == 'datetime':
            if unicode(self.date_format_box.text()).strip():
                display_dict = {'date_format':unicode(self.date_format_box.text()).strip()}
            else:
                display_dict = {'date_format': None}
        elif col_type == 'composite':
            if not unicode(self.composite_box.text()).strip():
                return self.simple_error('', _('You must enter a template for'
                    ' composite columns'))
            display_dict = {'composite_template':unicode(self.composite_box.text()).strip(),
                            'composite_sort': ['text', 'number', 'date', 'bool']
                                        [self.composite_sort_by.currentIndex()],
                            'make_category': self.composite_make_category.isChecked(),
                            'contains_html': self.composite_contains_html.isChecked(),
                        }
        elif col_type == 'enumeration':
            if not unicode(self.enum_box.text()).strip():
                return self.simple_error('', _('You must enter at least one'
                    ' value for enumeration columns'))
            l = [v.strip() for v in unicode(self.enum_box.text()).split(',') if v.strip()]
            l_lower = [v.lower() for v in l]
            for i,v in enumerate(l_lower):
                if v in l_lower[i+1:]:
                    return self.simple_error('', _('The value "{0}" is in the '
                    'list more than once, perhaps with different case').format(l[i]))
            c = unicode(self.enum_colors.text())
            if c:
                c = [v.strip() for v in unicode(self.enum_colors.text()).split(',')]
            else:
                c = []
            if len(c) != 0 and len(c) != len(l):
                return self.simple_error('', _('The colors box must be empty or '
                'contain the same number of items as the value box'))
            for tc in c:
                if tc not in QColor.colorNames():
                    return self.simple_error('',
                            _('The color {0} is unknown').format(tc))

            display_dict = {'enum_values': l, 'enum_colors': c}
        elif col_type == 'text' and is_multiple:
            display_dict = {'is_names': self.is_names.isChecked()}
        elif col_type in ['int', 'float']:
            if unicode(self.number_format_box.text()).strip():
                display_dict = {'number_format':unicode(self.number_format_box.text()).strip()}
            else:
                display_dict = {'number_format': None}

        if col_type in ['text', 'composite', 'enumeration'] and not is_multiple:
            display_dict['use_decorations'] = self.use_decorations.checkState()

        if not self.editing_col:
            self.parent.custcols[key] = {
                    'label':col,
                    'name':col_heading,
                    'datatype':col_type,
                    'display':display_dict,
                    'normalized':None,
                    'colnum':None,
                    'is_multiple':is_multiple,
                }
            item = QListWidgetItem(col_heading, self.parent.opt_columns)
            item.setData(Qt.UserRole, QVariant(key))
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked)
        else:
            idx = self.parent.opt_columns.currentRow()
            item = self.parent.opt_columns.item(idx)
            item.setText(col_heading)
            self.parent.custcols[self.orig_column_name]['label'] = col
            self.parent.custcols[self.orig_column_name]['name'] = col_heading
            self.parent.custcols[self.orig_column_name]['display'].update(display_dict)
            self.parent.custcols[self.orig_column_name]['*edited'] = True
            self.parent.custcols[self.orig_column_name]['*must_restart'] = True
        QDialog.accept(self)
开发者ID:Eksmo,项目名称:calibre,代码行数:104,代码来源:create_custom_column.py

示例12: accept

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setCheckState [as 别名]

#.........这里部分代码省略.........
        if not col_heading:
            return self.simple_error("", _("No column heading was provided"))

        db = self.parent.gui.library_view.model().db
        key = db.field_metadata.custom_field_prefix + col
        bad_col = False
        if key in self.parent.custcols:
            if not self.editing_col or self.parent.custcols[key]["colnum"] != self.orig_column_number:
                bad_col = True
        if bad_col:
            return self.simple_error("", _("The lookup name %s is already used") % col)

        bad_head = False
        for t in self.parent.custcols:
            if self.parent.custcols[t]["name"] == col_heading:
                if not self.editing_col or self.parent.custcols[t]["colnum"] != self.orig_column_number:
                    bad_head = True
        for t in self.standard_colheads:
            if self.standard_colheads[t] == col_heading:
                bad_head = True
        if bad_head:
            return self.simple_error("", _("The heading %s is already used") % col_heading)

        display_dict = {}

        if col_type == "datetime":
            if unicode(self.date_format_box.text()).strip():
                display_dict = {"date_format": unicode(self.date_format_box.text()).strip()}
            else:
                display_dict = {"date_format": None}
        elif col_type == "composite":
            if not unicode(self.composite_box.text()).strip():
                return self.simple_error("", _("You must enter a template for" " composite columns"))
            display_dict = {
                "composite_template": unicode(self.composite_box.text()).strip(),
                "composite_sort": ["text", "number", "date", "bool"][self.composite_sort_by.currentIndex()],
                "make_category": self.composite_make_category.isChecked(),
                "contains_html": self.composite_contains_html.isChecked(),
            }
        elif col_type == "enumeration":
            if not unicode(self.enum_box.text()).strip():
                return self.simple_error("", _("You must enter at least one" " value for enumeration columns"))
            l = [v.strip() for v in unicode(self.enum_box.text()).split(",") if v.strip()]
            l_lower = [v.lower() for v in l]
            for i, v in enumerate(l_lower):
                if v in l_lower[i + 1 :]:
                    return self.simple_error(
                        "",
                        _('The value "{0}" is in the ' "list more than once, perhaps with different case").format(l[i]),
                    )
            c = unicode(self.enum_colors.text())
            if c:
                c = [v.strip() for v in unicode(self.enum_colors.text()).split(",")]
            else:
                c = []
            if len(c) != 0 and len(c) != len(l):
                return self.simple_error(
                    "", _("The colors box must be empty or " "contain the same number of items as the value box")
                )
            for tc in c:
                if tc not in QColor.colorNames():
                    return self.simple_error("", _("The color {0} is unknown").format(tc))

            display_dict = {"enum_values": l, "enum_colors": c}
        elif col_type == "text" and is_multiple:
            display_dict = {"is_names": self.is_names.isChecked()}
        elif col_type in ["int", "float"]:
            if unicode(self.number_format_box.text()).strip():
                display_dict = {"number_format": unicode(self.number_format_box.text()).strip()}
            else:
                display_dict = {"number_format": None}

        if col_type in ["text", "composite", "enumeration"] and not is_multiple:
            display_dict["use_decorations"] = self.use_decorations.checkState()

        if not self.editing_col:
            self.parent.custcols[key] = {
                "label": col,
                "name": col_heading,
                "datatype": col_type,
                "display": display_dict,
                "normalized": None,
                "colnum": None,
                "is_multiple": is_multiple,
            }
            item = QListWidgetItem(col_heading, self.parent.opt_columns)
            item.setData(Qt.UserRole, QVariant(key))
            item.setData(Qt.DecorationRole, QVariant(QIcon(I("column.png"))))
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked)
        else:
            idx = self.parent.opt_columns.currentRow()
            item = self.parent.opt_columns.item(idx)
            item.setText(col_heading)
            self.parent.custcols[self.orig_column_name]["label"] = col
            self.parent.custcols[self.orig_column_name]["name"] = col_heading
            self.parent.custcols[self.orig_column_name]["display"].update(display_dict)
            self.parent.custcols[self.orig_column_name]["*edited"] = True
            self.parent.custcols[self.orig_column_name]["*must_restart"] = True
        QDialog.accept(self)
开发者ID:bjhemens,项目名称:calibre,代码行数:104,代码来源:create_custom_column.py


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