Mercurial > mercurial > hgweb_searcher03.cgi
changeset 13:bbd65edf71d4
Implement Hhs DB update dialog.
author | pyon@macmini |
---|---|
date | Sat, 24 May 2014 10:25:13 +0900 |
parents | 52958cd4a073 |
children | ac17a73e39b3 |
files | Changes include/db.h include/hhsdb.h include/myframe.h include/preview.h src/bprint.cpp src/db.cpp src/hhsdb.cpp src/myframe.cpp src/preview.cpp |
diffstat | 10 files changed, 239 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Sun May 18 19:49:15 2014 +0900 +++ b/Changes Sat May 24 10:25:13 2014 +0900 @@ -1,3 +1,10 @@ +version 03.14 +2014-05-23 + Implement Hhs DB update dialog. + Colouring selected thumbnail in PreviewDialog. + +---- + version 03.13 2014-05-21 Implement file infomation window in PreviewDialog.
--- a/include/db.h Sun May 18 19:49:15 2014 +0900 +++ b/include/db.h Sat May 24 10:25:13 2014 +0900 @@ -1,11 +1,13 @@ // Filename : db.h -// Last Change: 02-May-2014. +// Last Change: 21-May-2014. // #ifndef __DB_H__ #define __DB_H__ #include "common.h" +// 被保険者台帳を更新 +void UpdateHhs( wxArrayString info ); // 被保番で被保険者情報を取得 wxString GetHhsInfoByHhsNo( wxString hhsno ); // 被保険者番号リストから氏名を取得
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/hhsdb.h Sat May 24 10:25:13 2014 +0900 @@ -0,0 +1,33 @@ +// Filename : hhsdb.h +// Last Change: 21-May-2014. +// + +#ifndef __HHSDB_H__ +#define __HHSDB_H__ + +#include "common.h" + +class HhsDialog : public wxDialog +{ + DECLARE_EVENT_TABLE() + private: + + protected: + wxFilePickerCtrl* m_filePicker; + wxButton* m_buttonUpdate; + wxButton* m_buttonCancel; + + public: + HhsDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ); + ~HhsDialog(); + void OnUpdate( wxCommandEvent& WXUNUSED(event) ); +}; + +enum +{ + ID_FPICKR = wxID_HIGHEST + 130, + ID_UPDATE, +}; + +#endif //__HHSDB_H__ +
--- a/include/myframe.h Sun May 18 19:49:15 2014 +0900 +++ b/include/myframe.h Sat May 24 10:25:13 2014 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.h -// Last Change: 16-May-2014. +// Last Change: 20-May-2014. // #ifndef __MYFRAME_H__ #define __MYFRAME_H__ @@ -96,6 +96,7 @@ void OnBPrintMode( wxCommandEvent& WXUNUSED(event) ); void OnIndex( wxCommandEvent& WXUNUSED(event) ); void OnCache( wxCommandEvent& WXUNUSED(event) ); + void OnUpdateHhs( wxCommandEvent& WXUNUSED(event) ); void LoadParam( void ); void OnDBBackup( wxCommandEvent& WXUNUSED(event) ); void OnMaskParam( wxCommandEvent& WXUNUSED(event) ); @@ -126,6 +127,7 @@ ID_MNBPNT = wxID_HIGHEST + 10, ID_MNINDEX, ID_MNCACHE, + ID_MNHHSDB, ID_MNDBBKUP, ID_MNMASKPARAM, ID_MNMARKPARAM,
--- a/include/preview.h Sun May 18 19:49:15 2014 +0900 +++ b/include/preview.h Sat May 24 10:25:13 2014 +0900 @@ -1,5 +1,5 @@ // Filename : preview.h -// Last Change: 16-May-2014. +// Last Change: 23-May-2014. // #ifndef __PREVIEW_H__ @@ -15,6 +15,7 @@ PreviewDialog* m_parent; wxArrayString m_imagefiles; wxArrayString m_cachefiles; + wxImageList m_imageList; protected: wxStaticBitmap* m_bitmap0; @@ -34,7 +35,8 @@ void OnClick3( wxMouseEvent& event ); void OnClick4( wxMouseEvent& event ); void OnClick5( wxMouseEvent& event ); - void SetFiles( wxArrayString imagefiles, wxArrayString cachefiles ); + void SetFiles( wxArrayString imagefiles, wxArrayString cachefiles, int select ); + void SetImageList( int selected ); void Preview( int n ); }; @@ -60,7 +62,7 @@ PreviewDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ); ~PreviewDialog(); - void SetFiles( wxArrayString imagefiles, wxArrayString cachefiles ); + void SetFiles( wxArrayString imagefiles, wxArrayString cachefiles, int select ); void SetPreviewSize( void ); void SetPreviewImage( int n ); void OnPrint( wxCommandEvent& event );
--- a/src/bprint.cpp Sun May 18 19:49:15 2014 +0900 +++ b/src/bprint.cpp Sat May 24 10:25:13 2014 +0900 @@ -1,5 +1,5 @@ // Filename : bprint.cpp -// Last Change: 16-May-2014. +// Last Change: 21-May-2014. // #include "bprint.h" @@ -110,7 +110,7 @@ if ( info.IsEmpty() ) info.Add( wxEmptyString ); if ( path.IsEmpty() ) { - wxMessageBox( wxT("ファイルがありません.") ); + wxMessageBox( wxT("審査会がありません.") ); path.Add( wxEmptyString ); }
--- a/src/db.cpp Sun May 18 19:49:15 2014 +0900 +++ b/src/db.cpp Sat May 24 10:25:13 2014 +0900 @@ -1,11 +1,67 @@ // Filename : db.cpp -// Last Change: 02-May-2014. +// Last Change: 23-May-2014. // +#include <wx/tokenzr.h> #include "db.h" #include "wx/wxsqlite3.h" //********** HHS-DB **********// +/* 被保険者台帳を更新 */ +void UpdateHhs( wxArrayString info ) +{ + long n = info.GetCount(); + + wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), n, NULL, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); + pd.SetSize( wxSize( 320, 140 ) ); + + wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db"); + wxRemoveFile( gszFile ); + + wxSQLite3Database hhsdb; + hhsdb.Open( gszFile ); + hhsdb.Begin(); + + wxString sql = wxT( "PRAGMA foregin_keys=OFF" ); + wxSQLite3Statement stmt = hhsdb.PrepareStatement( sql ); + wxSQLite3ResultSet q = stmt.ExecuteQuery(); + + sql = wxT( "CREATE TABLE 'hhs_master' ( hhsno text PRIMARY KEY, birth text, name text, kana text, addr text, sex text )" ); + stmt = hhsdb.PrepareStatement( sql ); + q = stmt.ExecuteQuery(); + + wxString hhsno, birth, name, kana, addr, sex; + for ( long i = 0; i < n; i++ ) { + + info[i].Replace( wxT("\""), wxEmptyString, true ); + + wxStringTokenizer token( info[i], wxT(",") ); + hhsno = token.GetNextToken(); + birth = token.GetNextToken(); + name = token.GetNextToken(); + kana = token.GetNextToken(); + addr = token.GetNextToken(); + sex = token.GetNextToken(); + + stmt = hhsdb.PrepareStatement( "INSERT INTO hhs_master VALUES( ?, ?, ?, ?, ?, ? );" ); + stmt.Bind( 1, hhsno ); + stmt.Bind( 2, birth ); + stmt.Bind( 3, name ); + stmt.Bind( 4, kana ); + stmt.Bind( 5, addr ); + stmt.Bind( 6, sex ); + stmt.ExecuteQuery(); + stmt.Finalize(); + + if ( i % 1000 == 0 ) { + pd.Update( i, wxString::Format( wxT("%d / %d done."), i, n ) ); + } + } + + hhsdb.Commit(); + hhsdb.Close(); +} + /* 被保番で被保険者情報を取得 */ wxString GetHhsInfoByHhsNo( wxString hhsno ) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hhsdb.cpp Sat May 24 10:25:13 2014 +0900 @@ -0,0 +1,67 @@ +// Filename : hhsdb.cpp +// Last Change: 23-May-2014. +// + +#include "hhsdb.h" +#include "db.h" + +HhsDialog::HhsDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) + : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + this->SetBackgroundColour( wxColour( wxT("WHEAT") ) ); + + wxBoxSizer* bSizerTop; + bSizerTop = new wxBoxSizer( wxVERTICAL ); + + m_filePicker = new wxFilePickerCtrl( this, ID_FPICKR, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_USE_TEXTCTRL ); + bSizerTop->Add( m_filePicker, 0, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* bSizerButton; + bSizerButton = new wxBoxSizer( wxHORIZONTAL ); + + m_buttonUpdate = new wxButton( this, ID_UPDATE, wxT("更新処理開始"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButton->Add( m_buttonUpdate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButton->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizerTop->Add( bSizerButton, 0, wxALIGN_RIGHT, 5 ); + + this->SetSizer( bSizerTop ); + this->Layout(); + + this->Centre( wxBOTH ); +} + +HhsDialog::~HhsDialog() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( HhsDialog, wxDialog ) + EVT_BUTTON( ID_UPDATE, HhsDialog::OnUpdate ) +END_EVENT_TABLE() + +void HhsDialog::OnUpdate( wxCommandEvent& WXUNUSED(event) ) +{ + wxString file = m_filePicker->GetPath(); + + wxTextFile input( file ); + if ( !input.Exists() ) { + wxMessageBox( wxT("指定されたファイルがありません.") ); + return; + } + + wxArrayString hhs; + + wxCSConv cust( wxT("cp932") ); + input.Open( cust ); + for ( wxString buf = input.GetFirstLine(); !input.Eof(); buf = input.GetNextLine() ) { + hhs.Add( buf ); + } + input.Close(); + UpdateHhs( hhs ); + wxMessageBox( wxT("process done.") ); +} +
--- a/src/myframe.cpp Sun May 18 19:49:15 2014 +0900 +++ b/src/myframe.cpp Sat May 24 10:25:13 2014 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.cpp -// Last Change: 16-May-2014. +// Last Change: 23-May-2014. // #include "main.h" #include "db.h" @@ -8,6 +8,7 @@ #include "hist.h" #include "preview.h" #include "index.h" +#include "hhsdb.h" #include "cache.h" #include "param.h" #include "marksheet.h" @@ -194,7 +195,7 @@ PreviewDialog* pd = new PreviewDialog( m_parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); pd->Show(); pd->Maximize( true ); - pd->SetFiles( m_imagefiles, m_cachefiles ); + pd->SetFiles( m_imagefiles, m_cachefiles, n ); pd->SetPreviewImage( n ); } @@ -234,10 +235,8 @@ m_menuFile->AppendSeparator(); // ---- - /* wxMenuItem* m_menuItemHhsdb = new wxMenuItem( m_menuFile, ID_MNHHSDB, wxString( wxT("被保険者DB更新(&U)") ) , wxT("Update HHS databases"), wxITEM_NORMAL ); m_menuFile->Append( m_menuItemHhsdb ); - */ wxMenuItem* m_menuItemBkup = new wxMenuItem( m_menuFile, ID_MNDBBKUP, wxString( wxT("DBバックアップ(&B)") ) , wxT("Backup databases"), wxITEM_NORMAL ); m_menuFile->Append( m_menuItemBkup ); @@ -353,6 +352,7 @@ EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode ) EVT_MENU( ID_MNINDEX, MyFrame::OnIndex ) + EVT_MENU( ID_MNHHSDB, MyFrame::OnUpdateHhs ) EVT_MENU( ID_MNCACHE, MyFrame::OnCache ) EVT_MENU( ID_MNDBBKUP, MyFrame::OnDBBackup ) EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam ) @@ -575,6 +575,12 @@ cache->Setting( rootdir, THUMB_W, THUMB_H ); cache->ShowModal(); } +/* 被保険者DB更新 */ +void MyFrame::OnUpdateHhs( wxCommandEvent& WXUNUSED(event) ) +{ + HhsDialog* hd = new HhsDialog( this, wxID_ANY, wxT("被保険者DB更新"), wxDefaultPosition, wxSize( 500, 100 ), wxCAPTION|wxFRAME_NO_TASKBAR ); + hd->Show(); +} /* マークシートパラメータ設定ダイアログ */ void MyFrame::OnMarkParam( wxCommandEvent& WXUNUSED(event) ) {
--- a/src/preview.cpp Sun May 18 19:49:15 2014 +0900 +++ b/src/preview.cpp Sat May 24 10:25:13 2014 +0900 @@ -1,5 +1,5 @@ // Filename : preview.cpp -// Last Change: 16-May-2014. +// Last Change: 23-May-2014. // #include "marksheet.h" @@ -59,17 +59,20 @@ // Functions /* サムネイル表示 */ -void PThumbnailPanel::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles ) +void PThumbnailPanel::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles, int select ) { m_imagefiles = imagefiles; wxBitmap bmp; - bmp.LoadFile( cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp ); - bmp.LoadFile( cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp ); - bmp.LoadFile( cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp ); - bmp.LoadFile( cachefiles[3], wxBITMAP_TYPE_PNG ); m_bitmap3->SetBitmap( bmp ); - bmp.LoadFile( cachefiles[4], wxBITMAP_TYPE_PNG ); m_bitmap4->SetBitmap( bmp ); - bmp.LoadFile( cachefiles[5], wxBITMAP_TYPE_PNG ); m_bitmap5->SetBitmap( bmp ); + m_imageList.Create( THUMB_W, THUMB_H ); + + bmp.LoadFile( cachefiles[0], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); + bmp.LoadFile( cachefiles[1], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); + bmp.LoadFile( cachefiles[2], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); + bmp.LoadFile( cachefiles[3], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); + bmp.LoadFile( cachefiles[4], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); + bmp.LoadFile( cachefiles[5], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); + SetImageList( select ); } /* 画像クリックで拡大表示 */ void PThumbnailPanel::OnClick0( wxMouseEvent& WXUNUSED(event) ) { Preview( 0 ); } @@ -81,9 +84,48 @@ void PThumbnailPanel::Preview( int n ) { if ( m_imagefiles.GetCount() < n + 1 ) return; + SetImageList( n ); m_parent->SetPreviewImage( n ); } +/* サムネイル表示 */ +void PThumbnailPanel::SetImageList( int selected ) +{ + m_bitmap0->SetBitmap( m_imageList.GetBitmap(0) ); + m_bitmap1->SetBitmap( m_imageList.GetBitmap(1) ); + m_bitmap2->SetBitmap( m_imageList.GetBitmap(2) ); + m_bitmap3->SetBitmap( m_imageList.GetBitmap(3) ); + m_bitmap4->SetBitmap( m_imageList.GetBitmap(4) ); + m_bitmap5->SetBitmap( m_imageList.GetBitmap(5) ); + wxImage image = m_imageList.GetBitmap( selected ).ConvertToImage(); + unsigned char *data = image.GetData(); + for ( int y = 0; y < THUMB_H; y++ ) + for ( int x = 0; x <THUMB_W; x++ ) + data[ ( y * THUMB_W + x ) * 3 + 2 ] = 255; // 文字色:黒(0,0,0)->青(0,0,255) + + wxBitmap bmp_mask( image ); + + switch ( selected ) { + case 0: + m_bitmap0->SetBitmap( bmp_mask ); + break; + case 1: + m_bitmap1->SetBitmap( bmp_mask ); + break; + case 2: + m_bitmap2->SetBitmap( bmp_mask ); + break; + case 3: + m_bitmap3->SetBitmap( bmp_mask ); + break; + case 4: + m_bitmap4->SetBitmap( bmp_mask ); + break; + case 5: + m_bitmap5->SetBitmap( bmp_mask ); + break; + } +} //////////////////////////////////////////////////////// // プレビューダイアログ @@ -156,11 +198,11 @@ m_textInfo->SetValue( info ); } -void PreviewDialog::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles ) +void PreviewDialog::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles, int select ) { m_imagefiles = imagefiles; m_cachefiles = cachefiles; - m_thumbPanel->SetFiles( m_imagefiles, m_cachefiles ); + m_thumbPanel->SetFiles( m_imagefiles, m_cachefiles, select ); wxString title = wxT("プレビュー @ ") + m_imagefiles[0].BeforeLast( wxFILE_SEP_PATH ); this->SetTitle( title );