KiCad PCB EDA Suite
HOTKEY_FILTER Class Reference

Class to manage logic for filtering hotkeys based on user input. More...

Public Member Functions

 HOTKEY_FILTER (const wxString &aFilterStr)
 
bool FilterMatches (const HOTKEY &aHotkey) const
 Check if the filter matches the given hotkey. More...
 

Private Attributes

bool m_valid
 
wxString m_normalised_filter_str
 

Detailed Description

Class to manage logic for filtering hotkeys based on user input.

Definition at line 213 of file widget_hotkey_list.cpp.

Constructor & Destructor Documentation

◆ HOTKEY_FILTER()

HOTKEY_FILTER::HOTKEY_FILTER ( const wxString &  aFilterStr)
inline

Definition at line 216 of file widget_hotkey_list.cpp.

217  {
218  m_normalised_filter_str = aFilterStr.Upper();
219  m_valid = m_normalised_filter_str.size() > 0;
220  }
wxString m_normalised_filter_str

References m_normalised_filter_str, and m_valid.

Member Function Documentation

◆ FilterMatches()

bool HOTKEY_FILTER::FilterMatches ( const HOTKEY aHotkey) const
inline

Check if the filter matches the given hotkey.

Returns
true on match (or if filter is disabled)

Definition at line 227 of file widget_hotkey_list.cpp.

228  {
229  if( !m_valid )
230  return true;
231 
232  // Match in the (translated) filter string
233  const auto normedInfo = wxGetTranslation( aHotkey.m_Actions[ 0 ]->GetLabel() ).Upper();
234 
235  if( normedInfo.Contains( m_normalised_filter_str ) )
236  return true;
237 
238  const wxString keyName = KeyNameFromKeyCode( aHotkey.m_EditKeycode );
239 
240  if( keyName.Upper().Contains( m_normalised_filter_str ) )
241  return true;
242 
243  return false;
244  }
wxString m_normalised_filter_str
std::vector< TOOL_ACTION * > m_Actions
Definition: hotkey_store.h:36
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
int m_EditKeycode
Definition: hotkey_store.h:37

References KeyNameFromKeyCode(), HOTKEY::m_Actions, HOTKEY::m_EditKeycode, m_normalised_filter_str, and m_valid.

Member Data Documentation

◆ m_normalised_filter_str

wxString HOTKEY_FILTER::m_normalised_filter_str
private

Definition at line 248 of file widget_hotkey_list.cpp.

Referenced by FilterMatches(), and HOTKEY_FILTER().

◆ m_valid

bool HOTKEY_FILTER::m_valid
private

Definition at line 247 of file widget_hotkey_list.cpp.

Referenced by FilterMatches(), and HOTKEY_FILTER().


The documentation for this class was generated from the following file: