summaryrefslogtreecommitdiff
path: root/plugins/NewStory/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-09-11 18:21:26 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-09-11 18:21:26 +0300
commit120b68869dab681e9c2360cd2b3905ee3a7ecf4a (patch)
tree441f0ee6935a800892d3c947687e4ea1f56ea124 /plugins/NewStory/src
parent89b201f63f600d303b4f7b5bd2a6c199c4964d85 (diff)
fixes #4649 (NewStory: при выделении сообщения из истории (контакта, меты, системной истории или глобального поиска по всей истории) и открытом дереве дат вставать на дату сообщения)
Diffstat (limited to 'plugins/NewStory/src')
-rw-r--r--plugins/NewStory/src/history.h1
-rw-r--r--plugins/NewStory/src/history_control.cpp6
-rw-r--r--plugins/NewStory/src/history_dlg.cpp46
3 files changed, 50 insertions, 3 deletions
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, &timestamp); /* 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);