3
|
1 // Filename : dndfile.h
|
5
|
2 // Last Change: 12-Sep-2013.
|
3
|
3 //
|
5
|
4 #ifndef __DNDFILE_H__
|
|
5 #define __DNDFILE_H__
|
3
|
6
|
|
7 #include "db.h"
|
|
8
|
|
9 class DnDFile : public wxFileDropTarget
|
|
10 {
|
|
11 public:
|
|
12 DnDFile( wxGrid *grid )
|
|
13 {
|
|
14 m_grid = grid;
|
|
15 }
|
|
16 virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames )
|
|
17 {
|
|
18 size_t nFiles = filenames.GetCount();
|
|
19 if ( nFiles != 1 ) return false;
|
|
20
|
|
21 m_grid->ClearGrid();
|
4
|
22
|
|
23 // ファイルから被保番リストを生成
|
|
24 wxTextFile csv;
|
|
25 csv.Open( filenames[0] );
|
|
26
|
|
27 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") );
|
|
28 wxArrayString hhs;
|
|
29 for ( int n = 0; n < csv.GetLineCount(); n++ ) {
|
|
30 wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL );
|
|
31 if ( ! reHhs.Matches( hhsno ) )
|
|
32 continue;
|
|
33 hhs.Add( hhsno );
|
|
34 }
|
|
35 csv.Close();
|
|
36
|
|
37 //
|
|
38 int d = hhs.GetCount() - m_grid->GetNumberRows();
|
|
39 if ( d > 0 )
|
|
40 m_grid->AppendRows( d, true );
|
|
41
|
|
42 // グリッドに情報を読込み
|
|
43 wxArrayString res = GetHhsInfoAndPathByHhsNoList( hhs );
|
|
44 for ( int r = 0; r < res.GetCount(); r++ ) {
|
|
45 wxArrayString data = wxSplit( res[r], '_', '\\' );
|
|
46 m_grid->SetCellValue( r, 0, data[0] );
|
|
47 m_grid->SetCellValue( r, 1, data[1] );
|
|
48 m_grid->SetCellValue( r, 2, data[2] );
|
|
49 }
|
|
50
|
|
51 return true;
|
|
52 }
|
|
53
|
|
54 private:
|
|
55 wxGrid* m_grid;
|
|
56 };
|
|
57
|
5
|
58 #endif //__DNDFILE_H__
|