コード例 #1
0
    def testEditorActionCtor(self):

        parent = QgsAttributeEditorContainer('container', None)
        editor_action = QgsAttributeEditorAction(self.action1, parent)
        self.assertEqual(QUuid(editor_action.action(self.layer).id()),
                         self.action_id1)
        self.assertEqual(
            editor_action.action(self.layer).id(), self.action1.id())

        # Lazy load
        editor_action = QgsAttributeEditorAction(self.action1.id(), parent)
        self.assertEqual(QUuid(editor_action.action(self.layer).id()),
                         self.action_id1)
        self.assertEqual(
            editor_action.action(self.layer).id(), self.action1.id())
コード例 #2
0
    def testSetAction(self):

        parent = QgsAttributeEditorContainer('container', None)
        editor_action = QgsAttributeEditorAction(self.action1, parent)

        editor_action.setAction(self.action2)
        self.assertEqual(QUuid(editor_action.action(self.layer).id()),
                         self.action_id2)
コード例 #3
0
def getValue(val):
    value_type = val.WhichOneof('value_type')
    if value_type == 'null_value':
        return None
    elif value_type == 'string_value':
        return val.string_value
    elif value_type == 'int_value':
        return val.int_value
    elif value_type == 'long_value':
        return val.long_value
    elif value_type == 'bool_value':
        return val.bool_value
    elif value_type == 'double_value':
        return val.double_value
    elif value_type == 'float_value':
        return val.foat_value
    elif value_type == "geom_value":
        if len(val.geom_value) == 0:
            return None
        qgeom = QgsGeometry()
        qgeom.fromWkb(val.geom_value)
        return qgeom
    elif value_type == "byte_value":
        return val.byte_value
    elif value_type == "short_value":
        return val.short_value
    elif value_type == "char_value":
        return (val.char_value)
    elif value_type == "uuid_value":
        return QUuid(val.uuid_value)
    elif value_type == "datetime_value":
        return QDateTime.fromMSecsSinceEpoch(val.datetime_value)
    elif value_type == "date_value":
        dt = QDateTime.fromMSecsSinceEpoch(val.date_value)
        return dt.date()
    elif value_type == "time_value":
        dt = QDateTime.fromMSecsSinceEpoch(val.time_value)
        return dt.time()
    elif value_type == "timestamp_value":
        ts = val.timestamp_value
        dt = QDateTime.fromMSecsSinceEpoch(ts.seconds * 1000)
        dt.addMSecs(ts.nanos / 1000000)
        return dt.time()