Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/hhsdb.cpp @ 13:bbd65edf71d4
Implement Hhs DB update dialog.
| author | pyon@macmini |
|---|---|
| date | Sat, 24 May 2014 10:25:13 +0900 |
| parents | |
| children | a2ad87cad48b |
comparison
equal
deleted
inserted
replaced
| 12:52958cd4a073 | 13:bbd65edf71d4 |
|---|---|
| 1 // Filename : hhsdb.cpp | |
| 2 // Last Change: 23-May-2014. | |
| 3 // | |
| 4 | |
| 5 #include "hhsdb.h" | |
| 6 #include "db.h" | |
| 7 | |
| 8 HhsDialog::HhsDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | |
| 9 : wxDialog( parent, id, title, pos, size, style ) | |
| 10 { | |
| 11 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); | |
| 12 this->SetBackgroundColour( wxColour( wxT("WHEAT") ) ); | |
| 13 | |
| 14 wxBoxSizer* bSizerTop; | |
| 15 bSizerTop = new wxBoxSizer( wxVERTICAL ); | |
| 16 | |
| 17 m_filePicker = new wxFilePickerCtrl( this, ID_FPICKR, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_USE_TEXTCTRL ); | |
| 18 bSizerTop->Add( m_filePicker, 0, wxALL|wxEXPAND, 5 ); | |
| 19 | |
| 20 wxBoxSizer* bSizerButton; | |
| 21 bSizerButton = new wxBoxSizer( wxHORIZONTAL ); | |
| 22 | |
| 23 m_buttonUpdate = new wxButton( this, ID_UPDATE, wxT("更新処理開始"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 24 bSizerButton->Add( m_buttonUpdate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 25 | |
| 26 m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 27 bSizerButton->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 28 | |
| 29 bSizerTop->Add( bSizerButton, 0, wxALIGN_RIGHT, 5 ); | |
| 30 | |
| 31 this->SetSizer( bSizerTop ); | |
| 32 this->Layout(); | |
| 33 | |
| 34 this->Centre( wxBOTH ); | |
| 35 } | |
| 36 | |
| 37 HhsDialog::~HhsDialog() | |
| 38 { | |
| 39 } | |
| 40 | |
| 41 // Event Table | |
| 42 BEGIN_EVENT_TABLE( HhsDialog, wxDialog ) | |
| 43 EVT_BUTTON( ID_UPDATE, HhsDialog::OnUpdate ) | |
| 44 END_EVENT_TABLE() | |
| 45 | |
| 46 void HhsDialog::OnUpdate( wxCommandEvent& WXUNUSED(event) ) | |
| 47 { | |
| 48 wxString file = m_filePicker->GetPath(); | |
| 49 | |
| 50 wxTextFile input( file ); | |
| 51 if ( !input.Exists() ) { | |
| 52 wxMessageBox( wxT("指定されたファイルがありません.") ); | |
| 53 return; | |
| 54 } | |
| 55 | |
| 56 wxArrayString hhs; | |
| 57 | |
| 58 wxCSConv cust( wxT("cp932") ); | |
| 59 input.Open( cust ); | |
| 60 for ( wxString buf = input.GetFirstLine(); !input.Eof(); buf = input.GetNextLine() ) { | |
| 61 hhs.Add( buf ); | |
| 62 } | |
| 63 input.Close(); | |
| 64 UpdateHhs( hhs ); | |
| 65 wxMessageBox( wxT("process done.") ); | |
| 66 } | |
| 67 |
