morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::testing::detail::FakeTable Class Referencefinal

A fake TableWidget: properties columns, selectionMode, selection, and rowKey on a row. More...

#include <recording_backend.hpp>

Inheritance diagram for morph::ui::testing::detail::FakeTable:
morph::ui::testing::detail::FakeContainer< TableWidget > morph::ui::testing::detail::FakeLeaf< TableWidget > morph::ui::TableWidget morph::ui::ContainerWidget morph::ui::Widget

Public Member Functions

 FakeTable (std::shared_ptr< RecordStore > store, std::string kind, ContainerWidget const *parent)
 Records the new table, appended to parent, and logs its creation.
 ~FakeTable () override
 Removes the hook that points at this table, so nothing calls it once the table is gone, even if the record outlives it because recording the destruction failed.
 FakeTable (FakeTable const &)=delete
FakeTable & operator= (FakeTable const &)=delete
 FakeTable (FakeTable &&)=delete
FakeTable & operator= (FakeTable &&)=delete
void setColumns (std::vector< TableColumn > const &columns) override
 Records property columns, each as its escaped caption, a colon and its width.
void setShowHeader (bool shown) override
 Records property showHeader.
void setSelectionMode (SelectionMode mode) override
 Records property selectionMode, which RecordingBackend::selectRows enforces.
void setRowKey (Widget &row, Key const &key) override
 Records property rowKey on row, and marks the row when its key is requested.
void setRowTone (Widget &row, std::optional< Tone > tone) override
 Records the row's property tone (none for no tone).
void setSelection (std::vector< Key > const &keys) override
 Requests the rows with keys, and records property selection as the rows it marks.
void setOnSelectionChange (std::function< void(std::vector< Key >)> onSelectionChange) override
 Stores the handler RecordingBackend::selectRows calls.
void setOnActivate (std::function< void(Key)> onActivate) override
 Stores the handler RecordingBackend::activateRow calls.
void setRealizedWindow (std::size_t first, std::size_t count, std::size_t total) override
 Records property realizedWindow as <first>+<count>/<total>.
void setOnVisibleRangeChanged (std::function< void(std::size_t, std::size_t)> onVisibleRangeChanged) override
 Stores the handler RecordingBackend::scrollTable calls.
void scrollTo (std::size_t first, std::size_t count)
 Simulates the backend reporting a scroll: calls the handler setOnVisibleRangeChanged stored, as a real backend's own scroll callback would. Does nothing if nothing is subscribed (a table below its virtualization threshold never calls setOnVisibleRangeChanged, so this is a silent no-op for it, matching a real backend that never virtualizes).
SelectionMode mode () const noexcept
 The selection mode last set.
std::optional< int > rowOf (Key const &key) const
 The current row with key.
void selectByUser (std::vector< Key > const &keys)
 Marks the rows the user selected, as the requested keys; nothing is logged.
Public Member Functions inherited from morph::ui::testing::detail::FakeContainer< TableWidget >
void moveChild (Widget &child, std::size_t index) override
 Moves a child among its siblings and logs it.
Public Member Functions inherited from morph::ui::testing::detail::FakeLeaf< TableWidget >
 FakeLeaf (std::shared_ptr< RecordStore > store, std::string kind, ContainerWidget const *parent, PropList initial={})
 Records the new widget, appended to parent, and logs its creation.
 ~FakeLeaf () override
 Forgets the widget and logs its destruction; its remaining children become roots.
FakeLeaf & operator= (FakeLeaf const &)=delete
void setVisible (bool visible) override
 Records property visible.
void setEnabled (bool enabled) override
 Records property enabled.
void setLayout (LayoutHints const &hints) override
 Records property layout, as formatLayout gives it.
void setDragKey (std::optional< Key > const &key) override
 Records property dragKey and keeps the key for RecordingBackend::drag.
void setDropHandler (std::function< bool(Key const &)> accepts, std::function< void(Key)> onDrop) override
 Records property drop=handler and keeps both handlers for RecordingBackend::drag.
void setAccessibleName (std::string_view name) override
 Records property a11yName.
void setAccessibleRole (std::string_view role) override
 Records property a11yRole.
void setTestId (std::string_view testId) override
 Records property testId.
