← Back to team overview

kicad-developers team mailing list archive

[PATCH 26/27] Pin Table: display icon in pin type column

 

---
 eeschema/dialogs/dialog_lib_edit_pin_table.cpp | 50 +++++++++++++++++++++++---
 1 file changed, 45 insertions(+), 5 deletions(-)

diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
index 28b4938..cfc3ee8 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
@@ -154,7 +154,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent,
             100,
             wxAlignment( wxALIGN_LEFT | wxALIGN_TOP ),
             wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE );
-    wxDataViewTextRenderer* rend2 = new wxDataViewTextRenderer( wxT( "string" ), wxDATAVIEW_CELL_INERT );
+    wxDataViewIconTextRenderer* rend2 = new wxDataViewIconTextRenderer( wxT( "wxDataViewIconText" ), wxDATAVIEW_CELL_INERT );
     wxDataViewColumn* col2 = new wxDataViewColumn( _( "Type" ),
             rend2,
             DataViewModel::PIN_TYPE,
@@ -216,7 +216,23 @@ unsigned int DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetColumnCount() const
 
 wxString DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetColumnType( unsigned int aCol ) const
 {
-    return wxT( "string" );
+    switch( aCol )
+    {
+    case PIN_NUMBER:
+        return wxT( "string" );
+
+    case PIN_NAME:
+        return wxT( "string" );
+
+    case PIN_TYPE:
+        return wxT( "wxDataViewIconText" );
+
+    case PIN_POSITION:
+        return wxT( "string" );
+    }
+
+    assert( ! "Unhandled column" );
+    return wxT( "" );
 }
 
 
@@ -508,10 +524,30 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::GetValue( wxVariant& aValu
         {
             wxVariant value;
             (*i)->GetValue( value, aCol );
-            values.insert( value.GetString() );
+            if( aCol == PIN_TYPE )
+            {
+                wxDataViewIconText it;
+                it << value;
+                values.insert( it.GetText() );
+            }
+            else
+            {
+                values.insert( value.GetString() );
+            }
         }
 
-        aValue = boost::algorithm::join( values, "," );
+        if( values.size() > 1 )
+        {
+            wxString value = boost::algorithm::join( values, "," );
+            if( aCol == PIN_TYPE )
+                aValue << wxDataViewIconText( value, wxNullIcon );
+            else
+                aValue = value;
+        }
+        else
+        {
+            m_Members.front()->GetValue( aValue, aCol );
+        }
     }
 }
 
@@ -568,7 +604,11 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Pin::GetValue( wxVariant& aValue,
     break;
 
     case PIN_TYPE:
-        aValue = m_Backing->GetElectricalTypeName();
+        {
+            wxIcon icon;
+            icon.CopyFromBitmap( KiBitmap ( GetBitmap( m_Backing->GetType() ) ) );
+            aValue << wxDataViewIconText( m_Backing->GetElectricalTypeName(), icon );
+        }
         break;
 
     case PIN_POSITION:

Follow ups

References