summaryrefslogtreecommitdiff
path: root/plugins/QuickSearch
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/QuickSearch')
-rw-r--r--plugins/QuickSearch/src/stdafx.h11
-rw-r--r--plugins/QuickSearch/src/version.h2
-rw-r--r--plugins/QuickSearch/src/window.cpp97
-rw-r--r--plugins/QuickSearch/src/window_misc.cpp13
4 files changed, 101 insertions, 22 deletions
diff --git a/plugins/QuickSearch/src/stdafx.h b/plugins/QuickSearch/src/stdafx.h
index b5089aff12..b03499bb40 100644
--- a/plugins/QuickSearch/src/stdafx.h
+++ b/plugins/QuickSearch/src/stdafx.h
@@ -297,6 +297,10 @@ struct CStatusBarItem : public QSFlags
int liston = 0;
};
+#define WM_CONTACT_ADDED (WM_USER+2)
+#define WM_CONTACT_DELETED (WM_USER+3)
+#define WM_STATUS_CHANGED (WM_USER+4)
+
class QSMainDlg : public CDlgBase
{
friend struct CRowItem;
@@ -308,12 +312,16 @@ class QSMainDlg : public CDlgBase
UI_MESSAGE(WM_SYSCOMMAND, OnSysCommand);
UI_MESSAGE(WM_MOUSEMOVE, OnMouseMove);
UI_MESSAGE(WM_KEYDOWN, OnKeydown);
+ UI_MESSAGE(WM_CONTACT_ADDED, OnContactAdded);
+ UI_MESSAGE(WM_CONTACT_DELETED, OnContactDeleted);
+ UI_MESSAGE(WM_STATUS_CHANGED, OnStatusChanged);
UI_MESSAGE_MAP_END();
// internal methods
void AddColumn(int idx, ColumnItem *pCol);
void AddContactToList(MCONTACT hContact, CRowItem *pRow);
void AdvancedFilter();
+ void ChangeStatusPicture(CRowItem *pRow, MCONTACT hContact, LPARAM lParam);
void ConvertToMeta();
void CopyMultiLines();
void DeleteByList();
@@ -395,6 +403,9 @@ public:
INT_PTR OnSysCommand(UINT, WPARAM, LPARAM);
INT_PTR OnMouseMove(UINT, WPARAM, LPARAM);
INT_PTR OnKeydown(UINT, WPARAM, LPARAM);
+ INT_PTR OnContactAdded(UINT, WPARAM, LPARAM);
+ INT_PTR OnContactDeleted(UINT, WPARAM, LPARAM);
+ INT_PTR OnStatusChanged(UINT, WPARAM, LPARAM);
INT_PTR NewEditProc(UINT, WPARAM, LPARAM);
INT_PTR NewLVProc(UINT, WPARAM, LPARAM);
diff --git a/plugins/QuickSearch/src/version.h b/plugins/QuickSearch/src/version.h
index f9508cadc2..c33e010d53 100644
--- a/plugins/QuickSearch/src/version.h
+++ b/plugins/QuickSearch/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 1
#define __MINOR_VERSION 5
#define __RELEASE_NUM 0
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
diff --git a/plugins/QuickSearch/src/window.cpp b/plugins/QuickSearch/src/window.cpp
index c5ba5e9446..e49a871ec5 100644
--- a/plugins/QuickSearch/src/window.cpp
+++ b/plugins/QuickSearch/src/window.cpp
@@ -17,28 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-#define IDM_STAYONTOP (WM_USER+1)
+#define IDM_STAYONTOP (WM_USER+1)
static QSMainDlg *g_pDlg = 0;
/////////////////////////////////////////////////////////////////////////////////////////
-
-static int OnContactAdded(WPARAM, LPARAM)
-{
- return 0;
-}
-
-static int OnContactDeleted(WPARAM, LPARAM)
-{
- return 0;
-}
-
-static int OnStatusChanged(WPARAM, LPARAM)
-{
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// edit control window procedure
static LRESULT CALLBACK sttNewEditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -478,9 +461,9 @@ bool QSMainDlg::OnInitDialog()
ti.uId = UINT_PTR(m_grid.GetHwnd());
SendMessageW(HintWnd, TTM_ADDTOOLW, 0, LPARAM(&ti));
- hAdd = HookEvent(ME_DB_CONTACT_ADDED, &OnContactAdded);
- hDelete = HookEvent(ME_DB_CONTACT_DELETED, &OnContactDeleted);
- hChange = HookEvent(ME_CLIST_CONTACTICONCHANGED, &OnStatusChanged);
+ hAdd = HookEventMessage(ME_DB_CONTACT_ADDED, m_hwnd, WM_CONTACT_ADDED);
+ hDelete = HookEventMessage(ME_DB_CONTACT_DELETED, m_hwnd, WM_CONTACT_DELETED);
+ hChange = HookEventMessage(ME_CLIST_CONTACTICONCHANGED, m_hwnd, WM_STATUS_CHANGED);
return true;
}
@@ -531,6 +514,78 @@ int QSMainDlg::Resizer(UTILRESIZECONTROL *urc)
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// event handlers
+
+INT_PTR QSMainDlg::OnContactAdded(UINT, WPARAM hContact, LPARAM)
+{
+ auto *pRow = new CRowItem(hContact, this);
+ m_rows.insert(pRow);
+ AddContactToList(hContact, pRow);
+ ProcessLine(pRow);
+ Sort();
+ UpdateSB();
+ return 0;
+}
+
+INT_PTR QSMainDlg::OnContactDeleted(UINT, WPARAM hContact, LPARAM)
+{
+ int idx = -1;
+ CRowItem *pRow = 0;
+
+ for (auto &it : m_rows)
+ if (it->hContact == hContact) {
+ pRow = it;
+ idx = m_rows.indexOf(&it);
+ break;
+ }
+
+ if (idx == -1)
+ return 0;
+
+ int iItem = FindItem(pRow);
+ if (iItem != -1)
+ m_grid.DeleteItem(iItem);
+
+ m_rows.remove(idx);
+ UpdateSB();
+ return 0;
+}
+
+INT_PTR QSMainDlg::OnStatusChanged(UINT, WPARAM hContact, LPARAM lParam)
+{
+ auto *pRow = FindRow(hContact);
+ if (pRow == nullptr)
+ return 0;
+
+ int oldStatus = pRow->status;
+ int newStatus = Contact_GetStatus(hContact);
+ pRow->status = newStatus;
+
+ if (oldStatus != ID_STATUS_OFFLINE && newStatus != ID_STATUS_OFFLINE)
+ ChangeStatusPicture(pRow, hContact, lParam);
+ else if (oldStatus != ID_STATUS_OFFLINE) {
+ if (g_plugin.m_flags & QSO_SHOWOFFLINE)
+ ChangeStatusPicture(pRow, hContact, lParam);
+ else
+ ProcessLine(pRow, true);
+ }
+ else if (newStatus != ID_STATUS_OFFLINE) {
+ if (g_plugin.m_flags & QSO_SHOWOFFLINE)
+ ChangeStatusPicture(pRow, hContact, lParam);
+ else {
+ pRow->bActive = false;
+ m_grid.DeleteItem(FindItem(pRow));
+ }
+ }
+
+ if (g_plugin.m_flags & QSO_SORTBYSTATUS)
+ Sort();
+
+ UpdateSB();
+ return 0;
+}
+
INT_PTR QSMainDlg::OnSysCommand(UINT, WPARAM wParam, LPARAM)
{
if (wParam == IDM_STAYONTOP) {
diff --git a/plugins/QuickSearch/src/window_misc.cpp b/plugins/QuickSearch/src/window_misc.cpp
index 8caaa6066f..a0f75b4201 100644
--- a/plugins/QuickSearch/src/window_misc.cpp
+++ b/plugins/QuickSearch/src/window_misc.cpp
@@ -165,6 +165,19 @@ void QSMainDlg::AdvancedFilter()
UpdateSB();
}
+void QSMainDlg::ChangeStatusPicture(CRowItem *pRow, MCONTACT hContact, LPARAM lParam)
+{
+ int idx = FindItem(pRow);
+ if (idx == -1)
+ return;
+
+ LV_ITEMW li = {};
+ li.iItem = idx;
+ li.mask = LVIF_IMAGE;
+ li.iImage = lParam; //CallService(MS_CLIST_GETCONTACTICON,hContact,0);
+ m_grid.SetItem(&li);
+}
+
void QSMainDlg::CopyMultiLines()
{
CMStringW buf;