Loading...
Searching...
No Matches

Detailed Description

Classes

class  BackgroundSortFilterRowsBase
 The non-template portion of `BackgroundSortFilterRows`. More...
struct  BackgroundSortFilterRowsBase::ModelHooks
class  BackgroundSortFilterRows< Row >
 Append-only row storage for table models that filters and sorts rows on the worker pool. More...
class  FilterTarget
class  FilterEdit
class  FilteredView

Enumerations

enum  FilterOption { NoFilterOption = 0 , CaseSensitiveOption = 1 , UseRegexOption = 2 }

Class Documentation

◆ BackgroundSortFilterRowsBase

class BackgroundSortFilterRowsBase

The non-template portion of `BackgroundSortFilterRows`.

Contains the background job state machine, watcher lifecycle, and abandonment protocol, which are independent of the row type.

Public Member Functions

 BackgroundSortFilterRowsBase (ModelHooks hooks)
virtual ~BackgroundSortFilterRowsBase ()
 BackgroundSortFilterRowsBase (const BackgroundSortFilterRowsBase &)=delete
BackgroundSortFilterRowsBaseoperator= (const BackgroundSortFilterRowsBase &)=delete
bool busy () const
bool filtering () const
bool sorting () const

Protected Types

enum class  JobKind { Filter , Sort }

Protected Member Functions

void assertOwningThread () const
void shutdown ()
void abandonJob ()
void beginJob (JobKind kind, uint64_t filterGeneration, QFuture< void > future)
bool filterChangedDuringJob () const
virtual void commitJob (JobKind kind)=0

Protected Attributes

ModelHooks m_hooks
std::atomic< uint64_t > m_filterGeneration = 0

Member Enumeration Documentation

◆ JobKind

enum class BackgroundSortFilterRowsBase::JobKind
strongprotected
Enumerator
Filter 
Sort 

Constructor & Destructor Documentation

◆ BackgroundSortFilterRowsBase() [1/2]

BackgroundSortFilterRowsBase::BackgroundSortFilterRowsBase ( ModelHooks hooks)
inlineexplicit

◆ ~BackgroundSortFilterRowsBase()

virtual BackgroundSortFilterRowsBase::~BackgroundSortFilterRowsBase ( )
inlinevirtual

◆ BackgroundSortFilterRowsBase() [2/2]

BackgroundSortFilterRowsBase::BackgroundSortFilterRowsBase ( const BackgroundSortFilterRowsBase & )
delete

Member Function Documentation

◆ operator=()

BackgroundSortFilterRowsBase & BackgroundSortFilterRowsBase::operator= ( const BackgroundSortFilterRowsBase & )
delete

◆ busy()

bool BackgroundSortFilterRowsBase::busy ( ) const
inline

◆ filtering()

bool BackgroundSortFilterRowsBase::filtering ( ) const
inline

◆ sorting()

bool BackgroundSortFilterRowsBase::sorting ( ) const
inline

◆ assertOwningThread()

void BackgroundSortFilterRowsBase::assertOwningThread ( ) const
inlineprotected

◆ shutdown()

void BackgroundSortFilterRowsBase::shutdown ( )
inlineprotected

◆ abandonJob()

void BackgroundSortFilterRowsBase::abandonJob ( )
inlineprotected

◆ beginJob()

void BackgroundSortFilterRowsBase::beginJob ( JobKind kind,
uint64_t filterGeneration,
QFuture< void > future )
inlineprotected

◆ filterChangedDuringJob()

bool BackgroundSortFilterRowsBase::filterChangedDuringJob ( ) const
inlineprotected

◆ commitJob()

virtual void BackgroundSortFilterRowsBase::commitJob ( JobKind kind)
protectedpure virtual

Member Data Documentation

◆ m_hooks

ModelHooks BackgroundSortFilterRowsBase::m_hooks
protected

◆ m_filterGeneration

std::atomic<uint64_t> BackgroundSortFilterRowsBase::m_filterGeneration = 0
protected

◆ BackgroundSortFilterRowsBase::ModelHooks

struct BackgroundSortFilterRowsBase::ModelHooks
Class Members
function< void()> beginResetModel
function< void()> endResetModel
function< void(int first, int last)> beginInsertRows
function< void()> endInsertRows
function< void(bool active)> filteringChanged
function< void(bool active)> sortingChanged

