diff options
author | George Hazan <george.hazan@gmail.com> | 2023-11-04 18:08:10 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-11-04 18:08:10 +0300 |
commit | a8fb8956afebfe286bc6dad11b8e1e60037c6463 (patch) | |
tree | aafcda22cb5bc328c314c27b0829bb88ec344802 | |
parent | d601dcad8019dbf76ba4e61833be7d7a24f25d01 (diff) |
fixes #3787 (NewStory: при выделении нескольких сообщений только последнее цитируется и добавляется в закладки)
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 84 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 1 |
2 files changed, 48 insertions, 37 deletions
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); |