From a8fb8956afebfe286bc6dad11b8e1e60037c6463 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 4 Nov 2023 18:08:10 +0300 Subject: =?UTF-8?q?fixes=20#3787=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=D0=BD?= =?UTF-8?q?=D0=B5=D1=81=D0=BA=D0=BE=D0=BB=D1=8C=D0=BA=D0=B8=D1=85=20=D1=81?= =?UTF-8?q?=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20=D1=82=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4?= =?UTF-8?q?=D0=BD=D0=B5=D0=B5=20=D1=86=D0=B8=D1=82=D0=B8=D1=80=D1=83=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D0=B5=D1=82=D1=81=D1=8F=20=D0=B2=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA=D0=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/history_control.cpp | 84 ++++++++++++++++++-------------- plugins/NewStory/src/history_control.h | 1 + 2 files changed, 48 insertions(+), 37 deletions(-) (limited to 'plugins/NewStory') diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index f09d215156..6f8e1934d4 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -267,35 +267,7 @@ void NewstoryListData::ClearSelection(int iFirst, int iLast) void NewstoryListData::Copy(bool bTextOnly) { - CMStringW res; - - int eventCount = totalCount; - for (int i = 0; i < eventCount; i++) { - ItemData *p = GetItem(i); - if (!p->m_bSelected) - continue; - - if (p->m_bOfflineFile) { - DB::EventInfo dbei(p->hEvent); - DB::FILE_BLOB blob(dbei); - if (p->m_bOfflineDownloaded) - res.Append(blob.getLocalName()); - else - res.Append(_A2T(blob.getUrl())); - } - else { - if (bTextOnly) - res.Append(p->wtext); - else { // copy text only - CMStringW wszText(p->formatString()); - RemoveBbcodes(wszText); - res.Append(wszText); - } - } - res.Append(L"\r\n"); - } - - Utils_ClipboardCopy(res); + Utils_ClipboardCopy(GatherSelected(bTextOnly)); } void NewstoryListData::CopyUrl() @@ -455,6 +427,39 @@ void NewstoryListData::FixScrollPosition(bool bForce) } } +CMStringW NewstoryListData::GatherSelected(bool bTextOnly) +{ + CMStringW ret; + + int eventCount = totalCount; + for (int i = 0; i < eventCount; i++) { + ItemData *p = GetItem(i); + if (!p->m_bSelected) + continue; + + if (p->m_bOfflineFile) { + DB::EventInfo dbei(p->hEvent); + DB::FILE_BLOB blob(dbei); + if (p->m_bOfflineDownloaded) + ret.Append(blob.getLocalName()); + else + ret.Append(_A2T(blob.getUrl())); + } + else { + if (bTextOnly) + ret.Append(p->wtext); + else { // copy text only + CMStringW wszText(p->formatString()); + RemoveBbcodes(wszText); + ret.Append(wszText); + } + } + ret.Append(L"\r\n"); + } + + return ret; +} + ItemData* NewstoryListData::GetItem(int idx) const { if (totalCount == 0) @@ -614,12 +619,11 @@ void NewstoryListData::RecalcScrollBar() void NewstoryListData::Quote() { - if (pMsgDlg) - if (auto *pItem = LoadItem(caret)) { - CMStringW wszText(pItem->wtext); - RemoveBbcodes(wszText); - pMsgDlg->SetMessageText(Srmm_Quote(wszText)); - } + if (pMsgDlg) { + CMStringW wszText(GatherSelected(true)); + RemoveBbcodes(wszText); + pMsgDlg->SetMessageText(Srmm_Quote(wszText)); + } } void NewstoryListData::ScheduleDraw() @@ -676,7 +680,12 @@ void NewstoryListData::SetSelection(int iFirst, int iLast) void NewstoryListData::ToggleBookmark() { - if (auto *p = GetItem(caret)) { + int eventCount = totalCount; + for (int i = 0; i < eventCount; i++) { + ItemData *p = GetItem(i); + if (!p->m_bSelected) + continue; + if (p->dbe.flags & DBEF_BOOKMARK) p->dbe.flags &= ~DBEF_BOOKMARK; else @@ -684,8 +693,9 @@ void NewstoryListData::ToggleBookmark() db_event_edit(p->hEvent, &p->dbe); p->setText(); - InvalidateRect(m_hwnd, 0, FALSE); } + + InvalidateRect(m_hwnd, 0, FALSE); } void NewstoryListData::ToggleSelection(int iFirst, int iLast) diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 7e0328532d..6736b63171 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -75,6 +75,7 @@ struct NewstoryListData : public MZeroedObject int FindNext(const wchar_t *pwszText); int FindPrev(const wchar_t *pwszText); void FixScrollPosition(bool bForce = false); + CMStringW GatherSelected(bool bTextOnly); ItemData* GetItem(int idx) const; int GetItemFromPixel(int yPos); int GetItemHeight(int index); -- cgit v1.2.3