← Back to team overview

kicad-developers team mailing list archive

Re: Symbol field editor dialog improvements

 

Jeff Young <jeff@xxxxxxxxx> writes:

> Hi Ben,
>
> You probably saw my comments in the bug that 0002 has already been
> addressed.
>
I see that. That being said, I somewhat favor the approach taken in my
patch. The reason is that the committed solution behaves slightly
unfortunately when faced with projects containing different sets of
fields.

For instance, imagine I have a two projects

 * Proj1 has fields A, B, C
 * Proj2 has fields A, B, D

When I switch from one project to the other the state of fields C and D
will be forgotten. With my approach, however, they are retained. IMHO
this is a more consistent (and certainly, in my case, useful) behavior.

Not to mention, my patch is considerably simpler, avoiding the need to
serialise.

> Could you change the opening and closing braces to be on their own
> line in 0001? (The rest matches our coding standard so I assume you
> found it, but if not:
> http://kicad.readthedocs.io/en/stable/Documentation/development/coding-style-policy/
> ).
>
Done. Revised patch attached.

> Also, if you could use git format-patch to produce the patch that would be great.
>
Hmm, I had used git format-patch. Is there something wrong with the
patch to suggest that I hadn't?

Cheers,

 - Ben

Attachment: signature.asc
Description: PGP signature

>From b8807c2888f3995eec7709aae91c44b880b954a5 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@xxxxxxxxxxxxxxxx>
Date: Sat, 19 May 2018 11:25:28 -0400
Subject: [PATCH] field editor: Find components when reference field is clicked

This makes it significantly easier to find a particular component when
using the field editor, as I often do for part selection.
---
 eeschema/dialogs/dialog_fields_editor_global.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp
index f9e179452..308b68b8d 100644
--- a/eeschema/dialogs/dialog_fields_editor_global.cpp
+++ b/eeschema/dialogs/dialog_fields_editor_global.cpp
@@ -174,6 +174,10 @@ public:
             return GetValue( m_rows[ aRow ], aCol );
     }
 
+    std::vector<SCH_REFERENCE> GetRowReferences( int aRow )
+    {
+        return m_rows[ aRow ].m_Refs;
+    }
 
     wxString GetValue( DATA_MODEL_ROW& group, int aCol )
     {
@@ -823,7 +827,15 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnRegroupComponents( wxCommandEvent& event )
 void DIALOG_FIELDS_EDITOR_GLOBAL::OnTableCellClick( wxGridEvent& event )
 {
     if( event.GetCol() == REFERENCE )
+    {
         m_dataModel->ExpandCollapseRow( event.GetRow());
+        std::vector<SCH_REFERENCE> refs = m_dataModel->GetRowReferences( event.GetRow() );
+        if (refs.size() == 1)
+        {
+            m_parent->FindComponentAndItem( refs[0].GetRef() + refs[0].GetRefNumber(),
+                                            true, FIND_COMPONENT_ONLY, wxEmptyString, false );
+        }
+    }
     else
         event.Skip();
 }
-- 
2.16.2


Follow ups

References