Skip to content

Refactor Phase 2: extract SwrSweepController + FreeDvSessionController from MainWindow (header member reduction) #3557

@ten9876

Description

@ten9876

Follow-up to #3351 (now closed — Phases 0–1 + RadioSession delivered). This is the issue's original Phase 2, carved out as its own scoped effort because it's a different kind of change from the Phase 0–1 work that landed.

What Phase 1 did vs. what Phase 2 needs

Phase 1 (#3508#3541) moved subsystem code into sibling TUs — MainWindow_SwrSweep.cpp, MainWindow_DigitalModes.cpp, etc. — but the subsystems' state still lives in MainWindow.h. The header is still ~158 member variables. Phase 2 finishes the job the original issue named:

"Extracting a SwrSweepController / FreeDvSessionController that own their own timers and state would pull ~1,000+ lines and their member variables out of the 190-member header."

This is not behavior-preserving code motion. It moves state ownership and object lifetimes across a new class boundary — so it needs careful review and bench QA, unlike the Phase 1 TU splits.

Target 1 — SwrSweepController

The sweep is already a self-contained state machine; the state is even pre-grouped in a struct. Members to extract from MainWindow.h:

  • SwrSweepState m_swrSweep; (the whole struct — running/phase/meterSource/sliceId/panId/frequencies/samples/timing/power fields, ~20 fields at MainWindow.h:910)
  • QTimer m_swrSweepTimer;
  • The 14 methods already in MainWindow_SwrSweep.cpp (startSwrSweep, advanceSwrSweep, finishSwrSweep, …) become SwrSweepController methods.
  • The kSwrSweep* constants (currently in MainWindowHelpers.h) move to the controller.

Coupling to resolve: the sweep methods touch m_radioModel (commands), spectrumForSlice()/pan overlay (UI), and the status bar. The controller takes a RadioModel& + a small callback/signal interface for the UI bits — it should NOT depend on MainWindow's widgets directly (same model-vs-GUI-layer discipline as the RadioSession finding in #3555).

Target 2 — FreeDvSessionController

RADE + classic FreeDV state, ~15 members at MainWindow.h:958–977 (m_radeEngine, m_radeThread, m_radeSliceId, m_radeDaxStreamId, the RADE/FDV connection handles, m_fdvDisplaySliceId, m_fdvSnrMeterIndex, m_fdvSynced, …). Methods already in MainWindow_DigitalModes.cpp (activateRADE/deactivateRADE/activateFdvDisplay/…) become controller methods.

Caveat: more UI-coupled than the sweep (touches applet panel, VFO widgets, meters) — so the extraction boundary needs more care, or this target stays a "thin controller owning state + lifecycle, UI wiring stays in the GUI layer" split. Worth a design note before coding.

Acceptance

  • MainWindow.h member count drops by ~35 (the SWR + RADE/FDV members)
  • Both controllers live in the GUI layer but depend on RadioModel/AudioEngine, not on MainWindow's widgets
  • Behavior identical — full SWR-sweep + RADE + FreeDV bench QA
  • No new -Wreorder; build clean on the Qt 6.4.2 floor

Not in scope

Phase 3 (table-driven menu/shortcut builders) — separate follow-up.

Refs #3351 #3445

Metadata

Metadata

Assignees

No one assigned

    Labels

    GUIUser interfaceenhancementImprovement to existing featuremaintainer-reviewRequires maintainer review before any action is taken

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions