| 829 | } |
| 830 | |
| 831 | ModelIndex 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 | |
| 870 | ModelIndex UITreeView::openRowWithPath( std::string path, bool selectOpenedRow ) { |
| 871 | String::replaceAll( path, "\\", "/" ); |
no test coverage detected