← Back to team overview

kicad-developers team mailing list archive

[PATCH] Fixes for component table view

 

Wayne, et al,

I have attached a small patch implementing some of the improvements that
you suggested.

- Default column width expanded to match text
- Changed dialog style

Regards,
Oliver
From fe131fbffd74aeed6c6675c8fffaffe06d218bcd Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@xxxxxxxxx>
Date: Wed, 3 May 2017 15:24:58 +1000
Subject: [PATCH] Improvements for component table

Fixed default column width
Fixed dialog style
---
 eeschema/bom_table_model.cpp                |  9 +-------
 eeschema/dialogs/dialog_bom_editor.cpp      | 14 +++++++++++
 eeschema/dialogs/dialog_bom_editor_base.cpp |  2 +-
 eeschema/dialogs/dialog_bom_editor_base.fbp | 36 ++++++++++++++---------------
 eeschema/dialogs/dialog_bom_editor_base.h   |  2 +-
 5 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/eeschema/bom_table_model.cpp b/eeschema/bom_table_model.cpp
index d531dbd..f22022a 100644
--- a/eeschema/bom_table_model.cpp
+++ b/eeschema/bom_table_model.cpp
@@ -395,7 +395,7 @@ bool BOM_TABLE_GROUP::HasValueChanged( BOM_COLUMN* aField ) const
  *
  * @aSort - Sort the references
  */
