Explorar o código

Add advanced filter functionality to Advanced options

- Introduced an edit control for filtering properties in the advanced options dialog.
- Updated resource definitions to include the new edit control.
- Enhanced data exchange and message map to support filtering logic.
- Added logic to filter properties based on user input in real-time.
dcog989 hai 6 meses
pai
achega
030f827010
Modificáronse 4 ficheiros con 59 adicións e 5 borrados
  1. 4 3
      CP_Main.rc
  2. 48 2
      src/AdvGeneral.cpp
  3. 6 0
      src/AdvGeneral.h
  4. 1 0
      src/Resource.h

+ 4 - 3
CP_Main.rc

@@ -1021,12 +1021,13 @@ STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 CAPTION "Advanced Options"
 CAPTION "Advanced Options"
 FONT 10, "Segoe UI", 400, 0, 0x0
 FONT 10, "Segoe UI", 400, 0, 0x0
 BEGIN
 BEGIN
-    DEFPUSHBUTTON   "OK",IDOK,280,251,50,11
-    PUSHBUTTON      "Cancel",IDCANCEL,333,250,50,12
-    CONTROL         "",IDC_MFCPROPERTYGRID1,"MfcPropertyGrid",0x100,7,7,376,212
+    EDITTEXT        IDC_EDIT_ADV_FILTER,7,7,376,14,ES_AUTOHSCROLL
+    CONTROL         "",IDC_MFCPROPERTYGRID1,"MfcPropertyGrid",0x100,7,25,376,194
     PUSHBUTTON      "Compact and Repair Database",IDC_BT_COMPACT_AND_REPAIR,7,251,108,11
     PUSHBUTTON      "Compact and Repair Database",IDC_BT_COMPACT_AND_REPAIR,7,251,108,11
     PUSHBUTTON      "On Copy Scripts",IDC_BUTTON_COPY_SCRIPTS,7,224,108,11
     PUSHBUTTON      "On Copy Scripts",IDC_BUTTON_COPY_SCRIPTS,7,224,108,11
     PUSHBUTTON      "On Paste Scripts",IDC_BUTTON_PASTE_SCRIPTS,7,237,108,11
     PUSHBUTTON      "On Paste Scripts",IDC_BUTTON_PASTE_SCRIPTS,7,237,108,11
+    DEFPUSHBUTTON   "OK",IDOK,280,251,50,11
+    PUSHBUTTON      "Cancel",IDCANCEL,333,250,50,12
 END
 END
 
 
 IDD_SCRIPT_EDITOR DIALOGEX 0, 0, 435, 324
 IDD_SCRIPT_EDITOR DIALOGEX 0, 0, 435, 324

+ 48 - 2
src/AdvGeneral.cpp

@@ -27,6 +27,7 @@ void CAdvGeneral::DoDataExchange(CDataExchange* pDX)
 {
 {
 	CDialogEx::DoDataExchange(pDX);
 	CDialogEx::DoDataExchange(pDX);
 	DDX_Control(pDX, IDC_MFCPROPERTYGRID1, m_propertyGrid);
 	DDX_Control(pDX, IDC_MFCPROPERTYGRID1, m_propertyGrid);
+	DDX_Control(pDX, IDC_EDIT_ADV_FILTER, m_editFilter);
 }
 }
 
 
 
 
@@ -38,6 +39,7 @@ BEGIN_MESSAGE_MAP(CAdvGeneral, CDialogEx)
 	ON_BN_CLICKED(IDC_BUTTON_PASTE_SCRIPTS, &CAdvGeneral::OnBnClickedButtonPasteScripts2)
 	ON_BN_CLICKED(IDC_BUTTON_PASTE_SCRIPTS, &CAdvGeneral::OnBnClickedButtonPasteScripts2)
 	ON_WM_GETMINMAXINFO()
 	ON_WM_GETMINMAXINFO()
 	ON_WM_NCLBUTTONDOWN()
 	ON_WM_NCLBUTTONDOWN()
+	ON_EN_CHANGE(IDC_EDIT_ADV_FILTER, &CAdvGeneral::OnEnChangeAdvFilter)
 END_MESSAGE_MAP()
 END_MESSAGE_MAP()
 
 
 
 
@@ -165,8 +167,12 @@ BOOL CAdvGeneral::OnInitDialog()
 
 
 	m_propertyGrid.ModifyStyle(0, WS_CLIPCHILDREN);
 	m_propertyGrid.ModifyStyle(0, WS_CLIPCHILDREN);
 
 
+	// Store all properties for filtering
+	m_allProperties.RemoveAll();
+
 	CMFCPropertyGridProperty * pGroupTest = new CMFCPropertyGridProperty( _T( "Ditto" ) );
 	CMFCPropertyGridProperty * pGroupTest = new CMFCPropertyGridProperty( _T( "Ditto" ) );
-	m_propertyGrid.AddProperty(pGroupTest);	
+	m_propertyGrid.AddProperty(pGroupTest);
+	m_allProperties.Add(pGroupTest);
 
 
 	m_Resize.SetParent(m_hWnd);
 	m_Resize.SetParent(m_hWnd);
 	m_Resize.AddControl(IDC_MFCPROPERTYGRID1, DR_SizeWidth | DR_SizeHeight);
 	m_Resize.AddControl(IDC_MFCPROPERTYGRID1, DR_SizeWidth | DR_SizeHeight);
