← Back to team overview

kicad-developers team mailing list archive

Re: Symbol field editor dialog improvements

 

Hi Ben,

You probably saw my comments in the bug that 0002 has already been addressed.

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/ ).

Also, if you could use git format-patch to produce the patch that would be great.

Thanks,
Jeff.


> On 23 May 2018, at 20:42, Ben Gamari <ben@xxxxxxxxxxxxxxxx> wrote:
> 
> N.B. sending this again since the list seems to have eaten them when I
> sent them last weekend.
> 
> 
> Hi everyone,
> 
> Attached are two patches improving the usability of the symbol field
> editor dialog:
> 
> 0001: Teach the schematic editor to jump to a component when a cell in
>       the "Reference" column is clicked. I find this very helpful when
>       reviewing a design. This was in part motivated by #1772169
> 
> 0002: Save checkbox states, as requested by #1747602.
> 
> Hopefully these should be fairly uncontroversial.
> 
> Thanks!
> 
> Cheers,
> 
> - Ben
> 
> From c6d77d20bef7ab6b45fe5c4041cc22222d114115 Mon Sep 17 00:00:00 2001
> From: Ben Gamari <ben@xxxxxxxxxxxxxxxx>
> Date: Sat, 19 May 2018 11:25:28 -0400
> Subject: [PATCH 1/2] 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 | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp
> index d6445f3a6..f7b0784bd 100644
> --- a/eeschema/dialogs/dialog_fields_editor_global.cpp
> +++ b/eeschema/dialogs/dialog_fields_editor_global.cpp
> @@ -166,6 +166,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 )
>     {
> @@ -736,9 +740,14 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnRegroupComponents( wxCommandEvent& event )
> 
> void DIALOG_FIELDS_EDITOR_GLOBAL::OnTableCellClick( wxGridEvent& event )
> {
> -    if( event.GetCol() == REFERENCE )
> +    if( event.GetCol() == REFERENCE ) {
>         m_dataModel->ExpandCollapseRow( event.GetRow());
> -    else
> +        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
> 
> From da4768860f416168a0c95bcdabdc7c9fac988022 Mon Sep 17 00:00:00 2001
> From: Ben Gamari <ben@xxxxxxxxxxxxxxxx>
> Date: Sat, 19 May 2018 11:47:39 -0400
> Subject: [PATCH 2/2] field editor: Save checkbox states
> 
> This teaches the field editor dialog to remember the states of the
> "Show" and "Group By" checkboxes, as requested in #1747602.
> ---
> eeschema/dialogs/dialog_fields_editor_global.cpp | 29 +++++++++++++++++++++---
> eeschema/dialogs/dialog_fields_editor_global.h   |  1 +
> 2 files changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp
> index f7b0784bd..976aef44d 100644
> --- a/eeschema/dialogs/dialog_fields_editor_global.cpp
> +++ b/eeschema/dialogs/dialog_fields_editor_global.cpp
> @@ -30,6 +30,7 @@
> #include <bitmaps.h>
> #include <grid_tricks.h>
> #include <kicad_string.h>
> +#include <kiface_i.h>
> 
> #include <build_version.h>
> #include <general.h>
> @@ -514,6 +515,8 @@ DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent
>         DIALOG_FIELDS_EDITOR_GLOBAL_BASE( parent ),
>         m_parent( parent )
> {
> +    m_config = Kiface().KifaceSettings();
> +
>     // Get all components from the list of schematic sheets
>     SCH_SHEET_LIST sheets( g_RootSheet );
>     sheets.GetComponents( m_componentRefs, false );
> @@ -561,6 +564,14 @@ DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent
>     m_grid->UseNativeColHeader( true );
>     m_grid->SetTable( m_dataModel, true );
> 
> +    // Hide hidden-by-default fields
> +    for( int row = 0; row < m_fieldsCtrl->GetItemCount(); ++row )
> +    {
> +        if( !m_fieldsCtrl->GetToggleValue( row, SHOW_FIELD_COLUMN ) )
> +            m_grid->HideCol( row );
> +    }
> +
> +
>     // add Cut, Copy, and Paste to wxGrid
>     m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
> 
> @@ -636,6 +647,9 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::AddField( const wxString& aFieldName,
> 
>     wxVector<wxVariant> fieldsCtrlDataLine;
> 
> +    m_config->Read("SymbolFieldEditor/Show/" + aFieldName, &defaultShow);
> +    m_config->Read("SymbolFieldEditor/GroupBy/" + aFieldName, &defaultSortBy);
> +
>     fieldsCtrlDataLine.push_back( wxVariant( aFieldName ) );
>     fieldsCtrlDataLine.push_back( wxVariant( defaultShow ) );
>     fieldsCtrlDataLine.push_back( wxVariant( defaultSortBy ) );
> @@ -682,19 +696,28 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnColumnItemToggled( wxDataViewEvent& event )
>     default:
>         break;
> 
> -    case SHOW_FIELD_COLUMN:
> -        if( m_fieldsCtrl->GetToggleValue( row, col ) )
> +    case SHOW_FIELD_COLUMN: {
> +        bool value = m_fieldsCtrl->GetToggleValue( row, col );
> +        wxString fieldName = m_fieldsCtrl->GetTextValue(row, FIELD_NAME_COLUMN);
> +        m_config->Write( "SymbolFieldEditor/Show/"+fieldName, value );
> +
> +        if( value )
>             m_grid->ShowCol( row );
>         else
>             m_grid->HideCol( row );     // grid's columns map to fieldsCtrl's rows
>         break;
> +    }
> 
> -    case GROUP_BY_COLUMN:
> +    case GROUP_BY_COLUMN: {
> +        bool value = m_fieldsCtrl->GetToggleValue( row, col );
> +        wxString fieldName = m_fieldsCtrl->GetTextValue(row, FIELD_NAME_COLUMN);
> +        m_config->Write( "SymbolFieldEditor/GroupBy/"+fieldName, value );
>         m_dataModel->RebuildRows( m_groupComponentsBox, m_fieldsCtrl );
>         m_dataModel->Sort( m_grid->GetSortingColumn(), m_grid->IsSortOrderAscending() );
>         m_grid->ForceRefresh();
>         break;
>     }
> +    }
> }
> 
> 
> diff --git a/eeschema/dialogs/dialog_fields_editor_global.h b/eeschema/dialogs/dialog_fields_editor_global.h
> index 2ca13dd44..8e0176b9e 100644
> --- a/eeschema/dialogs/dialog_fields_editor_global.h
> +++ b/eeschema/dialogs/dialog_fields_editor_global.h
> @@ -43,6 +43,7 @@ public:
>     bool TransferDataFromWindow() override;
> 
> private:
> +    wxConfigBase*   m_config;
>     SCH_EDIT_FRAME* m_parent;
>     int             m_showColWidth;
>     int             m_groupByColWidth;
> -- 
> 2.16.2
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp



Follow ups

References