From 04d299ae0ed9a355a6e4bc403fe3615687db9695 Mon Sep 17 00:00:00 2001 From: Chris Pavlina Date: Wed, 19 Jul 2017 11:34:55 -0600 Subject: [PATCH] libedit: add correct unit/convert from component chooser Fixes: lp:1705073 * https://bugs.launchpad.net/kicad/+bug/1705073 --- eeschema/libedit.cpp | 13 +++++++++++-- eeschema/libeditframe.h | 9 ++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index c0bc65e7a7..3701dd4f4d 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -88,17 +88,26 @@ bool LIB_EDIT_FRAME::LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, PART_LIB* } -bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry ) +bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry, int aUnit, int aConvert ) { if( !LoadOneLibraryPartAux( aLibEntry, GetCurLib() ) ) return false; + if( aUnit > 0 ) + m_unit = aUnit; + + if( aConvert > 0 ) + m_convert = aConvert; + m_editPinsPerPartOrConvert = GetCurPart()->UnitsLocked() ? true : false; GetScreen()->ClearUndoRedoList(); Zoom_Automatique( false ); SetShowDeMorgan( GetCurPart()->HasConversion() ); + if( aUnit > 0 ) + UpdatePartSelectList(); + return true; } @@ -181,7 +190,7 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event ) PART_LIB* old = SetCurLib( searchLib ); - LoadComponentFromCurrentLib( libEntry ); + LoadComponentFromCurrentLib( libEntry, sel.Unit, sel.Convert ); SetCurLib( old ); diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index fed9b55318..619a72c60b 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -3,7 +3,7 @@ * * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2017 Wayne Stambaugh - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2017 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 @@ -495,11 +495,14 @@ private: /** * Function LoadComponentFromCurrentLib - * loads a component from the current active library. + * loads a component from the current active library, optionally setting the selected + * unit and convert * @param aLibEntry The component to load from \a aLibrary (can be an alias) + * @param aUnit Unit to be selected + * @param aConvert Convert to be selected * @return true if \a aLibEntry loaded correctly. */ - bool LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry ); + bool LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry, int aUnit = 0, int aConvert = 0 ); /** * Function LoadOneLibraryPartAux