1
0

Enable adding transactions from file through Drag and Drop

This commit is contained in:
Johann Bauer
2018-01-24 21:32:51 +01:00
parent fbcee9a6f6
commit 95da5a8bed
2 changed files with 45 additions and 1 deletions

View File

@@ -47,11 +47,12 @@ TX_ICONS = [
]
class HistoryList(MyTreeWidget):
class HistoryList(MyTreeWidget, AcceptFileDragDrop):
filter_columns = [2, 3, 4] # Date, Description, Amount
def __init__(self, parent=None):
MyTreeWidget.__init__(self, parent, self.create_menu, [], 3)
AcceptFileDragDrop.__init__(self, ".txn")
self.refresh_headers()
self.setColumnHidden(1, True)
@@ -205,3 +206,12 @@ class HistoryList(MyTreeWidget):
if item.data(0, Qt.UserRole) in to_delete:
root.removeChild(item)
_offset += 1
def onFileAdded(self, fn):
with open(fn) as f:
tx = self.parent.tx_from_text(f.read())
self.wallet.add_transaction(tx.txid(), tx)
self.wallet.save_transactions()
self.on_update()