diff options
-rw-r--r-- | plugins/NewStory/res/resource.rc | 2 | ||||
-rw-r--r-- | plugins/NewStory/res/users.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | plugins/NewStory/src/history_dlg.cpp | 72 | ||||
-rw-r--r-- | plugins/NewStory/src/main.cpp | 1 | ||||
-rw-r--r-- | plugins/NewStory/src/resource.h | 1 | ||||
-rw-r--r-- | plugins/NewStory/src/stdafx.h | 4 |
6 files changed, 69 insertions, 11 deletions
diff --git a/plugins/NewStory/res/resource.rc b/plugins/NewStory/res/resource.rc index 759e388f1d..751b909cf0 100644 --- a/plugins/NewStory/res/resource.rc +++ b/plugins/NewStory/res/resource.rc @@ -70,6 +70,8 @@ IDI_TIMETREE ICON "timetree.ico" IDI_OK ICON "ok.ico" +IDI_USERS ICON "users.ico" + ///////////////////////////////////////////////////////////////////////////// // diff --git a/plugins/NewStory/res/users.ico b/plugins/NewStory/res/users.ico Binary files differnew file mode 100644 index 0000000000..8198530f99 --- /dev/null +++ b/plugins/NewStory/res/users.ico diff --git a/plugins/NewStory/src/history_dlg.cpp b/plugins/NewStory/src/history_dlg.cpp index f6e4026a79..f4f6689ac1 100644 --- a/plugins/NewStory/src/history_dlg.cpp +++ b/plugins/NewStory/src/history_dlg.cpp @@ -125,6 +125,7 @@ class CHistoryDlg : public CDlgBase // bookmarks HIMAGELIST hBookmarksIcons = 0; + std::map<MCONTACT, std::vector<MEVENT>> m_events; // for filtered events // searchbar HWND m_hwndBtnCloseSearch; @@ -298,15 +299,52 @@ class CHistoryDlg : public CDlgBase ImageList_Destroy(hBookmarksIcons); hBookmarksIcons = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 1, 0); - ImageList_ReplaceIcon(hBookmarksIcons, -1, g_plugin.getIcon(IDI_BOOKMARK)); m_bookmarks.SetImageList(hBookmarksIcons, LVSIL_SMALL); - auto &pArray = m_histCtrl->items; - int numItems = pArray.getCount(); - for (int i = numItems - 1; i >= 0; i--) - if (auto *pItem = pArray.get(i, true)) - if (pItem->dbe.flags & DBEF_BOOKMARK) - m_bookmarks.AddItem(pItem->wtext, 0, i); + if (m_hContact == INVALID_CONTACT_ID) { + auto *pDB = db_get_current(); + + int iIconId = ImageList_ReplaceIcon(hBookmarksIcons, -1, g_plugin.getIcon(IDI_USERS)); + m_bookmarks.AddItem(TranslateT("All results"), iIconId, INVALID_CONTACT_ID); + + std::map<char *, int> protoMap; + + for (auto &cc : Contacts()) { + bool bAdded = false; + DB::ECPTR pCursor(pDB->EventCursor(cc, 0)); + while (MEVENT hEvent = pCursor.FetchNext()) { + DB::EventInfo dbei(hEvent, false); + if (dbei && dbei.flags & DBEF_BOOKMARK) { + if (!bAdded) { + auto *pa = Proto_GetContactAccount(cc); + char *szProto = (pa == nullptr) ? "SomeShit" : pa->szModuleName; + auto pProto = protoMap.find(szProto); + + if (pProto == protoMap.end()) { + iIconId = ImageList_ReplaceIcon(hBookmarksIcons, -1, Skin_LoadProtoIcon(szProto, ID_STATUS_ONLINE)); + protoMap[szProto] = iIconId; + } + else iIconId = (*pProto).second; + + m_bookmarks.AddItem(Clist_GetContactDisplayName(cc, 0), iIconId, cc); + bAdded = true; + } + + m_events[cc].push_back(hEvent); + } + } + } + } + else { + ImageList_ReplaceIcon(hBookmarksIcons, -1, g_plugin.getIcon(IDI_BOOKMARK)); + + auto &pArray = m_histCtrl->items; + int numItems = pArray.getCount(); + for (int i = 0; i < numItems; i++) + if (auto *pItem = pArray.get(i, true)) + if (pItem->dbe.flags & DBEF_BOOKMARK) + m_bookmarks.AddItem(pItem->wtext, 0, i); + } } void BuildTimeTree() @@ -421,7 +459,7 @@ public: m_toolbar.push_back(Button(btnOptions, Button::RIGHT)); m_timeTree.OnSelChanged = Callback(this, &CHistoryDlg::onSelChanged_TimeTree); - m_bookmarks.OnClick = m_bookmarks.OnItemChanging = Callback(this, &CHistoryDlg::onSelChanged_Bookmarks); + m_bookmarks.OnItemChanged = Callback(this, &CHistoryDlg::onSelChanged_Bookmarks); edtSearchText.OnChange = Callback(this, &CHistoryDlg::onChange_SearchText); @@ -564,11 +602,12 @@ public: m_histCtrl->AddEvent(m_hContact, 0, -1); BuildTimeTree(); - BuildBookmarksList(); SetFocus(m_histWindow.GetHwnd()); } else Utils_RestoreWindowPosition(m_hwnd, 0, MODULENAME, "glb_"); + BuildBookmarksList(); + m_histCtrl->SetContact(m_hContact); m_histCtrl->ScrollBottom(); @@ -1137,7 +1176,20 @@ public: void onSelChanged_Bookmarks(CCtrlListView::TEventInfo *ev) { - m_histCtrl->SetPos(m_bookmarks.GetItemData(ev->nmlv->iItem)); + int idx = m_bookmarks.GetItemData(ev->nmlv->iItem); + + if (m_hContact == INVALID_CONTACT_ID) { + m_histCtrl->Clear(); + + if (idx == INVALID_CONTACT_ID) { + for (auto &cc : m_events) + for (auto &hEvent : cc.second) + m_histCtrl->AddEvent(cc.first, hEvent, 1); + } + else for (auto &hEvent : m_events[idx]) + m_histCtrl->AddEvent(idx, hEvent, 1); + } + else m_histCtrl->SetPos(idx); } void onSelChanged_TimeTree(CCtrlTreeView::TEventInfo *) diff --git a/plugins/NewStory/src/main.cpp b/plugins/NewStory/src/main.cpp index d744d8435e..9f02dd23e4 100644 --- a/plugins/NewStory/src/main.cpp +++ b/plugins/NewStory/src/main.cpp @@ -76,6 +76,7 @@ static IconItem icons[] = { LPGEN("Find next"), "findnext", IDI_FINDNEXT }, { LPGEN("Jump to date"), "calendar", IDI_CALENDAR }, { LPGEN("Conversations"), "timetree", IDI_TIMETREE }, + { LPGEN("All results"), "users", IDI_USERS }, { LPGEN("Template group"), "tplgroup", IDI_TPLGROUP }, { LPGEN("Cancel edit"), "reset", IDI_RESET }, diff --git a/plugins/NewStory/src/resource.h b/plugins/NewStory/src/resource.h index 135868d80f..647d4d360c 100644 --- a/plugins/NewStory/src/resource.h +++ b/plugins/NewStory/src/resource.h @@ -27,6 +27,7 @@ #define IDI_CALENDAR 124 #define IDI_TPLGROUP 125 #define IDI_RESET 126 +#define IDI_USERS 127 #define IDI_VARHELP 128 #define IDI_TIMETREE 129 #define IDC_USERINFO 1000 diff --git a/plugins/NewStory/src/stdafx.h b/plugins/NewStory/src/stdafx.h index 788d00b3f3..56a9d9889a 100644 --- a/plugins/NewStory/src/stdafx.h +++ b/plugins/NewStory/src/stdafx.h @@ -28,6 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <Shlwapi.h> #include <malloc.h> +#include <map> + //Miranda headers #include <newpluginapi.h> #include <m_button.h> @@ -35,7 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_clc.h> #include <m_clistint.h> #include <m_contacts.h> -#include <m_database.h> +#include <m_db_int.h> #include <m_file.h> #include <m_fontservice.h> #include <m_history.h> |