◆ BackgroundSortFilterRows

class BackgroundSortFilterRows
template<typename Row>
class BackgroundSortFilterRows< Row >

Append-only row storage for table models that filters and sorts rows on the worker pool.

Filtering and sorting run as QtConcurrent jobs. Changing the filter abandons a running job at its next check and re-runs with the latest predicate, so rapid filter changes stay responsive. Appends and sorts requested while a job is running are deferred and applied when the job commits, allowing the job to read the rows without locking.

All methods must be called on the thread the object was created on (the GUI thread for table models): the job state machine and row vectors are single-thread-confined, with the worker threads communicating back only through the watcher's queued finished signal, and reading only the atomic generation counters and the unmutated rows. The filter predicate and comparator are called concurrently from worker threads and must be thread-safe.

Public Types

using Predicate = std::function<bool(const Row&)>
using PredicateFactory = std::function<Predicate()>
using Comparator = std::function<bool(const Row&, const Row&)>
using Index = uint32_t

Public Member Functions

 BackgroundSortFilterRows (ModelHooks hooks)
 ~BackgroundSortFilterRows () override
size_t displayCount () const
const Row & displayAt (size_t index) const
size_t totalCount () const
void clear ()
void append (std::vector< Row > rows)
void setFilter (Predicate filter)
void setFilterFactory (PredicateFactory factory)
void sort (Comparator comparator)
Public Member Functions inherited from BackgroundSortFilterRowsBase
 BackgroundSortFilterRowsBase (ModelHooks hooks)
virtual ~BackgroundSortFilterRowsBase ()
 BackgroundSortFilterRowsBase (const BackgroundSortFilterRowsBase &)=delete
BackgroundSortFilterRowsBaseoperator= (const BackgroundSortFilterRowsBase &)=delete
bool busy () const
bool filtering () const
bool sorting () const

Protected Member Functions

void commitJob (JobKind kind) override
Protected Member Functions inherited from BackgroundSortFilterRowsBase
void assertOwningThread () const
void shutdown ()
void abandonJob ()
void beginJob (JobKind kind, uint64_t filterGeneration, QFuture< void > future)
bool filterChangedDuringJob () const

Additional Inherited Members

Protected Types inherited from BackgroundSortFilterRowsBase
enum class  JobKind { Filter , Sort }
Protected Attributes inherited from BackgroundSortFilterRowsBase
ModelHooks m_hooks
std::atomic< uint64_t > m_filterGeneration = 0

Member Typedef Documentation

◆ Predicate

template<typename Row>
using BackgroundSortFilterRows< Row >::Predicate = std::function<bool(const Row&)>

◆ PredicateFactory

template<typename Row>
using BackgroundSortFilterRows< Row >::PredicateFactory = std::function<Predicate()>

◆ Comparator

template<typename Row>
using BackgroundSortFilterRows< Row >::Comparator = std::function<bool(const Row&, const Row&)>

◆ Index

template<typename Row>
using BackgroundSortFilterRows< Row >::Index = uint32_t

Constructor & Destructor Documentation

◆ BackgroundSortFilterRows()

template<typename Row>
BackgroundSortFilterRows< Row >::BackgroundSortFilterRows ( ModelHooks hooks)
inlineexplicit

◆ ~BackgroundSortFilterRows()

template<typename Row>
BackgroundSortFilterRows< Row >::~BackgroundSortFilterRows ( )
inlineoverride

Member Function Documentation

◆ displayCount()

template<typename Row>
size_t BackgroundSortFilterRows< Row >::displayCount ( ) const
inline

◆ displayAt()

template<typename Row>
const Row & BackgroundSortFilterRows< Row >::displayAt ( size_t index) const
inline

◆ totalCount()

template<typename Row>
size_t BackgroundSortFilterRows< Row >::totalCount ( ) const
inline

◆ clear()

template<typename Row>
void BackgroundSortFilterRows< Row >::clear ( )
inline

◆ append()

template<typename Row>
void BackgroundSortFilterRows< Row >::append ( std::vector< Row > rows)
inline

◆ setFilter()

template<typename Row>
void BackgroundSortFilterRows< Row >::setFilter ( Predicate filter)
inline

◆ setFilterFactory()

template<typename Row>
void BackgroundSortFilterRows< Row >::setFilterFactory ( PredicateFactory factory)
inline

