From ee7a91629442ba40e876e19e4cdd7af173e8e840 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 25 Dec 2023 14:19:05 +0300 Subject: NewStory: fast fetch()-based version of search (closes #4068 completely) --- plugins/NewStory/src/history_array.cpp | 11 +++++++++-- plugins/NewStory/src/history_control.cpp | 18 +----------------- plugins/NewStory/src/history_control.h | 5 ++--- 3 files changed, 12 insertions(+), 22 deletions(-) (limited to 'plugins') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 7fa979e204..1193f56449 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -54,8 +54,15 @@ bool Filter::check(ItemData *item) const } } - if (flags & (EVENTTEXT | EVENTONLY)) - return CheckFilter(item->getWBuf(), text); + if (flags & (EVENTTEXT | EVENTONLY)) { + if (item->m_bLoaded) + return CheckFilter(item->wtext, text); + + if (!item->fetch()) + return false; + + return CheckFilter(ptrW(DbEvent_GetTextW(&item->dbe, CP_UTF8)), text); + } return true; }; diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index c880bbd57a..32e01076c4 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -57,14 +57,12 @@ void InitHotkeys() NewstoryListData::NewstoryListData(HWND _1) : m_hwnd(_1), - loadTimer(Miranda_GetSystemWindow(), LPARAM(this)), - redrawTimer(Miranda_GetSystemWindow(), LPARAM(this)+1) + redrawTimer(Miranda_GetSystemWindow(), LPARAM(this)) { items.setOwner(_1); bSortAscending = g_plugin.bSortAscending; - loadTimer.OnEvent = Callback(this, &NewstoryListData::onTimer_Load); redrawTimer.OnEvent = Callback(this, &NewstoryListData::onTimer_Draw); } @@ -78,15 +76,6 @@ void NewstoryListData::onTimer_Draw(CTimer *pTimer) InvalidateRect(m_hwnd, 0, FALSE); } -void NewstoryListData::onTimer_Load(CTimer *pTimer) -{ - for (int i = 0; i < 100 && loadCount >= 0; i++) - LoadItem(loadCount--); - - if (loadCount < 0) - pTimer->Stop(); -} - void NewstoryListData::OnContextMenu(int index, POINT pt) { HMENU hMenu = NSMenu_Build(this, (index == -1) ? 0 : LoadItem(index)); @@ -132,11 +121,6 @@ void NewstoryListData::AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCoun ScheduleDraw(); items.addEvent(hContact, hFirstEvent, iCount); totalCount = items.getCount(); - - if (iCount == -1) { - loadCount = totalCount - 1; - loadTimer.Start(50); - } } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 658e351d9d..c60b57a667 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -19,7 +19,7 @@ struct NewstoryListData : public MZeroedObject int cachedWindowWidth = -1, cachedWindowHeight = -1; int cachedMaxDrawnItem = -1; int cachedScrollbarPos = -1, cachedScrollbarMax = -1; - int totalCount, loadCount = -1; + int totalCount; RECT rcLastPaint; @@ -28,14 +28,13 @@ struct NewstoryListData : public MZeroedObject HWND m_hwnd; HWND hwndEditBox; - CTimer redrawTimer, loadTimer; + CTimer redrawTimer; CSrmmBaseDialog *pMsgDlg = nullptr; void OnContextMenu(int index, POINT pt); void OnResize(int newWidth, int newHeight); void onTimer_Draw(CTimer *pTimer); - void onTimer_Load(CTimer *pTimer); void AddChatEvent(SESSION_INFO *si, const LOGINFO *lin); void AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCount); -- cgit v1.2.3