Skip to content

Commit

Permalink
DomainEditor: Indicate changed variables with bold face font
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Feb 2, 2019
1 parent 5eba886 commit dda2652
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Orange/widgets/utils/domaineditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import scipy.sparse as sp

from AnyQt.QtCore import Qt, QAbstractTableModel
from AnyQt.QtGui import QColor
from AnyQt.QtGui import QColor, QFont
from AnyQt.QtWidgets import QComboBox, QTableView, QSizePolicy

from Orange.data import DiscreteVariable, ContinuousVariable, StringVariable, \
Expand Down Expand Up @@ -43,6 +43,10 @@ class VarTableModel(QAbstractTableModel):
def __init__(self, variables, *args):
super().__init__(*args)
self.variables = variables
self.orig_variables = variables.copy()

def set_orig_variables(self, variables):
self.orig_variables = variables.copy()

def set_variables(self, variables):
self.modelAboutToBeReset.emit()
Expand Down Expand Up @@ -76,6 +80,11 @@ def data(self, index, role):
place = self.variables[row][Column.place]
mapping = [Place.meta, Place.feature, Place.class_var, None]
return TableModel.ColorForRole.get(mapping[place], None)
if role == Qt.FontRole:
if self.variables[row] != self.orig_variables[row]:
font = QFont()
font.setBold(True)
return font

def setData(self, index, value, role):
row, col = index.row(), index.column()
Expand Down Expand Up @@ -342,6 +351,7 @@ def _get_column(self, data, source_var, source_place):

def set_domain(self, domain):
self.variables = self.parse_domain(domain)
self.model().set_orig_variables(self.variables)

@staticmethod
def parse_domain(domain):
Expand Down

0 comments on commit dda2652

Please sign in to comment.