Skip to content

refactor(gui): extract column persistence out of CMuleListCtrl - #787

Merged
got3nks merged 1 commit into
amule-org:masterfrom
LSalami:search-dataview-phase2-prep
Aug 4, 2026
Merged

refactor(gui): extract column persistence out of CMuleListCtrl#787
got3nks merged 1 commit into
amule-org:masterfrom
LSalami:search-dataview-phase2-prep

Conversation

@LSalami

@LSalami LSalami commented Aug 4, 2026

Copy link
Copy Markdown

Summary

Extracts the column-name/width/sort-order persistence logic out of CMuleListCtrl into a new, widget-agnostic CListColumnStore, which talks to the list widget through a small IColumnWidthProvider interface (column count, get/set width by index).

This is prep work for #180 phase 2 (porting CSearchListCtrl to wxDataViewCtrl for accessibility, tracked under #675). @got3nks asked in the #180 discussion that this extraction land as its own, independently reviewable commit before the actual wxDataViewCtrl port, since the persistence logic — including the legacy pre-2.2.2 config migration path — must not be duplicated against wxDataViewColumn. The new search list control will reuse CListColumnStore unchanged instead of reimplementing it.

No behaviour change. Config keys (/eMule/TableOrdering<name>, /eMule/TableWidths<name>) and the on-disk format are unchanged, so existing user settings keep working. CMuleListCtrl keeps its full public API (SaveSettings/LoadSettings/InsertColumn/SetTableName/GetColumnIndex/...).

Notes

  • CMuleListCtrl now implements IColumnWidthProvider via explicit forwarding overrides (GetColumnCount/GetColumnWidth/SetColumnWidth) rather than relying on wxGenericListCtrl's identically-signatured methods to satisfy the interface implicitly — with two unrelated base classes, the compiler won't link one base's definition to the other's pure virtual on its own.
  • Sort-order mutation deliberately stays out of CListColumnStore: applying a loaded sort order has widget-specific side effects (CMuleListCtrl::SetSorting() also triggers a re-sort and validates against AltSortAllowed()), so LoadSettings() only decodes the stored order and hands it back to the caller to apply through its own SetSorting().
  • The last-known-width cache used by the hide/show-via-menu interaction (CMuleListCtrl::OnMenuSelected) moved into the store too (GetCachedWidth/SetCachedWidth), since it's part of the same per-column state.

Test plan

  • Builds clean (macOS, full amule target)
  • clang-format v18 (pinned) applied
  • clang-tidy Tier-1 (whole-tree) and Tier-2 (changed-lines) both clean on the touched files
  • Launched the built app against an isolated test config (own ports, not the real app) and confirmed column widths/sort order/hidden columns load and save back correctly, matching pre-refactor behaviour

Splits the column-name/width/sort-order load-save logic out of
CMuleListCtrl into a new widget-agnostic CListColumnStore, talking to
the list widget through a small IColumnWidthProvider interface
(column count, get/set width by index).

Why: prep for the wxDataViewCtrl port of CSearchListCtrl (amule-org#675/amule-org#180
phase 2). got3nks asked that this extraction land as its own,
independently reviewable commit, since the persistence logic
(including the legacy pre-2.2.2 config migration path) must not be
duplicated against wxDataViewColumn -- the new search list control
will reuse CListColumnStore unchanged instead of reimplementing it.
No new functionality: config keys ("/eMule/TableOrdering<name>",
"/eMule/TableWidths<name>") and on-disk format are unchanged, so
existing user settings keep working.

CMuleListCtrl keeps its public API (SaveSettings/LoadSettings/
InsertColumn/SetTableName/GetColumnIndex/...) and now implements
IColumnWidthProvider via explicit forwarding overrides -- needed
because C++ won't otherwise link wxGenericListCtrl's
GetColumnCount/GetColumnWidth/SetColumnWidth to the identically-named
pure virtuals of an unrelated second base class.

Verified: builds clean (macOS, full amule target); launched the
built app against an isolated ~/aMuleTest config dir (own ports,
never the real app) and confirmed column settings load and save back
correctly, matching pre-refactor behaviour. Ran the local
clang-tidy CI replica (Tier-1 whole-tree + Tier-2 changed-lines);
Tier-1 reported no hits in the new/changed files, Tier-2 flagged
narrowing conversions and a few modernize-* suggestions on the new
code, all fixed.
@got3nks
got3nks merged commit b7f498a into amule-org:master Aug 4, 2026
15 checks passed
@got3nks

got3nks commented Aug 4, 2026

Copy link
Copy Markdown

Merged — thanks @LSalami. Faithful extraction: the sort-order reversal and the pre-2.2.2 migration path both came through intact, config keys are untouched so existing settings keep working, and the public API is unchanged (only private helpers moved). Good base for the wxDataViewCtrl port.

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.

2 participants