-wxArrayString BOM_TABLE_GROUP::GetReferences( bool aSort) const
+wxArrayString BOM_TABLE_GROUP::GetReferences( bool aSort ) const
 {
     wxArrayString refs;
 
@@ -805,13 +805,6 @@ wxDataViewColumn* BOM_TABLE_MODEL::AddColumn( BOM_COLUMN* aColumn, int aPosition
     if( !found )
         m_widget->AppendColumn( column );
 
-    //TODO - wxCOL_WIDTH_AUTOSIZE prevents columns from thereafter being resized
-    // This requires some further attention
-
-    /**
-    column->SetWidth( wxCOL_WIDTH_AUTOSIZE );
-    column->SetWidth( column->GetWidth() );
-    **/
     column->SetResizeable( true );
 
     return column;
diff --git a/eeschema/dialogs/dialog_bom_editor.cpp b/eeschema/dialogs/dialog_bom_editor.cpp
index 84c6b04..1924cd2 100644
--- a/eeschema/dialogs/dialog_bom_editor.cpp
+++ b/eeschema/dialogs/dialog_bom_editor.cpp
@@ -85,6 +85,20 @@ DIALOG_BOM_EDITOR::DIALOG_BOM_EDITOR( SCH_EDIT_FRAME* parent ) :
 
     Update();
 
+    m_bomView->Update();
+
+    // Set default column widths
+    for( unsigned int ii = 0; ii < m_bomView->GetColumnCount(); ii++ )
+    {
+        auto col = m_bomView->GetColumn( ii );
+
+        if( !col )
+            continue;
+
+        col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
+        col->SetResizeable( true );
+    }
+
     Layout();
     GetSizer()->SetSizeHints( this );
     Centre();
diff --git a/eeschema/dialogs/dialog_bom_editor_base.cpp b/eeschema/dialogs/dialog_bom_editor_base.cpp
index 018e2b2..bb2f231 100644
--- a/eeschema/dialogs/dialog_bom_editor_base.cpp
+++ b/eeschema/dialogs/dialog_bom_editor_base.cpp
@@ -93,7 +93,7 @@ DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id,
 	sbSizer4->Add( m_sdbSizer1, 1, wxEXPAND, 5 );
 	
 	
-	bSizer6->Add( sbSizer4, 1, wxEXPAND, 5 );
+	bSizer6->Add( sbSizer4, 0, wxEXPAND, 10 );
 	
 	
 	m_leftPanel->SetSizer( bSizer6 );
diff --git a/eeschema/dialogs/dialog_bom_editor_base.fbp b/eeschema/dialogs/dialog_bom_editor_base.fbp
index b6427b0..11f796f 100644
--- a/eeschema/dialogs/dialog_bom_editor_base.fbp
+++ b/eeschema/dialogs/dialog_bom_editor_base.fbp
@@ -44,8 +44,8 @@
             <property name="minimum_size"></property>
             <property name="name">DIALOG_BOM_EDITOR_BASE</property>
             <property name="pos"></property>
-            <property name="size">1047,649</property>
-            <property name="style">wxCAPTION|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSTAY_ON_TOP</property>
+            <property name="size">1047,800</property>
+            <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
             <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
             <property name="title">BOM editor</property>
             <property name="tooltip"></property>
@@ -344,11 +344,11 @@
                                                 <property name="name">bSizer6</property>
                                                 <property name="orient">wxVERTICAL</property>
                                                 <property name="permission">none</property>
-                                                <object class="sizeritem" expanded="1">
+                                                <object class="sizeritem" expanded="0">
                                                     <property name="border">5</property>
                                                     <property name="flag">wxEXPAND</property>
                                                     <property name="proportion">0</property>
-                                                    <object class="wxStaticBoxSizer" expanded="1">
+                                                    <object class="wxStaticBoxSizer" expanded="0">
                                                         <property name="id">wxID_ANY</property>
                                                         <property name="label">Options</property>
                                                         <property name="minimum_size"></property>
@@ -445,11 +445,11 @@
                                                                 <event name="OnUpdateUI"></event>
                                                             </object>
                                                         </object>
-                                                        <object class="sizeritem" expanded="1">
+                                                        <object class="sizeritem" expanded="0">
                                                             <property name="border">5</property>
                                                             <property name="flag">wxALL|wxEXPAND</property>
                                                             <property name="proportion">0</property>
-                                                            <object class="wxButton" expanded="1">
+                                                            <object class="wxButton" expanded="0">
                                                                 <property name="BottomDockable">1</property>
                                                                 <property name="LeftDockable">1</property>
                                                                 <property name="RightDockable">1</property>
@@ -623,20 +623,20 @@
                                                         </object>
                                                     </object>
                                                 </object>
-                                                <object class="sizeritem" expanded="1">
+                                                <object class="sizeritem" expanded="0">
                                                     <property name="border">5</property>
                                                     <property name="flag">wxEXPAND</property>
                                                     <property name="proportion">5</property>
-                                                    <object class="wxBoxSizer" expanded="1">
+                                                    <object class="wxBoxSizer" expanded="0">
                                                         <property name="minimum_size"></property>
                                                         <property name="name">bSizer9</property>
                                                         <property name="orient">wxVERTICAL</property>
                                                         <property name="permission">none</property>
-                                                        <object class="sizeritem" expanded="1">
+                                                        <object class="sizeritem" expanded="0">
                                                             <property name="border">5</property>
                                                             <property name="flag">wxEXPAND</property>
                                                             <property name="proportion">1</property>
-                                                            <object class="wxStaticBoxSizer" expanded="1">
+                                                            <object class="wxStaticBoxSizer" expanded="0">
                                                                 <property name="id">wxID_ANY</property>
                                                                 <property name="label">Fields</property>
                                                                 <property name="minimum_size"></property>
@@ -717,21 +717,21 @@
                                                         </object>
                                                     </object>
                                                 </object>
-                                                <object class="sizeritem" expanded="1">
+                                                <object class="sizeritem" expanded="0">
                                                     <property name="border">5</property>
                                                     <property name="flag">wxEXPAND</property>
                                                     <property name="proportion">0</property>
-                                                    <object class="spacer" expanded="1">
+                                                    <object class="spacer" expanded="0">
                                                         <property name="height">0</property>
                                                         <property name="permission">protected</property>
                                                         <property name="width">0</property>
                                                     </object>
                                                 </object>
-                                                <object class="sizeritem" expanded="1">
-                                                    <property name="border">5</property>
+                                                <object class="sizeritem" expanded="0">
+                                                    <property name="border">10</property>
                                                     <property name="flag">wxEXPAND</property>
-                                                    <property name="proportion">1</property>
-                                                    <object class="wxStaticBoxSizer" expanded="1">
+                                                    <property name="proportion">0</property>
+                                                    <object class="wxStaticBoxSizer" expanded="0">
                                                         <property name="id">wxID_ANY</property>
                                                         <property name="label">Apply changes</property>
                                                         <property name="minimum_size"></property>
@@ -740,11 +740,11 @@
                                                         <property name="parent">1</property>
                                                         <property name="permission">none</property>
                                                         <event name="OnUpdateUI"></event>
-                                                        <object class="sizeritem" expanded="1">
+                                                        <object class="sizeritem" expanded="0">
                                                             <property name="border">5</property>
                                                             <property name="flag">wxEXPAND</property>
                                                             <property name="proportion">1</property>
-                                                            <object class="wxStdDialogButtonSizer" expanded="1">
+                                                            <object class="wxStdDialogButtonSizer" expanded="0">
                                                                 <property name="Apply">0</property>
                                                                 <property name="Cancel">1</property>
                                                                 <property name="ContextHelp">0</property>
diff --git a/eeschema/dialogs/dialog_bom_editor_base.h b/eeschema/dialogs/dialog_bom_editor_base.h
index c7689db..e7b04f1 100644
--- a/eeschema/dialogs/dialog_bom_editor_base.h
+++ b/eeschema/dialogs/dialog_bom_editor_base.h
@@ -86,7 +86,7 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM
 	
 	public:
 		
-		DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("BOM editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 1047,649 ), long style = wxCAPTION|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSTAY_ON_TOP ); 
+		DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("BOM editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 1047,800 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); 
 		~DIALOG_BOM_EDITOR_BASE();
 		
 		void m_splitter1OnIdle( wxIdleEvent& )
-- 
2.7.4


Follow ups