Remove unused DIALOG_FILE_DIR_PICKER
This class was replaced with native dialogs for choosing the files and directories
This commit is contained in:
parent
ffa30d75a3
commit
9dff31c2ac
|
@ -163,7 +163,6 @@ set( COMMON_DLG_SRCS
|
||||||
dialogs/dialog_configure_paths_base.cpp
|
dialogs/dialog_configure_paths_base.cpp
|
||||||
dialogs/dialog_display_info_HTML_base.cpp
|
dialogs/dialog_display_info_HTML_base.cpp
|
||||||
dialogs/dialog_edit_library_tables.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.cpp
|
||||||
dialogs/dialog_global_lib_table_config_base.cpp
|
dialogs/dialog_global_lib_table_config_base.cpp
|
||||||
dialogs/dialog_hotkey_list.cpp
|
dialogs/dialog_hotkey_list.cpp
|
||||||
|
|
|
@ -1,142 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2018 CERN
|
|
||||||
* Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
|
||||||
*
|
|
||||||
* Author: Maciej Suminski <maciej.suminski@cern.ch>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// inspired by David Hart's FileDirDlg widget (4Pane project)
|
|
||||||
|
|
||||||
#include "dialog_file_dir_picker.h"
|
|
||||||
#include <wx/filename.h>
|
|
||||||
|
|
||||||
|
|
||||||
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() );
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2018 CERN
|
|
||||||
* Author: Maciej Suminski <maciej.suminski@cern.ch>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// inspired by David Hart's FileDirDlg widget (4Pane project)
|
|
||||||
|
|
||||||
#ifndef __DIALOG_FILE_DIR_PICKER_H__
|
|
||||||
#define __DIALOG_FILE_DIR_PICKER_H__
|
|
||||||
|
|
||||||
#include <dialog_shim.h>
|
|
||||||
#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__
|
|
|
@ -52,7 +52,6 @@
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
#include <env_paths.h>
|
#include <env_paths.h>
|
||||||
#include <dialogs/dialog_file_dir_picker.h>
|
|
||||||
#include <dialog_edit_library_tables.h>
|
#include <dialog_edit_library_tables.h>
|
||||||
#include <footprint_viewer_frame.h>
|
#include <footprint_viewer_frame.h>
|
||||||
#include <footprint_edit_frame.h>
|
#include <footprint_edit_frame.h>
|
||||||
|
|
Loading…
Reference in New Issue