← Back to team overview

kicad-developers team mailing list archive

[PATCH] Add ability to filter parts by footprint text

 

Currently there is no way to filter by footprint in the component selector
window.

This simple patch adds the footprint text to the search string for each
item in the component selector window.

This means that the user can enter text such as "SOT-23-5" and all matching
footprints will appear.

Regards,
Oliver
From b3d5b169fcd7e855db73db9d3339de22d625b32e Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@xxxxxxxxx>
Date: Sun, 9 Jul 2017 23:08:33 +1000
Subject: [PATCH] Search component footprint text

- Added footprint text to serach string for each component
---
 eeschema/class_libentry.cpp |  8 ++++++++
 eeschema/class_libentry.h   |  3 +++
 eeschema/cmp_tree_model.cpp | 18 ++++++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp
index b87fb23..fd01fff 100644
--- a/eeschema/class_libentry.cpp
+++ b/eeschema/class_libentry.cpp
@@ -1350,6 +1350,14 @@ LIB_FIELD& LIB_PART::GetReferenceField()
 }
 
 
+LIB_FIELD& LIB_PART::GetFootprintField()
+{
+    LIB_FIELD* field = GetField( FOOTPRINT );
+    wxASSERT( field != NULL );
+    return *field;
+}
+
+
 bool LIB_PART::SaveDateAndTime( OUTPUTFORMATTER& aFormatter )
 {
     int year, mon, day, hour, min, sec;
diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h
index 485d6e9..c22b3e3 100644
--- a/eeschema/class_libentry.h
+++ b/eeschema/class_libentry.h
@@ -437,6 +437,9 @@ public:
     /** Return reference to the reference designator field. */
     LIB_FIELD& GetReferenceField();
 
+    /** Return reference to the footprint field */
+    LIB_FIELD& GetFootprintField();
+
     /**
      * Draw part.
      *
diff --git a/eeschema/cmp_tree_model.cpp b/eeschema/cmp_tree_model.cpp
index f8d7ef0..98c53b0 100644
--- a/eeschema/cmp_tree_model.cpp
+++ b/eeschema/cmp_tree_model.cpp
@@ -142,6 +142,24 @@ CMP_TREE_NODE_ALIAS::CMP_TREE_NODE_ALIAS( CMP_TREE_NODE* aParent, LIB_ALIAS* aAl
     MatchName   = aAlias->GetName().Lower();
     SearchText  = (aAlias->GetKeyWords() + "        " + Desc).Lower();
 
+    // Extract default footprint text
+    LIB_PART* part = aAlias->GetPart();
+
+    wxString footprint;
+
+    if( part )
+    {
+        footprint = part->GetFootprintField().GetText();
+    }
+
+    // If a footprint is defined for the part,
+    // add it to the serach string
+    if( !footprint.IsEmpty() )
+    {
+        SearchText += "        ";
+        SearchText += footprint.Lower();
+    }
+
     if( aAlias->GetPart()->IsMulti() )
     {
         for( int u = 1; u <= aAlias->GetPart()->GetUnitCount(); ++u )
-- 
2.7.4


Follow ups