1
// -------------------------------------------------------------------------------- //
2
// Copyright (C) 2008-2010 J.Rios
5
// This Program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2, or (at your option)
10
// This Program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; see the file LICENSE. If not, write to
17
// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
// http://www.gnu.org/copyleft/gpl.h"tml
20
// -------------------------------------------------------------------------------- //
24
#include "DbLibrary.h"
26
#include <wx/string.h>
27
#include <wx/listbox.h>
28
#include <wx/gdicmn.h>
30
#include <wx/colour.h>
31
#include <wx/settings.h>
32
#include <wx/stattext.h>
33
#include <wx/textctrl.h>
34
#include <wx/bitmap.h>
37
#include <wx/bmpbuttn.h>
38
#include <wx/button.h>
40
#include <wx/statbox.h>
41
#include <wx/dialog.h>
43
// -------------------------------------------------------------------------------- //
44
wxString inline NormalizeField( const wxString &name )
46
// Special chars: < > : " / \ | ? *
47
wxString RetVal = name;
48
RetVal.Replace( wxT( "<" ), wxT( "_" ) );
49
RetVal.Replace( wxT( ">" ), wxT( "_" ) );
50
RetVal.Replace( wxT( ":" ), wxT( "_" ) );
51
RetVal.Replace( wxT( "\"" ), wxT( "_" ) );
52
RetVal.Replace( wxT( "/" ), wxT( "_" ) );
53
RetVal.Replace( wxT( "\\" ), wxT( "_" ) );
54
RetVal.Replace( wxT( "|" ), wxT( "_" ) );
55
RetVal.Replace( wxT( "?" ), wxT( "_" ) );
56
RetVal.Replace( wxT( "*" ), wxT( "_" ) );
57
if( RetVal[ 0 ] == wxT( '.' ) )
58
RetVal[ 0 ] = wxT( '_' );
62
// -------------------------------------------------------------------------------- //
63
class guFileRenamer : public wxDialog
66
wxListBox * m_FilesListBox;
67
wxTextCtrl * m_NameTextCtrl;
68
wxTextCtrl * m_PatTextCtrl;
69
wxBitmapButton * m_PatApplyBtn;
70
wxBitmapButton * m_PatRevertBtn;
74
wxArrayString m_Files;
76
void OnFileSelected( wxCommandEvent& event );
77
void OnPatternChanged( wxCommandEvent& event );
78
void OnPatternApply( wxCommandEvent& event );
79
void OnPattternRevert( wxCommandEvent& event );
81
void OnOKButton( wxCommandEvent& event );
84
guFileRenamer( wxWindow * parent, guDbLibrary * db, const wxArrayString &files );
87
wxArrayString GetRenamedNames( void );
92
// -------------------------------------------------------------------------------- //