From 9dff31c2acf65edb72810be498e8b538a036ff1c Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Tue, 7 Jan 2020 23:40:00 +0000 Subject: [PATCH] Remove unused DIALOG_FILE_DIR_PICKER This class was replaced with native dialogs for choosing the files and directories --- common/CMakeLists.txt | 1 - common/dialogs/dialog_file_dir_picker.cpp | 142 ---------------------- common/dialogs/dialog_file_dir_picker.h | 69 ----------- pcbnew/dialogs/panel_fp_lib_table.cpp | 1 - 4 files changed, 213 deletions(-) delete mode 100644 common/dialogs/dialog_file_dir_picker.cpp delete mode 100644 common/dialogs/dialog_file_dir_picker.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index c97c1997b4..56d68fd74a 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -163,7 +163,6 @@ set( COMMON_DLG_SRCS dialogs/dialog_configure_paths_base.cpp dialogs/dialog_display_info_HTML_base.cpp dialogs/dialog_edit_library_tables.cpp - dialogs/dialog_file_dir_picker.cpp dialogs/dialog_global_lib_table_config.cpp dialogs/dialog_global_lib_table_config_base.cpp dialogs/dialog_hotkey_list.cpp diff --git a/common/dialogs/dialog_file_dir_picker.cpp b/common/dialogs/dialog_file_dir_picker.cpp deleted file mode 100644 index 4d2fc0a8cc..0000000000 --- a/common/dialogs/dialog_file_dir_picker.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2018 CERN - * Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors. - * - * Author: Maciej Suminski - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -// inspired by David Hart's FileDirDlg widget (4Pane project) - -#include "dialog_file_dir_picker.h" -#include - - -DIALOG_FILE_DIR_PICKER::DIALOG_FILE_DIR_PICKER( wxWindow* parent, const wxString& title, - const wxString& defaultPath, const wxString& wildcard, int style ) - : DIALOG_SHIM( parent, wxID_ANY, title, wxDefaultPosition, - wxSize( -1, 600 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) -{ - m_showHidden = nullptr; - - wxString path = defaultPath.IsEmpty() ? wxGetCwd() : defaultPath; - m_filesOnly = style & FD_RETURN_FILESONLY; - - int m_GDC_style = wxDIRCTRL_3D_INTERNAL | wxDIRCTRL_EDIT_LABELS; - - if( !wildcard.IsEmpty() ) - m_GDC_style |= wxDIRCTRL_SHOW_FILTERS; - - if( style & FD_MULTIPLE ) - m_GDC_style |= wxDIRCTRL_MULTIPLE; - - - SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* mainSizer; - mainSizer = new wxBoxSizer( wxVERTICAL ); - - m_GDC = new wxGenericDirCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, m_GDC_style ); - - m_GDC->ShowHidden( style & FD_SHOW_HIDDEN ); - - // TODO filter is not applied until it is reselected in the drop-down list, why? - if( !wildcard.IsEmpty() ) - m_GDC->SetFilter( wildcard ); - - mainSizer->Add( m_GDC, 1, wxEXPAND | wxALL, 5 ); - - // TODO commented out due to string freeze, uncomment in v6 - //m_showHidden = new wxCheckBox( this, wxID_ANY, _( "Show Hidden" ), wxDefaultPosition, wxDefaultSize, 0 ); - //m_showHidden->SetValue( style & FD_SHOW_HIDDEN ); - //mainSizer->Add( m_showHidden, 0, wxALL, 5 ); - - auto sdbSizer = new wxStdDialogButtonSizer(); - sdbSizer->AddButton( new wxButton( this, wxID_OK ) ); - sdbSizer->AddButton( new wxButton( this, wxID_CANCEL ) ); - sdbSizer->Realize(); - mainSizer->Add( sdbSizer, 0, wxEXPAND | wxALL, 5 ); - - SetSizer( mainSizer ); - Layout(); - Centre( wxBOTH ); - - // Use Connect() here instead of an event table entry, as otherwise an - // event is fired before the dialog is created and m_GDC and Text initialised - Connect( wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, - (wxObjectEventFunction) &DIALOG_FILE_DIR_PICKER::onHidden ); - - // Call SetDirectory() to make the path visible - SetDirectory( path ); -} - - -void DIALOG_FILE_DIR_PICKER::SetDirectory( const wxString& aDirectory ) const -{ - // Make the requested path visible. Without scrolling to the bottom, the requested path - // is just below the window. - wxArrayTreeItemIds selections; - auto treeCtrl = m_GDC->GetTreeCtrl(); - - treeCtrl->UnselectAll(); - m_GDC->SetPath( aDirectory ); - m_GDC->SetDefaultPath( aDirectory ); - treeCtrl->GetSelections( selections ); - - if( !selections.IsEmpty() && selections[0].IsOk() ) - { - auto lastChild = treeCtrl->GetLastChild( treeCtrl->GetRootItem() ); - - if( lastChild.IsOk() ) - treeCtrl->ScrollTo( lastChild ); - - treeCtrl->ScrollTo( selections[0] ); - } -} - - -wxString DIALOG_FILE_DIR_PICKER::GetDirectory() const -{ - wxFileName fileName( m_GDC->GetPath() ); - - // Strip the file name, if it is included in the path - return fileName.FileExists() ? fileName.GetPath() : fileName.GetFullPath(); -} - - -size_t DIALOG_FILE_DIR_PICKER::GetFilenames( wxArrayString& aFilePaths ) -{ - wxArrayTreeItemIds selectedIds; - size_t count = m_GDC->GetTreeCtrl()->GetSelections( selectedIds ); - - for( size_t c = 0; c < count; ++c ) - { - wxDirItemData* data = (wxDirItemData*) m_GDC->GetTreeCtrl()->GetItemData( selectedIds[c] ); - - if( m_filesOnly && wxDirExists( data->m_path ) ) - continue; // If we only want files, skip dirs - - aFilePaths.Add( data->m_path ); - } - - return aFilePaths.GetCount(); -} - - -void DIALOG_FILE_DIR_PICKER::onHidden( wxCommandEvent& event ) -{ - m_GDC->ShowHidden( event.IsChecked() ); -} diff --git a/common/dialogs/dialog_file_dir_picker.h b/common/dialogs/dialog_file_dir_picker.h deleted file mode 100644 index 9928539463..0000000000 --- a/common/dialogs/dialog_file_dir_picker.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2018 CERN - * Author: Maciej Suminski - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -// inspired by David Hart's FileDirDlg widget (4Pane project) - -#ifndef __DIALOG_FILE_DIR_PICKER_H__ -#define __DIALOG_FILE_DIR_PICKER_H__ - -#include -#include "wx/dirctrl.h" - - -enum FILE_DIR_PICKER_STYLE -{ - FD_MULTIPLE = 0x0001, - FD_SHOW_HIDDEN = 0x0002, - FD_RETURN_FILESONLY = 0x0004 -}; - -/** - * @brief Dialog that can select both files and directories. - */ -class DIALOG_FILE_DIR_PICKER : public DIALOG_SHIM -{ -public: - DIALOG_FILE_DIR_PICKER( wxWindow* parent, const wxString& message, const wxString& defaultPath, - const wxString& wildcard, int style = FD_MULTIPLE | FD_SHOW_HIDDEN ); - - void SetDirectory( const wxString& aDirectory ) const; - - wxString GetDirectory() const; - - /** - * Sets the wildcard filter. - * @param aFilter is the new filter - */ - void SetFilter( const wxString& aFilter ) - { - m_GDC->SetFilter( aFilter ); - } - - // Get multiple filepaths. Returns number found - size_t GetFilenames( wxArrayString& aFilepaths ); - -protected: - void onHidden( wxCommandEvent& event ); - - bool m_filesOnly; - wxGenericDirCtrl* m_GDC; - wxCheckBox* m_showHidden; - -}; - -#endif //__DIALOG_FILE_DIR_PICKER_H__ diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index b15472f6f7..2cfecfaf04 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include