Skip to content

refactor(gui): declare each column width once; persist the file-details list - #844

Merged
got3nks merged 2 commits into
amule-org:masterfrom
got3nks:refactor/dataview-column-registration
Aug 7, 2026
Merged

refactor(gui): declare each column width once; persist the file-details list#844
got3nks merged 2 commits into
amule-org:masterfrom
got3nks:refactor/dataview-column-registration

Conversation

@got3nks

@got3nks got3nks commented Aug 7, 2026

Copy link
Copy Markdown

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:

AppendTextColumn(_("File Name"), COLUMN_SHARED_NAME, wxDATAVIEW_CELL_INERT, 400, wxALIGN_LEFT, colFlags);
m_columnStore.RegisterColumn(COLUMN_SHARED_NAME, 400, "N");

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 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.

What changes

Three wrappers on CMuleDataViewCtrlAddTextColumn, 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 standalone RegisterColumn() is gone from the list subclasses.

CListColumnStore::RegisterColumn() itself is untouched: the legacy wxListCtrl lists still reach it through CMuleListCtrl::InsertColumn().

Why Add* and not an Append* overload

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, while the cleanup still removed its registration. With a distinct name it stayed visible as AppendTextColumn, and both grep and 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 OnIdleOnColumnWidthsChanged(). The dialog the user acted on is the one that writes, so the per-open lifetime is not a problem. New keys N and S under TableWidthsFileDetail / TableOrderingFileDetail; no GetOldColumnOrder() 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

amule and amulegui build 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 only ListColumnStore.cpp, MuleListCtrl.cpp and MuleDataViewCtrl.cpp; no list subclass still calls wx's Append*.

Manual GUI passes still to do: hide/show every column in each of the five lists, and a fresh-profile layout comparison.

got3nks added 2 commits August 7, 2026 16:30
…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.
@got3nks
got3nks merged commit 81ab756 into amule-org:master Aug 7, 2026
14 checks passed
@got3nks
got3nks deleted the refactor/dataview-column-registration branch August 7, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant