Separate storage at iteration of hotkeys from the HK list widget

This separates the "ground truth" store of hotkeys from what is shown
in the dialog. This will allow us to filter the displayed hotkeys
while keeping the same underlying data structures.

Now, the UI data items interact with an intermediate set of data, which
represents the "original" hotkey data, and the "changed" data. The
ultimate aim here is to allow UI elements to come and go, but the
hotkeys that are "in-edit" are preserved.

This also allows us to abstract some bookkeeping complexity
out of the WIDGET_HOTKEY_LIST class into a separate non-GUI
class.
This commit is contained in:
John Beard 2018-09-26 15:26:26 +01:00 committed by Wayne Stambaugh
parent 3927dc5820
commit 1f2c8fa698
7 changed files with 363 additions and 229 deletions

View File

@ -283,6 +283,7 @@ set( COMMON_SRCS
gr_basic.cpp
grid_tricks.cpp
hash_eda.cpp
hotkey_store.cpp
hotkeys_basic.cpp
html_messagebox.cpp
incremental_text_ctrl.cpp

View File

@ -32,10 +32,10 @@ PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aW
m_frame( aFrame ),
m_hotkeys( aHotkeys ),
m_showHotkeys( aShowHotkeys ),
m_nickname( aNickname )
m_nickname( aNickname ),
m_hotkeyStore( aShowHotkeys )
{
HOTKEY_SECTIONS sections = WIDGET_HOTKEY_LIST::GenSections( m_showHotkeys );
m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys, sections );
m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys, m_hotkeyStore );
m_hotkeyListCtrl->InstallOnPanel( m_panelHotkeys );
}
@ -60,12 +60,12 @@ bool PANEL_HOTKEYS_EDITOR::TransferDataFromWindow()
void PANEL_HOTKEYS_EDITOR::ResetClicked( wxCommandEvent& aEvent )
{
m_hotkeyListCtrl->TransferDataToControl();
m_hotkeyListCtrl->ResetAllHotkeys( false );
}
void PANEL_HOTKEYS_EDITOR::DefaultsClicked( wxCommandEvent& aEvent )
{
m_hotkeyListCtrl->TransferDefaultsToControl();
m_hotkeyListCtrl->ResetAllHotkeys( true );
}

129
common/hotkey_store.cpp Normal file
View File

@ -0,0 +1,129 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <hotkey_store.h>
HOTKEY_STORE::HOTKEY_STORE( EDA_HOTKEY_CONFIG* aHotkeys )
{
for( EDA_HOTKEY_CONFIG* section = aHotkeys; section->m_HK_InfoList; ++section )
{
m_hk_sections.push_back( genSection( *section ) );
}
}
HOTKEY_SECTION HOTKEY_STORE::genSection( EDA_HOTKEY_CONFIG& aSection )
{
HOTKEY_SECTION generated_section { {}, {}, aSection };
generated_section.m_name = wxGetTranslation( *aSection.m_Title );
for( EDA_HOTKEY** info_ptr = aSection.m_HK_InfoList; *info_ptr; ++info_ptr )
{
generated_section.m_hotkeys.push_back( { **info_ptr, *aSection.m_SectionTag } );
}
return generated_section;
}
std::vector<HOTKEY_SECTION>& HOTKEY_STORE::GetSections()
{
return m_hk_sections;
}
void HOTKEY_STORE::SaveAllHotkeys()
{
for( auto& section: m_hk_sections )
{
for( auto& hotkey: section.m_hotkeys )
{
hotkey.SaveHotkey();
}
}
}
void HOTKEY_STORE::ResetAllHotkeysToDefault()
{
for( auto& section: m_hk_sections )
{
for( auto& hotkey: section.m_hotkeys )
{
hotkey.GetCurrentValue().ResetKeyCodeToDefault();
}
}
}
void HOTKEY_STORE::ResetAllHotkeysToOriginal()
{
for( auto& section: m_hk_sections )
{
for( auto& hotkey: section.m_hotkeys )
{
hotkey.GetCurrentValue().m_KeyCode = hotkey.GetOriginalValue().m_KeyCode;
}
}
}
bool HOTKEY_STORE::CheckKeyConflicts( long aKey, const wxString& aSectionTag,
EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect )
{
EDA_HOTKEY* conflicting_key = nullptr;
EDA_HOTKEY_CONFIG* conflicting_section = nullptr;
for( auto& section: m_hk_sections )
{
const auto& sectionTag = *section.m_section.m_SectionTag;
if( aSectionTag != g_CommonSectionTag
&& sectionTag != g_CommonSectionTag
&& sectionTag != aSectionTag )
{
// This key and its conflict candidate are in orthogonal sections, so skip.
continue;
}
// See if any *current* hotkeys are in conflict
for( auto& hotkey: section.m_hotkeys )
{
auto& curr_hk = hotkey.GetCurrentValue();
if( aKey == curr_hk.m_KeyCode )
{
conflicting_key = &curr_hk;
conflicting_section = &section.m_section;
}
}
}
// Write the outparams
if( aConfKey )
*aConfKey = conflicting_key;
if( aConfSect )
*aConfSect = conflicting_section;
return conflicting_key == nullptr;
}

