refactor(gui): declare each column width once; persist the file-details list - #844
Merged
got3nks merged 2 commits intoAug 7, 2026
Merged
Conversation
…ls list
Two changes: a mechanical de-duplication across the wxDataViewCtrl lists, and
one behaviour change that comes with it -- the file-details dialog's list now
remembers its column widths and sort, which it never did.
Every column in the wxDataViewCtrl lists declared its width twice, in two
calls that nothing kept in sync:
AppendTextColumn(_("File Name"), COLUMN_SHARED_NAME, wxDATAVIEW_CELL_INERT,
400, wxALIGN_LEFT, colFlags);
m_columnStore.RegisterColumn(COLUMN_SHARED_NAME, 400, "N");
The two numbers are consumed by different paths, which is why nothing caught
the duplication: wx uses its copy as the initial on-screen width, while
CListColumnStore keeps its own as the width to restore a column to when it is
un-hidden with nothing cached for it. Let them drift and a column returns from
the header menu at a different width than it launched with. The legacy
CMuleListCtrl::InsertColumn() took the width and the persistence key in one
call and could not drift; the dataview port split that apart because
wxDataViewCtrl::AppendTextColumn() has nowhere to put a key.
Three wrappers on CMuleDataViewCtrl take the label, model column, key and
width together and forward the one width to both places. The 43 columns across
the server, search, friend and shared-files lists now go through them, and the
standalone RegisterColumn() calls are gone from every list subclass.
CListColumnStore::RegisterColumn() itself is untouched -- the legacy
wxListCtrl lists still reach it through CMuleListCtrl::InsertColumn().
Named Add* rather than overloading Append*: an overload with a different
signature still binds to the wx method wherever a call is missed, compiling
cleanly and persisting nothing. That is not hypothetical -- the sweep did miss
one, COL_DIRECTORY in the search list, whose trailing comment sits after a
comma and confused the rewrite. With a distinct name it stayed visible as
AppendTextColumn and both grep and the width/key check found it; as an
overload it would have compiled and silently stopped persisting that column.
No column's width, order, visibility or key changes: all 43 were verified
identical to master, before and after clang-format rewrapped the calls. No
column had drifted on master either, so this removes the possibility rather
than fixing a live symptom.
CFileDetailListCtrl gains persistence rather than staying out. It was the one
dataview list without it: a user who widened "File Name" lost it when the
dialog closed, and the sort reset to Sources-descending on every open. It
needs no teardown handling because saving is event-driven in the base -- header
click, show/hide, and drag-resize through OnIdle -- so the dialog the user
acted on is the one that writes. New keys N and S under TableWidthsFileDetail /
TableOrderingFileDetail; no GetOldColumnOrder() override, as nothing was ever
written under that name to migrate.
The wrappers hardcoded wxDATAVIEW_CELL_INERT, which is what every column in every list is today, so nothing changes. But it made the wrappers unusable for an editable column, and the way out would have been Append* plus a hand-written RegisterColumn() -- exactly the split this removes. A defaulted parameter keeps today's call sites untouched and leaves the door open. It goes last rather than in wx's position ahead of the width: width has no default, so nothing before it can have one either, and every caller would have had to spell out INERT.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two changes: a mechanical de-duplication across the wxDataViewCtrl lists, and one behaviour change that comes with it — the file-details dialog's list now remembers its column widths and sort order, which it never did. Details in its own section below; everything else is behaviour-preserving.
Every column in the wxDataViewCtrl lists declares its width twice, in two calls that nothing keeps in sync:
The two are consumed by different paths, which is why the duplication went unnoticed: wx uses its copy as the initial on-screen width, while
CListColumnStorekeeps its own as the width to restore a column to when it is un-hidden with nothing cached for it. Let them drift and a column returns from the header menu at a different width than it launched with.The legacy
CMuleListCtrl::InsertColumn()took the width and the persistence key in one call and could not drift. The dataview port split that apart, becausewxDataViewCtrl::AppendTextColumn()has nowhere to put a key.What changes
Three wrappers on
CMuleDataViewCtrl—AddTextColumn,AddIconTextColumn,AddBarColumn— take the label, model column, key and width together and forward the one width to both destinations. The 43 columns across the server, search, friend and shared-files lists go through them, and every standaloneRegisterColumn()is gone from the list subclasses.CListColumnStore::RegisterColumn()itself is untouched: the legacy wxListCtrl lists still reach it throughCMuleListCtrl::InsertColumn().Why
Add*and not anAppend*overloadAn overload with a different signature still binds to the wx method wherever a call is missed — compiling cleanly and persisting nothing.
That is not hypothetical. The sweep did miss one:
COL_DIRECTORYin the search list, whose trailing comment sits after a comma and confused the rewrite, while the cleanup still removed its registration. With a distinct name it stayed visible asAppendTextColumn, and bothgrepand the width/key check caught it. As an overload it would have compiled and silently stopped persisting that column.New behaviour: CFileDetailListCtrl gains persistence
It was the one dataview list without any: a user who widened "File Name" lost it the moment the dialog closed, and the sort reset to Sources-descending on every open.
It needs no teardown handling, because saving is event-driven in the base — header click, show/hide, and drag-resize through
OnIdle→OnColumnWidthsChanged(). The dialog the user acted on is the one that writes, so the per-open lifetime is not a problem. New keysNandSunderTableWidthsFileDetail/TableOrderingFileDetail; noGetOldColumnOrder()override, since nothing was ever written under that name to migrate.Behaviour elsewhere
No column's width, order, visibility or key changes. All 43 were checked identical to master — and re-checked after clang-format rewrapped the calls, since that rewrote the very lines carrying them.
Worth setting expectations for review: no column had drifted on master, so hide/show already returns the launch width today. This removes the possibility of drift rather than fixing a live symptom — there is nothing to reproduce before/after.
Testing
amuleandamuleguibuild clean; 33/33 unit tests; clang-format 18 and both clang-tidy tiers clean on the diff with 0 compiler errors. Validation greps:RegisterColumn(matches onlyListColumnStore.cpp,MuleListCtrl.cppandMuleDataViewCtrl.cpp; no list subclass still calls wx'sAppend*.Manual GUI passes still to do: hide/show every column in each of the five lists, and a fresh-profile layout comparison.