morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::table::Selection Class Reference

A table's selected keys and active key. More...

#include <selection.hpp>

Public Member Functions

bool select (RowId key)
 Selects a row; in Single mode it replaces the selection.
bool deselect (RowId key)
 Deselects a row.
bool toggle (RowId key)
 Selects an unselected row, or deselects a selected one.
void clear ()
 Deselects every row.
std::expected< void, TableError > selectAll (Engine const &engine)
 Selects every row in the engine's view.
void viewChanged (Engine const &engine)
 Brings the selection up to date after the view changed: with pruneOnFilter, drops selected rows no longer in the view.
void setActiveKey (std::optional< RowId > key)
 Moves the cursor.
std::optional< RowId > const & activeKey () const noexcept
 The row with the cursor.
bool contains (RowId const &key) const
 Whether a row is selected.
std::size_t selectedCount () const noexcept
 Selected rows.
std::vector< RowId > const & keys () const noexcept
 The selected keys, in the order they were selected.
SelectionOptions const & options () const noexcept
 The configuration.

Static Public Member Functions

static std::expected< Selection, TableError > create (SelectionOptions options)
 Builds a selection.
static bool activate (Engine const &engine, std::size_t viewRow, std::function< void(RowId const &)> const &onActivate)
 Activates the row at a view row: reports it and changes no selection.

Detailed Description

A table's selected keys and active key.

Definition at line 60 of file selection.hpp.

Member Function Documentation

◆ create()

std::expected< Selection, TableError > morph::table::Selection::create ( SelectionOptions options)
inlinestaticnodiscard

Builds a selection.

Parameters
optionsThe configuration.
Returns
The selection, or Unavailable when options asks to prune in server mode.

Definition at line 66 of file selection.hpp.

◆ select()

bool morph::table::Selection::select ( RowId key)
inline

Selects a row; in Single mode it replaces the selection.

Parameters
keyThe row's key, by value: it may come from keys(), which this call changes.
Returns
false in None mode.

Definition at line 79 of file selection.hpp.

◆ deselect()

bool morph::table::Selection::deselect ( RowId key)
inline

Deselects a row.

Parameters
keyThe row's key, by value: it may come from keys(), which this call changes.
Returns
true when it was selected.

Definition at line 98 of file selection.hpp.

◆ toggle()

bool morph::table::Selection::toggle ( RowId key)
inline

Selects an unselected row, or deselects a selected one.

Parameters
keyThe row's key, by value: it may come from keys(), which this call changes.
Returns
Whether the row is selected afterwards.

Definition at line 110 of file selection.hpp.

◆ clear()

void morph::table::Selection::clear ( )
inline

Deselects every row.

Definition at line 118 of file selection.hpp.

◆ selectAll()

std::expected< void, TableError > morph::table::Selection::selectAll ( Engine const & engine)
inline

Selects every row in the engine's view.

Parameters
engineThe table's engine.
Returns
Unavailable in server mode or unless the mode is Multiple.

Definition at line 126 of file selection.hpp.

◆ viewChanged()

void morph::table::Selection::viewChanged ( Engine const & engine)
inline

Brings the selection up to date after the view changed: with pruneOnFilter, drops selected rows no longer in the view.

Parameters
engineThe table's engine.

Definition at line 141 of file selection.hpp.

◆ setActiveKey()

void morph::table::Selection::setActiveKey ( std::optional< RowId > key)
inline

Moves the cursor.

Parameters
keyThe row's key, or nothing for no cursor.

Definition at line 156 of file selection.hpp.

◆ activeKey()

std::optional< RowId > const & morph::table::Selection::activeKey ( ) const
inlinenodiscardnoexcept

The row with the cursor.

Returns
Its key, or nothing.

Definition at line 160 of file selection.hpp.

◆ contains()

bool morph::table::Selection::contains ( RowId const & key) const
inlinenodiscard

Whether a row is selected.

Parameters
keyThe row's key.
Returns
true when selected.

Definition at line 165 of file selection.hpp.

◆ selectedCount()

std::size_t morph::table::Selection::selectedCount ( ) const
inlinenodiscardnoexcept

Selected rows.

Returns
The count.

Definition at line 169 of file selection.hpp.

◆ keys()

std::vector< RowId > const & morph::table::Selection::keys ( ) const
inlinenodiscardnoexcept

The selected keys, in the order they were selected.

Returns
The keys.

Definition at line 173 of file selection.hpp.

◆ options()

SelectionOptions const & morph::table::Selection::options ( ) const
inlinenodiscardnoexcept

The configuration.

Returns
The options.

Definition at line 177 of file selection.hpp.

◆ activate()

bool morph::table::Selection::activate ( Engine const & engine,
std::size_t viewRow,
std::function< void(RowId const &)> const & onActivate )
inlinestatic

Activates the row at a view row: reports it and changes no selection.

Parameters
engineThe table's engine.
viewRowThe view row.
onActivateReceives the row's key.
Returns
false when viewRow is past the view.

Definition at line 184 of file selection.hpp.


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