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 Mar 2, 2019
1 parent 2a2b2d1 commit c28c16c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Orange/widgets/utils/domaineditor.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from itertools import chain
from copy import deepcopy

import numpy as np
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 +44,13 @@ class VarTableModel(QAbstractTableModel):
def __init__(self, variables, *args):
super().__init__(*args)
self.variables = variables
self.set_orig_variables(variables)

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

def reset_variables(self):
self.set_variables(deepcopy(self.orig_variables))

def set_variables(self, variables):
self.modelAboutToBeReset.emit()
Expand Down Expand Up @@ -76,6 +84,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 +355,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 c28c16c

Please sign in to comment.