3
|
1 // Filename : dndfile.h
|
4
|
2 // Last Change: 11-Sep-2013.
|
3
|
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();
|
4
|
20
|
|
21 // ファイルから被保番リストを生成
|
|
22 wxTextFile csv;
|
|
23 csv.Open( filenames[0] );
|
|
24
|
|
25 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") );
|
|
26 wxArrayString hhs;
|
|
27 for ( int n = 0; n < csv.GetLineCount(); n++ ) {
|
|
28 wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL );
|
|
29 if ( ! reHhs.Matches( hhsno ) )
|
|
30 continue;
|
|
31 hhs.Add( hhsno );
|
|
32 }
|
|
33 csv.Close();
|
|
34
|
|
35 //
|
|
36 int d = hhs.GetCount() - m_grid->GetNumberRows();
|
|
37 if ( d > 0 )
|
|
38 m_grid->AppendRows( d, true );
|
|
39
|
|
40 // グリッドに情報を読込み
|
|
41 wxArrayString res = GetHhsInfoAndPathByHhsNoList( hhs );
|
|
42 for ( int r = 0; r < res.GetCount(); r++ ) {
|
|
43 wxArrayString data = wxSplit( res[r], '_', '\\' );
|
|
44 m_grid->SetCellValue( r, 0, data[0] );
|
|
45 m_grid->SetCellValue( r, 1, data[1] );
|
|
46 m_grid->SetCellValue( r, 2, data[2] );
|
|
47 }
|
|
48
|
|
49 return true;
|
|
50 }
|
|
51
|
|
52 private:
|
|
53 wxGrid* m_grid;
|
|
54 };
|
|
55
|
|
56 class DnDFile2 : public wxFileDropTarget
|
|
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();
|
3
|
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
|