Skip to content
Snippets Groups Projects
Commit f214b0e0 authored by Lan Dam's avatar Lan Dam
Browse files

adjust last row; rearrange add_row() to be more readable

parent 761cc38f
No related branches found
No related tags found
1 merge request!217Implement dialogs to edit valueColors for 2 multiColorDots plot types
...@@ -137,39 +137,37 @@ class MultiColorDotDialog(EditValueColorDialog): ...@@ -137,39 +137,37 @@ class MultiColorDotDialog(EditValueColorDialog):
:param rowid: id of current row :param rowid: id of current row
""" """
lower_bound_lnedit = QtWidgets.QLineEdit() lower_bound_lnedit = QtWidgets.QLineEdit()
self.main_layout.addWidget(lower_bound_lnedit, rowid, 1, 1, 1) lower_bound_lnedit.setEnabled(False)
lower_bound_lnedit.setReadOnly(True)
if rowid == 0:
lower_bound_lnedit.setHidden(True)
elif rowid < ROW_TOTAL - 1:
lower_bound_lnedit.setEnabled(False)
else:
lower_bound_lnedit.setHidden(True)
comparing_text = self.get_comparing_text(rowid) comparing_text = self.get_comparing_text(rowid)
self.main_layout.addWidget(QtWidgets.QLabel( comparing_label = QtWidgets.QLabel(comparing_text)
comparing_text), rowid, 2, 1, 1)
higher_bound_lnedit = QtWidgets.QLineEdit() higher_bound_lnedit = QtWidgets.QLineEdit()
validator = BoundValidator() validator = BoundValidator()
higher_bound_lnedit.setValidator(validator) higher_bound_lnedit.setValidator(validator)
self.main_layout.addWidget(higher_bound_lnedit, rowid, 3, 1, 1)
if rowid == ROW_TOTAL - 1: if rowid == 0:
higher_bound_lnedit.setEnabled(False) lower_bound_lnedit.setHidden(True)
elif rowid == ROW_TOTAL - 1:
higher_bound_lnedit.setHidden(True)
select_color_btn = QtWidgets.QPushButton("Select Color") select_color_btn = QtWidgets.QPushButton("Select Color")
select_color_btn.clicked.connect(
lambda: self.on_select_color(rowid))
# set focus policy to not be clicked by hitting enter in higher bound # set focus policy to not be clicked by hitting enter in higher bound
select_color_btn.setFocusPolicy(QtCore.Qt.NoFocus) select_color_btn.setFocusPolicy(QtCore.Qt.NoFocus)
self.main_layout.addWidget(select_color_btn, rowid, 4, 1, 1)
color_label = QtWidgets.QLabel() color_label = QtWidgets.QLabel()
color_label.setFixedWidth(30) color_label.setFixedWidth(30)
color_label.setAutoFillBackground(True) color_label.setAutoFillBackground(True)
# layout
self.main_layout.addWidget(lower_bound_lnedit, rowid, 1, 1, 1)
self.main_layout.addWidget(comparing_label, rowid, 2, 1, 1)
self.main_layout.addWidget(higher_bound_lnedit, rowid, 3, 1, 1)
self.main_layout.addWidget(select_color_btn, rowid, 4, 1, 1)
self.main_layout.addWidget(color_label, rowid, 5, 1, 1) self.main_layout.addWidget(color_label, rowid, 5, 1, 1)
select_color_btn.clicked.connect(
lambda: self.on_select_color(rowid))
return (lower_bound_lnedit, higher_bound_lnedit, return (lower_bound_lnedit, higher_bound_lnedit,
select_color_btn, color_label) select_color_btn, color_label)
...@@ -319,9 +317,8 @@ class MultiColorDotDialog(EditValueColorDialog): ...@@ -319,9 +317,8 @@ class MultiColorDotDialog(EditValueColorDialog):
self.rowid_value_dict = {i: float(self.higher_bound_lnedits[i].text()) self.rowid_value_dict = {i: float(self.higher_bound_lnedits[i].text())
for i in range(ROW_TOTAL - 1) for i in range(ROW_TOTAL - 1)
if self.higher_bound_lnedits[i].text() != ''} if self.higher_bound_lnedits[i].text() != ''}
last_row_lnedit = (self.lower_bound_lnedits[ROW_TOTAL - 1] last_row_lnedit = self.lower_bound_lnedits[ROW_TOTAL - 1]
if self.upper_equal
else self.higher_bound_lnedits[ROW_TOTAL - 1])
if len(self.rowid_value_dict) == 0: if len(self.rowid_value_dict) == 0:
last_row_lnedit.clear() last_row_lnedit.clear()
else: else:
...@@ -375,10 +372,8 @@ class MultiColorDotDialog(EditValueColorDialog): ...@@ -375,10 +372,8 @@ class MultiColorDotDialog(EditValueColorDialog):
self.lower_bound_lnedits[vc_idx + 1].setText(str(value)) self.lower_bound_lnedits[vc_idx + 1].setText(str(value))
else: else:
self.include_greater_than_chkbox.setChecked(True) self.include_greater_than_chkbox.setChecked(True)
if self.upper_equal: self.lower_bound_lnedits[ROW_TOTAL - 1].setText(str(value))
self.lower_bound_lnedits[ROW_TOTAL - 1].setText(str(value))
else:
self.higher_bound_lnedits[ROW_TOTAL - 1].setText(str(value))
if color == 'not plot': if color == 'not plot':
self.set_color_enabled(vc_idx, False) self.set_color_enabled(vc_idx, False)
else: else:
...@@ -417,11 +412,10 @@ class MultiColorDotDialog(EditValueColorDialog): ...@@ -417,11 +412,10 @@ class MultiColorDotDialog(EditValueColorDialog):
color = self.color_labels[ROW_TOTAL - 1].palette().window( color = self.color_labels[ROW_TOTAL - 1].palette().window(
).color().name() ).color().name()
val = f"{self.lower_bound_lnedits[ROW_TOTAL - 1].text()}"
if self.upper_equal: if self.upper_equal:
val = f"{self.lower_bound_lnedits[ROW_TOTAL - 1].text()}"
value_color_list.append(f"{val}<:{color}") value_color_list.append(f"{val}<:{color}")
else: else:
val = f"{self.higher_bound_lnedits[ROW_TOTAL - 1].text()}"
value_color_list.append(f"={val}:{color}") value_color_list.append(f"={val}:{color}")
self.value_color_str = '|'.join(value_color_list) self.value_color_str = '|'.join(value_color_list)
...@@ -444,7 +438,7 @@ class MultiColorDotLowerEqualDialog(MultiColorDotDialog): ...@@ -444,7 +438,7 @@ class MultiColorDotLowerEqualDialog(MultiColorDotDialog):
elif rowid < ROW_TOTAL - 1: elif rowid < ROW_TOTAL - 1:
comparing_text = "<= d <" comparing_text = "<= d <"
else: else:
comparing_text = " d =" comparing_text = "= d"
return comparing_text return comparing_text
def set_value(self): def set_value(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment