2020-06-09 15:56:53 +00:00
|
|
|
# NanoVNASaver
|
2020-06-25 17:52:30 +00:00
|
|
|
#
|
2020-06-09 15:56:53 +00:00
|
|
|
# A python program to view and export Touchstone data from a NanoVNA
|
2020-06-25 17:52:30 +00:00
|
|
|
# Copyright (C) 2019, 2020 Rune B. Broberg
|
2021-06-30 05:21:14 +00:00
|
|
|
# Copyright (C) 2020,2021 NanoVNA-Saver Authors
|
2019-08-29 13:10:35 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-09-16 13:47:37 +00:00
|
|
|
import logging
|
2019-08-28 18:20:07 +00:00
|
|
|
|
2023-03-12 07:02:58 +00:00
|
|
|
from PyQt6 import QtWidgets, QtCore, QtGui
|
2019-08-28 18:20:07 +00:00
|
|
|
|
2019-09-16 13:47:37 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2019-09-03 20:04:08 +00:00
|
|
|
|
2019-09-27 08:30:00 +00:00
|
|
|
class BandsWindow(QtWidgets.QWidget):
|
2020-06-09 15:56:53 +00:00
|
|
|
def __init__(self, app: QtWidgets.QWidget):
|
2019-09-27 08:30:00 +00:00
|
|
|
super().__init__()
|
|
|
|
|
2020-06-09 15:56:53 +00:00
|
|
|
self.app = app
|
2019-09-27 08:30:00 +00:00
|
|
|
self.setWindowTitle("Manage bands")
|
2019-10-02 08:07:38 +00:00
|
|
|
self.setWindowIcon(self.app.icon)
|
2019-09-27 08:30:00 +00:00
|
|
|
|
2023-03-12 07:02:58 +00:00
|
|
|
QtGui.QShortcut(QtCore.Qt.Key.Key_Escape, self, self.hide)
|
2019-09-27 08:30:00 +00:00
|
|
|
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
self.setLayout(layout)
|
|
|
|
self.setMinimumSize(500, 300)
|
|
|
|
|
|
|
|
self.bands_table = QtWidgets.QTableView()
|
|
|
|
self.bands_table.setModel(self.app.bands)
|
|
|
|
self.bands_table.horizontalHeader().setStretchLastSection(True)
|
|
|
|
|
|
|
|
layout.addWidget(self.bands_table)
|
|
|
|
|
|
|
|
btn_add_row = QtWidgets.QPushButton("Add row")
|
|
|
|
btn_delete_row = QtWidgets.QPushButton("Delete row")
|
|
|
|
btn_reset_bands = QtWidgets.QPushButton("Reset bands")
|
|
|
|
btn_layout = QtWidgets.QHBoxLayout()
|
|
|
|
btn_layout.addWidget(btn_add_row)
|
|
|
|
btn_layout.addWidget(btn_delete_row)
|
|
|
|
btn_layout.addWidget(btn_reset_bands)
|
|
|
|
layout.addLayout(btn_layout)
|
|
|
|
|
|
|
|
btn_add_row.clicked.connect(self.app.bands.addRow)
|
|
|
|
btn_delete_row.clicked.connect(self.deleteRows)
|
|
|
|
btn_reset_bands.clicked.connect(self.resetBands)
|
|
|
|
|
|
|
|
def deleteRows(self):
|
|
|
|
rows = self.bands_table.selectedIndexes()
|
|
|
|
for row in rows:
|
|
|
|
self.app.bands.removeRow(row.row())
|
|
|
|
|
|
|
|
def resetBands(self):
|
2020-06-09 15:56:53 +00:00
|
|
|
confirm = QtWidgets.QMessageBox(
|
2023-04-18 10:14:21 +00:00
|
|
|
QtWidgets.QMessageBox.Icon.Warning,
|
2020-06-09 15:56:53 +00:00
|
|
|
"Confirm reset",
|
|
|
|
"Are you sure you want to reset the bands to default?",
|
2023-04-18 10:14:21 +00:00
|
|
|
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.Cancel,
|
2023-03-08 08:40:39 +00:00
|
|
|
).exec()
|
2023-04-18 10:14:21 +00:00
|
|
|
if confirm == QtWidgets.QMessageBox.StandardButton.Yes:
|
2019-09-27 08:30:00 +00:00
|
|
|
self.app.bands.resetBands()
|