diff --git a/qa/tools/pns/pns_log_viewer_frame.cpp b/qa/tools/pns/pns_log_viewer_frame.cpp index e9870fd2b8..8bf9d3b120 100644 --- a/qa/tools/pns/pns_log_viewer_frame.cpp +++ b/qa/tools/pns/pns_log_viewer_frame.cpp @@ -153,6 +153,7 @@ PNS_LOG_VIEWER_FRAME::PNS_LOG_VIEWER_FRAME( wxFrame* frame ) : wxITEM_NORMAL ); m_listPopupMenu->Append( ID_LIST_SHOW_ALL, wxT( "Show all" ), wxT( "" ), wxITEM_NORMAL ); m_listPopupMenu->Append( ID_LIST_SHOW_NONE, wxT( "Show none" ), wxT( "" ), wxITEM_NORMAL ); + m_listPopupMenu->Append( ID_LIST_DISPLAY_LINE, wxT( "Go to line in vs code" ), wxT( "" ), wxITEM_NORMAL ); m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_ITEM_CONTEXT_MENU, wxMouseEventHandler( PNS_LOG_VIEWER_FRAME::onListRightClick ), nullptr, @@ -601,7 +602,27 @@ void PNS_LOG_VIEWER_FRAME::onListRightClick( wxMouseEvent& event ) return; } + case ID_LIST_DISPLAY_LINE: + { + wxVector selectedItems; + + if( m_itemList->GetSelections( selectedItems ) == 1 ) + { + wxString filename = m_itemList->GetItemText(selectedItems.back(), 2); + wxString line = m_itemList->GetItemText(selectedItems.back(), 4); + + //todo: add IDE selection somewhere in the GUI + // clion: + //wxExecute( wxString::Format( "clion --line %s %s", line, m_filenameToPathMap[filename] ) ); + + if( !filename.empty() && !line.empty() ) + wxExecute( wxString::Format("code --goto %s:%s", m_filenameToPathMap[filename], line) ); + } + + return; } + } + return; } @@ -726,7 +747,13 @@ void PNS_LOG_VIEWER_FRAME::buildListTree( wxTreeListItem item, m_itemList->SetItemText( ritem, 1, ent->m_name ); } - m_itemList->SetItemText( ritem, 2, wxFileNameFromPath( ent->m_srcLoc.fileName ) ); + wxString fullfilepath = ent->m_srcLoc.fileName; + wxString filename = wxFileNameFromPath( fullfilepath ); + + if( !filename.empty() ) + m_filenameToPathMap.insert( { filename, fullfilepath } ); + + m_itemList->SetItemText( ritem, 2, filename ); m_itemList->SetItemText( ritem, 3, ent->m_srcLoc.funcName ); m_itemList->SetItemText( ritem, 4, wxString::Format("%d", ent->m_srcLoc.line ) ); diff --git a/qa/tools/pns/pns_log_viewer_frame.h b/qa/tools/pns/pns_log_viewer_frame.h index 924d97610d..aa6d169e53 100644 --- a/qa/tools/pns/pns_log_viewer_frame.h +++ b/qa/tools/pns/pns_log_viewer_frame.h @@ -42,6 +42,7 @@ #define ID_LIST_COPY 10001 #define ID_LIST_SHOW_ALL 10002 #define ID_LIST_SHOW_NONE 10003 +#define ID_LIST_DISPLAY_LINE 10004 class PNS_LOG_VIEWER_OVERLAY; @@ -89,6 +90,7 @@ private: int m_rewindIter; wxMenu* m_listPopupMenu; std::shared_ptr m_previewItems; + std::map m_filenameToPathMap; bool m_showThinLines = true; bool m_showRPIs = true;