summaryrefslogtreecommitdiff
path: root/plugins/Msg_Export/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-07-21 18:55:43 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-07-21 18:55:43 +0300
commitd472fe01dd600ff638cb8cbd2aec0d35e9f473ce (patch)
tree91b359a35b7198457fd841f3df47b75d6d07466e /plugins/Msg_Export/src
parent47687c2f661b8a0515f8624caa513a72b29cbb9a (diff)
fixes #1743 (Msg_Export: add "Select none" and "Select all" to context menu)
Diffstat (limited to 'plugins/Msg_Export/src')
-rwxr-xr-xplugins/Msg_Export/src/options.cpp66
-rwxr-xr-xplugins/Msg_Export/src/resource.h10
-rw-r--r--plugins/Msg_Export/src/version.h2
3 files changed, 40 insertions, 38 deletions
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp
index 0d795588bf..162929d257 100755
--- a/plugins/Msg_Export/src/options.cpp
+++ b/plugins/Msg_Export/src/options.cpp
@@ -404,7 +404,6 @@ public:
class CContactsOptDlg : public CDlgBase
{
- CCtrlButton btnExportAll, btnExportSel, btnUserDetails, btnAutoFileName, btnClearAll, btnSetDefault;
CCtrlListView listUsers;
CCtrlHyperlink urlHelp;
@@ -412,25 +411,13 @@ public:
CContactsOptDlg() :
CDlgBase(g_plugin, IDD_OPT_CONTACTS),
urlHelp(this, IDC_OPEN_HELP, "https://miranda-ng.org/p/Msg_Export/"),
- listUsers(this, IDC_MAP_USER_LIST),
- btnClearAll(this, IDC_CLEAR_ALL),
- btnExportAll(this, IDC_EXPORTALL),
- btnExportSel(this, ID_EXPORTSELECTED),
- btnSetDefault(this, ID_SET_TO_DEFAULT),
- btnUserDetails(this, ID_USERLIST_USERDETAILS),
- btnAutoFileName(this, IDC_AUTO_FILENAME)
+ listUsers(this, IDC_MAP_USER_LIST)
{
listUsers.OnKeyDown = Callback(this, &CContactsOptDlg::list_KeyDown);
listUsers.OnBuildMenu = Callback(this, &CContactsOptDlg::list_OnMenu);
listUsers.OnColumnClick = Callback(this, &CContactsOptDlg::list_ColumnClick);
listUsers.OnDoubleClick = Callback(this, &CContactsOptDlg::list_DoubleClick);
listUsers.OnEndLabelEdit = Callback(this, &CContactsOptDlg::list_LabelEdit);
-
- btnClearAll.OnClick = Callback(this, &CContactsOptDlg::onClick_ClearAll);
- btnExportAll.OnClick = btnExportSel.OnClick = Callback(this, &CContactsOptDlg::onClick_Export);
- btnSetDefault.OnClick = Callback(this, &CContactsOptDlg::onClick_SetDefault);
- btnUserDetails.OnClick = Callback(this, &CContactsOptDlg::onClick_Details);
- btnAutoFileName.OnClick = Callback(this, &CContactsOptDlg::onClick_AutoFileName);
}
bool OnInitDialog() override
@@ -504,6 +491,8 @@ public:
}
listUsers.SortItems(CompareFunc, 1);
+ Select(true);
+
sItem.mask = LVIF_STATE;
sItem.iItem = 0;
sItem.iSubItem = 0;
@@ -543,17 +532,9 @@ public:
return true;
}
- void onClick_Export(CCtrlButton *pButton)
+ void Export()
{
- bool bOnlySelected = pButton->GetCtrlId() != IDC_EXPORTALL;
- int nTotalContacts = listUsers.GetItemCount();
-
- int nContacts;
- if (bOnlySelected)
- nContacts = listUsers.GetSelectedCount();
- else
- nContacts = nTotalContacts;
-
+ int nContacts = listUsers.GetSelectedCount();
if (nContacts <= 0) {
MessageBox(m_hwnd, TranslateT("No contacts found to export"), MSG_BOX_TITEL, MB_OK);
return;
@@ -565,10 +546,10 @@ public:
LVITEM sItem = { 0 };
sItem.mask = LVIF_PARAM;
+ int nTotalContacts = listUsers.GetItemCount();
for (int nCur = 0; nCur < nTotalContacts; nCur++) {
- if (bOnlySelected)
- if (!(listUsers.GetItemState(nCur, LVIS_SELECTED) & LVIS_SELECTED))
- continue;
+ if (!(listUsers.GetItemState(nCur, LVIS_SELECTED) & LVIS_SELECTED))
+ continue;
sItem.iItem = nCur;
if (!listUsers.GetItem(&sItem))
@@ -586,7 +567,7 @@ public:
mir_forkThread<ExportDialogData>(&exportContactsMessages, data);
}
- void onClick_Details(CCtrlButton*)
+ void Details()
{
LVITEM sItem;
sItem.mask = LVIF_PARAM;
@@ -595,7 +576,7 @@ public:
CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)sItem.lParam, 0);
}
- void onClick_AutoFileName(CCtrlButton*)
+ void AutoFileName()
{
LVITEM sItem = { 0 };
@@ -665,7 +646,7 @@ public:
}
}
- void onClick_ClearAll(CCtrlButton*)
+ void ClearAll()
{
LVITEM sItem = { 0 };
sItem.mask = LVIF_TEXT;
@@ -680,7 +661,17 @@ public:
NotifyChange();
}
- void onClick_SetDefault(CCtrlButton*)
+ void Select(bool bCheck)
+ {
+ int nContacts = listUsers.GetItemCount();
+ if (nContacts <= 0)
+ return;
+
+ for (int nCur = 0; nCur < nContacts; nCur++)
+ listUsers.SetItemState(nCur, bCheck ? LVIS_SELECTED : 0, LVIS_SELECTED);
+ }
+
+ void SetDefault()
{
int nContacts = listUsers.GetItemCount();
if (nContacts <= 0)
@@ -723,9 +714,18 @@ public:
GetCursorPos(&pt);
TranslateMenu(hMenu);
- TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, m_hwnd, nullptr);
-
+ int iRet = TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, nullptr);
DestroyMenu(hMainMenu);
+
+ switch (iRet) {
+ case ID_EXPORT: Export(); break;
+ case ID_USERLIST_USERDETAILS: Details(); break;
+ case ID_CLEAR_ALL: ClearAll(); break;
+ case ID_SELECT_ALL: Select(true); break;
+ case ID_SELECT_NONE: Select(false); break;
+ case ID_SET_TO_DEFAULT: SetDefault(); break;
+ case ID_AUTO_FILENAME: AutoFileName(); break;
+ }
}
}
diff --git a/plugins/Msg_Export/src/resource.h b/plugins/Msg_Export/src/resource.h
index 9616639263..77919cd84f 100755
--- a/plugins/Msg_Export/src/resource.h
+++ b/plugins/Msg_Export/src/resource.h
@@ -18,8 +18,6 @@
#define IDC_EXPORT_TIMEFORMAT 1004
#define IDC_EXPORT_DIR_BROWSE 1032
#define IDC_MAP_USER_LIST 1034
-#define IDC_AUTO_FILENAME 1035
-#define IDC_CLEAR_ALL 1036
#define IDC_EXPORT_PROGRESS 1037
#define IDC_EXP_ALL_STATUS 1039
#define IDC_OPEN_HELP 1041
@@ -44,17 +42,21 @@
#define IDC_USE_UTF8_IN_NEW_FILES 1074
#define IDC_USE_UTF8_IN_NEW_FILES2 1075
#define IDC_USE_JSON 1075
-#define ID_EXPORTSELECTED 40002
+#define ID_EXPORT 40002
#define ID_EDIT_COPY 40003
#define ID_SET_TO_DEFAULT 40004
#define ID_USERLIST_USERDETAILS 40005
+#define ID_AUTO_FILENAME 40006
+#define ID_CLEAR_ALL 40007
+#define ID_SELECT_ALL 40008
+#define ID_SELECT_NONE 40009
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 126
-#define _APS_NEXT_COMMAND_VALUE 40006
+#define _APS_NEXT_COMMAND_VALUE 40010
#define _APS_NEXT_CONTROL_VALUE 1075
#define _APS_NEXT_SYMED_VALUE 101
#endif
diff --git a/plugins/Msg_Export/src/version.h b/plugins/Msg_Export/src/version.h
index 2c0170c472..2eca8083c7 100644
--- a/plugins/Msg_Export/src/version.h
+++ b/plugins/Msg_Export/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 3
#define __MINOR_VERSION 1
#define __RELEASE_NUM 2
-#define __BUILD_NUM 5
+#define __BUILD_NUM 6
#include <stdver.h>