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
c711d3a3
Commit
c711d3a3
authored
9 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
Wallets ammount units displayed in header
Fix all wallet columns editable Fix empty name when edit is canceled
parent
67bafcdd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cutecoin/models/wallets.py
+25
-20
25 additions, 20 deletions
src/cutecoin/models/wallets.py
with
25 additions
and
20 deletions
src/cutecoin/models/wallets.py
+
25
−
20
View file @
c711d3a3
...
@@ -11,14 +11,16 @@ import logging
...
@@ -11,14 +11,16 @@ import logging
class
WalletsFilterProxyModel
(
QSortFilterProxyModel
):
class
WalletsFilterProxyModel
(
QSortFilterProxyModel
):
def
__init__
(
self
,
parent
=
None
):
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
)
super
().
__init__
(
parent
)
self
.
community
=
None
self
.
account
=
None
def
columnCount
(
self
,
parent
):
def
columnCount
(
self
,
parent
):
return
self
.
sourceModel
().
columnCount
(
None
)
return
self
.
sourceModel
().
columnCount
(
None
)
def
setSourceModel
(
self
,
source
M
odel
):
def
setSourceModel
(
self
,
source
_m
odel
):
self
.
community
=
source
M
odel
.
community
self
.
community
=
source
_m
odel
.
community
self
.
account
=
source
M
odel
.
account
self
.
account
=
source
_m
odel
.
account
super
().
setSourceModel
(
source
M
odel
)
super
().
setSourceModel
(
source
_m
odel
)
def
lessThan
(
self
,
left
,
right
):
def
lessThan
(
self
,
left
,
right
):
"""
"""
...
@@ -26,7 +28,7 @@ class WalletsFilterProxyModel(QSortFilterProxyModel):
...
@@ -26,7 +28,7 @@ class WalletsFilterProxyModel(QSortFilterProxyModel):
"""
"""
left_data
=
self
.
sourceModel
().
data
(
left
,
Qt
.
DisplayRole
)
left_data
=
self
.
sourceModel
().
data
(
left
,
Qt
.
DisplayRole
)
right_data
=
self
.
sourceModel
().
data
(
right
,
Qt
.
DisplayRole
)
right_data
=
self
.
sourceModel
().
data
(
right
,
Qt
.
DisplayRole
)
return
(
left_data
<
right_data
)
return
left_data
<
right_data
def
data
(
self
,
index
,
role
):
def
data
(
self
,
index
,
role
):
source_index
=
self
.
mapToSource
(
index
)
source_index
=
self
.
mapToSource
(
index
)
...
@@ -37,16 +39,12 @@ class WalletsFilterProxyModel(QSortFilterProxyModel):
...
@@ -37,16 +39,12 @@ class WalletsFilterProxyModel(QSortFilterProxyModel):
source_data
=
pubkey
source_data
=
pubkey
return
source_data
return
source_data
if
source_index
.
column
()
==
self
.
sourceModel
().
columns_types
.
index
(
'
amount
'
):
if
source_index
.
column
()
==
self
.
sourceModel
().
columns_types
.
index
(
'
amount
'
):
amount_ref
=
self
.
account
.
units_to_ref
(
source_data
,
amount_ref
=
self
.
account
.
units_to_ref
(
source_data
,
self
.
community
)
self
.
community
)
units_ref
=
self
.
account
.
diff_ref_name
(
self
.
community
.
short_currency
)
if
type
(
amount_ref
)
is
int
:
if
type
(
amount_ref
)
is
int
:
formatter
=
"
{0} {1}
"
return
"
{0}
"
.
format
(
amount_ref
)
else
:
else
:
formatter
=
"
{0:.2f} {1}
"
return
"
{0:.2f}
"
.
format
(
amount_ref
)
return
formatter
.
format
(
amount_ref
,
units_ref
)
return
source_data
return
source_data
...
@@ -63,9 +61,7 @@ class WalletsTableModel(QAbstractTableModel):
...
@@ -63,9 +61,7 @@ class WalletsTableModel(QAbstractTableModel):
super
().
__init__
(
parent
)
super
().
__init__
(
parent
)
self
.
account
=
account
self
.
account
=
account
self
.
community
=
community
self
.
community
=
community
self
.
columns_texts
=
{
'
name
'
:
'
Name
'
,
self
.
columns_headers
=
(
'
Name
'
,
'
Pubkey
'
,
'
Amount
'
)
'
pubkey
'
:
'
Pubkey
'
,
'
amount
'
:
'
Amount
'
}
self
.
columns_types
=
(
'
name
'
,
'
pubkey
'
,
'
amount
'
)
self
.
columns_types
=
(
'
name
'
,
'
pubkey
'
,
'
amount
'
)
@property
@property
...
@@ -80,15 +76,19 @@ class WalletsTableModel(QAbstractTableModel):
...
@@ -80,15 +76,19 @@ class WalletsTableModel(QAbstractTableModel):
def
headerData
(
self
,
section
,
orientation
,
role
):
def
headerData
(
self
,
section
,
orientation
,
role
):
if
role
==
Qt
.
DisplayRole
:
if
role
==
Qt
.
DisplayRole
:
col_type
=
self
.
columns_types
[
section
]
if
self
.
columns_types
[
section
]
==
'
amount
'
:
return
self
.
columns_texts
[
col_type
]
return
'
{:}
\n
({:})
'
.
format
(
self
.
columns_headers
[
section
],
self
.
account
.
ref_name
(
self
.
community
.
short_currency
)
)
return
self
.
columns_headers
[
section
]
def
wallet_data
(
self
,
row
):
def
wallet_data
(
self
,
row
):
name
=
self
.
wallets
[
row
].
name
name
=
self
.
wallets
[
row
].
name
amount
=
self
.
wallets
[
row
].
value
(
self
.
community
)
amount
=
self
.
wallets
[
row
].
value
(
self
.
community
)
pubkey
=
self
.
wallets
[
row
].
pubkey
pubkey
=
self
.
wallets
[
row
].
pubkey
return
(
name
,
pubkey
,
amount
)
return
name
,
pubkey
,
amount
def
data
(
self
,
index
,
role
):
def
data
(
self
,
index
,
role
):
row
=
index
.
row
()
row
=
index
.
row
()
...
@@ -100,11 +100,16 @@ class WalletsTableModel(QAbstractTableModel):
...
@@ -100,11 +100,16 @@ class WalletsTableModel(QAbstractTableModel):
if
role
==
Qt
.
EditRole
:
if
role
==
Qt
.
EditRole
:
row
=
index
.
row
()
row
=
index
.
row
()
col
=
index
.
column
()
col
=
index
.
column
()
if
col
==
self
.
columns_types
.
index
(
'
name
'
):
# Change model only if value not empty...
if
col
==
self
.
columns_types
.
index
(
'
name
'
)
and
value
:
self
.
wallets
[
row
].
name
=
value
self
.
wallets
[
row
].
name
=
value
self
.
dataChanged
.
emit
(
index
,
index
)
self
.
dataChanged
.
emit
(
index
,
index
)
return
True
return
True
return
False
return
False
def
flags
(
self
,
index
):
def
flags
(
self
,
index
):
return
Qt
.
ItemIsSelectable
|
Qt
.
ItemIsEnabled
|
Qt
.
ItemIsEditable
default_flags
=
Qt
.
ItemIsSelectable
|
Qt
.
ItemIsEnabled
# Only name column is editable
if
index
.
column
()
==
0
:
return
default_flags
|
Qt
.
ItemIsEditable
return
default_flags
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