コード例 #1
0
ファイル: currency_test.py プロジェクト: mrbez/pydosh
	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')
コード例 #2
0
ファイル: tagModel.py プロジェクト: mrbez/pydosh
    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)
コード例 #3
0
ファイル: tagModel.py プロジェクト: innerhippy/pydosh
	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)