Skip to content

Commit

Permalink
itemmodels.TableModel: Qt.BackgroundRole should be QBrush
Browse files Browse the repository at this point in the history
Fixes report in Data Table.
  • Loading branch information
kernc committed Sep 16, 2016
1 parent 8ae84ef commit 1980720
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Orange/widgets/utils/domaineditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def data(self, index, role):
if role == QtCore.Qt.BackgroundRole:
place = self.variables[row][Column.place]
mapping = [Place.meta, Place.feature, Place.class_var, None]
return TableModel.ColorForRole.get(mapping[place], None)
return TableModel.BackgroundForRole.get(mapping[place], None)

def setData(self, index, value, role):
row, col = index.row(), index.column()
Expand Down
15 changes: 7 additions & 8 deletions Orange/widgets/utils/itemmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from functools import reduce, partial, lru_cache
from xml.sax.saxutils import escape

from PyQt4.QtGui import QItemSelectionModel, QColor
from PyQt4.QtGui import QItemSelectionModel, QColor, QBrush
from PyQt4.QtCore import (
Qt, QAbstractListModel, QAbstractTableModel, QModelIndex, QByteArray
)
Expand Down Expand Up @@ -756,10 +756,10 @@ class TableModel(QAbstractTableModel):
ClassVar, Meta, Attribute = range(3)

#: Default background color for domain roles
ColorForRole = {
ClassVar: QColor(160, 160, 160),
Meta: QColor(220, 220, 200),
Attribute: None,
BackgroundForRole = {
ClassVar: QBrush(Qt.gray),
Meta: QBrush(QColor(220, 220, 200)),
Attribute: QBrush(Qt.white),
}

#: Standard column descriptor
Expand Down Expand Up @@ -804,13 +804,13 @@ def make_basket_formater(vars, density, role):

def make_basket(vars, density, role):
return TableModel.Basket(
vars, TableModel.Attribute, self.ColorForRole[role], density,
vars, TableModel.Attribute, self.BackgroundForRole[role], density,
make_basket_formater(vars, density, role)
)

def make_column(var, role):
return TableModel.Column(
var, role, self.ColorForRole[role],
var, role, self.BackgroundForRole[role],
partial(format_dense, var)
)

Expand Down Expand Up @@ -1040,7 +1040,6 @@ def data(self, index, role,
return instance[coldesc.var]
elif role == _Qt_BackgroundRole:
return coldesc.background
return self.color_for_role[coldesc.role]
elif role == _ValueRole and isinstance(coldesc, TableModel.Column):
return instance[coldesc.var]
elif role == _ClassValueRole:
Expand Down

0 comments on commit 1980720

Please sign in to comment.