def __init__(self, timeInfo, layer): print timeInfo QtGui.QDialog.__init__( self, None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.buttonBox.accepted.connect(self.okPressed) self.buttonBox.rejected.connect(self.cancelPressed) self.timeInfo = timeInfo self.ok = False fields = [f.name() for f in layer.pendingFields()] self.toDateAttributeComboBox.addItems(fields) self.fromDateAttributeComboBox.addItems(fields) if timeInfo is None: self.radioButtonNoTimeInfo.setChecked(True) elif isinstance(timeInfo[0], basestring): self.fromDateAttributeComboBox.setCurrentIndex( self.fromDateAttributeComboBox.findText(timeInfo[0])) self.toDateAttributeComboBox.setCurrentIndex( self.toDateAttributeComboBox.findText(timeInfo[1])) self.radioButtonFeatureTimeInfo.setChecked(True) else: self.radioButtonLayerTimeInfo.setChecked(True) self.toDateTimeEdit.setDateTime( QDateTime.fromMSecsSinceEpoch(timeInfo[0])) self.fromDateTimeEdit.setDateTime( QDateTime.fromMSecsSinceEpoch(timeInfo[1]))
def setTimeSpan(self, time_values): self._time_from = self._time_to = None if time_values is not None and len(time_values): self._time_to = time_to = QDateTime.fromMSecsSinceEpoch(1000 * time_values[-1]).toUTC() if len(time_values) > 1: time_from = QDateTime.fromMSecsSinceEpoch(1000 * time_values[0]).toUTC() if time_from.secsTo(time_to) < 23 * 3600: # timespan < 23 hours self._time_from = time_from self.update()
def setTimeSpan(self, time_values): self._time_from = self._time_to = None if time_values is not None and len(time_values): self._time_to = time_to = QDateTime.fromMSecsSinceEpoch( 1000 * time_values[-1]).toUTC() if len(time_values) > 1: time_from = QDateTime.fromMSecsSinceEpoch( 1000 * time_values[0]).toUTC() if time_from.secsTo( time_to) < 23 * 3600: # timespan < 23 hours self._time_from = time_from self.update()
def valuesChanged(self, minValue, maxValue): self.slider_values = (minValue, maxValue) self._delta = max(1, (maxValue - minValue)) minTime = self.slider.scale(minValue) maxTime = self.slider.scale(maxValue) from_dt = QDateTime.fromMSecsSinceEpoch(minTime * 1000).toUTC() to_dt = QDateTime.fromMSecsSinceEpoch(maxTime * 1000).toUTC() with blockSignals(self.date_from, self.date_to): self.date_from.setDateTime(from_dt) self.date_to.setDateTime(to_dt) self.send_selection(minTime, maxTime)
def setTime(self, time_value): text = '--:--:--' if time_value is not None: time = QDateTime.fromMSecsSinceEpoch(1000 * time_value).toUTC().time() text = time.toString("hh:mm:ss") self.display(text)
def method_0(self, binaryReader_0, qafileVersion_0): num = binaryReader_0.ReadInt32() self.title = GZipStream.UncompressString(binaryReader_0.ReadBytes(num)) self.stamp = QDateTime.fromMSecsSinceEpoch(binaryReader_0.ReadInt64()) self.colorCode = binaryReader_0.ReadInt32() num1 = binaryReader_0.ReadInt32() for i in range(num1): qAReportEntry = QAReportEntry() qAReportEntry.method_0(binaryReader_0, qafileVersion_0) self.children.append(qAReportEntry)
def __init__(self, timeInfo, layer): QtGui.QDialog.__init__(self, None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.buttonBox.accepted.connect(self.okPressed) self.buttonBox.rejected.connect(self.cancelPressed) self.timeInfo = timeInfo self.ok = False fields = [f.name() for f in layer.pendingFields()] self.toDateAttributeComboBox.addItems(fields) self.fromDateAttributeComboBox.addItems(fields) if timeInfo is None: self.radioButtonNoTimeInfo.setChecked(True) elif isinstance(timeInfo[0], basestring): self.fromDateAttributeComboBox.setCurrentIndex(self.fromDateAttributeComboBox.findText(timeInfo[0])) self.toDateAttributeComboBox.setCurrentIndex(self.toDateAttributeComboBox.findText(timeInfo[1])) self.radioButtonFeatureTimeInfo.setChecked(True) else: self.radioButtonLayerTimeInfo.setChecked(True) self.toDateTimeEdit.setDateTime(QDateTime.fromMSecsSinceEpoch(timeInfo[0])) self.fromDateTimeEdit.setDateTime(QDateTime.fromMSecsSinceEpoch(timeInfo[1]))
def set_data(self, data): if data is None or not len(data): self.clear() return data = Timeseries.from_data_table(data) if not data.time_variable: self.clear() return time_values = np.sort(data.time_values) date_to = date_from = QDateTime.fromMSecsSinceEpoch(1000 * time_values[-1]).toUTC().date() if len(time_values) > 1: date_from = QDateTime.fromMSecsSinceEpoch(1000 * time_values[0]).toUTC().date() self.calendar.setDateRange(date_from, date_to) self.calendar.update() self.analog_clock.setTimeSpan(time_values) self.digital_clock.setTime(time_values[-1]) self.calendar.setDisabled(False) self.digital_clock.setDisabled(False)
def set_data(self, data): slider = self.slider self.data = data = None if data is None else Timeseries.from_data_table(data) def disabled(): slider.setFormatter(str) slider.setHistogram(None) slider.setScale(0, 0) slider.setValues(0, 0) slider.setDisabled(True) self.send('Subset', None) if data is None: disabled() return if not isinstance(data.time_variable, TimeVariable): self.Error.no_time_variable() disabled() return self.Error.clear() var = data.time_variable time_values = data.time_values slider.setDisabled(False) slider.setHistogram(time_values) slider.setFormatter(var.repr_val) slider.setScale(time_values.min(), time_values.max()) self.valuesChanged(slider.minimumValue(), slider.maximumValue()) # Update datetime edit fields min_dt = QDateTime.fromMSecsSinceEpoch(time_values[0] * 1000).toUTC() max_dt = QDateTime.fromMSecsSinceEpoch(time_values[-1] * 1000).toUTC() self.date_from.setDateTimeRange(min_dt, max_dt) self.date_to.setDateTimeRange(min_dt, max_dt) date_format = ' '.join((self.DATE_FORMATS[0] if var.have_date else '', self.DATE_FORMATS[1] if var.have_time else '')).strip() self.date_from.setDisplayFormat(date_format) self.date_to.setDisplayFormat(date_format)
def set_data(self, data): if data is None or not len(data): self.clear() return data = Timeseries.from_data_table(data) if not data.time_variable: self.clear() return time_values = np.sort(data.time_values) date_to = date_from = QDateTime.fromMSecsSinceEpoch( 1000 * time_values[-1]).toUTC().date() if len(time_values) > 1: date_from = QDateTime.fromMSecsSinceEpoch( 1000 * time_values[0]).toUTC().date() self.calendar.setDateRange(date_from, date_to) self.calendar.update() self.analog_clock.setTimeSpan(time_values) self.digital_clock.setTime(time_values[-1]) self.calendar.setDisabled(False) self.digital_clock.setDisabled(False)