◆ sort()

template<typename Row>
void BackgroundSortFilterRows< Row >::sort ( Comparator comparator)
inline

◆ commitJob()

template<typename Row>
void BackgroundSortFilterRows< Row >::commitJob ( JobKind kind)
inlineoverrideprotectedvirtual

◆ FilterTarget

class FilterTarget

Public Member Functions

virtual ~FilterTarget ()
virtual void setFilter (const std::string &filter, FilterOptions options)=0
virtual void scrollToFirstItem ()=0
virtual void scrollToCurrentItem ()=0
virtual void ensureSelection ()=0
virtual void activateSelection ()=0
virtual void closeFilter ()

Constructor & Destructor Documentation

◆ ~FilterTarget()

virtual FilterTarget::~FilterTarget ( )
inlinevirtual

Member Function Documentation

◆ setFilter()

virtual void FilterTarget::setFilter ( const std::string & filter,
FilterOptions options )
pure virtual

◆ scrollToFirstItem()

virtual void FilterTarget::scrollToFirstItem ( )
pure virtual

◆ scrollToCurrentItem()

virtual void FilterTarget::scrollToCurrentItem ( )
pure virtual

◆ ensureSelection()

virtual void FilterTarget::ensureSelection ( )
pure virtual

◆ activateSelection()

virtual void FilterTarget::activateSelection ( )
pure virtual

◆ closeFilter()

virtual void FilterTarget::closeFilter ( )
virtual

Reimplemented in BndbImportDialog, and LogView.

◆ FilterEdit

class FilterEdit

Signals

void optionsChanged (FilterOptions options)

Public Member Functions

 FilterEdit (FilterTarget *target)
void showRegexToggle (bool enabled)
void setRegexValidationError (const QString &error)
FilterOptions getFilterOptions () const

Protected Member Functions

virtual void paintEvent (QPaintEvent *event) override
virtual void keyPressEvent (QKeyEvent *event) override

Constructor & Destructor Documentation

◆ FilterEdit()

FilterEdit::FilterEdit ( FilterTarget * target)

Member Function Documentation

◆ showRegexToggle()

void FilterEdit::showRegexToggle ( bool enabled)

◆ setRegexValidationError()

void FilterEdit::setRegexValidationError ( const QString & error)

◆ getFilterOptions()

FilterOptions FilterEdit::getFilterOptions ( ) const
inline

◆ optionsChanged

void FilterEdit::optionsChanged ( FilterOptions options)
signal

◆ paintEvent()

virtual void FilterEdit::paintEvent ( QPaintEvent * event)
overrideprotectedvirtual

◆ keyPressEvent()

virtual void FilterEdit::keyPressEvent ( QKeyEvent * event)
overrideprotectedvirtual

◆ FilteredView

class FilteredView

Public Member Functions

 FilteredView (QWidget *parent, QWidget *filtered, FilterTarget *target, FilterEdit *edit=nullptr)
void setFilterPlaceholderText (const QString &text)
void setFilterToolTip (const QString &text)
void updateFonts ()
void clearFilter ()
void showFilter (const QString &initialText)
void focusAndSelectFilter ()
bool hasFilterText () const

Static Public Member Functions

static bool match (const std::string &name, const std::string &filter, bool caseSensitive=false)

Constructor & Destructor Documentation

◆ FilteredView()

FilteredView::FilteredView ( QWidget * parent,
QWidget * filtered,
FilterTarget * target,
FilterEdit * edit = nullptr )

Member Function Documentation

◆ setFilterPlaceholderText()

void FilteredView::setFilterPlaceholderText ( const QString & text)

◆ setFilterToolTip()

void FilteredView::setFilterToolTip ( const QString & text)

◆ updateFonts()

void FilteredView::updateFonts ( )

◆ clearFilter()

void FilteredView::clearFilter ( )

◆ showFilter()

void FilteredView::showFilter ( const QString & initialText)

◆ focusAndSelectFilter()

void FilteredView::focusAndSelectFilter ( )

◆ hasFilterText()

bool FilteredView::hasFilterText ( ) const

◆ match()

bool FilteredView::match ( const std::string & name,
const std::string & filter,
bool caseSensitive = false )
static

Enumeration Type Documentation

◆ FilterOption

Enumerator
NoFilterOption 
CaseSensitiveOption 
UseRegexOption