Mercurial > mercurial > hgweb_searcher03.cgi
comparison include/dndfile.h @ 5:bc2e2b304095
Clean up code.
| author | pyon@macmini |
|---|---|
| date | Sat, 14 Sep 2013 08:54:47 +0900 |
| parents | fdba695b99f1 |
| children | 92188f60323d |
comparison
equal
deleted
inserted
replaced
| 4:fdba695b99f1 | 5:bc2e2b304095 |
|---|---|
| 1 // Filename : dndfile.h | 1 // Filename : dndfile.h |
| 2 // Last Change: 11-Sep-2013. | 2 // Last Change: 12-Sep-2013. |
| 3 // | 3 // |
| 4 #ifndef __DNDFILE_H__ | |
| 5 #define __DNDFILE_H__ | |
| 4 | 6 |
| 5 #include "db.h" | 7 #include "db.h" |
| 6 | 8 |
| 7 class DnDFile : public wxFileDropTarget | 9 class DnDFile : public wxFileDropTarget |
| 8 { | 10 { |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 wxGrid* m_grid; | 55 wxGrid* m_grid; |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 class DnDFile2 : public wxFileDropTarget | 58 #endif //__DNDFILE_H__ |
| 57 { | |
| 58 public: | |
| 59 DnDFile2( wxGrid *grid ) | |
| 60 { | |
| 61 m_grid = grid; | |
| 62 } | |
| 63 virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames ) | |
| 64 { | |
| 65 size_t nFiles = filenames.GetCount(); | |
| 66 if ( nFiles != 1 ) return false; | |
| 67 | |
| 68 m_grid->ClearGrid(); | |
| 69 wxTextFile csv; | |
| 70 csv.Open( filenames[0] ); | |
| 71 | |
| 72 int d = csv.GetLineCount() - m_grid->GetNumberRows(); | |
| 73 if ( d > 0 ) | |
| 74 m_grid->AppendRows( d, true ); | |
| 75 | |
| 76 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); | |
| 77 for ( int n = 0, j = 0; n < csv.GetLineCount(); n++ ) { | |
| 78 wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL ); | |
| 79 if ( ! reHhs.Matches( hhsno ) ) { | |
| 80 j++; | |
| 81 continue; | |
| 82 } | |
| 83 int r = n - j; | |
| 84 | |
| 85 wxArrayString info = wxSplit( GetHhsInfoByHhsNo( hhsno ), '_', '\\' ); | |
| 86 wxArrayString path = GetPathByHhsNo( hhsno ); | |
| 87 | |
| 88 if ( info.IsEmpty() ) info.Add( wxEmptyString ); | |
| 89 if ( path.IsEmpty() ) path.Add( wxEmptyString ); | |
| 90 | |
| 91 m_grid->SetCellValue( r, 0, hhsno ); | |
| 92 m_grid->SetCellValue( r, 1, info[0] ); | |
| 93 m_grid->SetCellValue( r, 2, path[0] ); | |
| 94 } | |
| 95 csv.Close(); | |
| 96 return true; | |
| 97 } | |
| 98 | |
| 99 private: | |
| 100 wxGrid* m_grid; | |
| 101 }; | |
| 102 |
