From f7f7e3e918d4e5410931b318c049722347c4a2b4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 31 Aug 2015 08:43:33 +0200 Subject: [PATCH] Remove useless or not working code used in Load/Save config. --- common/basicframe.cpp | 4 ++-- common/draw_frame.cpp | 4 ++-- eeschema/eeschema_config.cpp | 4 ---- eeschema/libeditframe.cpp | 8 +------- eeschema/libeditframe.h | 8 -------- eeschema/viewlib_frame.cpp | 20 +++++--------------- eeschema/viewlib_frame.h | 9 --------- include/wxstruct.h | 20 ++++++++++++++++++++ pcbnew/modview_frame.cpp | 9 ++------- pcbnew/modview_frame.h | 7 ------- 10 files changed, 32 insertions(+), 61 deletions(-) diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 5276d7f49b..a9ddf4a311 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -227,7 +227,7 @@ void EDA_BASE_FRAME::LoadSettings( wxConfigBase* aCfg ) { int maximized = 0; - wxString baseCfgName = GetName(); + wxString baseCfgName = ConfigBaseName(); wxString text = baseCfgName + wxT( "Pos_x" ); aCfg->Read( text, &m_FramePos.x ); @@ -275,7 +275,7 @@ void EDA_BASE_FRAME::SaveSettings( wxConfigBase* aCfg ) if( IsIconized() ) return; - wxString baseCfgName = GetName(); + wxString baseCfgName = ConfigBaseName(); m_FrameSize = GetSize(); m_FramePos = GetPosition(); diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index c2f6b70cf7..42936ef233 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -658,7 +658,7 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg ) { EDA_BASE_FRAME::LoadSettings( aCfg ); - wxString baseCfgName = GetName(); + wxString baseCfgName = ConfigBaseName(); aCfg->Read( baseCfgName + CursorShapeEntryKeyword, &m_cursorShape, ( long )0 ); @@ -685,7 +685,7 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg ) { EDA_BASE_FRAME::SaveSettings( aCfg ); - wxString baseCfgName = GetName(); + wxString baseCfgName = ConfigBaseName(); aCfg->Write( baseCfgName + CursorShapeEntryKeyword, m_cursorShape ); aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() ); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 5c8b7331fd..4603253d77 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -738,8 +738,6 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) { EDA_DRAW_FRAME::LoadSettings( aCfg ); - wxConfigPathChanger cpc( aCfg, m_configPath ); - SetGridColor( GetLayerColor( LAYER_GRID ) ); SetDrawBgColor( GetLayerColor( LAYER_BACKGROUND ) ); @@ -765,8 +763,6 @@ void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg ) { EDA_DRAW_FRAME::SaveSettings( aCfg ); - wxConfigPathChanger cpc( aCfg, m_configPath ); - aCfg->Write( lastLibExportPathEntry, m_lastLibExportPath ); aCfg->Write( lastLibImportPathEntry, m_lastLibImportPath ); aCfg->Write( DefaultPinLengthEntry, (long) GetDefaultPinLength() ); diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 0eb1d36e08..97f738ebcf 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -179,12 +179,11 @@ END_EVENT_TABLE() LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ), - wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GetLibEditFrameName() ) + wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, LIB_EDIT_FRAME_NAME ) { wxASSERT( aParent ); m_showAxis = true; // true to draw axis - m_configPath = wxT( "LibraryEditor" ); SetShowDeMorgan( false ); m_drawSpecificConvert = true; m_drawSpecificUnit = false; @@ -304,11 +303,6 @@ LIB_EDIT_FRAME::~LIB_EDIT_FRAME() m_tempCopyComponent = NULL; } -const wxChar* LIB_EDIT_FRAME::GetLibEditFrameName() -{ - return LIB_EDIT_FRAME_NAME; -} - void LIB_EDIT_FRAME::SetDrawItem( LIB_ITEM* drawItem ) { diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index dc7e1fbc49..6ae14cecf4 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -56,7 +56,6 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME wxComboBox* m_partSelectBox; ///< a Box to select a part to edit (if any) wxComboBox* m_aliasSelectBox; ///< a box to select the alias to edit (if any) - wxString m_configPath; wxString m_lastLibImportPath; wxString m_lastLibExportPath; @@ -134,13 +133,6 @@ public: ~LIB_EDIT_FRAME(); - /** - * Function GetLibEditFrameName (static) - * @return the frame name used when creating the frame - * used to get a reference to this frame, if exists - */ - static const wxChar* GetLibEditFrameName(); - /** The current library being edited, or NULL if none. */ PART_LIB* GetCurLib(); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index c7973d8887..16812ab1e3 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2015 KiCad Developers, see change_log.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 @@ -105,14 +105,14 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT : #endif KICAD_DEFAULT_DRAWFRAME_STYLE, - GetLibViewerFrameName() ) + LIB_VIEW_FRAME_NAME ) { - wxASSERT( aFrameType==FRAME_SCH_VIEWER || aFrameType==FRAME_SCH_VIEWER_MODAL ); + wxASSERT( aFrameType == FRAME_SCH_VIEWER || aFrameType == FRAME_SCH_VIEWER_MODAL ); if( aFrameType == FRAME_SCH_VIEWER_MODAL ) SetModal( true ); - m_configPath = wxT( "LibraryViewer" ); + m_configFrameName = LIB_VIEW_FRAME_NAME; // Give an icon wxIcon icon; @@ -243,12 +243,6 @@ LIB_VIEW_FRAME::~LIB_VIEW_FRAME() } -const wxChar* LIB_VIEW_FRAME::GetLibViewerFrameName() -{ - return LIB_VIEW_FRAME_NAME; -} - - void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) { if( !IsModal() ) @@ -549,8 +543,6 @@ void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg ) SetGridColor( GetLayerColor( LAYER_GRID ) ); SetDrawBgColor( GetLayerColor( LAYER_BACKGROUND ) ); - wxConfigPathChanger cpc( aCfg, m_configPath ); - aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 150 ); aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 ); @@ -567,8 +559,6 @@ void LIB_VIEW_FRAME::SaveSettings( wxConfigBase* aCfg ) { EDA_DRAW_FRAME::SaveSettings( aCfg ); - wxConfigPathChanger cpc( aCfg, m_configPath ); - if( m_libListWidth && m_libList ) { m_libListWidth = m_libList->GetSize().x; diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index aef61adc24..ab7ecb21cf 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -61,13 +61,6 @@ public: ~LIB_VIEW_FRAME(); - /** - * Function GetLibViewerFrameName (static) - * @return the frame name used when creating the frame - * used to get a reference to this frame, if exists - */ - static const wxChar* GetLibViewerFrameName(); - void OnSize( wxSizeEvent& event ); /** @@ -179,8 +172,6 @@ private: bool m_listPowerCmpOnly; wxArrayString m_allowedLibs; - wxString m_configPath; // subpath for configuration - // TODO(hzeller): looks like these members were chosen to be static to survive different // instances of this browser and communicate it to the next instance. This looks like an // ugly hack, and should be solved differently. diff --git a/include/wxstruct.h b/include/wxstruct.h index ee9bbfa308..184218a5d9 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -129,6 +129,9 @@ protected: wxPoint m_FramePos; wxSize m_FrameSize; + wxString m_configFrameName; ///< prefix used in config to identify some params (frame size...) + ///< if empty, the frame name defined in CTOR is used + wxAuiToolBar* m_mainToolBar; ///< Standard horizontal Toolbar wxString m_AboutTitle; ///< Name of program displayed in About. @@ -248,6 +251,23 @@ public: */ virtual void SaveSettings( wxConfigBase* aCfg ); + /** + * Function ConfigBaseName + * @return a base name prefix used in Load/Save settings to build + * the full name of keys used in config. + * This is usually the name of the frame set by CTOR, unless m_configFrameName + * contains a base name. + * this is the case of frames which can be shown in normal or modal mode. + * This is needed because we want only one base name prefix, + * regardless the mode used. + */ + wxString ConfigBaseName() + { + wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName; + return baseCfgName; + } + + /** * Function SaveProjectSettings * saves changes to the project settings to the project (.pro) file. diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 7ade7dfd98..fe1839092d 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -126,14 +126,14 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT : #endif KICAD_DEFAULT_DRAWFRAME_STYLE, - GetFootprintViewerFrameName() ) + FOOTPRINT_VIEWER_FRAME_NAME ) { wxASSERT( aFrameType==FRAME_PCB_MODULE_VIEWER || aFrameType==FRAME_PCB_MODULE_VIEWER_MODAL ); if( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ) SetModal( true ); - m_configPath = wxT( "FootprintViewer" ); + m_configFrameName = FOOTPRINT_VIEWER_FRAME_NAME; m_showAxis = true; // true to draw axis. // Give an icon @@ -288,11 +288,6 @@ FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME() } -const wxChar* FOOTPRINT_VIEWER_FRAME::GetFootprintViewerFrameName() -{ - return FOOTPRINT_VIEWER_FRAME_NAME; -} - void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event ) { diff --git a/pcbnew/modview_frame.h b/pcbnew/modview_frame.h index 902fc77082..cd472d6b12 100644 --- a/pcbnew/modview_frame.h +++ b/pcbnew/modview_frame.h @@ -52,13 +52,6 @@ protected: public: ~FOOTPRINT_VIEWER_FRAME(); - /** - * Function GetFootprintViewerFrameName (static) - * @return the frame name used when creating the frame - * used to get a reference to this frame, if exists - */ - static const wxChar* GetFootprintViewerFrameName(); - virtual EDA_COLOR_T GetGridColor() const; /**