Пример #1
0
    def add_transaction_entry(self, transaction):
        self.insertRow(0)
        confirms = None
        if "confirmations" in transaction:
            confirms = transaction["confirmations"]
        unixtime = transaction["time"]
        address = "N/A"
        if "address" in transaction:
            address = transaction["address"]
        credit = transaction["amount"]
        balance = "N/A"
        category = transaction["category"]

        status_item = TransactionItem("")
        if confirms is None:
            status_item.setText("N/A")
        status_item.confirmations = confirms
        self.setItem(0, 0, status_item)

        date_item = TransactionItem("")
        self.setItem(0, 1, date_item)
        self.update_transaction_time(0, unixtime)

        if category == "send":
            description = self.tr("Sent to %s") % address
        elif category == "receive":
            fullto = address
            acct = transaction.get("account", None)
            if acct:
                fullto = "%s: %s" % (acct, address)
            description = self.tr("Received to %s") % (fullto,)
        elif category in ("generate", "immature"):
            description = self.tr("Generated")
            status_item.category = category
        elif category == "move":
            description = self.tr("Moved")
        else:
            description = self.tr("Unknown")
        trans_item = TransactionItem(description)
        self.setItem(0, 2, trans_item)

        credits_item = TransactionItem(humanAmount(credit), Qt.AlignRight)
        credits_item.amount = credit
        self.setItem(0, 3, credits_item)

        balance_item = TransactionItem(humanAmount(balance), Qt.AlignRight)
        self.setItem(0, 4, balance_item)

        self.update_confirmation(0, confirms, adjustment=False)

        return status_item
Пример #2
0
    def do_payment(self):
        if not self.amount.text():
            self.amount.setFocus(Qt.OtherFocusReason)
            return
        self.hide()

        addy = self.destaddy.text()
        if not self.core.validate_address(addy):
            error = QMessageBox(QMessageBox.Critical, 
                                self.tr('Invalid address'),
                                self.tr('Invalid address: %s')%addy)
            error.exec_()
            self.reject()
            return

        amount = self.amount.text()
        amount += ' ' + self.amount_unit.itemData(self.amount_unit.currentIndex())
        amount = humanToAmount(amount)

        balance = self.core.balance()
        if amount > balance:
            error = QMessageBox(QMessageBox.Critical, 
                                self.tr('Insufficient balance'),
                            self.tr('Balance of %g is too small.') % (humanAmount(balance),))
            error.exec_()
            self.reject()
            return

        try:
            self.core.send(addy, amount)
        except Exception, e:
            error = QMessageBox(QMessageBox.Critical, 
                                self.tr('Error sending'),
                            self.tr('Your send failed: %s') % (e,))
            error.exec_()
            self.reject()
            return
Пример #3
0
 def refresh_balance_label(self):
     bltext = self.tr("Balance: %s") % (humanAmount(self.balance, wantTLA=True),)
     self.balance_label.setText(bltext)
     if hasattr(self, "tray") and self.tray:
         self.tray.setToolTip(bltext)
Пример #4
0
 def update_amounts(self):
     for i in xrange(self.rowCount()):
         credits_item = self.item(i, 3)
         credits_item.setText(humanAmount(credits_item.amount))