def __init__(self, parent): QtGui.QWidget.__init__(self, parent) ui.loadUi(self, 'signals.ui') self._signal = SignalSignals() formatters = [None, format_freq, format_rate, None, format_level] self._model = Model(self._signal, self.HEADER, self.HEADER_TIPS, formatters, 1) self._proxyModel = QtGui.QSortFilterProxyModel(self) self._proxyModel.setDynamicSortFilter(True) self._proxyModel.setSourceModel(self._model) self._tableSignals.setModel(self._proxyModel) selection = self._tableSignals.selectionModel() selection.selectionChanged.connect(self.__on_signal_select) self._contextMenu = TableSelectionMenu(self._tableSignals, self._model, self.hasSelection) self.__set_width() palette = self.palette() colour = palette.color(QtGui.QPalette.Active, QtGui.QPalette.Highlight) palette.setColor(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, colour) self.setPalette(palette)
def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self._signal = SignalSurveys() ui.loadUi(self, 'surveys.ui') self._model = Model(self._signal, self.HEADER, self.HEADER_TIPS) proxyModel = QtGui.QSortFilterProxyModel(self) proxyModel.setDynamicSortFilter(True) proxyModel.setSourceModel(self._model) self._tableSurveys.setModel(proxyModel) self._contextMenu = TableSelectionMenu(self._tableSurveys, self._model) self.__set_width()
def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self._signal = SignalScans() ui.loadUi(self, 'scans.ui') formatters = [None, format_qtime, None] self._model = Model(self._signal, self.HEADER, self.HEADER_TIPS, formatters) proxyModel = QtGui.QSortFilterProxyModel(self) proxyModel.setDynamicSortFilter(True) proxyModel.setSourceModel(self._model) self._tableScans.setModel(proxyModel) self._contextMenu = TableSelectionMenu(self._tableScans, self._model) self.__set_width()
class WidgetSignals(QtGui.QWidget): HEADER = [None, 'Freq', 'Rate', 'Seen', 'Level'] HEADER_TIPS = ['Included', 'Signal frequency (MHz)', 'Avergae rate (PPM)', 'Total detections', 'Average level (dB)'] def __init__(self, parent): QtGui.QWidget.__init__(self, parent) ui.loadUi(self, 'signals.ui') self._signal = SignalSignals() formatters = [None, format_freq, format_rate, None, format_level] self._model = Model(self._signal, self.HEADER, self.HEADER_TIPS, formatters, 1) self._proxyModel = QtGui.QSortFilterProxyModel(self) self._proxyModel.setDynamicSortFilter(True) self._proxyModel.setSourceModel(self._model) self._tableSignals.setModel(self._proxyModel) selection = self._tableSignals.selectionModel() selection.selectionChanged.connect(self.__on_signal_select) self._contextMenu = TableSelectionMenu(self._tableSignals, self._model, self.hasSelection) self.__set_width() palette = self.palette() colour = palette.color(QtGui.QPalette.Active, QtGui.QPalette.Highlight) palette.setColor(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, colour) self.setPalette(palette) def __set_width(self): self._tableSignals.resizeColumnsToContents() margins = self.layout().contentsMargins() width = self._tableSignals.verticalHeader().width() width += self._tableSignals.horizontalHeader().length() width += self._tableSignals.style().pixelMetric(QtGui.QStyle.PM_ScrollBarExtent) width += self._tableSignals.frameWidth() * 2 width += margins.left() + margins.right() width += self.layout().spacing() self.setMaximumWidth(width) def __on_signal_select(self, selected, deselected): selection = [] selected = selected.indexes() deslected = deselected.indexes() self.__append_selection(selection, selected, True) self.__append_selection(selection, deslected, False) self._signal.select.emit(selection) @QtCore.Slot(bool) def on__buttonHistogram_clicked(self, _clicked): dlg = DialogHistogram(self._model.get_all(), self._model.get_filtered()) dlg.exec_() def __append_selection(self, selection, select, selected): signals = self._model.get() for index in select: data = index.data() if data is not None and index.column() == 1: mapped = self._proxyModel.mapToSource(index) freq = signals[mapped.row()] selection.append((freq, selected)) def connect(self, on_filter, on_selected): self._model.connect(on_filter) self._signal.select.connect(on_selected) def select(self, frequencies): freqs = ['{:.4f}'.format(f / 1e6) for f in frequencies] scroll = None self._tableSignals.clearSelection() for i in range(self._model.rowCount()): index = self._model.index(i, 1) if index.data() in freqs: mapped = self._proxyModel.mapFromSource(index) self._tableSignals.selectRow(mapped.row()) if scroll is None: scroll = mapped if scroll is not None: self._tableSignals.scrollTo(mapped) def hasSelection(self): return self._tableSignals.selectionModel().hasSelection() def set(self, signals): self._model.set(signals) self.__set_width() self._tableSignals.setEnabled(True) self._buttonHistogram.setEnabled(True) def set_font(self, font): newFont = QtGui.QFont() newFont.fromString(font) self._tableSignals.setFont(newFont) self.__set_width() def get(self): return self._model.get() def get_filters(self): return self._model.get_filters() def get_filtered(self): return self._model.get_filtered() def clear(self): self._model.set([]) self._model.set_filtered([], False) self._tableSignals.setEnabled(False) self._buttonHistogram.setEnabled(False)
class WidgetSurveys(QtGui.QWidget): HEADER = [None, 'Name'] HEADER_TIPS = ['Included', 'Survey name'] def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self._signal = SignalSurveys() ui.loadUi(self, 'surveys.ui') self._model = Model(self._signal, self.HEADER, self.HEADER_TIPS) proxyModel = QtGui.QSortFilterProxyModel(self) proxyModel.setDynamicSortFilter(True) proxyModel.setSourceModel(self._model) self._tableSurveys.setModel(proxyModel) self._contextMenu = TableSelectionMenu(self._tableSurveys, self._model) self.__set_width() def __set_width(self): self._tableSurveys.resizeColumnsToContents() margins = self.layout().contentsMargins() width = self._tableSurveys.verticalHeader().width() width += self._tableSurveys.horizontalHeader().length() width += self._tableSurveys.style().pixelMetric(QtGui.QStyle.PM_ScrollBarExtent) width += self._tableSurveys.frameWidth() * 2 width += margins.left() + margins.right() width += self.layout().spacing() self.setMaximumWidth(width) @QtCore.Slot(str) def on__comboSurveys_activated(self, survey): if survey == 'All': self._model.set_filtered([]) else: surveys = self._model.get() surveys.remove(survey.encode("utf-8")) self._model.set_filtered(surveys) def __on_filter(self): surveys = self._model.get() filtered = self._model.get_filtered() selected = set(surveys) - set(filtered) if len(filtered) == 0: self._comboSurveys.setCurrentIndex(0) elif len(selected) == 1: index = surveys.index(list(selected)[0]) self._comboSurveys.setCurrentIndex(index + 1) else: self._comboSurveys.setCurrentIndex(-1) self._signal.filter.emit() def connect(self, slot): self._signal.filter.connect(slot) def set(self, surveys): self._model.set(surveys) self.__set_width() self._comboSurveys.clear() self._comboSurveys.addItem('All') self._comboSurveys.addItems(surveys) self._tableSurveys.setEnabled(True) self._comboSurveys.setEnabled(True) def set_font(self, font): newFont = QtGui.QFont() newFont.fromString(font) self._tableSurveys.setFont(newFont) self.__set_width() def get(self): return self._model.get() def get_filtered(self): return self._model.get_filtered() def get_font(self): return self._tableSurveys.font().toString() def clear(self): self._model.set([]) self._model.set_filtered([], False) self._tableSurveys.setEnabled(False) self._comboSurveys.setEnabled(False)
class WidgetScans(QtGui.QWidget): HEADER = [None, 'Time', 'Freq'] HEADER_TIPS = ['Included', 'Scan time', 'Scan frequency (MHz)'] def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self._signal = SignalScans() ui.loadUi(self, 'scans.ui') formatters = [None, format_qtime, None] self._model = Model(self._signal, self.HEADER, self.HEADER_TIPS, formatters) proxyModel = QtGui.QSortFilterProxyModel(self) proxyModel.setDynamicSortFilter(True) proxyModel.setSourceModel(self._model) self._tableScans.setModel(proxyModel) self._contextMenu = TableSelectionMenu(self._tableScans, self._model) self.__set_width() def __set_width(self): self._tableScans.resizeColumnsToContents() margins = self.layout().contentsMargins() width = self._tableScans.verticalHeader().width() width += self._tableScans.horizontalHeader().length() width += self._tableScans.style().pixelMetric( QtGui.QStyle.PM_ScrollBarExtent) width += self._tableScans.frameWidth() * 2 width += margins.left() + margins.right() width += self.layout().spacing() self.setMaximumWidth(width) @QtCore.Slot(bool) def on__buttonRange_clicked(self, _clicked): timeStamps = self._model.get() dialog = DialogScansRange(self, timeStamps) if dialog.exec_(): filtered = dialog.get_filtered() self._model.set_filtered(filtered) def connect(self, slot): self._model.connect(slot) def set(self, scans): self._model.set(scans) self.__set_width() self._tableScans.setEnabled(True) self._buttonRange.setEnabled(True) def set_font(self, font): newFont = QtGui.QFont() newFont.fromString(font) self._tableScans.setFont(newFont) self.__set_width() def get(self): return self._model.get() def get_filtered(self): return self._model.get_filtered() def clear(self): self._model.set([]) self._model.set_filtered([], False) self._tableScans.setEnabled(False) self._buttonRange.setEnabled(False)
class WidgetScans(QtGui.QWidget): HEADER = [None, 'Time', 'Freq'] HEADER_TIPS = ['Included', 'Scan time', 'Scan frequency (MHz)'] def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self._signal = SignalScans() ui.loadUi(self, 'scans.ui') formatters = [None, format_qtime, None] self._model = Model(self._signal, self.HEADER, self.HEADER_TIPS, formatters) proxyModel = QtGui.QSortFilterProxyModel(self) proxyModel.setDynamicSortFilter(True) proxyModel.setSourceModel(self._model) self._tableScans.setModel(proxyModel) self._contextMenu = TableSelectionMenu(self._tableScans, self._model) self.__set_width() def __set_width(self): self._tableScans.resizeColumnsToContents() margins = self.layout().contentsMargins() width = self._tableScans.verticalHeader().width() width += self._tableScans.horizontalHeader().length() width += self._tableScans.style().pixelMetric(QtGui.QStyle.PM_ScrollBarExtent) width += self._tableScans.frameWidth() * 2 width += margins.left() + margins.right() width += self.layout().spacing() self.setMaximumWidth(width) @QtCore.Slot(bool) def on__buttonRange_clicked(self, _clicked): timeStamps = self._model.get() dialog = DialogScansRange(self, timeStamps) if dialog.exec_(): filtered = dialog.get_filtered() self._model.set_filtered(filtered) def connect(self, slot): self._model.connect(slot) def set(self, scans): self._model.set(scans) self.__set_width() self._tableScans.setEnabled(True) self._buttonRange.setEnabled(True) def set_font(self, font): newFont = QtGui.QFont() newFont.fromString(font) self._tableScans.setFont(newFont) self.__set_width() def get(self): return self._model.get() def get_filtered(self): return self._model.get_filtered() def clear(self): self._model.set([]) self._model.set_filtered([], False) self._tableScans.setEnabled(False) self._buttonRange.setEnabled(False)