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
19d6c003
Commit
19d6c003
authored
10 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
New transactions table history : working ! :)
parent
494843cf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cutecoin/gui/currency_tab.py
+13
-3
13 additions, 3 deletions
src/cutecoin/gui/currency_tab.py
src/cutecoin/models/txhistory.py
+39
-82
39 additions, 82 deletions
src/cutecoin/models/txhistory.py
with
52 additions
and
85 deletions
src/cutecoin/gui/currency_tab.py
+
13
−
3
View file @
19d6c003
...
@@ -14,7 +14,7 @@ from PyQt5.QtCore import QModelIndex, Qt, pyqtSlot, QObject, QThread, pyqtSignal
...
@@ -14,7 +14,7 @@ from PyQt5.QtCore import QModelIndex, Qt, pyqtSlot, QObject, QThread, pyqtSignal
from
PyQt5.QtGui
import
QIcon
from
PyQt5.QtGui
import
QIcon
from
..gen_resources.currency_tab_uic
import
Ui_CurrencyTabWidget
from
..gen_resources.currency_tab_uic
import
Ui_CurrencyTabWidget
from
.community_tab
import
CommunityTabWidget
from
.community_tab
import
CommunityTabWidget
from
..models.txhistory
import
HistoryTableModel
from
..models.txhistory
import
HistoryTableModel
,
TxFilterProxyModel
from
..models.wallets
import
WalletsListModel
from
..models.wallets
import
WalletsListModel
from
..models.wallet
import
WalletListModel
from
..models.wallet
import
WalletListModel
from
..tools.exceptions
import
NoPeerAvailable
from
..tools.exceptions
import
NoPeerAvailable
...
@@ -104,9 +104,18 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
...
@@ -104,9 +104,18 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
self
.
date_to
.
setDateTime
(
blockchain_lastblock
)
self
.
date_to
.
setDateTime
(
blockchain_lastblock
)
self
.
date_to
.
setMaximumDateTime
(
blockchain_lastblock
)
self
.
date_to
.
setMaximumDateTime
(
blockchain_lastblock
)
self
.
table_history
.
setModel
(
ts_from
=
self
.
date_from
.
dateTime
().
toTime_t
()
HistoryTableModel
(
self
.
app
.
current_account
,
self
.
community
))
ts_to
=
self
.
date_to
.
dateTime
().
toTime_t
()
model
=
HistoryTableModel
(
self
.
app
.
current_account
,
self
.
community
)
proxy
=
TxFilterProxyModel
(
self
.
community
,
ts_from
,
ts_to
)
proxy
.
setSourceModel
(
model
)
proxy
.
setDynamicSortFilter
(
True
)
proxy
.
setSortRole
(
Qt
.
DisplayRole
)
self
.
table_history
.
setModel
(
proxy
)
self
.
table_history
.
setSortingEnabled
(
True
)
self
.
table_history
.
setSortingEnabled
(
True
)
self
.
tab_community
=
CommunityTabWidget
(
self
.
app
.
current_account
,
self
.
tab_community
=
CommunityTabWidget
(
self
.
app
.
current_account
,
self
.
community
,
self
.
community
,
self
.
password_asker
)
self
.
password_asker
)
...
@@ -211,3 +220,4 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
...
@@ -211,3 +220,4 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
ts_to
=
self
.
date_to
.
dateTime
().
toTime_t
()
ts_to
=
self
.
date_to
.
dateTime
().
toTime_t
()
if
self
.
table_history
.
model
():
if
self
.
table_history
.
model
():
self
.
table_history
.
model
().
set_period
(
ts_from
,
ts_to
)
self
.
table_history
.
model
().
set_period
(
ts_from
,
ts_to
)
self
.
table_history
.
model
().
invalidate
()
This diff is collapsed.
Click to expand it.
src/cutecoin/models/txhistory.py
+
39
−
82
View file @
19d6c003
...
@@ -7,10 +7,41 @@ Created on 5 févr. 2014
...
@@ -7,10 +7,41 @@ Created on 5 févr. 2014
import
logging
import
logging
from
..core.person
import
Person
from
..core.person
import
Person
from
..tools.exceptions
import
PersonNotFoundError
from
..tools.exceptions
import
PersonNotFoundError
from
PyQt5.QtCore
import
QAbstractTableModel
,
Qt
,
QVariant
,
Q
AbstractProxyModel
from
PyQt5.QtCore
import
QAbstractTableModel
,
Qt
,
QVariant
,
Q
SortFilterProxyModel
,
QDateTime
from
PyQt5.QtGui
import
QFont
from
PyQt5.QtGui
import
QFont
from
operator
import
itemgetter
import
datetime
class
TxFilterProxyModel
(
QSortFilterProxyModel
):
def
__init__
(
self
,
community
,
ts_from
,
ts_to
,
parent
=
None
):
super
().
__init__
(
parent
)
self
.
community
=
community
self
.
ts_from
=
ts_from
self
.
ts_to
=
ts_to
def
set_period
(
self
,
ts_from
,
ts_to
):
"""
Filter table by given timestamps
"""
logging
.
debug
(
"
Filtering from {0} to {1}
"
.
format
(
ts_from
,
ts_to
))
self
.
ts_from
=
ts_from
self
.
ts_to
=
ts_to
def
filterAcceptsRow
(
self
,
sourceRow
,
sourceParent
):
def
in_period
(
tx
):
block
=
self
.
community
.
get_block
(
tx
[
0
])
return
(
block
.
mediantime
in
range
(
self
.
ts_from
,
self
.
ts_to
))
tx
=
self
.
sourceModel
().
transactions
[
sourceRow
]
return
in_period
(
tx
)
def
lessThan
(
self
,
left
,
right
):
"""
Sort table by given column number.
"""
logging
.
debug
(
self
.
sortOrder
())
left_data
=
self
.
sourceModel
().
data
(
left
,
Qt
.
DisplayRole
)
right_data
=
self
.
sourceModel
().
data
(
right
,
Qt
.
DisplayRole
)
return
(
left_data
<
right_data
)
class
HistoryTableModel
(
QAbstractTableModel
):
class
HistoryTableModel
(
QAbstractTableModel
):
...
@@ -32,7 +63,7 @@ class HistoryTableModel(QAbstractTableModel):
...
@@ -32,7 +63,7 @@ class HistoryTableModel(QAbstractTableModel):
self
.
account
.
transactions_received
(
self
.
community
)
self
.
account
.
transactions_received
(
self
.
community
)
def
rowCount
(
self
,
parent
):
def
rowCount
(
self
,
parent
):
return
len
(
self
.
transactions
)
return
len
(
self
.
transactions
)
def
columnCount
(
self
,
parent
):
def
columnCount
(
self
,
parent
):
return
len
(
self
.
columns
)
return
len
(
self
.
columns
)
...
@@ -57,9 +88,9 @@ class HistoryTableModel(QAbstractTableModel):
...
@@ -57,9 +88,9 @@ class HistoryTableModel(QAbstractTableModel):
sender
=
pubkey
sender
=
pubkey
date_ts
=
self
.
community
.
get_block
(
tx
[
0
]).
mediantime
date_ts
=
self
.
community
.
get_block
(
tx
[
0
]).
mediantime
date
=
d
ate
time
.
datet
ime
.
from
t
ime
stamp
(
date_ts
)
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)
date
=
QD
ate
T
ime
.
from
T
ime
_t
(
date_ts
)
return
(
date
,
sender
,
""
,
"
{0}
"
.
format
(
amount
),
comment
)
return
(
date
.
date
()
,
sender
,
""
,
"
{0}
"
.
format
(
amount
),
comment
)
def
data_sent
(
self
,
tx
):
def
data_sent
(
self
,
tx
):
amount
=
0
amount
=
0
...
@@ -77,9 +108,9 @@ class HistoryTableModel(QAbstractTableModel):
...
@@ -77,9 +108,9 @@ class HistoryTableModel(QAbstractTableModel):
except
PersonNotFoundError
:
except
PersonNotFoundError
:
receiver
=
pubkey
receiver
=
pubkey
date_ts
=
self
.
community
.
get_block
(
tx
[
0
]).
mediantime
date_ts
=
self
.
community
.
get_block
(
tx
[
0
]).
mediantime
date
=
d
ate
time
.
datet
ime
.
from
t
ime
stamp
(
date_ts
)
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)
date
=
QD
ate
T
ime
.
from
T
ime
_t
(
date_ts
)
return
(
date
,
receiver
,
"
-{0}
"
.
format
(
amount
),
""
,
comment
)
return
(
date
.
date
()
,
receiver
,
"
-{0}
"
.
format
(
amount
),
""
,
comment
)
def
data
(
self
,
index
,
role
):
def
data
(
self
,
index
,
role
):
row
=
index
.
row
()
row
=
index
.
row
()
...
@@ -104,79 +135,5 @@ class HistoryTableModel(QAbstractTableModel):
...
@@ -104,79 +135,5 @@ class HistoryTableModel(QAbstractTableModel):
font
.
setItalic
(
False
)
font
.
setItalic
(
False
)
return
font
return
font
def
sort
(
self
,
section
,
order
):
"""
Sort table by given column number.
"""
self
.
layoutAboutToBeChanged
.
emit
()
def
uid
(
tx
):
if
tx
in
self
.
account
.
transactions_received
(
self
.
community
):
pubkey
=
tx
[
1
].
issuers
[
0
]
else
:
pubkey
=
tx
[
1
].
outputs
[
0
].
pubkey
try
:
receiver
=
Person
.
lookup
(
pubkey
,
self
.
community
).
name
except
PersonNotFoundError
:
receiver
=
pubkey
return
receiver
def
amount_received
(
tx
):
amount
=
0
if
tx
in
self
.
account
.
transactions_received
(
self
.
community
):
for
o
in
tx
[
1
].
outputs
:
pubkeys
=
[
w
.
pubkey
for
w
in
self
.
account
.
wallets
]
if
o
.
pubkey
not
in
pubkeys
:
amount
+=
o
.
amount
return
amount
def
amount_sent
(
tx
):
amount
=
0
if
tx
in
self
.
account
.
transactions_sent
(
self
.
community
)
\
or
tx
in
self
.
account
.
transactions_awaiting
(
self
.
community
):
for
o
in
tx
[
1
].
outputs
:
pubkeys
=
[
w
.
pubkey
for
w
in
self
.
account
.
wallets
]
if
o
.
pubkey
not
in
pubkeys
:
amount
+=
o
.
amount
return
amount
def
comment
(
tx
):
return
tx
[
1
].
comment
key_getter
=
{
0
:
itemgetter
(
0
),
1
:
uid
,
2
:
amount_sent
,
3
:
amount_received
,
4
:
comment
}
self
.
transactions
=
self
.
account
.
transactions_sent
(
self
.
community
)
+
\
self
.
account
.
transactions_awaiting
(
self
.
community
)
+
\
self
.
account
.
transactions_received
(
self
.
community
)
self
.
transactions
=
sorted
(
self
.
transactions
,
reverse
=
(
order
==
Qt
.
DescendingOrder
),
key
=
key_getter
[
section
])
self
.
layoutChanged
.
emit
()
def
set_period
(
self
,
ts_from
,
ts_to
):
"""
Filter table by given timestamps
"""
self
.
layoutAboutToBeChanged
.
emit
()
logging
.
debug
(
"
Filtering from {0} to {1}
"
.
format
(
ts_from
,
ts_to
))
def
in_period
(
tx
):
block
=
self
.
community
.
get_block
(
tx
[
0
])
return
(
block
.
mediantime
in
range
(
ts_from
,
ts_to
))
self
.
transactions
=
self
.
account
.
transactions_sent
(
self
.
community
)
+
\
self
.
account
.
transactions_awaiting
(
self
.
community
)
+
\
self
.
account
.
transactions_received
(
self
.
community
)
self
.
transactions
=
[
tx
for
tx
in
filter
(
in_period
,
self
.
transactions
)]
self
.
layoutChanged
.
emit
()
def
flags
(
self
,
index
):
def
flags
(
self
,
index
):
return
Qt
.
ItemIsSelectable
|
Qt
.
ItemIsEnabled
return
Qt
.
ItemIsSelectable
|
Qt
.
ItemIsEnabled
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