View File

@ -51,24 +51,25 @@ enum ID_WHKL_MENU_IDS
};
/**
* Class WIDGET_HOTKEY_CLIENT_DATA
* Stores the hotkey and section tag associated with each row. To change a
* hotkey, edit it in the row's client data, then call WIDGET_HOTKEY_LIST::UpdateFromClientData().
* Stores the hotkey change data associated with each row. To change a
* hotkey, edit it via GetCurrentValue() in the row's client data, then call
* WIDGET_HOTKEY_LIST::UpdateFromClientData().
*/
class WIDGET_HOTKEY_CLIENT_DATA : public wxClientData
{
EDA_HOTKEY m_hotkey;
wxString m_section_tag;
CHANGED_HOTKEY& m_changed_hotkey;
public:
WIDGET_HOTKEY_CLIENT_DATA( const EDA_HOTKEY& aHotkey, const wxString& aSectionTag )
: m_hotkey( aHotkey ), m_section_tag( aSectionTag )
WIDGET_HOTKEY_CLIENT_DATA( CHANGED_HOTKEY& aChangedHotkey )
: m_changed_hotkey( aChangedHotkey )
{}
EDA_HOTKEY& GetHotkey() { return m_hotkey; }
const wxString& GetSectionTag() const { return m_section_tag; }
CHANGED_HOTKEY& GetChangedHotkey() { return m_changed_hotkey; }
};
@ -261,7 +262,7 @@ void WIDGET_HOTKEY_LIST::UpdateFromClientData()
if( hkdata )
{
EDA_HOTKEY& hk = hkdata->GetHotkey();
const EDA_HOTKEY& hk = hkdata->GetChangedHotkey().GetCurrentValue();
SetItemText( i, 0, wxGetTranslation( hk.m_InfoMsg ) );
SetItemText( i, 1, KeyNameFromKeyCode( hk.m_KeyCode ) );
@ -270,19 +271,6 @@ void WIDGET_HOTKEY_LIST::UpdateFromClientData()
}
void WIDGET_HOTKEY_LIST::LoadSection( EDA_HOTKEY_CONFIG* aSection )
{
HOTKEY_LIST list;
for( EDA_HOTKEY** info_ptr = aSection->m_HK_InfoList; *info_ptr; ++info_ptr )
{
list.push_back( **info_ptr );
}
m_hotkeys.push_back( list );
}
void WIDGET_HOTKEY_LIST::EditItem( wxTreeListItem aItem )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( aItem );
@ -305,14 +293,17 @@ void WIDGET_HOTKEY_LIST::EditItem( wxTreeListItem aItem )
bool exists;
KeyNameFromKeyCode( key, &exists );
if( exists && hkdata->GetHotkey().m_KeyCode != key )
auto& changed_hk = hkdata->GetChangedHotkey();
auto& curr_hk = changed_hk.GetCurrentValue();
if( exists && curr_hk.m_KeyCode != key )
{
wxString tag = hkdata->GetSectionTag();
wxString tag = changed_hk.GetSectionTag();
bool canUpdate = ResolveKeyConflicts( key, tag );
if( canUpdate )
{
hkdata->GetHotkey().m_KeyCode = key;
curr_hk.m_KeyCode = key;
}
}
@ -328,27 +319,7 @@ void WIDGET_HOTKEY_LIST::EditItem( wxTreeListItem aItem )
void WIDGET_HOTKEY_LIST::ResetItem( wxTreeListItem aItem )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( aItem );
EDA_HOTKEY* hk = &hkdata->GetHotkey();
for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index )
{
wxString& section_tag = *( m_sections[sec_index].m_section->m_SectionTag );
if( section_tag != hkdata->GetSectionTag() )
continue;
HOTKEY_LIST& each_list = m_hotkeys[sec_index];
HOTKEY_LIST::iterator hk_it;
for( hk_it = each_list.begin(); hk_it != each_list.end(); ++hk_it )
{
if( hk_it->m_Idcommand == hk->m_Idcommand )
{
hk->m_KeyCode = hk_it->m_KeyCode;
break;
}
}
}
hkdata->GetChangedHotkey().ResetHotkey();
UpdateFromClientData();
}
@ -357,8 +328,8 @@ void WIDGET_HOTKEY_LIST::ResetItem( wxTreeListItem aItem )
void WIDGET_HOTKEY_LIST::ResetItemToDefault( wxTreeListItem aItem )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( aItem );
EDA_HOTKEY* hk = &hkdata->GetHotkey();
hk->ResetKeyCodeToDefault();
hkdata->GetChangedHotkey().GetCurrentValue().ResetKeyCodeToDefault();
UpdateFromClientData();
}
@ -404,11 +375,11 @@ void WIDGET_HOTKEY_LIST::OnMenu( wxCommandEvent& aEvent )
break;
case ID_RESET_ALL:
TransferDataToControl();
ResetAllHotkeys( false );
break;
case ID_DEFAULT_ALL:
TransferDefaultsToControl();
ResetAllHotkeys( true );
break;
default:
@ -417,67 +388,14 @@ void WIDGET_HOTKEY_LIST::OnMenu( wxCommandEvent& aEvent )
}
bool WIDGET_HOTKEY_LIST::CheckKeyConflicts( long aKey, const wxString& aSectionTag,
EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect )
{
EDA_HOTKEY* conflicting_key = NULL;
struct EDA_HOTKEY_CONFIG* conflicting_section = NULL;
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
if( !hkdata )
continue;
EDA_HOTKEY& hk = hkdata->GetHotkey();
wxString tag = hkdata->GetSectionTag();
if( aSectionTag != g_CommonSectionTag
&& tag != g_CommonSectionTag
&& tag != aSectionTag )
{
// This key and its conflict candidate are in orthogonal sections, so skip.
continue;
}
if( aKey == hk.m_KeyCode )
{
conflicting_key = &hk;
// Find the section
HOTKEY_SECTIONS::iterator it;
for( it = m_sections.begin(); it != m_sections.end(); ++it )
{
if( *it->m_section->m_SectionTag == tag )
{
conflicting_section = it->m_section;
break;
}
}
}
}
// Write the outparams
if( aConfKey )
*aConfKey = conflicting_key;
if( aConfSect )
*aConfSect = conflicting_section;
return conflicting_key == NULL;
}
bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( long aKey, const wxString& aSectionTag )
{
EDA_HOTKEY* conflicting_key = NULL;
EDA_HOTKEY_CONFIG* conflicting_section = NULL;
EDA_HOTKEY* conflicting_key = nullptr;
EDA_HOTKEY_CONFIG* conflicting_section = nullptr;
CheckKeyConflicts( aKey, aSectionTag, &conflicting_key, &conflicting_section );
m_hk_store.CheckKeyConflicts( aKey, aSectionTag, &conflicting_key, &conflicting_section );
if( conflicting_key != NULL )
if( conflicting_key != nullptr )
{
wxString info = wxGetTranslation( conflicting_key->m_InfoMsg );
wxString msg = wxString::Format(
@ -490,6 +408,7 @@ bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( long aKey, const wxString& aSectio
if( dlg.ShowModal() == wxID_YES )
{
// Reset the other hotkey
conflicting_key->m_KeyCode = 0;
UpdateFromClientData();
return true;
@ -506,9 +425,9 @@ bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( long aKey, const wxString& aSectio
}
WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, const HOTKEY_SECTIONS& aSections )
WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore )
: TWO_COLUMN_TREE_LIST( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_SINGLE ),
m_sections( aSections )
m_hk_store( aHotkeyStore )
{
AppendColumn( _( "Command (double-click to edit)" ) );
AppendColumn( _( "Hotkey" ) );
@ -521,22 +440,6 @@ WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, const HOTKEY_SECTIONS
}
HOTKEY_SECTIONS WIDGET_HOTKEY_LIST::GenSections( EDA_HOTKEY_CONFIG* aHotkeys )
{
HOTKEY_SECTIONS sections;
for( EDA_HOTKEY_CONFIG* section = aHotkeys; section->m_HK_InfoList; ++section )
{
HOTKEY_SECTION sec;
sec.m_name = wxGetTranslation( *section->m_Title );
sec.m_section = section;
sections.push_back( sec );
}
return sections;
}
void WIDGET_HOTKEY_LIST::InstallOnPanel( wxPanel* aPanel )
{
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
@ -546,50 +449,43 @@ void WIDGET_HOTKEY_LIST::InstallOnPanel( wxPanel* aPanel )
}
bool WIDGET_HOTKEY_LIST::TransferDefaultsToControl()
void WIDGET_HOTKEY_LIST::ResetAllHotkeys( bool aResetToDefault )
{
Freeze();
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
// Reset all the hotkeys, not just the ones shown
// Should not need to check conflicts, as the state we're about
// to set to a should be consistent
if( aResetToDefault )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
if( hkdata == NULL)
continue;
hkdata->GetHotkey().ResetKeyCodeToDefault();
m_hk_store.ResetAllHotkeysToDefault();
}
else
{
m_hk_store.ResetAllHotkeysToOriginal();
}
UpdateFromClientData();
Thaw();
return true;
}
bool WIDGET_HOTKEY_LIST::TransferDataToControl()
{
Freeze();
DeleteAllItems();
m_hotkeys.clear();
for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index )
for( auto& section: m_hk_store.GetSections() )
{
// LoadSection pushes into m_hotkeys
LoadSection( m_sections[sec_index].m_section );
wxASSERT( m_hotkeys.size() == sec_index + 1 );
wxString section_tag = *( m_sections[sec_index].m_section->m_SectionTag );
// Create parent tree item
wxTreeListItem parent = AppendItem( GetRootItem(), m_sections[sec_index].m_name );
wxTreeListItem parent = AppendItem( GetRootItem(), section.m_name );
HOTKEY_LIST& each_list = m_hotkeys[sec_index];
HOTKEY_LIST::iterator hk_it;
for( hk_it = each_list.begin(); hk_it != each_list.end(); ++hk_it )
for( auto& hotkey: section.m_hotkeys )
{
wxTreeListItem item = AppendItem( parent, wxEmptyString );
SetItemData( item, new WIDGET_HOTKEY_CLIENT_DATA( &*hk_it, section_tag ) );
SetItemData( item, new WIDGET_HOTKEY_CLIENT_DATA( hotkey ) );
}
Expand( parent );
@ -604,32 +500,7 @@ bool WIDGET_HOTKEY_LIST::TransferDataToControl()
bool WIDGET_HOTKEY_LIST::TransferDataFromControl()
{
for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index )
{
EDA_HOTKEY_CONFIG* section = m_sections[sec_index].m_section;
for( EDA_HOTKEY** info_ptr = section->m_HK_InfoList; *info_ptr; ++info_ptr )
{
EDA_HOTKEY* info = *info_ptr;
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
if( !hkdata )
continue;
EDA_HOTKEY& hk = hkdata->GetHotkey();
if( hk.m_Idcommand == info->m_Idcommand )
{
info->m_KeyCode = hk.m_KeyCode;
break;
}
}
}
}
m_hk_store.SaveAllHotkeys();
return true;
}

168
include/hotkey_store.h Normal file
View File

@ -0,0 +1,168 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file hotkey_store.h
*/
#ifndef HOTKEY_STORE__H
#define HOTKEY_STORE__H
#include <hotkeys_basic.h>
/**
* Class that manages a hotkey that can be changed, reset to its
* old value, a default or saved.
*/
class CHANGED_HOTKEY
{
public:
CHANGED_HOTKEY( EDA_HOTKEY& aHotkey, const wxString& aTag ):
m_orig( aHotkey ),
m_changed( aHotkey ),
m_tag( aTag )
{}
EDA_HOTKEY& GetCurrentValue()
{
return m_changed;
}
const EDA_HOTKEY& GetCurrentValue() const
{
return m_changed;
}
/**
* Reset the changed hotkey back to the original value.
*/
void ResetHotkey()
{
m_changed = m_orig;
}
/**
* Save changed hotkey to the original location.
*/
void SaveHotkey()
{
m_orig = m_changed;
}
const wxString& GetSectionTag() const
{
return m_tag;
}
private:
// Reference to an "original" hotkey config
EDA_HOTKEY& m_orig;
// A separate changeable config
EDA_HOTKEY m_changed;
// The hotkey section tag, used to spot conflicts
const wxString& m_tag;
};
/**
* Associates a set of hotkeys (a section) with a display name and the hotkeys
*/
struct HOTKEY_SECTION
{
// The displayed, translated, name of the section
wxString m_name;
// List of update-able hotkey data for this section
std::vector<CHANGED_HOTKEY> m_hotkeys;
// Back reference to the underlying hotkey data of this section
EDA_HOTKEY_CONFIG& m_section;
};
/**
* A class that contains a set of hotkeys, arranged into "sections"
* and provides some book-keeping functions for them.
*/
class HOTKEY_STORE
{
public:
using SECTION_LIST = std::vector<HOTKEY_SECTION>;
/**
* Construct a HOTKEY_STORE from a list of hotkey sections
*
* @param aHotkeys the hotkey configs that will be managed by this store.
*/
HOTKEY_STORE( EDA_HOTKEY_CONFIG* aHotkeys );
/**
* Get the list of sections managed by this store
*/
SECTION_LIST& GetSections();
/**
* Persist all changes to hotkeys in the store to the underlying
* data structures.
*/
void SaveAllHotkeys();
/**
* Reset every hotkey in the store to the default values
*/
void ResetAllHotkeysToDefault();
/**
* Resets every hotkey to the original values.
*/
void ResetAllHotkeysToOriginal();
/**
* Check whether the given key conflicts with anything in this store.
*
* @param aKey - key to check
* @param aSectionTag - section tag into which the key is proposed to be installed
* @param aConfKey - if not NULL, outparam getting the key this one conflicts with
* @param aConfSect - if not NULL, outparam getting the section this one conflicts with
*/
bool CheckKeyConflicts( long aKey, const wxString& aSectionTag,
EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect );
private:
/**
* Generate a HOTKEY_SECTION for a single section
* described by an EDA_HOTKEY_CONFIG
*/
HOTKEY_SECTION genSection( EDA_HOTKEY_CONFIG& aSection );
// Internal data for every hotkey passed in
SECTION_LIST m_hk_sections;
};
#endif // HOTKEY_STORE__H

View File

@ -25,6 +25,8 @@
#define PANEL_HOTKEYS_EDITOR_H
#include <hotkeys_basic.h>
#include <hotkey_store.h>
#include "../common/dialogs/panel_hotkeys_editor_base.h"
#include <widgets/widget_hotkey_list.h>
@ -37,6 +39,7 @@ protected:
struct EDA_HOTKEY_CONFIG* m_showHotkeys;
wxString m_nickname;
HOTKEY_STORE m_hotkeyStore;
WIDGET_HOTKEY_LIST* m_hotkeyListCtrl;
bool TransferDataToWindow() override;

View File

@ -36,26 +36,15 @@
#include <widgets/two_column_tree_list.h>
#include <hotkeys_basic.h>
#include <hotkey_store.h>
/**
* struct HOTKEY_SECTION
* Associates a hotkey configuration with a name.
*/
struct HOTKEY_SECTION
{
wxString m_name;
EDA_HOTKEY_CONFIG* m_section;
};
typedef std::vector<HOTKEY_SECTION> HOTKEY_SECTIONS;
typedef std::vector<EDA_HOTKEY> HOTKEY_LIST;
class WIDGET_HOTKEY_CLIENT_DATA;
class WIDGET_HOTKEY_LIST : public TWO_COLUMN_TREE_LIST
{
HOTKEY_SECTIONS m_sections;
std::vector<HOTKEY_LIST> m_hotkeys;
HOTKEY_STORE& m_hk_store;
wxTreeListItem m_context_menu_item;
/**
@ -79,12 +68,6 @@ class WIDGET_HOTKEY_LIST : public TWO_COLUMN_TREE_LIST
void UpdateFromClientData();
protected:
/**
* Method LoadSection
* Generates a HOTKEY_LIST from the given hotkey configuration array and pushes
* it to m_hotkeys.
*/
void LoadSection( EDA_HOTKEY_CONFIG* aSection );
/**
* Method EditItem
@ -128,18 +111,6 @@ protected:
*/
void OnSize( wxSizeEvent& aEvent );
/**
* Method CheckKeyConflicts
* Check whether the given key conflicts with anything in this WIDGET_HOTKEY_LIST.
*
* @param aKey - key to check
* @param aSectionTag - section tag into which the key is proposed to be installed
* @param aConfKey - if not NULL, outparam getting the key this one conflicts with
* @param aConfSect - if not NULL, outparam getting the section this one conflicts with
*/
bool CheckKeyConflicts( long aKey, const wxString& aSectionTag,
EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect );
/**
* Method ResolveKeyConflicts
* Check if we can set a hotkey, and prompt the user if there is a conflict between
@ -163,18 +134,10 @@ public:
* Create a WIDGET_HOTKEY_LIST.
*
* @param aParent - parent widget
* @param aSections - list of the hotkey sections to display and their names.
* See WIDGET_HOTKEY_LIST::GenSections for a way to generate these easily
* from an EDA_HOTKEY_CONFIG*.
* @param aHotkeys - EDA_HOTKEY_CONFIG data - a hotkey store is constructed
* from this.
*/
WIDGET_HOTKEY_LIST( wxWindow* aParent, const HOTKEY_SECTIONS& aSections );
/**
* Static method GenSections
* Generate a list of sections and names from an EDA_HOTKEY_CONFIG*. Titles
* will be looked up from translations.
*/
static HOTKEY_SECTIONS GenSections( EDA_HOTKEY_CONFIG* aHotkeys );
WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore );
/**
* Method InstallOnPanel
@ -185,16 +148,15 @@ public:
void InstallOnPanel( wxPanel* aPanel );
/**
* Method TransferDefaultsToControl
* Set hotkeys in the control to default values.
* @return true iff the operation was successful
* Set hotkeys in the control to default or original values.
* @param aResetToDefault if true,.reset to the defaults inherent to the
* hotkeym, else reset to the value they had when the dialog was invoked.
*/
bool TransferDefaultsToControl();
void ResetAllHotkeys( bool aResetToDefault );
/**
* Method TransferDataToControl
* Load the hotkey data into the control. It is safe to call this multiple times,
* for example to reset the control.
* Load the hotkey data from the store into the control.
* @return true iff the operation was successful
*/
bool TransferDataToControl();