Exemplo n.º 1
0
    def _create_selector_view(self, parent, model: QtCore.QAbstractTableModel):
        selector_view = QtWidgets.QListView(parent)
        selector_view.setAlternatingRowColors(True)
        selector_view.setUniformItemSizes(True)
        selector_view.setModel(model)

        MIN_ROWS_VIS = 4

        if model.rowCount() < MIN_ROWS_VIS:
            min_rows = model.rowCount()
        else:
            min_rows = MIN_ROWS_VIS

        selector_view.setFixedHeight((selector_view.sizeHintForRow(0) *
                                      min_rows) + 4)

        selector_view.setSizePolicy(SELECTOR_VIEW_SIZE_POLICY)

        selector_view.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectRows)

        selector_view.selectionModel().currentChanged.connect(
            self._update_tool_selected)

        return selector_view
Exemplo n.º 2
0
 def setModel(self, model: QAbstractTableModel):
     super().setModel(model)
     for row in range(model.rowCount()):
         for col in range(model.columnCount()):
             span = model.span(model.index(row, col))
             if span.height() > 1 or span.width() > 1:
                 self.setSpan(row, col, span.height(), span.width())