qt: HistoryList to also use BaseColumnsEnum
This commit is contained in:
@@ -30,7 +30,7 @@ import datetime
|
|||||||
from datetime import date
|
from datetime import date
|
||||||
from typing import TYPE_CHECKING, Tuple, Dict
|
from typing import TYPE_CHECKING, Tuple, Dict
|
||||||
import threading
|
import threading
|
||||||
from enum import IntEnum
|
import enum
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from PyQt5.QtGui import QMouseEvent, QFont, QBrush, QColor
|
from PyQt5.QtGui import QMouseEvent, QFont, QBrush, QColor
|
||||||
@@ -79,18 +79,6 @@ TX_ICONS = [
|
|||||||
ROLE_SORT_ORDER = Qt.UserRole + 1000
|
ROLE_SORT_ORDER = Qt.UserRole + 1000
|
||||||
|
|
||||||
|
|
||||||
class HistoryColumns(IntEnum):
|
|
||||||
STATUS = 0
|
|
||||||
DESCRIPTION = 1
|
|
||||||
AMOUNT = 2
|
|
||||||
BALANCE = 3
|
|
||||||
FIAT_VALUE = 4
|
|
||||||
FIAT_ACQ_PRICE = 5
|
|
||||||
FIAT_CAP_GAINS = 6
|
|
||||||
TXID = 7
|
|
||||||
SHORT_ID = 8 # ~SCID
|
|
||||||
|
|
||||||
|
|
||||||
class HistorySortModel(QSortFilterProxyModel):
|
class HistorySortModel(QSortFilterProxyModel):
|
||||||
def lessThan(self, source_left: QModelIndex, source_right: QModelIndex):
|
def lessThan(self, source_left: QModelIndex, source_right: QModelIndex):
|
||||||
item1 = self.sourceModel().data(source_left, ROLE_SORT_ORDER)
|
item1 = self.sourceModel().data(source_left, ROLE_SORT_ORDER)
|
||||||
@@ -464,12 +452,24 @@ class HistoryModel(CustomModel, Logger):
|
|||||||
|
|
||||||
|
|
||||||
class HistoryList(MyTreeView, AcceptFileDragDrop):
|
class HistoryList(MyTreeView, AcceptFileDragDrop):
|
||||||
|
|
||||||
|
class Columns(MyTreeView.BaseColumnsEnum):
|
||||||
|
STATUS = enum.auto()
|
||||||
|
DESCRIPTION = enum.auto()
|
||||||
|
AMOUNT = enum.auto()
|
||||||
|
BALANCE = enum.auto()
|
||||||
|
FIAT_VALUE = enum.auto()
|
||||||
|
FIAT_ACQ_PRICE = enum.auto()
|
||||||
|
FIAT_CAP_GAINS = enum.auto()
|
||||||
|
TXID = enum.auto()
|
||||||
|
SHORT_ID = enum.auto() # ~SCID
|
||||||
|
|
||||||
filter_columns = [
|
filter_columns = [
|
||||||
HistoryColumns.STATUS,
|
Columns.STATUS,
|
||||||
HistoryColumns.DESCRIPTION,
|
Columns.DESCRIPTION,
|
||||||
HistoryColumns.AMOUNT,
|
Columns.AMOUNT,
|
||||||
HistoryColumns.TXID,
|
Columns.TXID,
|
||||||
HistoryColumns.SHORT_ID,
|
Columns.SHORT_ID,
|
||||||
]
|
]
|
||||||
|
|
||||||
def tx_item_from_proxy_row(self, proxy_row):
|
def tx_item_from_proxy_row(self, proxy_row):
|
||||||
@@ -892,3 +892,6 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
|
|||||||
def get_role_data_from_coordinate(self, row, col, *, role):
|
def get_role_data_from_coordinate(self, row, col, *, role):
|
||||||
idx = self.model().mapToSource(self.model().index(row, col))
|
idx = self.model().mapToSource(self.model().index(row, col))
|
||||||
return self.hm.data(idx, role).value()
|
return self.hm.data(idx, role).value()
|
||||||
|
|
||||||
|
|
||||||
|
HistoryColumns = HistoryList.Columns
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import webbrowser
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from functools import partial, lru_cache, wraps
|
from functools import partial, lru_cache, wraps
|
||||||
from typing import (NamedTuple, Callable, Optional, TYPE_CHECKING, Union, List, Dict, Any,
|
from typing import (NamedTuple, Callable, Optional, TYPE_CHECKING, Union, List, Dict, Any,
|
||||||
Sequence, Iterable, Tuple)
|
Sequence, Iterable, Tuple, Type)
|
||||||
|
|
||||||
from PyQt5 import QtWidgets, QtCore
|
from PyQt5 import QtWidgets, QtCore
|
||||||
from PyQt5.QtGui import (QFont, QColor, QCursor, QPixmap, QStandardItem, QImage,
|
from PyQt5.QtGui import (QFont, QColor, QCursor, QPixmap, QStandardItem, QImage,
|
||||||
@@ -624,6 +624,8 @@ class MyTreeView(QTreeView):
|
|||||||
# this is overridden to get a 0-based counter
|
# this is overridden to get a 0-based counter
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
Columns: Type[BaseColumnsEnum]
|
||||||
|
|
||||||
def __init__(self, parent: 'ElectrumWindow', create_menu, *,
|
def __init__(self, parent: 'ElectrumWindow', create_menu, *,
|
||||||
stretch_column=None, editable_columns=None):
|
stretch_column=None, editable_columns=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|||||||
Reference in New Issue
Block a user