Mercurial > mercurial > hgweb_searcher03.cgi
comparison include/dndfile.h @ 3:1a64119ab257
Equipment Regist print-target by Drag & Drop.
| author | pyon@macmini |
|---|---|
| date | Tue, 27 Aug 2013 18:50:00 +0900 |
| parents | |
| children | fdba695b99f1 |
comparison
equal
deleted
inserted
replaced
| 2:c066fde99517 | 3:1a64119ab257 |
|---|---|
| 1 // Filename : dndfile.h | |
| 2 // Last Change: 27-Aug-2013. | |
| 3 // | |
| 4 | |
| 5 #include "db.h" | |
| 6 | |
| 7 class DnDFile : public wxFileDropTarget | |
| 8 { | |
| 9 public: | |
| 10 DnDFile( wxGrid *grid ) | |
| 11 { | |
| 12 m_grid = grid; | |
| 13 } | |
| 14 virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames ) | |
| 15 { | |
| 16 size_t nFiles = filenames.GetCount(); | |
| 17 if ( nFiles != 1 ) return false; | |
| 18 | |
| 19 m_grid->ClearGrid(); | |
| 20 wxTextFile csv; | |
| 21 csv.Open( filenames[0] ); | |
| 22 | |
| 23 int d = csv.GetLineCount() - m_grid->GetNumberRows(); | |
| 24 if ( d > 0 ) | |
| 25 m_grid->AppendRows( d, true ); | |
| 26 | |
| 27 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); | |
| 28 for ( int n = 0, j = 0; n < csv.GetLineCount(); n++ ) { | |
| 29 wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL ); | |
| 30 if ( ! reHhs.Matches( hhsno ) ) { | |
| 31 j++; | |
| 32 continue; | |
| 33 } | |
| 34 int r = n - j; | |
| 35 | |
| 36 wxArrayString info = wxSplit( GetHhsInfoByHhsNo( hhsno ), '_', '\\' ); | |
| 37 wxArrayString path = GetPathByHhsNo( hhsno ); | |
| 38 | |
| 39 if ( info.IsEmpty() ) info.Add( wxEmptyString ); | |
| 40 if ( path.IsEmpty() ) path.Add( wxEmptyString ); | |
| 41 | |
| 42 m_grid->SetCellValue( r, 0, hhsno ); | |
| 43 m_grid->SetCellValue( r, 1, info[0] ); | |
| 44 m_grid->SetCellValue( r, 2, path[0] ); | |
| 45 } | |
| 46 csv.Close(); | |
| 47 return true; | |
| 48 } | |
| 49 | |
| 50 private: | |
| 51 wxGrid* m_grid; | |
| 52 }; | |
| 53 |
