From 4e3a0e69d4e291aaa115287688ddf5d1b73a8ed1 Mon Sep 17 00:00:00 2001
From: destinyk <destiny.kuehn@student.nmt.edu>
Date: Fri, 1 Mar 2024 14:07:09 -0700
Subject: [PATCH] make sensor type a label and add value to be copied to text
 in popup

---
 nexus/StationSelectDialog.py | 15 +++++++++------
 nexus/StationSelectDialog.ui | 17 ++++-------------
 nexus/nexus.py               | 29 ++++++++++++++++++-----------
 3 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/nexus/StationSelectDialog.py b/nexus/StationSelectDialog.py
index 1c252454..8e4a1b23 100644
--- a/nexus/StationSelectDialog.py
+++ b/nexus/StationSelectDialog.py
@@ -28,11 +28,12 @@ def load_ui(filename):
     return ret
 
 class StationSelectDialog(*load_ui('StationSelectDialog.ui')):
-    def __init__(self, stations, copy, parent=None):
+    def __init__(self, stations, action, values, parent=None):
         super().__init__(parent)
         self.stations = stations
         self.stat_map = {}
-        self.copy = copy
+        self.action = action
+        self.values = values
         self.setupUi()
 
     def accept(self):
@@ -59,12 +60,14 @@ class StationSelectDialog(*load_ui('StationSelectDialog.ui')):
         self.setWindowTitle('Select Stations')
         self.tableWidget.setSelectionMode(QAbstractItemView.ExtendedSelection)
 
-        if self.copy == 'type & gain':
-            self.typeCB.setChecked(True)
+        if self.action == 'type & gain':
             self.gainCB.setChecked(True)
-            self.sensorCB.setParent(None)
+            self.gainCB.setText(f"Copy Datalogger Gain: {self.values[0]}")
+            self.typeCB.setChecked(True)
+            self.typeCB.setText(f"Copy Datalogger Type: {self.values[1]}")
+            self.sensor_label.setParent(None)
         else:
-            self.sensorCB.setChecked(True)
+            self.sensor_label.setText(f"Copy Sensor Type: {self.values[0]}")
             self.typeCB.setParent(None)
             self.gainCB.setParent(None)
         
diff --git a/nexus/StationSelectDialog.ui b/nexus/StationSelectDialog.ui
index 3bcb5042..bf0bf6f6 100644
--- a/nexus/StationSelectDialog.ui
+++ b/nexus/StationSelectDialog.ui
@@ -22,11 +22,8 @@
               <verstretch>0</verstretch>
               </sizepolicy>
             </property>
-            <property name="text">
-              <string>Copy Datalogger Type</string>
-            </property>
             <property name="toolTip">
-                <string>Copy datalogger type from main window to selected stations in table</string>
+                <string>Copy stated datalogger type to selected stations in table</string>
               </property>
           </widget>
         </item>
@@ -38,27 +35,21 @@
                 <verstretch>0</verstretch>
                 </sizepolicy>
               </property>
-              <property name="text">
-                <string>Copy Datalogger Gain</string>
-              </property>
               <property name="toolTip">
-                <string>Copy datalogger gain from main window to selected stations in table</string>
+                <string>Copy stated datalogger gain to selected stations in table</string>
               </property>
             </widget>
           </item>
           <item>
-            <widget class="QCheckBox" name="sensorCB">
+            <widget class="QLabel" name="sensor_label">
             <property name="sizePolicy">
                 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                 </sizepolicy>
               </property>
-              <property name="text">
-                <string>Copy Sensor Type</string>
-              </property>
               <property name="toolTip">
-                <string>Copy sensor type from main window to selected stations in table</string>
+                <string>Copy stated sensor type to selected stations in table</string>
               </property>
             </widget>
           </item>
diff --git a/nexus/nexus.py b/nexus/nexus.py
index ed8dfd09..b46d93ef 100755
--- a/nexus/nexus.py
+++ b/nexus/nexus.py
@@ -1289,26 +1289,34 @@ class StationWidget(WidgetBase, *load_ui("StationWidget.ui")):
 
     def copy_dltype_and_gain(self):
         stations = self.get_stations()
-        self.copy_to_stations(stations, 'type & gain')
+        self.copy_to_stations(
+            stations,
+            'type & gain',
+            [self.uiDLGain.text(), self.uiDLType.currentText()])
     
     def copy_sensor(self):
         stations = self.get_stations()
-        self.copy_to_stations(stations, 'sensor')
+        self.copy_to_stations(
+            stations,
+            'sensor',
+            [self.uiSensorType.currentText()])
     
-    def copy_to_stations(self, stations, caller):
-        dialog = StationSelectDialog(stations, caller, parent=self)
+    def copy_to_stations(self, stations, action, values):
+        dialog = StationSelectDialog(stations, action, values, parent=self)
         if dialog.exec_():
-            checked_boxes = {"DLtype": dialog.typeCB.isChecked(),
-                             "DLgain": dialog.gainCB.isChecked(),
-                             "Stype": dialog.sensorCB.isChecked()}
-            self.update_inventory(dialog.selected_stations, checked_boxes)
+            if dialog.sensor_label.parent() is None:
+                copy_this = {"DLtype": dialog.typeCB.isChecked(),
+                                "DLgain": dialog.gainCB.isChecked()}
+            else:
+                copy_this = {"Stype": True}
+            self.update_stations(dialog.selected_stations, copy_this)
         self.stat_node_to_obj_map = {}
 
-    def update_inventory(self, stations, checked_boxes):
+    def update_stations(self, stations, copy_this):
         for stat in stations:
             for node, obj in self.stat_node_to_obj_map.items():
                 if stat == obj:
-                    for key, value in checked_boxes.items():
+                    for key, value in copy_this.items():
                         if value:
                             if key == "DLtype":
                                 node.set_dl_type(self.uiDLType.currentIndex())
@@ -1317,7 +1325,6 @@ class StationWidget(WidgetBase, *load_ui("StationWidget.ui")):
                             else:
                                 node.set_sensor_type(self.uiSensorType.currentIndex())
 
-
     def get_stations(self):
         """
         Get all stations from inventory to
-- 
GitLab