Save/restore TransactionView and recentRequestsView tables column sizes. Sorting order is not saved/restored intentionally.
Based on #204 (the first commit).
In Qt 5 the last column resizing with dragging its left edge works
out-of-the-box.
The current TableViewLastColumnResizingFixer implementation could put
the last column content out of the view port and confuse a user.
This change improves code readability.
This is move-only change.
Sorting order is not saved/restored intentionally.
This is move-only change.
Sorting order is not saved/restored intentionally.
… if the idea is to save the column sizes if adjusted by the user and restore them on next use (is that the goal of this pull?)…
Correct.
Why not save the sorting order too?
After a while users could forget/unnotice another sort order, and that could cause their panic (when they are not looking at the recently made transaction).
EDIT: while testing the sorting order preservation was uncomfortable for me.
-resetguisettings
?)
I guess this is also resettable by
-resetguisettings
?
Correct. -resetguisettings
affects all of the settings those use a QSettings
class instance.
ACK 964885d04801c6ab77ce4705cff01c9d83bc3ed8, tested on macOS 11.1 Qt 5.15.2
PR works well and does what it says it will do. Confirmed that the column width’s of transactions and recent requests are saved and then restored upon node restart. Code looks good and it removes some complexity (yay, less lines of code).
Below are screenshots comparing the behavior between master
and this pr
Master: Start point
Master: Resize
Master: Restart, column width does not persist
PR: Start
PR: Resize
PR: Restart, column width persists
161+ transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
162+ transactionView->setSortingEnabled(true);
163+ transactionView->verticalHeader()->hide();
164+
165+ QSettings settings;
166+ if (!transactionView->horizontalHeader()->restoreState(settings.value("TransactionViewHeaderState").toByteArray())) {
TransactionViewHeaderState
string literal is used twice in same .cpp file. Maybe we can then consider this as “magic string” (as magic constant) and avoid duplicating, using some local .cpp-file constant?
Your suggestion is nice to apply to all of the setting names in a follow up pr.
True. Maybe even GUISettings
class to wrap calls to QSettings
with methods like getTransactionViewHeaderState()
.
-resetguisettings
) works as expected.
but now, after opening bitcoin-qt, the transactions aren’t chronologically sorted until I click the date column header twice.
Thank you for reporting. Fixed in #229.
Also, this doesn’t fix “Requested payments history” and “Peers” column widths issues.
Are you sure about the “Requested payments history” tab?
The “Peers” tab is WIP :)
While working on #256, two flaws were noted in this PR.
QTableView::setColumnWidth
does not work without model set (but it is not documented by Qt).:disappointed: