← Back to team overview

kicad-developers team mailing list archive

[Patch] Fixes for the github 3D library fetching dialog

 

The attached patch modifies the behavior of the wizard for fetching the 3d
libraries from github to fetch the list of libraries if the URL is modified
by the user (e.g. if they go to page 2, then back to page 1 and modify the
URL it will now fetch the library list for the modified URL). It also fixes
an issue where the library list was not populating when first visiting the
second page (it would only populate if you tried searching or went back to
page 1 and then page 2).

-Ian
From 5893a4a6c4e30d7eaa244e35ad7939757d582153 Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@xxxxxxxx>
Date: Sat, 4 May 2019 00:56:51 +0100
Subject: [PATCH] pcbnew: 3D library fetching dialog improvements

CHANGED: Made the github library fetch dialog update the library list
when the URL is changed.

CHANGED: Fixed issue with library list not updating when first displaying
the second dialog page.
---
 .../wizard_3DShape_Libs_downloader.cpp        | 21 +++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/pcbnew/dialogs/wizard_3DShape_Libs_downloader.cpp b/pcbnew/dialogs/wizard_3DShape_Libs_downloader.cpp
index 10d8a71bf..57f5da49c 100644
--- a/pcbnew/dialogs/wizard_3DShape_Libs_downloader.cpp
+++ b/pcbnew/dialogs/wizard_3DShape_Libs_downloader.cpp
@@ -512,10 +512,27 @@ void WIZARD_3DSHAPE_LIBS_DOWNLOADER::setupGithubList()
     m_checkList3Dlibnames->GetCheckedItems( checkedIndices );
     enableNext( checkedIndices.GetCount() > 0 );
 
-    // Update only if necessary
-    if( m_githubLibs.GetCount() == 0 )
+    // Update only if the text has changed or the list is empty
+    if( m_githubLibs.GetCount() == 0 || m_textCtrlGithubURL->IsModified() )
+    {
+        m_githubLibs.Clear();
         getLibsListGithub( m_githubLibs );
 
+        // Populate the list
+        m_checkList3Dlibnames->Clear();
+        for( unsigned int i = 0; i < m_githubLibs.GetCount(); ++i )
+        {
+            const wxString& lib = m_githubLibs[i].AfterLast( '/' );
+            m_checkList3Dlibnames->Append( lib );
+        }
+
+        m_textCtrlGithubURL->SetModified( 0 );
+    }
+
+    if( !m_checkList3Dlibnames->IsEmpty() )
+        m_checkList3Dlibnames->EnsureVisible( 0 );
+
+    // Clear the search box
     m_searchCtrl3Dlibs->Clear();
 
     // Clear the review list so it will be reloaded
-- 
2.17.2


Follow ups