From bd8e76b932dc7ec988d0f41e5204f54eeebe1069 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 8 Aug 2023 16:10:18 +0300 Subject: =?UTF-8?q?fixes=20#3621=20(NewStory:=20=D1=88=D0=B0=D0=B1=D0=BB?= =?UTF-8?q?=D0=BE=D0=BD=20=D1=81=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8=D1=8E=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B3=D0=BB=D1=8F=D0=B4=D0=B8=D1=82=20=D1=83=D0=B6=D0=B0?= =?UTF-8?q?=D1=81=D0=BD=D0=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/history_array.cpp | 47 ++++++++++++++++++++++++---------- plugins/NewStory/src/history_array.h | 10 +++++++- plugins/NewStory/src/templates.cpp | 7 +++-- plugins/NewStory/src/templates.h | 1 + 4 files changed, 49 insertions(+), 16 deletions(-) (limited to 'plugins/NewStory/src') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index bd12438503..6b3f34d4de 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -49,6 +49,7 @@ bool Filter::check(ItemData *item) const ItemData::ItemData() { memset(this, 0, sizeof(*this)); + m_grouping = g_plugin.bMsgGrouping ? -1 : GROUPING_NONE; savedHeight = -1; } @@ -59,27 +60,41 @@ ItemData::~ItemData() MTextDestroy(data); } +void ItemData::checkPrev() +{ + // not set yet + if (m_grouping != (uint8_t)-1) + return; + + m_grouping = GROUPING_NONE; + if (!pPrev) + return; + + // we don't group anything but messages + load(false); + if (dbe.eventType != EVENTTYPE_MESSAGE) + return; + + pPrev->load(false); + if (pPrev->hContact == hContact && pPrev->dbe.eventType == dbe.eventType && (pPrev->dbe.flags & DBEF_SENT) == (dbe.flags & DBEF_SENT)) { + if (pPrev->m_grouping != GROUPING_ITEM) { + pPrev->m_grouping = GROUPING_HEAD; + pPrev->setText(); + } + m_grouping = GROUPING_ITEM; + } +} + void ItemData::checkCreate(HWND hwnd) { if (data == nullptr) { + checkPrev(); setText(); MTextSetParent(data, hwnd); MTextActivate(data, true); } } -bool ItemData::isGrouped() const -{ - if (pPrev && g_plugin.bMsgGrouping) { - if (!pPrev->m_bLoaded) - pPrev->load(true); - - if (pPrev->hContact == hContact && (pPrev->dbe.flags & DBEF_SENT) == (dbe.flags & DBEF_SENT)) - return true; - } - return false; -} - bool ItemData::isLink(POINT pt, CMStringW &url) const { int cp = MTextSendMessage(0, data, EM_CHARFROMPOS, 0, LPARAM(&pt)); @@ -127,7 +142,13 @@ bool ItemData::isLinkChar(int idx) const int ItemData::getTemplate() const { switch (dbe.eventType) { - case EVENTTYPE_MESSAGE: return isGrouped() ? TPL_MSG_GRP : TPL_MESSAGE; + case EVENTTYPE_MESSAGE: + switch (m_grouping) { + case GROUPING_HEAD: return TPL_MSG_HEAD; + case GROUPING_ITEM: return TPL_MSG_GRP; + } + return TPL_MESSAGE; + case EVENTTYPE_FILE: return TPL_FILE; case EVENTTYPE_STATUSCHANGE: return TPL_SIGN; case EVENTTYPE_AUTHREQUEST: return TPL_AUTH; diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 8f24cd49dc..d7e55433fa 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -1,6 +1,13 @@ #ifndef __history_array__ #define __history_array__ +enum +{ + GROUPING_NONE = 0, + GROUPING_HEAD = 1, + GROUPING_ITEM = 2, +}; + struct ItemData { MCONTACT hContact; @@ -10,6 +17,7 @@ struct ItemData bool m_bSelected; bool m_bLoaded; bool m_bOfflineFile, m_bOfflineDownloaded; + uint8_t m_grouping; int savedTop, savedHeight; @@ -23,11 +31,11 @@ struct ItemData ItemData(); ~ItemData(); + void checkPrev(); void checkCreate(HWND hwnd); void setText(); void load(bool bFullLoad); - bool isGrouped() const; bool isLink(POINT pt, CMStringW &url) const; bool isLinkChar(int idx) const; diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index ee0375e595..451342034e 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -307,10 +307,13 @@ TemplateInfo templates[TPL_COUNT] = { vfGlobal, vfContact, 0, 0, 0 } }, { "tpl/msglog/msg", LPGENW("Message log"), IDI_SENDMSG, LPGENW("Messages"), - L"%I%i%B[b][color=red]%N[/color], %t:[/b]\x0d\x0a%M", 0, 0, + L"%I%i%B[b]%N, %t:[/b]\r\n%M", 0, 0, + { vfGlobal, vfContact, vfEvent, vfMessage, 0 } }, + { "tpl/msglog/msg_head", LPGENW("Message log"), IDI_SENDMSG, LPGENW("Group head"), + L"%I%i%B[b]%N, %t:[/b] %M", 0, 0, { vfGlobal, vfContact, vfEvent, vfMessage, 0 } }, { "tpl/msglog/msg_grp", LPGENW("Message log"), IDI_SENDMSG, LPGENW("Grouped messages"), - L"%I%i%B[b]%t:[/b] %M", 0, 0, + L"%I%i%B[b]%h:%m:%s:[/b] %M", 0, 0, { vfGlobal, vfContact, vfEvent, vfMessage, 0 } }, { "tpl/msglog/file", LPGENW("Message log"), -SKINICON_EVENT_FILE, LPGENW("Files"), L"%I%i%B[b]%N, %t:[/b]%n%M", 0, 0, diff --git a/plugins/NewStory/src/templates.h b/plugins/NewStory/src/templates.h index 2368aa731b..a2564940c4 100644 --- a/plugins/NewStory/src/templates.h +++ b/plugins/NewStory/src/templates.h @@ -51,6 +51,7 @@ enum TPL_TITLE, TPL_MESSAGE, + TPL_MSG_HEAD, TPL_MSG_GRP, TPL_FILE, TPL_SIGN, -- cgit v1.2.3