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


Python Qt.QListView类代码示例

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


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

示例1: __init__

 def __init__(self, parent):
     QListView.__init__(self, parent)
     setup_dnd_interface(self)
     self.setUniformItemSizes(True)
     self.setWrapping(True)
     self.setFlow(self.LeftToRight)
     # We cannot set layout mode to batched, because that breaks
     # restore_vpos()
     # self.setLayoutMode(self.Batched)
     self.setResizeMode(self.Adjust)
     self.setSelectionMode(self.ExtendedSelection)
     self.setVerticalScrollMode(self.ScrollPerPixel)
     self.delegate = CoverDelegate(self)
     self.delegate.animation.valueChanged.connect(self.animation_value_changed)
     self.delegate.animation.finished.connect(self.animation_done)
     self.setItemDelegate(self.delegate)
     self.setSpacing(self.delegate.spacing)
     self.padding_left = 0
     self.set_color()
     self.ignore_render_requests = Event()
     self.thumbnail_cache = ThumbnailCache(max_size=gprefs['cover_grid_disk_cache_size'],
         thumbnail_size=(self.delegate.cover_size.width(), self.delegate.cover_size.height()))
     self.render_thread = None
     self.update_item.connect(self.re_render, type=Qt.QueuedConnection)
     self.doubleClicked.connect(self.double_clicked)
     self.setCursor(Qt.PointingHandCursor)
     self.gui = parent
     self.context_menu = None
     self.update_timer = QTimer(self)
     self.update_timer.setInterval(200)
     self.update_timer.timeout.connect(self.update_viewport)
     self.update_timer.setSingleShot(True)
开发者ID:shamray,项目名称:calibre,代码行数:32,代码来源:alternate_views.py

示例2: __init__

 def __init__(self, completer_widget, max_visible_items=7):
     QListView.__init__(self)
     self.completer_widget = weakref.ref(completer_widget)
     self.setWindowFlags(Qt.Popup)
     self.max_visible_items = max_visible_items
     self.setEditTriggers(self.NoEditTriggers)
     self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self.setSelectionBehavior(self.SelectRows)
     self.setSelectionMode(self.SingleSelection)
     self.setAlternatingRowColors(True)
     self.setModel(CompleteModel(self))
     self.setMouseTracking(True)
     self.entered.connect(self.item_entered)
     self.activated.connect(self.item_chosen)
     self.pressed.connect(self.item_chosen)
     self.installEventFilter(self)
开发者ID:089git,项目名称:calibre,代码行数:16,代码来源:complete2.py

示例3: handle_mouse_press_event

 def handle_mouse_press_event(self, ev):
     if QApplication.keyboardModifiers() & Qt.ShiftModifier:
         # Shift-Click in QLitView is broken. It selects extra items in
         # various circumstances, for example, click on some item in the
         # middle of a row then click on an item in the next row, all items
         # in the first row will be selected instead of only items after the
         # middle item.
         index = self.indexAt(ev.pos())
         if not index.isValid():
             return
         ci = self.currentIndex()
         sm = self.selectionModel()
         sm.setCurrentIndex(index, sm.NoUpdate)
         if not ci.isValid():
             return
         if not sm.hasSelection():
             sm.select(index, sm.ClearAndSelect)
             return
         cr = ci.row()
         tgt = index.row()
         top = self.model().index(min(cr, tgt), 0)
         bottom = self.model().index(max(cr, tgt), 0)
         sm.select(QItemSelection(top, bottom), sm.Select)
     else:
         return QListView.mousePressEvent(self, ev)
开发者ID:shamray,项目名称:calibre,代码行数:25,代码来源:alternate_views.py

示例4: event

 def event(self, e):
     if e.type() == e.Paint:
         p = QPainter(self)
         # Without this the viewport margin is rendered in QPalette::Window
         # instead of QPalette::Base
         p.fillRect(0, 0, self.padding_left+2, self.height(), self.palette().color(QPalette.Base))
         p.end()
     return QListView.event(self, e)
开发者ID:banksps,项目名称:calibre,代码行数:8,代码来源:alternate_views.py

