From 120b68869dab681e9c2360cd2b3905ee3a7ecf4a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 11 Sep 2024 18:21:26 +0300 Subject: =?UTF-8?q?fixes=20#4649=20(NewStory:=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=81?= =?UTF-8?q?=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=D0=B7?= =?UTF-8?q?=20=D0=B8=D1=81=D1=82=D0=BE=D1=80=D0=B8=D0=B8=20(=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=D0=BA=D1=82=D0=B0,=20=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=8B,=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=B8=D1=81=D1=82=D0=BE=D1=80=D0=B8=D0=B8=20=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D0=B2=D1=81=D0=B5=D0=B9=20=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=B8)=20=D0=B8=20=D0=BE=D1=82=D0=BA=D1=80?= =?UTF-8?q?=D1=8B=D1=82=D0=BE=D0=BC=20=D0=B4=D0=B5=D1=80=D0=B5=D0=B2=D0=B5?= =?UTF-8?q?=20=D0=B4=D0=B0=D1=82=20=D0=B2=D1=81=D1=82=D0=B0=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BD=D0=B0=20=D0=B4=D0=B0=D1=82=D1=83=20=D1=81?= =?UTF-8?q?=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/history.h | 1 + plugins/NewStory/src/history_control.cpp | 6 ++++- plugins/NewStory/src/history_dlg.cpp | 46 ++++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/NewStory/src/history.h b/plugins/NewStory/src/history.h index 1a60805f59..84d3169f0f 100644 --- a/plugins/NewStory/src/history.h +++ b/plugins/NewStory/src/history.h @@ -27,6 +27,7 @@ enum UM_GET_EVENT_CONTACT, UM_BOOKMARKS = WM_USER + 0x601, + UM_LOCATETIME = WM_USER + 0x602, }; extern MWindowList g_hNewstoryWindows, g_hNewstoryLogs; diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index c8744915a6..9d3f85cf61 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -888,7 +888,11 @@ void NewstoryListData::ScheduleDraw() void NewstoryListData::SetCaret(int idx, bool bEnsureVisible) { if (idx < totalCount) { - caret = idx; + if (idx != caret) { + caret = idx; + PostMessage(GetParent(m_hwnd), UM_LOCATETIME, caret, 0); + } + if (bEnsureVisible) EnsureVisible(idx); } diff --git a/plugins/NewStory/src/history_dlg.cpp b/plugins/NewStory/src/history_dlg.cpp index de4b4567fd..eb239d100e 100644 --- a/plugins/NewStory/src/history_dlg.cpp +++ b/plugins/NewStory/src/history_dlg.cpp @@ -321,7 +321,7 @@ class CHistoryDlg : public CDlgBase if (CurYear != PrevYear) { _itow(CurYear, buf, 10); tvi.item.pszText = buf; - tvi.item.lParam = 0; + tvi.item.lParam = CurYear; hCurYear = TreeView_InsertItem(m_timeTree.GetHwnd(), &tvi); PrevYear = CurYear; } @@ -336,7 +336,7 @@ class CHistoryDlg : public CDlgBase _itow(CurDay, buf, 10); tvi.hParent = hCurMonth; tvi.item.pszText = buf; - tvi.item.lParam = 0; + tvi.item.lParam = CurDay; hCurDay = TreeView_InsertItem(m_timeTree.GetHwnd(), &tvi); PrevDay = CurDay; } @@ -346,6 +346,41 @@ class CHistoryDlg : public CDlgBase m_timeTree.SelectItem(root); } + HTREEITEM FindSibling(HTREEITEM root, int value) + { + if (root) { + if (value < 1000) + root = m_timeTree.GetChild(root); + + for (HTREEITEM hti = root; hti; hti = m_timeTree.GetNextSibling(hti)) { + TVITEMEX tvi; + tvi.mask = TVIF_PARAM; + m_timeTree.GetItem(hti, &tvi); + if (tvi.lParam == value) + return hti; + } + } + + return nullptr; + } + + void LocateDateTime(int iTimestamp) + { + struct tm ts = { 0 }; + time_t timestamp = iTimestamp; + errno_t err = localtime_s(&ts, ×tamp); /* statically alloced, local time correction */ + if (err != 0) + return; + + HTREEITEM hti = FindSibling(m_timeTree.GetRoot(), ts.tm_year + 1900); + hti = FindSibling(hti, ts.tm_mon + 1); + hti = FindSibling(hti, ts.tm_mday); + if (hti) { + disableTimeTreeChange = true; + m_timeTree.SelectItem(hti); + } + } + CSplitter splitTime; CCtrlEdit edtSearchText; CCtrlMButton btnUserInfo, btnSendMsg, btnUserMenu, btnCopy, btnOptions, btnFilter; @@ -1113,6 +1148,13 @@ public: case WM_USER + 0x600: if (wParam) m_histWindow.SendMsg(NSM_SEEKTIME, wParam, 0); + break; + + case UM_LOCATETIME: + if (m_dwOptions & WND_OPT_TIMETREE) + if (auto *pItem = m_histCtrl->GetItem(wParam)) + LocateDateTime(pItem->dbe.timestamp); + break; } return CDlgBase::DlgProc(msg, wParam, lParam); -- cgit v1.2.3