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

Method openRowWithPath

src/eepp/ui/uitreeview.cpp:831–868  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

829}
830
831ModelIndex UITreeView::openRowWithPath( const std::vector<std::string>& pathTree,
832 bool selectOpenedRow ) {
833 const Model* model = getModel();
834 if ( !model || !model->hasChildren() )
835 return {};
836 ModelIndex parentIndex = {};
837 for ( size_t i = 0; i < pathTree.size(); i++ ) {
838 ModelIndex foundIndex = {};
839 const auto& part = pathTree[i];
840
841 traverseTree(
842 [&model, &foundIndex, &part, &parentIndex,
843 i]( const int&, const ModelIndex& index, const size_t& indentLevel, const Float& ) {
844 Variant var = model->data( index );
845 if ( i == indentLevel && var.isValid() && var.toString() == part ) {
846 if ( !parentIndex.isValid() || parentIndex == index.parent() ) {
847 foundIndex = index;
848 return IterationDecision::Stop;
849 }
850 }
851 return IterationDecision::Continue;
852 } );
853
854 if ( foundIndex == ModelIndex() )
855 break;
856
857 tryOpenModelIndex( foundIndex );
858
859 parentIndex = foundIndex;
860
861 if ( i == pathTree.size() - 1 ) {
862 if ( selectOpenedRow )
863 setSelection( foundIndex );
864 return foundIndex;
865 }
866 }
867 return {};
868}
869
870ModelIndex UITreeView::openRowWithPath( std::string path, bool selectOpenedRow ) {
871 String::replaceAll( path, "\\", "/" );

Callers 5

loadImageFromMediumMethod · 0.80
newFolderMethod · 0.80
resolvePathMethod · 0.80
showDocumentSymbolsMethod · 0.80

Calls 9

getModelFunction · 0.85
ModelIndexFunction · 0.85
hasChildrenMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
isValidMethod · 0.45
toStringMethod · 0.45
parentMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected