def getTimelineOptions(self, appdef):
        layers = appdef["Layers"]
        times = set()
        for layer in layers:
            if layer.timeInfo is not None:
                if isinstance(layer.timeInfo[0], basestring):
                    features = layer.layer.getFeatures()
                    for feature in features:
                        for field in layer.timeInfo:
                            try:
                                value = feature[field]
                                if isinstance(value, QDate):
                                    t = QDateTime()
                                    t.setDate(value)
                                else:
                                    t = QDateTime.fromString(
                                        unicode(value), Qt.ISODate)
                                if t.isValid():
                                    times.add(t.toMSecsSinceEpoch())
                            except:
                                pass
                else:
                    times.add(layer.timeInfo[0])
                    times.add(layer.timeInfo[1])

        if times:
            return [min(times), max(times)]
        else:
            return [0, 1]
示例#2
0
    def showpickdialog(self):
        """
        Open the date time picker dialog

        control - The control that will recive the user set date time.
        """

        if type(self.datewidget) is QDateEdit:
            mode = "Date"
        else:
            mode = "DateTime"

        dlg = DateTimePickerDialog(mode)
        dlg.setWindowTitle("Select a date")
        if self.datewidget.dateTime() == DateWidget.DEFAULTDATE:
            dlg.setAsNow()
        else:
            dlg.setDateTime(self.datewidget.dateTime())

        dlg.setMinValue(self.datewidget.minimumDate())
        if dlg.exec_():
            datetime = QDateTime()
            datetime.setDate(dlg.getSelectedDate())
            datetime.setTime(dlg.getSelectedTime())
            self.setvalue(datetime)
    def getTimelineOptions(self, appdef):
        layers = appdef["Layers"]
        times = set()
        for layer in layers:
            if layer.timeInfo is not None:
                if isinstance(layer.timeInfo[0], basestring):
                    features = layer.layer.getFeatures()
                    for feature in features:
                        for field in layer.timeInfo:
                            try:
                                value = feature[field]
                                if isinstance(value, QDate):
                                    t = QDateTime()
                                    t.setDate(value)
                                else:
                                    t = QDateTime.fromString(unicode(value), Qt.ISODate)
                                if t.isValid():
                                    times.add(t.toMSecsSinceEpoch())
                            except:
                                pass
                else:
                    times.add(layer.timeInfo[0])
                    times.add(layer.timeInfo[1])

        if times:
            return [min(times), max(times)]
        else:
            return [0,1]
示例#4
0
 def value(self):
     datetime = QDateTime()
     datetime.setDate(self.getSelectedDate())
     datetime.setTime(self.getSelectedTime())
     return datetime
 def value(self):
     datetime = QDateTime()
     datetime.setDate(self.getSelectedDate())
     datetime.setTime(self.getSelectedTime())
     return datetime