示例5: moveCursor

 def moveCursor(self, action, modifiers):
     index = QListView.moveCursor(self, action, modifiers)
     if action in (QListView.MoveLeft, QListView.MoveRight) and index.isValid():
         ci = self.currentIndex()
         if ci.isValid() and index.row() == ci.row():
             nr = index.row() + (1 if action == QListView.MoveRight else -1)
             if 0 <= nr < self.model().rowCount(QModelIndex()):
                 index = self.model().index(nr, 0)
     return index
开发者ID:Hainish,项目名称:calibre,代码行数:9,代码来源:alternate_views.py

示例6: __init__

 def __init__(self, parent=None):
     self.last_mouse_idx = -1
     QListView.__init__(self, parent)
     self._model = CharModel(self)
     self.setModel(self._model)
     self.delegate = CharDelegate(self)
     self.setItemDelegate(self.delegate)
     self.setFlow(self.LeftToRight)
     self.setWrapping(True)
     self.setMouseTracking(True)
     self.setSpacing(2)
     self.setUniformItemSizes(True)
     self.setContextMenuPolicy(Qt.CustomContextMenu)
     self.customContextMenuRequested.connect(self.context_menu)
     self.showing_favorites = False
     pi = plugins['progress_indicator'][0]
     if hasattr(pi, 'set_no_activate_on_click'):
         pi.set_no_activate_on_click(self)
     self.activated.connect(self.item_activated)
     self.clicked.connect(self.item_activated)
开发者ID:mapopescu,项目名称:calibre,代码行数:20,代码来源:char_select.py

示例7: create_filterable_names_list

def create_filterable_names_list(names, filter_text=None, parent=None):
    nl = QListView(parent)
    nl.m = m = NamesModel(names, parent=nl)
    m.filtered.connect(lambda all_items: nl.scrollTo(m.index(0)))
    nl.setModel(m)
    nl.d = NamesDelegate(nl)
    nl.setItemDelegate(nl.d)
    f = QLineEdit(parent)
    f.setPlaceholderText(filter_text or '')
    f.textEdited.connect(m.filter)
    return nl, f
开发者ID:sidneijp,项目名称:calibre,代码行数:11,代码来源:widgets.py

示例8: __init__

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.l = l = QGridLayout(self)
        self.setLayout(l)

        self.l1 = l1 = QLabel('<p>'+_(
            'You can control the color of columns in the'
            ' book list by creating "rules" that tell calibre'
            ' what color to use. Click the Add Rule button below'
            ' to get started.<p>You can <b>change an existing rule</b> by double'
            ' clicking it.'))
        l1.setWordWrap(True)
        l.addWidget(l1, 0, 0, 1, 2)

        self.add_button = QPushButton(QIcon(I('plus.png')), _('Add Rule'),
                self)
        self.remove_button = QPushButton(QIcon(I('minus.png')),
                _('Remove Rule'), self)
        self.add_button.clicked.connect(self.add_rule)
        self.remove_button.clicked.connect(self.remove_rule)
        l.addWidget(self.add_button, 1, 0)
        l.addWidget(self.remove_button, 1, 1)

        self.g = g = QGridLayout()
        self.rules_view = QListView(self)
        self.rules_view.doubleClicked.connect(self.edit_rule)
        self.rules_view.setSelectionMode(self.rules_view.SingleSelection)
        self.rules_view.setAlternatingRowColors(True)
        self.rtfd = RichTextDelegate(parent=self.rules_view, max_width=400)
        self.rules_view.setItemDelegate(self.rtfd)
        g.addWidget(self.rules_view, 0, 0, 2, 1)

        self.up_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-up.png')))
        b.setToolTip(_('Move the selected rule up'))
        b.clicked.connect(self.move_up)
        g.addWidget(b, 0, 1, 1, 1, Qt.AlignTop)
        self.down_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-down.png')))
        b.setToolTip(_('Move the selected rule down'))
        b.clicked.connect(self.move_down)
        g.addWidget(b, 1, 1, 1, 1, Qt.AlignBottom)

        l.addLayout(g, 2, 0, 1, 2)
        l.setRowStretch(2, 10)

        self.add_advanced_button = b = QPushButton(QIcon(I('plus.png')),
                _('Add Advanced Rule'), self)
        b.clicked.connect(self.add_advanced)
        l.addWidget(b, 3, 0, 1, 2)
