def testAttributeNameRole(self): m = QgsPointCloudAttributeModel() m.setAttributes(create_attributes()) self.assertEqual( m.data(m.index(0, 0), QgsPointCloudAttributeModel.AttributeNameRole), 'x') self.assertEqual( m.data(m.index(1, 0), QgsPointCloudAttributeModel.AttributeNameRole), 'y') self.assertEqual( m.data(m.index(2, 0), QgsPointCloudAttributeModel.AttributeNameRole), 'z') self.assertEqual( m.data(m.index(3, 0), QgsPointCloudAttributeModel.AttributeNameRole), 'cat') self.assertEqual( m.data(m.index(4, 0), QgsPointCloudAttributeModel.AttributeNameRole), 'red') self.assertEqual( m.data(m.index(5, 0), QgsPointCloudAttributeModel.AttributeNameRole), None) m.setAllowEmptyAttributeName(True) self.assertEqual( m.data(m.index(0, 0), QgsPointCloudAttributeModel.AttributeNameRole), None) self.assertEqual( m.data(m.index(1, 0), QgsPointCloudAttributeModel.AttributeNameRole), 'x') self.assertEqual( m.data(m.index(2, 0), QgsPointCloudAttributeModel.AttributeNameRole), 'y') self.assertEqual( m.data(m.index(5, 0), QgsPointCloudAttributeModel.AttributeNameRole), 'red')
def testIsNumericRole(self): m = QgsPointCloudAttributeModel() m.setAttributes(create_attributes()) self.assertTrue( m.data(m.index(0, 0), QgsPointCloudAttributeModel.IsNumericRole)) self.assertTrue( m.data(m.index(1, 0), QgsPointCloudAttributeModel.IsNumericRole)) self.assertTrue( m.data(m.index(2, 0), QgsPointCloudAttributeModel.IsNumericRole)) self.assertFalse( m.data(m.index(3, 0), QgsPointCloudAttributeModel.IsNumericRole)) self.assertTrue( m.data(m.index(4, 0), QgsPointCloudAttributeModel.IsNumericRole)) self.assertFalse( m.data(m.index(5, 0), QgsPointCloudAttributeModel.IsNumericRole)) m.setAllowEmptyAttributeName(True) self.assertFalse( m.data(m.index(0, 0), QgsPointCloudAttributeModel.IsNumericRole)) self.assertTrue( m.data(m.index(1, 0), QgsPointCloudAttributeModel.IsNumericRole)) self.assertTrue( m.data(m.index(2, 0), QgsPointCloudAttributeModel.IsNumericRole)) self.assertTrue( m.data(m.index(5, 0), QgsPointCloudAttributeModel.IsNumericRole))
def testAttributeIndexRole(self): m = QgsPointCloudAttributeModel() m.setAttributes(create_attributes()) self.assertEqual( m.data(m.index(0, 0), QgsPointCloudAttributeModel.AttributeIndexRole), 0) self.assertEqual( m.data(m.index(1, 0), QgsPointCloudAttributeModel.AttributeIndexRole), 1) self.assertEqual( m.data(m.index(2, 0), QgsPointCloudAttributeModel.AttributeIndexRole), 2) self.assertEqual( m.data(m.index(3, 0), QgsPointCloudAttributeModel.AttributeIndexRole), 3) self.assertEqual( m.data(m.index(4, 0), QgsPointCloudAttributeModel.AttributeIndexRole), 4) self.assertEqual( m.data(m.index(5, 0), QgsPointCloudAttributeModel.AttributeIndexRole), None) m.setAllowEmptyAttributeName(True) self.assertEqual( m.data(m.index(0, 0), QgsPointCloudAttributeModel.AttributeIndexRole), None) self.assertEqual( m.data(m.index(1, 0), QgsPointCloudAttributeModel.AttributeIndexRole), 0) self.assertEqual( m.data(m.index(2, 0), QgsPointCloudAttributeModel.AttributeIndexRole), 1) self.assertEqual( m.data(m.index(5, 0), QgsPointCloudAttributeModel.AttributeIndexRole), 4)
def testTypeRole(self): m = QgsPointCloudAttributeModel() m.setAttributes(create_attributes()) self.assertEqual( m.data(m.index(0, 0), QgsPointCloudAttributeModel.AttributeTypeRole), QgsPointCloudAttribute.Float) self.assertEqual( m.data(m.index(1, 0), QgsPointCloudAttributeModel.AttributeTypeRole), QgsPointCloudAttribute.Float) self.assertEqual( m.data(m.index(2, 0), QgsPointCloudAttributeModel.AttributeTypeRole), QgsPointCloudAttribute.Float) self.assertEqual( m.data(m.index(3, 0), QgsPointCloudAttributeModel.AttributeTypeRole), QgsPointCloudAttribute.Char) self.assertEqual( m.data(m.index(4, 0), QgsPointCloudAttributeModel.AttributeTypeRole), QgsPointCloudAttribute.Int32) self.assertEqual( m.data(m.index(5, 0), QgsPointCloudAttributeModel.AttributeTypeRole), None) m.setAllowEmptyAttributeName(True) self.assertEqual( m.data(m.index(0, 0), QgsPointCloudAttributeModel.AttributeTypeRole), None) self.assertEqual( m.data(m.index(1, 0), QgsPointCloudAttributeModel.AttributeTypeRole), QgsPointCloudAttribute.Float) self.assertEqual( m.data(m.index(2, 0), QgsPointCloudAttributeModel.AttributeTypeRole), QgsPointCloudAttribute.Float) self.assertEqual( m.data(m.index(5, 0), QgsPointCloudAttributeModel.AttributeTypeRole), QgsPointCloudAttribute.Int32)
def testTooltip(self): m = QgsPointCloudAttributeModel() m.setAttributes(create_attributes()) self.assertEqual( m.data(m.index(0, 0), Qt.ToolTipRole), "<b>x</b><br><font style='font-family:monospace; white-space: nowrap;'>Float</font>" ) self.assertEqual( m.data(m.index(1, 0), Qt.ToolTipRole), "<b>y</b><br><font style='font-family:monospace; white-space: nowrap;'>Float</font>" ) self.assertEqual( m.data(m.index(2, 0), Qt.ToolTipRole), "<b>z</b><br><font style='font-family:monospace; white-space: nowrap;'>Float</font>" ) self.assertEqual( m.data(m.index(3, 0), Qt.ToolTipRole), "<b>cat</b><br><font style='font-family:monospace; white-space: nowrap;'>Character</font>" ) self.assertEqual( m.data(m.index(4, 0), Qt.ToolTipRole), "<b>red</b><br><font style='font-family:monospace; white-space: nowrap;'>Integer</font>" ) self.assertEqual(m.data(m.index(5, 0), Qt.ToolTipRole), None) m.setAllowEmptyAttributeName(True) self.assertEqual(m.data(m.index(0, 0), Qt.ToolTipRole), None) self.assertEqual( m.data(m.index(1, 0), Qt.ToolTipRole), "<b>x</b><br><font style='font-family:monospace; white-space: nowrap;'>Float</font>" ) self.assertEqual( m.data(m.index(2, 0), Qt.ToolTipRole), "<b>y</b><br><font style='font-family:monospace; white-space: nowrap;'>Float</font>" ) self.assertEqual( m.data(m.index(5, 0), Qt.ToolTipRole), "<b>red</b><br><font style='font-family:monospace; white-space: nowrap;'>Integer</font>" )