void setTooltip (std::string_view text) override
 Records property tooltip.
void setSurface (std::string_view surface) override
 Records property surface.
void setKeys (std::vector< std::string > const &chords, std::function< void(std::string)> onChord) override
 Records property keys, the chords joined by commas, and keeps the chords and the handler for RecordingBackend::press.
void focus () override
 Moves the backend's recorded focus here, and logs focus.
void setOnHover (std::function< void()> onHover) override
 Keeps the handler for RecordingBackend::hover.
Public Member Functions inherited from morph::ui::TableWidget
virtual void setExistingKeys (std::vector< Key > const &keys)
 Tells the backend every key currently in the table's data, realized or not – called whenever that set changes (a data change, or a scroll that dewindows or re-realizes a row). A virtualized backend needs this to know a selected key still exists in the data when it has no realized row for it right now (setRowKey alone cannot say that, since it is only ever called for a realized row): without it, a backend that reconstructs "does this key still exist" purely from its realized children would silently drop a selected key's membership the moment its row scrolls out of view. A backend that never virtualizes may ignore this – every key it cares about already has a realized row, by definition, so setRowKey alone already tells it everything this call would add.
Public Member Functions inherited from morph::ui::Widget
 Widget (Widget const &)=delete
Widget & operator= (Widget const &)=delete
 Widget (Widget &&)=delete
Widget & operator= (Widget &&)=delete

Additional Inherited Members

Protected Member Functions inherited from morph::ui::testing::detail::FakeLeaf< TableWidget >
void set (std::string_view name, std::string value)
 Records a property set through a setter.
Callbacks & callbacks ()
 This widget's handlers.
RecordStore & store () const noexcept
 The store this widget records into.
