Mercurial > mercurial > hgweb_mover2.cgi
comparison src/myframe.cpp @ 37:3b54f3deeed9 v2.4
fix undo-command.
| author | pyon@macmini |
|---|---|
| date | Fri, 18 Nov 2011 20:46:12 +0900 |
| parents | 405e08552527 |
| children | 044cc2f5af81 |
comparison
equal
deleted
inserted
replaced
| 36:73116df23be8 | 37:3b54f3deeed9 |
|---|---|
| 1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
| 2 // Last Change: 17-Nov-2011. | 2 // Last Change: 18-Nov-2011. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "main.h" | 5 #include "main.h" |
| 6 #include "myframe.h" | 6 #include "myframe.h" |
| 7 #include "param.h" | 7 #include "param.h" |
| 12 #define LOGO_H 86 | 12 #define LOGO_H 86 |
| 13 #define HHSN_W 288 | 13 #define HHSN_W 288 |
| 14 #define HHSN_H 49 | 14 #define HHSN_H 49 |
| 15 #define THUMB_W 160 | 15 #define THUMB_W 160 |
| 16 #define THUMB_H 226 | 16 #define THUMB_H 226 |
| 17 | |
| 18 #if defined(__WXMSW__) | |
| 19 #define MOVECMD wxT("move") | |
| 20 #else | |
| 21 #define MOVECMD wxT("mv") | |
| 22 #endif | |
| 23 | 17 |
| 24 | 18 |
| 25 // resources | 19 // resources |
| 26 // the application icon (under Windows and OS/2 it is in resources and even | 20 // the application icon (under Windows and OS/2 it is in resources and even |
| 27 // though we could still include the XPM here it would be unused) | 21 // though we could still include the XPM here it would be unused) |
| 258 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLDIR, MyFrame::OnOpenHhsDir ) | 252 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLDIR, MyFrame::OnOpenHhsDir ) |
| 259 EVT_CLOSE( MyFrame::SaveConfig ) | 253 EVT_CLOSE( MyFrame::SaveConfig ) |
| 260 END_EVENT_TABLE() | 254 END_EVENT_TABLE() |
| 261 | 255 |
| 262 // Event Handlers & Functions | 256 // Event Handlers & Functions |
| 257 /* 自動検知 ON/OFF */ | |
| 263 void MyFrame::ToggleAutoDetect(wxCommandEvent& event) | 258 void MyFrame::ToggleAutoDetect(wxCommandEvent& event) |
| 264 { | 259 { |
| 265 if ( event.IsChecked() ) autodetect_mode = true; | 260 if ( event.IsChecked() ) autodetect_mode = true; |
| 266 else autodetect_mode = false; | 261 else autodetect_mode = false; |
| 267 } | 262 } |
| 315 to.Append( dt.Format(wxT("%Y%m%d")) ); // C:/20xx/20yymmdd | 310 to.Append( dt.Format(wxT("%Y%m%d")) ); // C:/20xx/20yymmdd |
| 316 to.Append( wxFILE_SEP_PATH ); // C:/20xx/20yymmdd/ | 311 to.Append( wxFILE_SEP_PATH ); // C:/20xx/20yymmdd/ |
| 317 to.Append( m_comboBoxCcn->GetValue() ); // C:/20xx/20yymmdd/XXN | 312 to.Append( m_comboBoxCcn->GetValue() ); // C:/20xx/20yymmdd/XXN |
| 318 m_textCtrlDist->SetValue( to ); | 313 m_textCtrlDist->SetValue( to ); |
| 319 | 314 |
| 320 | |
| 321 wxString ccn = m_comboBoxCcn->GetValue(); | 315 wxString ccn = m_comboBoxCcn->GetValue(); |
| 322 if ( to.Len() < 15 || ccn.IsEmpty() ) { | 316 if ( to.Len() < 15 || ccn.IsEmpty() ) { |
| 323 wxMessageBox(wxT("フォルダを指定してください.")); | 317 wxMessageBox(wxT("フォルダを指定してください.")); |
| 324 return; | 318 return; |
| 325 } | 319 } |
| 346 | 340 |
| 347 wxMessageBox(wxT("移動先フォルダ準備完了")); | 341 wxMessageBox(wxT("移動先フォルダ準備完了")); |
| 348 wxString cmd = wxT("explorer ") + to; | 342 wxString cmd = wxT("explorer ") + to; |
| 349 wxExecute( cmd ); | 343 wxExecute( cmd ); |
| 350 } | 344 } |
| 345 | |
| 351 /* 検知 */ | 346 /* 検知 */ |
| 352 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) | 347 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) |
| 353 { | 348 { |
| 354 by_autodetect = false; | 349 by_autodetect = false; |
| 355 UpdateCache(); | 350 UpdateCache(); |
| 409 wxString from = workdir + wxFILE_SEP_PATH + file; | 404 wxString from = workdir + wxFILE_SEP_PATH + file; |
| 410 wxString to = hhsdir + wxFILE_SEP_PATH + file; | 405 wxString to = hhsdir + wxFILE_SEP_PATH + file; |
| 411 wxRenameFile( from, to, true ); | 406 wxRenameFile( from, to, true ); |
| 412 wxGetApp().WriteLog( wxT("moved : ") + file ); | 407 wxGetApp().WriteLog( wxT("moved : ") + file ); |
| 413 | 408 |
| 414 wxString movecmd = MOVECMD; | 409 m_undo.Insert( to, 0 ); |
| 415 from.Replace( wxT("\\"), wxT("\\\\"), true ); | |
| 416 to.Replace( wxT("\\"), wxT("\\\\"), true ); | |
| 417 m_undo.Insert( movecmd + wxT(" ") + to + wxT(" ") + from, 0 ); | |
| 418 } | 410 } |
| 419 } | 411 } |
| 420 /* 選択したファイルを削除 */ | 412 /* 選択したファイルを削除 */ |
| 421 void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event)) | 413 void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event)) |
| 422 { | 414 { |
| 431 wxString from = workdir + wxFILE_SEP_PATH + file; | 423 wxString from = workdir + wxFILE_SEP_PATH + file; |
| 432 wxString to = trash + wxFILE_SEP_PATH + file; | 424 wxString to = trash + wxFILE_SEP_PATH + file; |
| 433 wxRenameFile( from, to, true ); | 425 wxRenameFile( from, to, true ); |
| 434 wxGetApp().WriteLog( wxT("deleted : ") + file ); | 426 wxGetApp().WriteLog( wxT("deleted : ") + file ); |
| 435 | 427 |
| 436 wxString movecmd = MOVECMD; | 428 m_undo.Insert( to, 0 ); |
| 437 from.Replace( wxT("\\"), wxT("\\\\"), true ); | 429 } |
| 438 to.Replace( wxT("\\"), wxT("\\\\"), true ); | 430 |
| 439 m_undo.Insert( movecmd + wxT(" ") + to + wxT(" ") + from, 0 ); | |
| 440 } | |
| 441 UpdateCache(); | 431 UpdateCache(); |
| 442 ClearGuess(); | 432 ClearGuess(); |
| 443 UpdateListImage(); | 433 UpdateListImage(); |
| 444 m_buttonUndo->Enable(true); | 434 m_buttonUndo->Enable(true); |
| 445 } | 435 } |
| 446 /* アンドゥ */ | 436 /* アンドゥ */ |
| 447 void MyFrame::OnUndo(wxCommandEvent& WXUNUSED(event)) | 437 void MyFrame::OnUndo(wxCommandEvent& WXUNUSED(event)) |
| 448 { | 438 { |
| 439 wxString workdir = m_dirPickerWork->GetPath(); | |
| 449 for ( int i=0; i<m_undo.GetCount(); i++ ) { | 440 for ( int i=0; i<m_undo.GetCount(); i++ ) { |
| 450 wxExecute( m_undo[i] ); | 441 wxFileName file( m_undo[i] ); |
| 442 wxString to = workdir + wxFILE_SEP_PATH + file.GetFullName(); | |
| 443 wxRenameFile( m_undo[i], to, true ); | |
| 451 } | 444 } |
| 452 wxMessageBox(wxT("戻し完了.")); | 445 wxMessageBox(wxT("戻し完了.")); |
| 453 m_buttonUndo->Enable(false); | 446 m_buttonUndo->Enable(false); |
| 454 m_undo.Clear(); | 447 m_undo.Clear(); |
| 455 UpdateCache(); | 448 UpdateCache(); |