开发者ID:yeyanchao,项目名称:calibre,代码行数:51,代码来源:coloring.py

示例9: __init__

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.l = l = QGridLayout(self)
        self.setLayout(l)

        self.enabled = c = QCheckBox(self)
        l.addWidget(c, l.rowCount(), 0, 1, 2)
        c.setVisible(False)
        c.stateChanged.connect(self.changed)

        self.l1 = l1 = QLabel('')
        l1.setWordWrap(True)
        l.addWidget(l1, l.rowCount(), 0, 1, 2)

        self.add_button = QPushButton(QIcon(I('plus.png')), _('Add Rule'),
                self)
        self.remove_button = QPushButton(QIcon(I('minus.png')),
                _('Remove Rule'), self)
        self.add_button.clicked.connect(self.add_rule)
        self.remove_button.clicked.connect(self.remove_rule)
        l.addWidget(self.add_button, l.rowCount(), 0)
        l.addWidget(self.remove_button, l.rowCount() - 1, 1)

        self.g = g = QGridLayout()
        self.rules_view = QListView(self)
        self.rules_view.doubleClicked.connect(self.edit_rule)
        self.rules_view.setSelectionMode(self.rules_view.SingleSelection)
        self.rules_view.setAlternatingRowColors(True)
        self.rtfd = RichTextDelegate(parent=self.rules_view, max_width=400)
        self.rules_view.setItemDelegate(self.rtfd)
        g.addWidget(self.rules_view, 0, 0, 2, 1)

        self.up_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-up.png')))
        b.setToolTip(_('Move the selected rule up'))
        b.clicked.connect(self.move_up)
        g.addWidget(b, 0, 1, 1, 1, Qt.AlignTop)
        self.down_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-down.png')))
        b.setToolTip(_('Move the selected rule down'))
        b.clicked.connect(self.move_down)
        g.addWidget(b, 1, 1, 1, 1, Qt.AlignBottom)

        l.addLayout(g, l.rowCount(), 0, 1, 2)
        l.setRowStretch(l.rowCount() - 1, 10)

        self.add_advanced_button = b = QPushButton(QIcon(I('plus.png')),
                _('Add Advanced Rule'), self)
        b.clicked.connect(self.add_advanced)
        l.addWidget(b, l.rowCount(), 0, 1, 2)
开发者ID:piewsook,项目名称:calibre,代码行数:51,代码来源:coloring.py

示例10: mouseMoveEvent

 def mouseMoveEvent(self, ev):
     index = self.indexAt(ev.pos())
     if index.isValid():
         row = index.row()
         if row != self.last_mouse_idx:
             self.last_mouse_idx = row
             char_code, ok = self.model().data(index, Qt.UserRole).toInt()
             if ok:
                 self.show_name.emit(char_code)
         self.setCursor(Qt.PointingHandCursor)
     else:
         self.setCursor(Qt.ArrowCursor)
         self.show_name.emit(-1)
         self.last_mouse_idx = -1
     return QListView.mouseMoveEvent(self, ev)
开发者ID:mapopescu,项目名称:calibre,代码行数:15,代码来源:char_select.py

示例11: EditRules

