changeset 37:3b54f3deeed9 v2.4

fix undo-command.
author pyon@macmini
date Fri, 18 Nov 2011 20:46:12 +0900
parents 73116df23be8
children 044cc2f5af81
files include/myframe.h src/myframe.cpp
diffstat 2 files changed, 11 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/include/myframe.h	Fri Nov 18 20:45:39 2011 +0900
+++ b/include/myframe.h	Fri Nov 18 20:46:12 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : myframe.h
-// Last Change: 17-Nov-2011.
+// Last Change: 18-Nov-2011.
 //
 
 #ifndef __myframe__
--- a/src/myframe.cpp	Fri Nov 18 20:45:39 2011 +0900
+++ b/src/myframe.cpp	Fri Nov 18 20:46:12 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : myframe.cpp
-// Last Change: 17-Nov-2011.
+// Last Change: 18-Nov-2011.
 //
 
 #include "main.h"
@@ -15,12 +15,6 @@
 #define THUMB_W 160
 #define THUMB_H 226
 
-#if defined(__WXMSW__)
-    #define MOVECMD wxT("move")
-#else
-    #define MOVECMD wxT("mv")
-#endif
-
 
 // resources
 // the application icon (under Windows and OS/2 it is in resources and even
@@ -260,6 +254,7 @@
 END_EVENT_TABLE()
 
 // Event Handlers & Functions
+/* 自動検知 ON/OFF */
 void MyFrame::ToggleAutoDetect(wxCommandEvent& event)
 {
     if ( event.IsChecked() ) autodetect_mode = true;
@@ -317,7 +312,6 @@
     to.Append( m_comboBoxCcn->GetValue() );     // C:/20xx/20yymmdd/XXN
     m_textCtrlDist->SetValue( to );
 
-
     wxString ccn = m_comboBoxCcn->GetValue();
     if ( to.Len() < 15 || ccn.IsEmpty() ) {
         wxMessageBox(wxT("フォルダを指定してください."));
@@ -348,6 +342,7 @@
     wxString cmd = wxT("explorer ") + to;
     wxExecute( cmd );
 }
+
 /* 検知 */
 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event))
 {
@@ -411,10 +406,7 @@
         wxRenameFile( from, to, true );
         wxGetApp().WriteLog( wxT("moved : ") + file );
 
-        wxString movecmd = MOVECMD;
-        from.Replace( wxT("\\"), wxT("\\\\"), true );
-        to.Replace(   wxT("\\"), wxT("\\\\"), true );
-        m_undo.Insert( movecmd + wxT(" ") + to + wxT(" ") + from, 0 );
+        m_undo.Insert( to, 0 );
     }
 }
 /* 選択したファイルを削除 */
@@ -433,11 +425,9 @@
         wxRenameFile( from, to, true );
         wxGetApp().WriteLog( wxT("deleted : ") + file );
 
-        wxString movecmd = MOVECMD;
-        from.Replace( wxT("\\"), wxT("\\\\"), true );
-        to.Replace(   wxT("\\"), wxT("\\\\"), true );
-        m_undo.Insert( movecmd + wxT(" ") + to + wxT(" ") + from, 0 );
+        m_undo.Insert( to, 0 );
     }
+
     UpdateCache();
     ClearGuess();
     UpdateListImage();
@@ -446,8 +436,11 @@
 /* アンドゥ */
 void MyFrame::OnUndo(wxCommandEvent& WXUNUSED(event))
 {
+    wxString workdir = m_dirPickerWork->GetPath();
     for ( int i=0; i<m_undo.GetCount(); i++ ) {
-        wxExecute( m_undo[i] );
+        wxFileName file( m_undo[i] );
+        wxString to = workdir + wxFILE_SEP_PATH + file.GetFullName();
+        wxRenameFile( m_undo[i], to, true );
     }
     wxMessageBox(wxT("戻し完了."));
     m_buttonUndo->Enable(false);