Mercurial > mercurial > hgweb_searcher03.cgi
view include/dndfile.h @ 4:fdba695b99f1
More fast ( read from DB ).
Improve the precision of marksheet judgement.
author | pyon@macmini |
---|---|
date | Wed, 11 Sep 2013 19:09:14 +0900 |
parents | 1a64119ab257 |
children | bc2e2b304095 |
line wrap: on
line source
// Filename : dndfile.h // Last Change: 11-Sep-2013. // #include "db.h" class DnDFile : public wxFileDropTarget { public: DnDFile( wxGrid *grid ) { m_grid = grid; } virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames ) { size_t nFiles = filenames.GetCount(); if ( nFiles != 1 ) return false; m_grid->ClearGrid(); // ファイルから被保番リストを生成 wxTextFile csv; csv.Open( filenames[0] ); wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); wxArrayString hhs; for ( int n = 0; n < csv.GetLineCount(); n++ ) { wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL ); if ( ! reHhs.Matches( hhsno ) ) continue; hhs.Add( hhsno ); } csv.Close(); // int d = hhs.GetCount() - m_grid->GetNumberRows(); if ( d > 0 ) m_grid->AppendRows( d, true ); // グリッドに情報を読込み wxArrayString res = GetHhsInfoAndPathByHhsNoList( hhs ); for ( int r = 0; r < res.GetCount(); r++ ) { wxArrayString data = wxSplit( res[r], '_', '\\' ); m_grid->SetCellValue( r, 0, data[0] ); m_grid->SetCellValue( r, 1, data[1] ); m_grid->SetCellValue( r, 2, data[2] ); } return true; } private: wxGrid* m_grid; }; class DnDFile2 : public wxFileDropTarget { public: DnDFile2( wxGrid *grid ) { m_grid = grid; } virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames ) { size_t nFiles = filenames.GetCount(); if ( nFiles != 1 ) return false; m_grid->ClearGrid(); wxTextFile csv; csv.Open( filenames[0] ); int d = csv.GetLineCount() - m_grid->GetNumberRows(); if ( d > 0 ) m_grid->AppendRows( d, true ); wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); for ( int n = 0, j = 0; n < csv.GetLineCount(); n++ ) { wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL ); if ( ! reHhs.Matches( hhsno ) ) { j++; continue; } int r = n - j; wxArrayString info = wxSplit( GetHhsInfoByHhsNo( hhsno ), '_', '\\' ); wxArrayString path = GetPathByHhsNo( hhsno ); if ( info.IsEmpty() ) info.Add( wxEmptyString ); if ( path.IsEmpty() ) path.Add( wxEmptyString ); m_grid->SetCellValue( r, 0, hhsno ); m_grid->SetCellValue( r, 1, info[0] ); m_grid->SetCellValue( r, 2, path[0] ); } csv.Close(); return true; } private: wxGrid* m_grid; };