mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-26 02:28:17 +08:00
d3b80b26e3
* Implement basic functionality * Change approach. move filter controls to manager edit redrawing to always work with new GetVisibleItemCount() and GetVisibleItemByIndex() calls * Fix performance issues. Some refactoring. * Handle toggleAll correctly * Handle dangling elements when filter is on Make an item visible if it has at least one visible subitem * Support filtering for selected and shouldRename * Refactor for readability, remove useless member from PowerRenameUI * Change variable names in PowerRenameUI for clarity Use wrapper function RedrawItems() and SetItemCount() for consistency * Handle result value properly in getVisibleItemByIndex() * Add FlagsApplicable filter * Add visual indication of filters * Improve performance Check if no filter is selected Call SetItemCount() only when necessary * Refactor for readability * Get lock in setVisible() * Change function names to camel case * Change function names to start with uppercase * Change filter behaviour when search area is empty Show all elements when search area is empty and ShouldRename filter is selected Avoid warnings * Resolve conflicts
60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#pragma once
|
|
#include "pch.h"
|
|
#include <vector>
|
|
#include <string>
|
|
#include "srwlock.h"
|
|
|
|
#include "PowerRenameInterfaces.h"
|
|
|
|
#define DEFAULT_FLAGS MatchAllOccurences
|
|
|
|
class CPowerRenameRegEx : public IPowerRenameRegEx
|
|
{
|
|
public:
|
|
// IUnknown
|
|
IFACEMETHODIMP QueryInterface(_In_ REFIID iid, _Outptr_ void** resultInterface);
|
|
IFACEMETHODIMP_(ULONG) AddRef();
|
|
IFACEMETHODIMP_(ULONG) Release();
|
|
|
|
// IPowerRenameRegEx
|
|
IFACEMETHODIMP Advise(_In_ IPowerRenameRegExEvents* regExEvents, _Out_ DWORD* cookie);
|
|
IFACEMETHODIMP UnAdvise(_In_ DWORD cookie);
|
|
IFACEMETHODIMP GetSearchTerm(_Outptr_ PWSTR* searchTerm);
|
|
IFACEMETHODIMP PutSearchTerm(_In_ PCWSTR searchTerm);
|
|
IFACEMETHODIMP GetReplaceTerm(_Outptr_ PWSTR* replaceTerm);
|
|
IFACEMETHODIMP PutReplaceTerm(_In_ PCWSTR replaceTerm);
|
|
IFACEMETHODIMP GetFlags(_Out_ DWORD* flags);
|
|
IFACEMETHODIMP PutFlags(_In_ DWORD flags);
|
|
IFACEMETHODIMP Replace(_In_ PCWSTR source, _Outptr_ PWSTR* result);
|
|
|
|
static HRESULT s_CreateInstance(_Outptr_ IPowerRenameRegEx **renameRegEx);
|
|
|
|
protected:
|
|
CPowerRenameRegEx();
|
|
virtual ~CPowerRenameRegEx();
|
|
|
|
void _OnSearchTermChanged();
|
|
void _OnReplaceTermChanged();
|
|
void _OnFlagsChanged();
|
|
|
|
size_t _Find(std::wstring data, std::wstring toSearch, bool caseInsensitive, size_t pos);
|
|
|
|
DWORD m_flags = DEFAULT_FLAGS;
|
|
PWSTR m_searchTerm = nullptr;
|
|
PWSTR m_replaceTerm = nullptr;
|
|
|
|
CSRWLock m_lock;
|
|
CSRWLock m_lockEvents;
|
|
|
|
DWORD m_cookie = 0;
|
|
|
|
struct RENAME_REGEX_EVENT
|
|
{
|
|
IPowerRenameRegExEvents* pEvents;
|
|
DWORD cookie;
|
|
};
|
|
|
|
_Guarded_by_(m_lockEvents) std::vector<RENAME_REGEX_EVENT> m_renameRegExEvents;
|
|
|
|
long m_refCount = 0;
|
|
}; |