MCPcopy Create free account
hub / github.com/SpartanJ/eepp / findRowWithText

Method findRowWithText

src/eepp/ui/uitableview.cpp:383–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381}
382
383ModelIndex UITableView::findRowWithText( const std::string& text, const bool& caseSensitive,
384 FindRowWithTextMatchKind matchKind ) const {
385 const Model* model = getModel();
386 ConditionalLock l( getModel() != nullptr,
387 getModel() ? &const_cast<Model*>( getModel() )->resourceMutex() : nullptr );
388 if ( !model || !model->hasChildren() )
389 return {};
390 size_t rc = model->rowCount();
391 for ( size_t i = 0; i < rc; i++ ) {
392 ModelIndex index = model->index(
393 i, model->keyColumn() != -1 ? model->keyColumn()
394 : ( model->treeColumn() >= 0 ? model->treeColumn() : 0 ) );
395 Variant var = model->data( index );
396 if ( var.isValid() ) {
397 bool matches = false;
398 switch ( matchKind ) {
399 case Abstract::UIAbstractView::FindRowWithTextMatchKind::Equals:
400 matches = var.toString() == text;
401 break;
402 case Abstract::UIAbstractView::FindRowWithTextMatchKind::StartsWith:
403 matches = String::startsWith( caseSensitive ? var.toString()
404 : String::toLower( var.toString() ),
405 caseSensitive ? text : String::toLower( text ) );
406 break;
407 case Abstract::UIAbstractView::FindRowWithTextMatchKind::Contains:
408 matches = caseSensitive ? String::contains( var.toString(), text )
409 : String::icontains( var.toString(), text );
410 break;
411 }
412
413 if ( matches )
414 return model->index( index.row(), 0 );
415 }
416 }
417 return {};
418}
419
420}} // namespace EE::UI

Callers

nothing calls this directly

Calls 11

getModelFunction · 0.85
keyColumnMethod · 0.80
rowMethod · 0.80
containsFunction · 0.50
hasChildrenMethod · 0.45
rowCountMethod · 0.45
indexMethod · 0.45
treeColumnMethod · 0.45
dataMethod · 0.45
isValidMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected