diff src/myframe.cpp @ 21:eb3f5c7c990f

small changes.
author pyon@macmini
date Mon, 25 Jul 2011 05:20:55 +0900
parents b67c74848dd0
children 05f76f9f9186
line wrap: on
line diff
--- a/src/myframe.cpp	Thu Jul 21 05:38:27 2011 +0900
+++ b/src/myframe.cpp	Mon Jul 25 05:20:55 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : mainframe.cpp
-// Last Change: 06-Jul-2011.
+// Last Change: 22-Jul-2011.
 //
 #include "wx/html/htmprint.h"
 #include "wx/print.h"
@@ -7,6 +7,7 @@
 #include "symbol.h"
 #include "common.h"
 #include "myframe.h"
+#include "ccnframe.h"
 #include "hhsdb.h"
 #include "htmlhelp.h"
 #include "main.h"
@@ -714,63 +715,16 @@
 /* インデックス作成 */
 void MyFrame::OnMkIndex(wxCommandEvent& WXUNUSED(event))
 {
-	wxDateTime dt = m_datePicker->GetValue();
-    wxString month = dt.Format(wxT("%m"));
-    wxString year  = dt.Format(wxT("%Y"));
-    if ( month.IsSameAs(wxT("01")) || month.IsSameAs(wxT("02")) || month.IsSameAs(wxT("03")) ) {
-        long y;
-        year.ToLong( &y, 10 );
-        y--;
-        year = wxString::Format(wxT("%d"),y);
-    }
-    wxString pathroot = wxGetApp().rootdir + wxFILE_SEP_PATH + year + dt.Format(wxT("\\%Y%m%d"));
-    wxDir rootd(pathroot);
-    if ( !wxDir::Exists(pathroot) ) {
-        wxMessageBox( wxT("フォルダが存在しません.")+pathroot );
-        return;
-    }
-
-    wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 200, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
-    pd.SetSize( wxSize(320,140) );
-    int count=0;
-
-    wxString ccndir;
-    bool cont = rootd.GetFirst( &ccndir, wxT("*.*"), wxDIR_DIRS );
-    while ( cont ) {
-        wxString gszFile = wxGetCwd() + wxT("/db/ccn.db");
-        wxSQLite3Database ccndb;
-        ccndb.Open( gszFile );
+    FrameHhsDB *f = (FrameHhsDB*)FindWindowById( ID_HHSDB );
 
-        wxSQLite3Statement stmt = ccndb.PrepareStatement("INSERT OR REPLACE INTO ccn VALUES( ?, datetime('now','localtime') )");
-        stmt.Bind( 1, dt.Format(wxT("%Y-%m-%d")) );
-        stmt.ExecuteQuery();
-
-        stmt.Finalize();
-
-        wxDir ccnd( pathroot + wxFILE_SEP_PATH + ccndir );
-        if ( !ccnd.IsOpened() ) return;
-        wxString hhsdir;
-        bool c = ccnd.GetFirst( &hhsdir, wxT("*.*"), wxDIR_DIRS );
-	    wxRegEx reHhs(wxT("^0[1238][0-9]{8}$"));	// 被保番チェック
-        while ( c ) {
-            if ( reHhs.Matches(hhsdir) ) {
-                wxString path = pathroot + wxFILE_SEP_PATH + ccndir + wxFILE_SEP_PATH + hhsdir;
-
-                stmt = ccndb.PrepareStatement("INSERT OR REPLACE INTO path VALUES( ?, ? )");
-                stmt.Bind( 1, hhsdir );
-                stmt.Bind( 2, path );
-                stmt.ExecuteQuery();
-
-                stmt.Finalize();
-            }
-            c = ccnd.GetNext(&hhsdir);
-            pd.Update( count++, hhsdir+wxT("@")+ccndir+wxT("を処理しました.") );
-        }
-        ccndb.Close();
-
-        cont = rootd.GetNext(&ccndir);
+    if ( f == NULL ) {
+        FrameHhsDB *hhsdb = new FrameHhsDB( this, ID_HHSDB ); 
+        hhsdb->Show(true);
     }
-    wxMessageBox(wxT("インデックス作成が終了しました."));
+    else {
+        f->Raise();
+    }
+    return;
 }
 
 /* インデックス更新一覧 */