@@ -322,7 +328,8 @@ BOOL CAdvGeneral::OnInitDialog()
 	AddTrueFalse(pGroupTest, _T("Write debug to OutputDebugString"), CGetSetOptions::GetEnableDebugLogging(), SETTING_DEBUG_TO_OUTPUT_STRING);
 	AddTrueFalse(pGroupTest, _T("Write debug to OutputDebugString"), CGetSetOptions::GetEnableDebugLogging(), SETTING_DEBUG_TO_OUTPUT_STRING);
 
 
 	CMFCPropertyGridProperty * regexFilterGroup = new CMFCPropertyGridProperty(_T("Exclude clips by Regular Expressions"));
 	CMFCPropertyGridProperty * regexFilterGroup = new CMFCPropertyGridProperty(_T("Exclude clips by Regular Expressions"));
-	m_propertyGrid.AddProperty(regexFilterGroup);	
+	m_propertyGrid.AddProperty(regexFilterGroup);
+	m_allProperties.Add(regexFilterGroup);
 
 
 	CString processFilterDesc = _T("Process making the copy first must match this before the Regex will be applied (empty or * for all processes) (separate multiples by ;)");
 	CString processFilterDesc = _T("Process making the copy first must match this before the Regex will be applied (empty or * for all processes) (separate multiples by ;)");
 	CString regexFilterDesc = _T("If copied text matches this regular expression then the clip will not be saved to Ditto");
 	CString regexFilterDesc = _T("If copied text matches this regular expression then the clip will not be saved to Ditto");
@@ -1044,3 +1051,42 @@ void CAdvGeneral::OnNcLButtonDown(UINT nHitTest, CPoint point)
 
 
 	CDialog::OnNcLButtonDown(nHitTest, point);
 	CDialog::OnNcLButtonDown(nHitTest, point);
 }
 }
+
+void CAdvGeneral::OnEnChangeAdvFilter()
+{
+	CString filterText;
+	m_editFilter.GetWindowText(filterText);
+	filterText.MakeLower();
+
+	m_propertyGrid.RemoveAll();
+
+	for (int i = 0; i < m_allProperties.GetSize(); ++i)
+	{
+		CMFCPropertyGridProperty* pProp = m_allProperties[i];
+		CString name = pProp->GetName();
+		name.MakeLower();
+		if (filterText.IsEmpty() || name.Find(filterText) >= 0)
+		{
+			m_propertyGrid.AddProperty(pProp);
+		}
+		else
+		{
+			// Check subitems
+			BOOL found = FALSE;
+			for (int j = 0; j < pProp->GetSubItemsCount(); ++j)
+			{
+				CString subName = pProp->GetSubItem(j)->GetName();
+				subName.MakeLower();
+				if (subName.Find(filterText) >= 0)
+				{
+					found = TRUE;
+					break;
+				}
+			}
+			if (found)
+			{
+				m_propertyGrid.AddProperty(pProp);
+			}
+		}
+	}
+}

+ 6 - 0
src/AdvGeneral.h

@@ -1,6 +1,7 @@
 #pragma once
 #pragma once
 #include "afxpropertygridctrl.h"
 #include "afxpropertygridctrl.h"
 #include "DialogResizer.h"
 #include "DialogResizer.h"
+#include <afxcoll.h>
 
 
 class CAdvGeneral : public CDialogEx
 class CAdvGeneral : public CDialogEx
 {
 {
@@ -21,6 +22,11 @@ protected:
 
 
 	void AddTrueFalse(CMFCPropertyGridProperty * pGroupTest, CString desc, BOOL value, int settingId);
 	void AddTrueFalse(CMFCPropertyGridProperty * pGroupTest, CString desc, BOOL value, int settingId);
 
 
+	CEdit m_editFilter;
+	CArray<CMFCPropertyGridProperty*, CMFCPropertyGridProperty*> m_allProperties;
+
+	afx_msg void OnEnChangeAdvFilter();
+
 	DECLARE_MESSAGE_MAP()
 	DECLARE_MESSAGE_MAP()
 public:
 public:
 	CMFCPropertyGridCtrl m_propertyGrid;
 	CMFCPropertyGridCtrl m_propertyGrid;

+ 1 - 0
src/Resource.h

@@ -240,6 +240,7 @@
 #define IDR_MENU_NO_DB                  387
 #define IDR_MENU_NO_DB                  387
 #define IDI_ICON3                       388
 #define IDI_ICON3                       388
 #define IDI_MAINFRAME_NO_DB             388
 #define IDI_MAINFRAME_NO_DB             388
+#define IDC_EDIT_ADV_FILTER             5001
 #define IDC_PATH                        1000
 #define IDC_PATH                        1000
 #define IDC_GET_PATH                    1001
 #define IDC_GET_PATH                    1001
 #define IDC_SELECT_SOUND                1002
 #define IDC_SELECT_SOUND                1002