Skip to content
Snippets Groups Projects

Fix channel prefer dialog not save

Merged Lan Dam requested to merge i222_channel_prefer_dialog_not_save into develop
2 unresolved threads
1 file
+ 9
13
Compare changes
  • Side-by-side
  • Inline
from typing import Dict, List, Union
from typing import Dict, List, Union, Optional
from pathlib import Path
from PySide6 import QtWidgets, QtCore
@@ -81,12 +81,7 @@ class ChannelPreferDialog(OneWindowAtATimeDialog):
"""
avail_data_types: list of available data types in DB
"""
self.avail_data_types: List[str] = []
"""
working_data_types: list of available data types that aren't default
one
"""
self.working_data_types: List[str] = self.get_data_types(
self.avail_data_types: List[str] = self.get_data_types(
include_default=False)
"""
curr_row: current row
@@ -247,7 +242,6 @@ class ChannelPreferDialog(OneWindowAtATimeDialog):
)
self.soh_list_table_widget.setRowCount(TOTAL_ROW)
self.avail_data_types = self.get_data_types()
for row_idx in range(TOTAL_ROW):
self.add_row(row_idx)
self.update_data_table_widget_items()
@@ -436,6 +430,7 @@ class ChannelPreferDialog(OneWindowAtATimeDialog):
def add_db_channels(self):
"""
Add channels from DB to preferred channel list.
A DB data_type is required in to retrieve its channels from DB
"""
if not self.validate_row(check_data_type=True):
return
@@ -587,7+582,7 @@
return False
ret = trunc_add_db('ChannelPrefer', sql_list)
if ret is not True:
display_tracking_info(self.parent, ret, LogType.ERROR)
self.parent.pref_soh_list = [
t.strip() for t in self.soh_list_item.text().split(',')]
self.parent.pref_soh_list_name = self.soh_list_name_item.text().strip()
@@ -596,7+591,7 @@
self.changed = False
return True
def create_save_row_sql(self, row_idx: int) -> Union[bool, str]:
def create_save_row_sql(self, row_idx: int) -> Optional[str]:
"""
Read info from the row with index row_idx to create insert sql.
@@ -616,17 +611,18 @@ class ChannelPreferDialog(OneWindowAtATimeDialog):
row_idx, COL['IDs']).text()
if idx.strip() == '' and name.strip() == '':
return ''
if data_type not in self.working_data_types:
display_id = row_idx + 1
if data_type == '':
msg = (f"Please add a data type that isn't Default for row"
f" {row_idx}.")
f" {display_id}.")
QtWidgets.QMessageBox.information(self, "Missing info", msg)
return
if idx.strip() == '' and name.strip() != '':
msg = f"Please add Preferred SOH list for row {row_idx}."
msg = f"Please add Preferred SOH list for row {display_id}."
QtWidgets.QMessageBox.information(self, "Missing info", msg)
return
if name.strip() == '' and idx.strip() != '':
msg = f"Please add Name for row {row_idx}."
msg = f"Please add Name for row {display_id}."
QtWidgets.QMessageBox.information(self, "Missing info", msg)
return
return (f"INSERT INTO ChannelPrefer (name, IDs, dataType, current)"
Loading