Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
04710d3f
Commit
04710d3f
authored
10 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
Improve transactions table view
parent
c8e3b7c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cutecoin/gui/currency_tab.py
+2
-2
2 additions, 2 deletions
src/cutecoin/gui/currency_tab.py
src/cutecoin/models/txhistory.py
+35
-18
35 additions, 18 deletions
src/cutecoin/models/txhistory.py
with
37 additions
and
20 deletions
src/cutecoin/gui/currency_tab.py
+
2
−
2
View file @
04710d3f
...
...
@@ -10,7 +10,7 @@ import requests
from
ucoinpy.api
import
bma
from
PyQt5.QtWidgets
import
QWidget
,
QMenu
,
QAction
,
QApplication
,
\
QMessageBox
,
QDialog
,
QAbstractItemView
QMessageBox
,
QDialog
,
QAbstractItemView
,
QHeaderView
from
PyQt5.QtCore
import
QModelIndex
,
Qt
,
pyqtSlot
,
QObject
,
\
QThread
,
pyqtSignal
,
QDateTime
from
PyQt5.QtGui
import
QIcon
...
...
@@ -122,7 +122,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
self
.
table_history
.
setModel
(
proxy
)
self
.
table_history
.
setSelectionBehavior
(
QAbstractItemView
.
SelectRows
)
self
.
table_history
.
setSortingEnabled
(
True
)
self
.
table_history
.
horizontalHeader
().
setSectionResizeMode
(
QHeaderView
.
ResizeToContents
)
self
.
tab_community
=
CommunityTabWidget
(
self
.
app
.
current_account
,
self
.
community
,
self
.
password_asker
)
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/models/txhistory.py
+
35
−
18
View file @
04710d3f
...
...
@@ -32,7 +32,7 @@ class TxFilterProxyModel(QSortFilterProxyModel):
def
filterAcceptsRow
(
self
,
sourceRow
,
sourceParent
):
def
in_period
(
date_ts
):
return
(
date_ts
in
range
(
self
.
ts_from
,
self
.
ts_to
))
date_col
=
self
.
sourceModel
().
columns
.
index
(
'
D
ate
'
)
date_col
=
self
.
sourceModel
().
column
_type
s
.
index
(
'
d
ate
'
)
source_index
=
self
.
sourceModel
().
index
(
sourceRow
,
date_col
)
date
=
self
.
sourceModel
().
data
(
source_index
,
Qt
.
DisplayRole
)
return
in_period
(
date
)
...
...
@@ -60,32 +60,30 @@ class TxFilterProxyModel(QSortFilterProxyModel):
def
data
(
self
,
index
,
role
):
source_index
=
self
.
mapToSource
(
index
)
source_data
=
self
.
sourceModel
().
data
(
source_index
,
role
)
state_col
=
self
.
sourceModel
().
columns
.
index
(
'
S
tate
'
)
state_col
=
self
.
sourceModel
().
column
_type
s
.
index
(
'
s
tate
'
)
state_index
=
self
.
sourceModel
().
index
(
source_index
.
row
(),
state_col
)
state_data
=
self
.
sourceModel
().
data
(
state_index
,
Qt
.
DisplayRole
)
if
role
==
Qt
.
DisplayRole
:
if
source_index
.
column
()
==
self
.
sourceModel
().
columns
.
index
(
'
UID/Public key
'
):
if
source_index
.
column
()
==
self
.
sourceModel
().
column
_type
s
.
index
(
'
uid
'
):
if
source_data
.
__class__
==
Person
:
tx_person
=
source_data
.
name
else
:
tx_person
=
"
pub:{0}
"
.
format
(
source_data
[:
5
])
source_data
=
tx_person
return
source_data
if
source_index
.
column
()
==
self
.
sourceModel
().
columns
.
index
(
'
D
ate
'
):
if
source_index
.
column
()
==
self
.
sourceModel
().
column
_type
s
.
index
(
'
d
ate
'
):
date
=
QDateTime
.
fromTime_t
(
source_data
)
return
date
.
date
()
if
source_index
.
column
()
==
self
.
sourceModel
().
columns
.
index
(
'
P
ayment
'
):
if
source_index
.
column
()
==
self
.
sourceModel
().
column
_type
s
.
index
(
'
p
ayment
'
):
if
source_data
is
not
""
:
amount_ref
=
self
.
account
.
units_to_diff_ref
(
source_data
,
self
.
community
)
ref_name
=
self
.
account
.
diff_ref_name
(
self
.
community
.
short_currency
)
return
"
{0:.2f} {1}
"
.
format
(
amount_ref
,
ref_name
)
if
source_index
.
column
()
==
self
.
sourceModel
().
columns
.
index
(
'
Deposit
'
):
return
"
{0:.2f}
"
.
format
(
amount_ref
)
if
source_index
.
column
()
==
self
.
sourceModel
().
column_types
.
index
(
'
deposit
'
):
if
source_data
is
not
""
:
amount_ref
=
self
.
account
.
units_to_diff_ref
(
source_data
,
self
.
community
)
ref_name
=
self
.
account
.
diff_ref_name
(
self
.
community
.
short_currency
)
return
"
{0:.2f} {1}
"
.
format
(
amount_ref
,
ref_name
)
return
"
{0:.2f}
"
.
format
(
amount_ref
)
if
role
==
Qt
.
FontRole
:
font
=
QFont
()
...
...
@@ -104,6 +102,12 @@ class TxFilterProxyModel(QSortFilterProxyModel):
return
QColor
(
Qt
.
red
)
elif
state_data
==
Transfer
.
TO_SEND
:
return
QColor
(
Qt
.
blue
)
if
role
==
Qt
.
TextAlignmentRole
:
if
source_index
.
column
()
==
self
.
sourceModel
().
column_types
.
index
(
'
deposit
'
)
or
source_index
.
column
()
==
self
.
sourceModel
().
column_types
.
index
(
'
payment
'
):
return
Qt
.
AlignRight
|
Qt
.
AlignVCenter
if
source_index
.
column
()
==
self
.
sourceModel
().
column_types
.
index
(
'
date
'
):
return
Qt
.
AlignCenter
return
source_data
...
...
@@ -120,8 +124,25 @@ class HistoryTableModel(QAbstractTableModel):
super
().
__init__
(
parent
)
self
.
account
=
account
self
.
community
=
community
self
.
columns
=
(
'
Date
'
,
'
UID/Public key
'
,
'
Payment
'
,
'
Deposit
'
,
'
Comment
'
,
'
State
'
)
self
.
account
.
referential
self
.
column_types
=
(
'
date
'
,
'
uid
'
,
'
payment
'
,
'
deposit
'
,
'
comment
'
,
'
state
'
)
self
.
column_headers
=
(
'
Date
'
,
'
UID/Public key
'
,
'
Payment
\n
({:})
'
.
format
(
self
.
account
.
diff_ref_name
(
self
.
community
.
short_currency
)),
'
Deposit
\n
({:})
'
.
format
(
self
.
account
.
diff_ref_name
(
self
.
community
.
short_currency
)),
'
Comment
'
,
'
State
'
)
@property
def
transfers
(
self
):
...
...
@@ -131,11 +152,11 @@ class HistoryTableModel(QAbstractTableModel):
return
len
(
self
.
transfers
)
def
columnCount
(
self
,
parent
):
return
len
(
self
.
columns
)
return
len
(
self
.
column
_type
s
)
def
headerData
(
self
,
section
,
orientation
,
role
):
if
role
==
Qt
.
DisplayRole
:
return
self
.
columns
[
section
]
return
self
.
column
_header
s
[
section
]
def
data_received
(
self
,
transfer
):
amount
=
transfer
.
metadata
[
'
amount
'
]
...
...
@@ -152,9 +173,6 @@ class HistoryTableModel(QAbstractTableModel):
date_ts
=
transfer
.
metadata
[
'
time
'
]
amount_ref
=
self
.
account
.
units_to_ref
(
amount
,
self
.
community
)
ref_name
=
self
.
account
.
ref_name
(
self
.
community
.
short_currency
)
return
(
date_ts
,
sender
,
""
,
amount
,
comment
,
transfer
.
state
)
...
...
@@ -186,7 +204,6 @@ class HistoryTableModel(QAbstractTableModel):
transfer
=
self
.
transfers
[
row
]
if
role
==
Qt
.
DisplayRole
:
if
type
(
transfer
)
is
Received
:
print
(
col
,
self
.
data_received
(
transfer
)[
col
])
return
self
.
data_received
(
transfer
)[
col
]
else
:
return
self
.
data_sent
(
transfer
)[
col
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment