|
7 | 7 | #include "LogManager.h" |
8 | 8 | #include "MachinePidTidTreeView.h" |
9 | 9 | #include "DialogGoTo.h" |
| 10 | +#include "DialogSameFilesList.h" |
| 11 | + |
10 | 12 | #include <ftlShell.h> |
11 | 13 | #include <regex> |
12 | 14 |
|
@@ -59,8 +61,9 @@ CLogItemView::~CLogItemView() |
59 | 61 | } |
60 | 62 |
|
61 | 63 | BEGIN_MESSAGE_MAP(CLogItemView, CListView) |
62 | | - ON_COMMAND_EX(ID_EDIT_GOTO, &CLogItemView::OnEditGoTo) |
63 | | - ON_NOTIFY(HDN_ITEMCLICK, 0, &CLogItemView::OnHdnItemclickListAllLogitems) |
| 64 | + ON_COMMAND_EX(ID_EDIT_GOTO, &CLogItemView::OnEditGoTo) |
| 65 | + ON_COMMAND_EX(ID_EDIT_CLEAR_CACHE, &CLogItemView::OnEditClearCache) |
| 66 | + ON_NOTIFY(HDN_ITEMCLICK, 0, &CLogItemView::OnHdnItemclickListAllLogitems) |
64 | 67 | //ON_NOTIFY_RANGE(LVN_COLUMNCLICK,0,0xffff,OnColumnClick) |
65 | 68 | //ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnGetdispinfo) |
66 | 69 | ON_NOTIFY_REFLECT(NM_CLICK, &CLogItemView::OnNMClick) |
@@ -485,39 +488,62 @@ void CLogItemView::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult) |
485 | 488 | } |
486 | 489 | if (!strFileName.IsEmpty() && line != 0) |
487 | 490 | { |
488 | | - TCHAR szPathFull[MAX_PATH] = {0}; |
489 | | - if (PathIsRelative(strFileName)) |
490 | | - { |
491 | | - if (rLogManager.NeedScanSourceFiles()) |
492 | | - { |
493 | | - CString strExistSourceDir = AfxGetApp()->GetProfileString(SECTION_CONFIG, ENTRY_SOURCE_DIR); |
| 491 | + TCHAR szPathFull[MAX_PATH] = { 0 }; |
| 492 | + |
| 493 | + //优先在缓存里面查找(主要是减少 重复文件时的选择问题), 如果有, 则直接使用, 否则再走后面的逻辑 |
| 494 | + CString strFileLineCache; |
| 495 | + strFileLineCache.Format(TEXT("%s:%d"), strFileName, line); |
| 496 | + CString strFullPathFromUserCache = rLogManager.GetFullPathFromUserCache(strFileLineCache); |
| 497 | + if (!strFullPathFromUserCache.IsEmpty()) |
| 498 | + { |
| 499 | + StringCchCopy(szPathFull, _countof(szPathFull), strFullPathFromUserCache); |
| 500 | + } |
| 501 | + else { |
| 502 | + if (PathIsRelative(strFileName)) |
| 503 | + { |
| 504 | + if (rLogManager.NeedScanSourceFiles()) |
| 505 | + { |
| 506 | + CString strExistSourceDir = AfxGetApp()->GetProfileString(SECTION_CONFIG, ENTRY_SOURCE_DIR); |
| 507 | + |
| 508 | + CFDirBrowser dirBrowser(TEXT("Choose Project Source Root Path"), m_hWnd, strExistSourceDir); |
| 509 | + if (dirBrowser.DoModal()) |
| 510 | + { |
| 511 | + CString strFolderPath = dirBrowser.GetSelectPath(); |
| 512 | + AfxGetApp()->WriteProfileString(SECTION_CONFIG, ENTRY_SOURCE_DIR, strFolderPath); |
| 513 | + rLogManager.ScanSourceFiles(strFolderPath); |
| 514 | + } |
| 515 | + } |
| 516 | + |
| 517 | + SameNameFilePathListPtr spFilePathList = rLogManager.FindFileFullPath(ATLPath::FindFileName(strFileName)); |
| 518 | + if (spFilePathList != nullptr) |
| 519 | + { |
| 520 | + int nSameFileNameCount = spFilePathList->size(); |
| 521 | + if (nSameFileNameCount > 1) |
| 522 | + { |
| 523 | + FTLTRACEEX(FTL::tlWarn, TEXT("find %d source files with %s"), nSameFileNameCount, strFileName); |
| 524 | + CDialogSameFilesList dlgSameFilesList(spFilePathList); |
| 525 | + if (IDOK == dlgSameFilesList.DoModal()) |
| 526 | + { |
| 527 | + StringCchCopy(szPathFull, _countof(szPathFull), dlgSameFilesList.GetSelectFilePath()); |
| 528 | + rLogManager.SetFullPathForUserCache(strFileLineCache, szPathFull); |
| 529 | + } |
| 530 | + } |
| 531 | + if (szPathFull[0] == TEXT('\0')) |
| 532 | + { |
| 533 | + StringCchCopy(szPathFull, _countof(szPathFull), spFilePathList->front()); |
| 534 | + } |
| 535 | + //TODO: if there are more than one file with same name, then prompt user choose |
| 536 | + |
| 537 | + } |
| 538 | + } |
| 539 | + else |
| 540 | + { |
| 541 | + StringCchCopy(szPathFull, _countof(szPathFull), strFileName); |
| 542 | + } |
| 543 | + } |
494 | 544 |
|
495 | | - CFDirBrowser dirBrowser(TEXT("Choose Project Source Root Path"), m_hWnd, strExistSourceDir); |
496 | | - if (dirBrowser.DoModal()) |
497 | | - { |
498 | | - CString strFolderPath = dirBrowser.GetSelectPath(); |
499 | | - AfxGetApp()->WriteProfileString(SECTION_CONFIG, ENTRY_SOURCE_DIR, strFolderPath); |
500 | | - rLogManager.ScanSourceFiles(strFolderPath); |
501 | | - } |
502 | | - } |
503 | | - |
504 | | - SameNameFilePathListPtr spFilePathList = rLogManager.FindFileFullPath(ATLPath::FindFileName(strFileName)); |
505 | | - if (spFilePathList != nullptr) |
506 | | - { |
507 | | - int nSameFileNameCount = spFilePathList->size(); |
508 | | - if (nSameFileNameCount > 1) |
509 | | - { |
510 | | - FTLTRACEEX(FTL::tlWarn, TEXT("find %d source files with %s"), nSameFileNameCount, strFileName); |
511 | | - } |
512 | | - //TODO: if there are more than one file with same name, then prompt user choose |
513 | | - StringCchCopy(szPathFull, _countof(szPathFull), spFilePathList->front()); |
514 | | - } |
515 | | - } |
516 | | - else |
517 | | - { |
518 | | - StringCchCopy(szPathFull, _countof(szPathFull), strFileName); |
519 | | - } |
520 | 545 | CString path(szPathFull); |
| 546 | + FTLASSERT(!path.IsEmpty()); |
521 | 547 | if (!path.IsEmpty()) |
522 | 548 | { |
523 | 549 | path.Replace(_T('/'), _T('\\')); |
@@ -910,3 +936,10 @@ BOOL CLogItemView::OnEditGoTo(UINT nID) |
910 | 936 | } |
911 | 937 | return bRet; |
912 | 938 | } |
| 939 | + |
| 940 | +BOOL CLogItemView::OnEditClearCache(UINT nID) |
| 941 | +{ |
| 942 | + CLogManager& logManager = GetDocument()->m_FTLogManager; |
| 943 | + logManager.ClearUserFullPathCache(); |
| 944 | + return TRUE; |
| 945 | +} |
0 commit comments