comparison src/rsearcher.cpp @ 13:f5ffc34f045a

manage DB.
author pyon@macmini
date Wed, 14 Nov 2018 19:43:40 +0900
parents 799b6008db8e
children c1dc1fcee7fe
comparison
equal deleted inserted replaced
12:240752cbe11b 13:f5ffc34f045a
1 // Filename : rsearcher.cpp 1 // Filename : rsearcher.cpp
2 // Last Change: 2018-11-09 金 09:01:40. 2 // Last Change: 2018-11-14 水 14:06:25.
3 // 3 //
4 4
5 #include <wx/arrstr.h> 5 #include <wx/arrstr.h>
6 #include <wx/html/htmprint.h> 6 #include <wx/html/htmprint.h>
7 #include <wx/clipbrd.h> 7 #include <wx/clipbrd.h>
288 EVT_BUTTON( ID_FOCUS, MainFrame::OnFocus ) 288 EVT_BUTTON( ID_FOCUS, MainFrame::OnFocus )
289 EVT_BUTTON( ID_PZOOM, MainFrame::OnPlusZoom ) 289 EVT_BUTTON( ID_PZOOM, MainFrame::OnPlusZoom )
290 EVT_BUTTON( ID_MZOOM, MainFrame::OnMinusZoom ) 290 EVT_BUTTON( ID_MZOOM, MainFrame::OnMinusZoom )
291 EVT_BUTTON( ID_DARK, MainFrame::OnDark ) 291 EVT_BUTTON( ID_DARK, MainFrame::OnDark )
292 EVT_BUTTON( ID_SWIN, MainFrame::OnSatellite ) 292 EVT_BUTTON( ID_SWIN, MainFrame::OnSatellite )
293 EVT_BUTTON( ID_UPIDX, MainFrame::OnUpdateIndex )
294 EVT_BUTTON( ID_DLMAN, MainFrame::OnDownloadManual )
293 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp ) 295 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp )
294 EVT_BUTTON( wxID_CLOSE, MainFrame::OnBClose ) 296 EVT_BUTTON( wxID_CLOSE, MainFrame::OnBClose )
295 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout ) 297 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout )
296 END_EVENT_TABLE() 298 END_EVENT_TABLE()
297 299
423 int w = bmp.GetWidth(); 425 int w = bmp.GetWidth();
424 int h = bmp.GetHeight(); 426 int h = bmp.GetHeight();
425 stl->SetScroll( w, h ); 427 stl->SetScroll( w, h );
426 428
427 stl->Show(); 429 stl->Show();
430 }
431
432 void MainFrame::OnUpdateIndex( wxCommandEvent& WXUNUSED(event ) )
433 {
434 GetDB( 0, 0, 2 );
435 UpdateIndex();
436 wxMessageBox( wxT( "update index done." ) );
437 }
438
439 void MainFrame::OnDownloadManual( wxCommandEvent& WXUNUSED(event) )
440 {
441 wxString execmd = wxT( "cmd /c start manual.pdf" );
442 wxExecute( execmd );
428 } 443 }
429 444
430 void MainFrame::OnHelp( wxCommandEvent& WXUNUSED(event) ) 445 void MainFrame::OnHelp( wxCommandEvent& WXUNUSED(event) )
431 { 446 {
432 wxString version, build; 447 wxString version, build;
570 m_buttonMzoom->Hide(); 585 m_buttonMzoom->Hide();
571 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 ); 586 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 );
572 m_buttonDark->Hide(); 587 m_buttonDark->Hide();
573 m_buttonSatellite = new wxButton( this, ID_SWIN, wxT( "Satellite" ), wxDefaultPosition, wxDefaultSize, 0 ); 588 m_buttonSatellite = new wxButton( this, ID_SWIN, wxT( "Satellite" ), wxDefaultPosition, wxDefaultSize, 0 );
574 m_buttonSatellite->Hide(); 589 m_buttonSatellite->Hide();
590 m_buttonDLMan = new wxButton( this, ID_DLMAN, wxT( "Manual" ), wxDefaultPosition, wxDefaultSize, 0 );
591 m_buttonDLMan->Hide();
592 m_buttonUpdateIndex = new wxButton( this, ID_UPIDX, wxT( "Update Index" ), wxDefaultPosition, wxDefaultSize, 0 );
593 m_buttonUpdateIndex->Hide();
575 m_buttonClose = new wxButton( this, wxID_CLOSE, wxT( "Close" ), wxDefaultPosition, wxDefaultSize, 0 ); 594 m_buttonClose = new wxButton( this, wxID_CLOSE, wxT( "Close" ), wxDefaultPosition, wxDefaultSize, 0 );
576 m_buttonClose->Hide(); 595 m_buttonClose->Hide();
577 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 ); 596 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 );
578 m_buttonHelp->Hide(); 597 m_buttonHelp->Hide();
579 598
593 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); 612 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
594 } 613 }
595 614
596 void MainFrame::SetAccelerator( void ) 615 void MainFrame::SetAccelerator( void )
597 { 616 {
598 wxAcceleratorEntry entries[9]; 617 wxAcceleratorEntry entries[11];
599 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT ); 618 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT );
600 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP ); 619 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP );
601 entries[2].Set( wxACCEL_NORMAL, WXK_F4, ID_FOCUS ); 620 entries[2].Set( wxACCEL_NORMAL, WXK_F2, ID_DLMAN );
602 entries[3].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM ); 621 entries[3].Set( wxACCEL_NORMAL, WXK_F4, ID_FOCUS );
603 entries[4].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM ); 622 entries[4].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM );
604 entries[5].Set( wxACCEL_NORMAL, (int)'D', ID_DARK ); 623 entries[5].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM );
605 entries[6].Set( wxACCEL_CTRL, (int)'Q', wxID_CLOSE ); 624 entries[6].Set( wxACCEL_NORMAL, (int)'D', ID_DARK );
606 entries[7].Set( wxACCEL_SHIFT, (int)'W', ID_SWIN ); 625 entries[7].Set( wxACCEL_CTRL, (int)'Q', wxID_CLOSE );
607 entries[8].Set( wxACCEL_SHIFT, (int)'L', ID_DARK ); // now building ( logout ) 626 entries[8].Set( wxACCEL_SHIFT, (int)'W', ID_SWIN );
608 wxAcceleratorTable accel( 8, entries ); 627 entries[9].Set( wxACCEL_SHIFT, (int)'R', ID_UPIDX );
628 entries[10].Set( wxACCEL_SHIFT, (int)'L', ID_DARK ); // now building ( logout )
629 wxAcceleratorTable accel( 10, entries );
609 SetAcceleratorTable( accel ); 630 SetAcceleratorTable( accel );
610 } 631 }
611 632
612 void MainFrame::Cmd( wxString cmd ) 633 void MainFrame::Cmd( wxString cmd )
613 { 634 {
627 648
628 if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) { 649 if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) {
629 return; 650 return;
630 } 651 }
631 652
632 if ( cmd.IsSameAs( wxT( "3915" ), true ) ) { 653 if ( cmd.IsSameAs( wxT( "3915" ), true ) && m_user.IsSameAs( wxT( "root" ) ) ) {
633 ManageDBFrame *mngframe = new ManageDBFrame( this, wxID_ANY, wxT( "Management Window" ), wxDefaultPosition, wxSize( 300, 180 ), wxCAPTION|wxTAB_TRAVERSAL ); 654 ManageDBFrame *mngframe = new ManageDBFrame( this, wxID_ANY, wxT( "Management Window" ), wxDefaultPosition, wxSize( 300, 180 ), wxCAPTION|wxTAB_TRAVERSAL );
655 mngframe->SetDBdir( m_dbdir );
656 mngframe->SetServer( m_server );
634 mngframe->Show(); 657 mngframe->Show();
658 m_searchCtrl->Clear();
635 return; 659 return;
636 } 660 }
637 661
638 if ( cmd.IsSameAs( wxT( "." ), false ) ) { 662 if ( cmd.IsSameAs( wxT( "." ), false ) ) {
639 wxString appdir = wxGetCwd(); 663 wxString appdir = wxGetCwd();
870 { 894 {
871 wxProgressDialog pd( wxT( "Load Data" ), wxT( "Now loading..." ), 100, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); 895 wxProgressDialog pd( wxT( "Load Data" ), wxT( "Now loading..." ), 100, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
872 pd.SetSize( wxSize( 320, 140 ) ); 896 pd.SetSize( wxSize( 320, 140 ) );
873 897
874 // index 898 // index
875 wxTextFile file; 899 UpdateIndex();
876 file.Open( wxT( "index.db" ) );
877 for ( int i = 0; i < file.GetLineCount(); i++ )
878 m_index.Add( file.GetLine( i ) );
879 file.Close();
880 m_index.Sort( true );
881 900
882 // decrypto 901 // decrypto
883 wxString key = wxT( "12345678900123456789abcdefabcdef" ); 902 wxString key = wxT( "12345678900123456789abcdefabcdef" );
884 wxArrayString args; 903 wxArrayString args;
885 args.Add( wxT( "crypto.exe" ) ); 904 args.Add( wxT( "crypto.exe" ) );
903 wxArrayString buf = wxSplit( output[i], ',', '\\' ); 922 wxArrayString buf = wxSplit( output[i], ',', '\\' );
904 hhash[ buf[0] ] = new HhsClass( buf ); // no, birth, name, kana, addr, sex 923 hhash[ buf[0] ] = new HhsClass( buf ); // no, birth, name, kana, addr, sex
905 } 924 }
906 } 925 }
907 926
927 void MainFrame::UpdateIndex( void )
928 {
929 wxString oldest = wxT( "30001231" );
930 wxString newest = wxT( "20000401" );
931 wxTextFile file;
932 file.Open( wxT( "index.db" ) );
933 for ( int i = 0; i < file.GetLineCount(); i++ ) {
934 wxArrayString buf = wxSplit( file.GetLine( i ), ':', '\\' );
935 if ( oldest.Cmp( buf[1] ) == 1 ) oldest = buf[1];
936 if ( newest.Cmp( buf[1] ) == -1 ) newest = buf[1];
937 m_index.Add( file.GetLine( i ) );
938 }
939 file.Close();
940 m_index.Sort( true );
941 m_textCtrlLog->SetValue( wxT( "Index: " ) + oldest + wxT( " - " ) + newest );
942 }
943
908 void MainFrame::PasteSearch( void ) 944 void MainFrame::PasteSearch( void )
909 { 945 {
910 wxString s; 946 wxString s;
911 if ( wxTheClipboard->Open() ) { 947 if ( wxTheClipboard->Open() ) {
912 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) { 948 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) {