From ef62b01dd1e527880741b50005bf7749a3c2c092 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 25 Apr 2024 09:19:22 -0700 Subject: [PATCH] Make import/export flags explicit IO plugins can import/export or both. This sets an explicit boolean for controlling which options are available. --- eeschema/files-io.cpp | 2 +- include/io/io_base.h | 7 +++++-- pcbnew/files.cpp | 2 +- pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 1a5db21701..e9f8b8838b 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -715,7 +715,7 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent ) const IO_BASE::IO_FILE_DESC& desc = pi->GetSchematicFileDesc(); - if( desc.m_FileExtensions.empty() ) + if( desc.m_FileExtensions.empty() || !desc.m_CanRead ) continue; if( !fileFiltersStr.IsEmpty() ) diff --git a/include/io/io_base.h b/include/io/io_base.h index 0263ceb677..78640eca17 100644 --- a/include/io/io_base.h +++ b/include/io/io_base.h @@ -41,12 +41,15 @@ public: std::vector m_FileExtensions; ///< Filter used for file pickers if m_IsFile is true std::vector m_ExtensionsInDir; ///< In case of folders: extensions of files inside bool m_IsFile; ///< Whether the library is a folder or a file + bool m_CanRead; ///< Whether the IO can read this file type + bool m_CanWrite; ///< Whether the IO can write this file type IO_FILE_DESC( const wxString& aDescription, const std::vector& aFileExtensions, - const std::vector& aExtsInFolder = {}, bool aIsFile = true ) : + const std::vector& aExtsInFolder = {}, bool aIsFile = true, + bool aCanRead = true, bool aCanWrite = true ) : m_Description( aDescription ), m_FileExtensions( aFileExtensions ), m_ExtensionsInDir( aExtsInFolder ), - m_IsFile( aIsFile ) + m_IsFile( aIsFile ), m_CanRead( aCanRead ), m_CanWrite( aCanWrite ) { } diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 426cd291f5..e37d925e19 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -112,7 +112,7 @@ bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, int aCt const IO_BASE::IO_FILE_DESC& desc = pi->GetBoardFileDesc(); - if( desc.m_FileExtensions.empty() ) + if( desc.m_FileExtensions.empty() || !desc.m_CanRead ) continue; descriptions.emplace_back( desc ); diff --git a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h index a2317736ea..89261d89ac 100644 --- a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h +++ b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h @@ -85,7 +85,7 @@ public: const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override { - return IO_BASE::IO_FILE_DESC( wxEmptyString, {} ); + return IO_BASE::IO_FILE_DESC( wxEmptyString, {}, {}, false, false, true ); } const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override