std::shared_ptr< RecordStore > const & sharedStore () const noexcept
 The store, shared: what a part this widget makes (an overlay's footer) records into.
int id () const noexcept
 This widget's id.

Detailed Description

A fake TableWidget: properties columns, selectionMode, selection, and rowKey on a row.

selection shows the rows the widget marks: the requested keys, in the order requested, that one of its current rows has. The requested keys are kept, so a row that arrives with one of them is marked and a row that goes is unmarked; that re-marking is the widget's own doing and is not logged.

Definition at line 1376 of file recording_backend.hpp.

Constructor & Destructor Documentation

◆ FakeTable()

morph::ui::testing::detail::FakeTable::FakeTable ( std::shared_ptr< RecordStore > store,
std::string kind,
ContainerWidget const * parent )
inline

Records the new table, appended to parent, and logs its creation.

Parameters
storeWhere the widget records itself.
kindThe kind shown in the log and the dump.
parentThe container it is appended to, or null for a root.

Definition at line 1382 of file recording_backend.hpp.

◆ ~FakeTable()

morph::ui::testing::detail::FakeTable::~FakeTable ( )
inlineoverride

Removes the hook that points at this table, so nothing calls it once the table is gone, even if the record outlives it because recording the destruction failed.

Definition at line 1392 of file recording_backend.hpp.

Member Function Documentation

◆ setColumns()

void morph::ui::testing::detail::FakeTable::setColumns ( std::vector< TableColumn > const & columns)
inlineoverridevirtual

Records property columns, each as its escaped caption, a colon and its width.

Parameters
columnsThe columns, in order.

Implements morph::ui::TableWidget.

Definition at line 1407 of file recording_backend.hpp.

◆ setShowHeader()

void morph::ui::testing::detail::FakeTable::setShowHeader ( bool shown)
inlineoverridevirtual

Records property showHeader.

Parameters
shownWhether the header row is drawn.

Implements morph::ui::TableWidget.

Definition at line 1415 of file recording_backend.hpp.

◆ setSelectionMode()

void morph::ui::testing::detail::FakeTable::setSelectionMode ( SelectionMode mode)
inlineoverridevirtual

Records property selectionMode, which RecordingBackend::selectRows enforces.

Parameters
modeNone, one, or any number.

Implements morph::ui::TableWidget.

Definition at line 1419 of file recording_backend.hpp.

◆ setRowKey()

void morph::ui::testing::detail::FakeTable::setRowKey ( Widget & row,
Key const & key )
inlineoverridevirtual

Records property rowKey on row, and marks the row when its key is requested.

Parameters
rowOne of this table's rows.
keyThe row's key.
Exceptions
std::logic_errorwhen row is not this table's child.

Implements morph::ui::TableWidget.

Definition at line 1428 of file recording_backend.hpp.

◆ setRowTone()

void morph::ui::testing::detail::FakeTable::setRowTone ( Widget & row,
std::optional< Tone > tone )
inlineoverridevirtual

Records the row's property tone (none for no tone).

Parameters
rowOne of this table's rows.
toneThe tone, or none.
Exceptions
std::logic_errorwhen row is not this table's child.

Implements morph::ui::TableWidget.

Definition at line 1442 of file recording_backend.hpp.

◆ setSelection()

void morph::ui::testing::detail::FakeTable::setSelection ( std::vector< Key > const & keys)
inlineoverridevirtual

Requests the rows with keys, and records property selection as the rows it marks.

Parameters
keysThe selected keys.

Implements morph::ui::TableWidget.

Definition at line 1452 of file recording_backend.hpp.

◆ setOnSelectionChange()

void morph::ui::testing::detail::FakeTable::setOnSelectionChange ( std::function< void(std::vector< Key >)> onSelectionChange)
inlineoverridevirtual

Stores the handler RecordingBackend::selectRows calls.

Parameters
onSelectionChangeThe handler.

Implements morph::ui::TableWidget.

Definition at line 1459 of file recording_backend.hpp.

◆ setOnActivate()

void morph::ui::testing::detail::FakeTable::setOnActivate ( std::function< void(Key)> onActivate)
inlineoverridevirtual

Stores the handler RecordingBackend::activateRow calls.

Parameters
onActivateThe handler.

Implements morph::ui::TableWidget.

Definition at line 1465 of file recording_backend.hpp.

◆ setRealizedWindow()

void morph::ui::testing::detail::FakeTable::setRealizedWindow ( std::size_t first,
std::size_t count,
std::size_t total )
inlineoverridevirtual

Records property realizedWindow as <first>+<count>/<total>.

Parameters
firstThe view index of the first realized row.
countHow many rows are realized, starting at first.
totalHow many rows the table's data has, realized or not.

Reimplemented from morph::ui::TableWidget.

Definition at line 1471 of file recording_backend.hpp.

◆ setOnVisibleRangeChanged()

void morph::ui::testing::detail::FakeTable::setOnVisibleRangeChanged ( std::function< void(std::size_t, std::size_t)> onVisibleRangeChanged)
inlineoverridevirtual

Stores the handler RecordingBackend::scrollTable calls.

Parameters
onVisibleRangeChangedThe handler.

Reimplemented from morph::ui::TableWidget.

Definition at line 1477 of file recording_backend.hpp.

◆ scrollTo()

void morph::ui::testing::detail::FakeTable::scrollTo ( std::size_t first,
std::size_t count )
inline

Simulates the backend reporting a scroll: calls the handler setOnVisibleRangeChanged stored, as a real backend's own scroll callback would. Does nothing if nothing is subscribed (a table below its virtualization threshold never calls setOnVisibleRangeChanged, so this is a silent no-op for it, matching a real backend that never virtualizes).

Parameters
firstThe view index of the first row now wanted.
countHow many rows from first are wanted.

Definition at line 1487 of file recording_backend.hpp.

◆ mode()

SelectionMode morph::ui::testing::detail::FakeTable::mode ( ) const
inlinenodiscardnoexcept

The selection mode last set.

Returns
The mode; None until setSelectionMode runs.

Definition at line 1495 of file recording_backend.hpp.

◆ rowOf()

std::optional< int > morph::ui::testing::detail::FakeTable::rowOf ( Key const & key) const
inlinenodiscard

The current row with key.

Parameters
keyThe key.
Returns
The row's id, or nullopt when no current row has key.

Definition at line 1500 of file recording_backend.hpp.

◆ selectByUser()

void morph::ui::testing::detail::FakeTable::selectByUser ( std::vector< Key > const & keys)
inline

Marks the rows the user selected, as the requested keys; nothing is logged.

Parameters
keysKeys of current rows.

Definition at line 1511 of file recording_backend.hpp.


The documentation for this class was generated from the following file: