def test_formatCurrency(self): self.assertEqual(currency.formatCurrency(23), u'23.00') self.assertEqual(currency.formatCurrency(23.00), u'23.00') self.assertEqual(currency.formatCurrency(23000), u'23,000.00') self.assertEqual(currency.formatCurrency(23000.00), u'23,000.00') self.assertEqual(currency.formatCurrency(-23000.00), u'-23,000.00') self.assertRaises(ValueError, currency.formatCurrency, u'23')
def data(self, item, role=QtCore.Qt.DisplayRole): if role == QtCore.Qt.DisplayRole: if item.column() == enum.kTags_RecordIds: tags = set([ int(i) for i in super(TagModel, self).data(item).split(',') if i ]) return tags elif item.column() in (enum.kTags_Amount_in, enum.kTags_Amount_out): amount = super(TagModel, self).data(item) return currency.formatCurrency(amount) if amount else None elif role == QtCore.Qt.CheckStateRole and item.column( ) == enum.kTags_TagName: if item.data() in self.__selectedTagNames: return QtCore.Qt.Checked else: return QtCore.Qt.Unchecked elif role == QtCore.Qt.UserRole and item.column() in ( enum.kTags_Amount_in, enum.kTags_Amount_out): return super(TagModel, self).data(item) return super(TagModel, self).data(item, role)
def data(self, item, role=QtCore.Qt.DisplayRole): if role == QtCore.Qt.DisplayRole: if item.column() == enum.kTags_RecordIds: tags = set([int(i) for i in super(TagModel, self).data(item).split(',') if i]) return tags elif item.column() in (enum.kTags_Amount_in, enum.kTags_Amount_out): amount = super(TagModel, self).data(item) return currency.formatCurrency(amount) if amount else None elif role == QtCore.Qt.CheckStateRole and item.column() == enum.kTags_TagName: if item.data() in self.__selectedTagNames: return QtCore.Qt.Checked else: return QtCore.Qt.Unchecked elif role == QtCore.Qt.UserRole and item.column() in (enum.kTags_Amount_in, enum.kTags_Amount_out): return super(TagModel, self).data(item) return super(TagModel, self).data(item, role)