Mercurial > mercurial > hgweb_mover2.cgi
changeset 26:5a934c8e1b95 v2.2dev
implement shorcutkeys & file count
author | pyon@macmini |
---|---|
date | Thu, 03 Nov 2011 15:48:26 +0900 |
parents | b3b3b8e97b54 |
children | d21de4693652 |
files | TODO include/main.h include/myframe.h src/myframe.cpp |
diffstat | 4 files changed, 84 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/TODO Thu Nov 03 15:47:25 2011 +0900 +++ b/TODO Thu Nov 03 15:48:26 2011 +0900 @@ -6,15 +6,12 @@ * ccn folder make -* hhs explore & file count * hhs name from db * error check hhsno * color red if guess hhsno failed * help -* F5 detect -* F7 move ---------------------------------------------------------------------- Memo
--- a/include/main.h Thu Nov 03 15:47:25 2011 +0900 +++ b/include/main.h Thu Nov 03 15:48:26 2011 +0900 @@ -1,5 +1,5 @@ // Filename : main.h -// Last Change: 23-Oct-2011. +// Last Change: 03-Nov-2011. // #include "wx/wx.h" #include "wx/config.h" @@ -9,7 +9,7 @@ #define VER 2 #define REV 2 -#define BLD 20111027 +#define BLD 20111104 // private classes // Define a new application type, each program should derive a class from wxApp
--- a/include/myframe.h Thu Nov 03 15:47:25 2011 +0900 +++ b/include/myframe.h Thu Nov 03 15:48:26 2011 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.h -// Last Change: 01-Nov-2011. +// Last Change: 03-Nov-2011. // #ifndef __myframe__ @@ -16,6 +16,7 @@ wxImageList* m_imageList; wxArrayString m_undo; wxTimer m_timer; + wxArrayString m_hhsList; CacheHash CH; protected: @@ -45,7 +46,7 @@ wxListCtrl* m_listCtrlView; - wxListCtrl* m_listCtrlDir; + wxListCtrl* m_listCtrlHhsDir; wxButton* m_buttonDetect; wxButton* m_buttonMove; wxButton* m_buttonDel; @@ -63,14 +64,18 @@ void ViewLarge(wxListEvent& event); void OnDetect(wxCommandEvent& event); void OnMove(wxCommandEvent& event); - void OnMoveAndDetect(wxCommandEvent& event); void OnDelete(wxCommandEvent& event); void OnUndo(wxCommandEvent& event); void UpdateListImage(void); void UpdateCache(void); + void ListHhsDir(void); + void MoveImages(void); void OnOpenHhsDir(wxListEvent& event); // $B0J2<!$Dj7?$b$N(B void OnTimer(wxTimerEvent& event); + void OnChar(wxKeyEvent& event); + void F5_Shortcut(void); + void F7_Shortcut(void); void OnIdle(wxIdleEvent& event); void OnWinSize(wxSizeEvent& event); void OnWinMove(wxMoveEvent& event);
--- a/src/myframe.cpp Thu Nov 03 15:47:25 2011 +0900 +++ b/src/myframe.cpp Thu Nov 03 15:48:26 2011 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.cpp -// Last Change: 02-Nov-2011. +// Last Change: 03-Nov-2011. // #include "main.h" @@ -155,19 +155,19 @@ bSizerButton->Add( gSizer, 0, wxALL, 5 ); - m_listCtrlDir = new wxListCtrl( this, ID_LISTCTRLDIR, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); + m_listCtrlHhsDir = new wxListCtrl( this, ID_LISTCTRLDIR, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); wxListItem itemCol; itemCol.SetText( wxT("通番") ); - m_listCtrlDir->InsertColumn( 0, itemCol ); - m_listCtrlDir->SetColumnWidth( 0, 50 ); + m_listCtrlHhsDir->InsertColumn( 0, itemCol ); + m_listCtrlHhsDir->SetColumnWidth( 0, 50 ); itemCol.SetText( wxT("被保険者番号") ); - m_listCtrlDir->InsertColumn( 1, itemCol ); - m_listCtrlDir->SetColumnWidth( 1, 100 ); + m_listCtrlHhsDir->InsertColumn( 1, itemCol ); + m_listCtrlHhsDir->SetColumnWidth( 1, 100 ); itemCol.SetText( wxT("ファイル数") ); - m_listCtrlDir->InsertColumn( 2, itemCol ); - m_listCtrlDir->SetColumnWidth( 2, 60 ); + m_listCtrlHhsDir->InsertColumn( 2, itemCol ); + m_listCtrlHhsDir->SetColumnWidth( 2, 60 ); - bSizerButton->Add( m_listCtrlDir, 1, wxEXPAND|wxALL, 5 ); + bSizerButton->Add( m_listCtrlHhsDir, 1, wxEXPAND|wxALL, 5 ); bSizerManip->Add( bSizerButton, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); @@ -193,6 +193,7 @@ // Event Table BEGIN_EVENT_TABLE( MyFrame, wxFrame ) + EVT_CHAR( MyFrame::OnChar ) EVT_IDLE( MyFrame::OnIdle ) EVT_TIMER( ID_TIMER, MyFrame::OnTimer ) EVT_SIZE( MyFrame::OnWinSize ) @@ -261,21 +262,29 @@ /* 検知 */ void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) { - UpdateCache(); - UpdateListImage(); + F5_Shortcut(); // UpdateCache -> UpdateListImage +} + +/* 移動 */ +void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) +{ + F7_Shortcut(); // MoveImages -> UpdateCache -> UpdateListImage -> ListHhsDir } /* 選択したファイルを移動 */ -void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) +void MyFrame::MoveImages() { m_undo.Clear(); wxString workdir = m_dirPickerWork->GetPath(); wxString distdir = m_textCtrlDist->GetValue(); + wxString hhsno = m_textCtrlGuess->GetValue(); + + m_hhsList.Remove(hhsno); + m_hhsList.Add(hhsno); long item = -1; for ( ;; ) { item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if ( item == -1 ) break; - wxString hhsno = m_textCtrlGuess->GetValue(); if ( !wxDirExists( distdir + wxFILE_SEP_PATH + hhsno ) ) wxMkdir( distdir + wxFILE_SEP_PATH + hhsno ); wxString file = m_listCtrlView->GetItemText( item ); @@ -286,9 +295,6 @@ wxString movecmd = MOVECMD; m_undo.Insert( movecmd + wxT(" ") + to + wxT(" ") + from, 0 ); } - UpdateCache(); - UpdateListImage(); - m_buttonUndo->Enable(true); } /* 選択したファイルを削除 */ void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event)) @@ -323,6 +329,7 @@ m_undo.Clear(); UpdateCache(); UpdateListImage(); + ListHhsDir(); } /* 画像をリストコントロールに表示 */ @@ -473,7 +480,6 @@ m_buttonDetect->Enable(false); wxGetApp().WriteLog( wxT("start updating cache") ); - SetStatusText( wxT("rebuiling cache..."), 0 ); wxStopWatch sw; sw.Start(0); @@ -485,14 +491,11 @@ } wxString workdir = m_dirPickerWork->GetPath(); - wxDir dir( workdir ); - if ( !dir.IsOpened() ) return; - wxArrayString filenames; wxListItem item; /* キャッシュ作成 */ - unsigned int n = dir.GetAllFiles( workdir, &filenames, wxT("*.jpg"), wxDIR_FILES ); + unsigned int n = wxDir::GetAllFiles( workdir, &filenames, wxT("*.jpg"), wxDIR_FILES ); for ( int i=0; i<n; i++ ) { wxString fullpath = filenames[i]; wxFileName f( fullpath ); @@ -526,7 +529,7 @@ ci->modtime = wxEmptyString; // TODO. CH[ci->filename] = ci; // add hash - SetStatusText( wxString::Format( wxT("rebuiling cache...(%.1fsec passed)"), (float)sw.Time()/1000 ), 0 ); + SetStatusText( wxString::Format( wxT("rebuiling cache...( %d/%d :%.1fsec passed )"), i+1, n, (float)sw.Time()/1000 ), 0 ); wxGetApp().WriteLog( file + wxT(" appended.") + wxString::Format(wxT(" ( m=%d z=%f l=%d )"), m ? 1 : 0, z, l ) ); } @@ -547,19 +550,44 @@ m_timer.Start( 20*1000, wxTIMER_ONE_SHOT ); // restart } -/* 被保険者を開く */ +/* 被保険者フォルダを列挙 */ +void MyFrame::ListHhsDir() +{ + wxString distdir = m_textCtrlDist->GetValue(); + wxString hhsdir; + wxString buf; + + m_listCtrlHhsDir->DeleteAllItems(); + for ( int i=0; i<m_hhsList.GetCount(); i++ ) { + hhsdir = distdir + wxFILE_SEP_PATH + m_hhsList[i]; + wxArrayString filenames; + unsigned int n = wxDir::GetAllFiles( hhsdir, &filenames, wxT("*.jpg"), wxDIR_FILES ); + + m_listCtrlHhsDir->InsertItem( i, -1 ); + buf.Printf(wxT("%d"),i+1); + m_listCtrlHhsDir->SetItem( i, 0, buf, -1 ); + m_listCtrlHhsDir->SetItem( i, 1, m_hhsList[i], -1 ); + buf.Printf(wxT("%d"),n); + m_listCtrlHhsDir->SetItem( i, 2, buf, -1 ); + if ( i % 2 ) m_listCtrlHhsDir->SetItemBackgroundColour( i, wxColour(wxT("WHEAT")) ); + } +} + +/* 被保険者フォルダを開く */ void MyFrame::OnOpenHhsDir(wxListEvent& event) { - wxString hhsdir = m_textCtrlDist->GetValue(); + wxString hhsdir; + hhsdir.Append( m_textCtrlDist->GetValue() ); hhsdir.Append( wxFILE_SEP_PATH ); wxListItem item = event.GetItem(); item.SetColumn(1); item.SetMask(wxLIST_MASK_TEXT); - m_listCtrlDir->GetItem( item ); + m_listCtrlHhsDir->GetItem( item ); hhsdir.Append( item.GetText() ); wxString execmd = wxT("explorer ") + hhsdir; wxExecute( execmd ); + //wxMessageBox(hhsdir); } // 以下,定型もの @@ -567,6 +595,27 @@ { UpdateCache(); } + +/* キーハンドリング */ +void MyFrame::OnChar(wxKeyEvent& event) +{ + if ( event.GetKeyCode() == WXK_F5 ) F5_Shortcut(); + if ( event.GetKeyCode() == WXK_F7 ) F7_Shortcut(); +} +void MyFrame::F5_Shortcut() +{ + UpdateCache(); + UpdateListImage(); +} +void MyFrame::F7_Shortcut() +{ + MoveImages(); + UpdateCache(); + UpdateListImage(); + ListHhsDir(); + m_buttonUndo->Enable(true); +} + /* アイドリング */ void MyFrame::OnIdle(wxIdleEvent& event) {