(self, view, data)
Setup the `view` (QTableView) with `data` (Orange.data.Table)
Setup the `view` (QTableView) with `data` (Orange.data.Table)
Setup the view ( QTableView ) with data ( Orange . data . Table )
def _setup_table_view(self, view, data):
        """Setup the `view` (QTableView) with `data` (Orange.data.Table)
        """
        datamodel = RichTableModel(data)
        rowcount = data.approx_len()

        if self.color_by_class and data.domain.has_discrete_class:
            color_schema = [
                QColor(*c) for c in data.domain.class_var.colors]
        else:
            color_schema = None
        if self.show_distributions:
            view.setItemDelegate(
                TableBarItemDelegate(
                    view, color=self.dist_color, color_schema=color_schema)
            )
        else:
            view.setItemDelegate(TableDataDelegate(view))

        # Enable/disable view sorting based on data's type
        view.setSortingEnabled(is_sortable(data))
        header = view.horizontalHeader()
        header.setSectionsClickable(is_sortable(data))
        header.setSortIndicatorShown(is_sortable(data))
        header.sortIndicatorChanged.connect(self.update_selection)

        view.setModel(datamodel)

        vheader = view.verticalHeader()
        option = view.viewOptions()
        size = view.style().sizeFromContents(
            QStyle.CT_ItemViewItem, option,
            QSize(20, 20), view)

        vheader.setDefaultSectionSize(size.height() + 2)
        vheader.setMinimumSectionSize(5)
        vheader.setSectionResizeMode(QHeaderView.Fixed)

        # Limit the number of rows displayed in the QTableView
        # (workaround for QTBUG-18490 / QTBUG-28631)
        maxrows = (2 ** 31 - 1) // (vheader.defaultSectionSize() + 2)
        if rowcount > maxrows:
            sliceproxy = TableSliceProxy(
                parent=view, rowSlice=slice(0, maxrows))
            sliceproxy.setSourceModel(datamodel)
            # First reset the view (without this the header view retains
            # it's state - at this point invalid/broken)
            view.setModel(None)
            view.setModel(sliceproxy)

        assert view.model().rowCount() <= maxrows
        assert vheader.sectionSize(0) > 1 or datamodel.rowCount() == 0

        # update the header (attribute names)
        self._update_variable_labels(view)

        selmodel = BlockSelectionModel(
            view.model(), parent=view, selectBlocks=not self.select_rows)
        view.setSelectionModel(selmodel)
        view.selectionFinished.connect(self.update_selection)
def _setup_table_view ( self , view , data ) : datamodel = RichTableModel ( data ) rowcount = data . approx_len ( ) if self . color_by_class and data . domain . has_discrete_class : color_schema = [ QColor ( * c ) for c in data . domain . class_var . colors ] else : color_schema = None if self . show_distributions : view . setItemDelegate ( TableBarItemDelegate ( view , color = self . dist_color , color_schema = color_schema ) ) else : view . setItemDelegate ( TableDataDelegate ( view ) ) # Enable/disable view sorting based on data's type view . setSortingEnabled ( is_sortable ( data ) ) header = view . horizontalHeader ( ) header . setSectionsClickable ( is_sortable ( data ) ) header . setSortIndicatorShown ( is_sortable ( data ) ) header . sortIndicatorChanged . connect ( self . update_selection ) view . setModel ( datamodel ) vheader = view . verticalHeader ( ) option = view . viewOptions ( ) size = view . style ( ) . sizeFromContents ( QStyle . CT_ItemViewItem , option , QSize ( 20 , 20 ) , view ) vheader . setDefaultSectionSize ( size . height ( ) + 2 ) vheader . setMinimumSectionSize ( 5 ) vheader . setSectionResizeMode ( QHeaderView . Fixed ) # Limit the number of rows displayed in the QTableView # (workaround for QTBUG-18490 / QTBUG-28631) maxrows = ( 2 ** 31 - 1 ) // ( vheader . defaultSectionSize ( ) + 2 ) if rowcount > maxrows : sliceproxy = TableSliceProxy ( parent = view , rowSlice = slice ( 0 , maxrows ) ) sliceproxy . setSourceModel ( datamodel ) # First reset the view (without this the header view retains # it's state - at this point invalid/broken) view . setModel ( None ) view . setModel ( sliceproxy ) assert view . model ( ) . rowCount ( ) <= maxrows assert vheader . sectionSize ( 0 ) > 1 or datamodel . rowCount ( ) == 0 # update the header (attribute names) self . _update_variable_labels ( view ) selmodel = BlockSelectionModel ( view . model ( ) , parent = view , selectBlocks = not self . select_rows ) view . setSelectionModel ( selmodel ) view . selectionFinished . connect ( self . update_selection )