class EditRules(QWidget): # {{{

    changed = pyqtSignal()

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.l = l = QGridLayout(self)
        self.setLayout(l)

        self.l1 = l1 = QLabel('<p>'+_(
            'You can control the color of columns in the'
            ' book list by creating "rules" that tell calibre'
            ' what color to use. Click the Add Rule button below'
            ' to get started.<p>You can <b>change an existing rule</b> by double'
            ' clicking it.'))
        l1.setWordWrap(True)
        l.addWidget(l1, 0, 0, 1, 2)

        self.add_button = QPushButton(QIcon(I('plus.png')), _('Add Rule'),
                self)
        self.remove_button = QPushButton(QIcon(I('minus.png')),
                _('Remove Rule'), self)
        self.add_button.clicked.connect(self.add_rule)
        self.remove_button.clicked.connect(self.remove_rule)
        l.addWidget(self.add_button, 1, 0)
        l.addWidget(self.remove_button, 1, 1)

        self.g = g = QGridLayout()
        self.rules_view = QListView(self)
        self.rules_view.doubleClicked.connect(self.edit_rule)
        self.rules_view.setSelectionMode(self.rules_view.SingleSelection)
        self.rules_view.setAlternatingRowColors(True)
        self.rtfd = RichTextDelegate(parent=self.rules_view, max_width=400)
        self.rules_view.setItemDelegate(self.rtfd)
        g.addWidget(self.rules_view, 0, 0, 2, 1)

        self.up_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-up.png')))
        b.setToolTip(_('Move the selected rule up'))
        b.clicked.connect(self.move_up)
        g.addWidget(b, 0, 1, 1, 1, Qt.AlignTop)
        self.down_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-down.png')))
        b.setToolTip(_('Move the selected rule down'))
        b.clicked.connect(self.move_down)
        g.addWidget(b, 1, 1, 1, 1, Qt.AlignBottom)

        l.addLayout(g, 2, 0, 1, 2)
        l.setRowStretch(2, 10)

        self.add_advanced_button = b = QPushButton(QIcon(I('plus.png')),
                _('Add Advanced Rule'), self)
        b.clicked.connect(self.add_advanced)
        l.addWidget(b, 3, 0, 1, 2)

    def initialize(self, fm, prefs, mi):
        self.model = RulesModel(prefs, fm)
        self.rules_view.setModel(self.model)
        self.fm = fm
        self.mi = mi

    def _add_rule(self, dlg):
        if dlg.exec_() == dlg.Accepted:
            col, r = dlg.rule
            if r and col:
                idx = self.model.add_rule(col, r)
                self.rules_view.scrollTo(idx)
                self.changed.emit()

    def add_rule(self):
            d = RuleEditor(self.model.fm)
            d.add_blank_condition()
            self._add_rule(d)

    def add_advanced(self):
        td = TemplateDialog(self, '', mi=self.mi, fm=self.fm, color_field='')
        self._add_rule(td)

    def edit_rule(self, index):
        try:
            col, rule = self.model.data(index, Qt.UserRole)
        except:
            return
        if isinstance(rule, Rule):
            d = RuleEditor(self.model.fm)
            d.apply_rule(col, rule)
        else:
            d = TemplateDialog(self, rule, mi=self.mi, fm=self.fm, color_field=col)
        if d.exec_() == d.Accepted:
            col, r = d.rule
            if r is not None and col:
                self.model.replace_rule(index, col, r)
                self.rules_view.scrollTo(index)
                self.changed.emit()

    def get_selected_row(self, txt):
        sm = self.rules_view.selectionModel()
        rows = list(sm.selectedRows())
        if not rows:
#.........这里部分代码省略.........
开发者ID:yeyanchao,项目名称:calibre,代码行数:101,代码来源:coloring.py

示例12: resizeEvent

 def resizeEvent(self, e):
     self.center_grid()
     return QListView.resizeEvent(self, e)
开发者ID:banksps,项目名称:calibre,代码行数:3,代码来源:alternate_views.py

示例13: currentChanged

 def currentChanged(self, current, previous):
     self.changed.emit()
     QListView.currentChanged(self, current, previous)
开发者ID:BobPyron,项目名称:calibre,代码行数:3,代码来源:font_family_chooser.py

示例14: __init__

 def __init__(self, parent):
     QListView.__init__(self, parent)
     self.setSelectionMode(self.SingleSelection)
     self.setAlternatingRowColors(True)
     self.d = FontFamilyDelegate(self)
     self.setItemDelegate(self.d)
开发者ID:BobPyron,项目名称:calibre,代码行数:6,代码来源:font_family_chooser.py

示例15: wheelEvent

 def wheelEvent(self, e):
     self.ignore_render_requests.set()
     QListView.wheelEvent(self, e)
     self.update_timer.start()
开发者ID:jackpinto,项目名称:calibre,代码行数:4,代码来源:alternate_views.py


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