OSDN Git Service

ArrayLP_TPIFILEINFOをwxArrayPtrVoidに変更するなどの微修正。
[tpi/lychee.git] / src / lychee / frm_main.cpp
index 1cb8112..1baeee3 100644 (file)
@@ -85,6 +85,7 @@ MainFrame::~MainFrame()
                this->conf.WriteId(CONF_LISTVIEW_C_PATH,     this->list_ctrl->GetColumnWidth(7));\r
                this->conf.WriteId(CONF_LISTVIEW_C_TYPE,     this->list_ctrl->GetColumnWidth(8));\r
                this->conf.WriteId(CONF_LISTVIEW_C_NO,       this->list_ctrl->GetColumnWidth(9));\r
+               this->conf.WriteId(CONF_LISTVIEW_C_COMMENT,  this->list_ctrl->GetColumnWidth(10));\r
                this->conf.WriteId(CONF_LISTVIEW_S_COLUMN,   g_nSortColumn);\r
                this->conf.WriteId(CONF_LISTVIEW_S_ASCEND,   g_fSortAscend);\r
        }\r
@@ -174,6 +175,7 @@ void MainFrame::OnInit(wxInitDialogEvent&)
        this->list_ctrl->InsertColumn(7, _("Path"),          wxLIST_FORMAT_LEFT,   this->conf.ReadId(CONF_LISTVIEW_C_PATH,     100l));\r
        this->list_ctrl->InsertColumn(8, _("Type"),          wxLIST_FORMAT_LEFT,   this->conf.ReadId(CONF_LISTVIEW_C_TYPE,     100l));\r
        this->list_ctrl->InsertColumn(9, _("No."),           wxLIST_FORMAT_RIGHT,  this->conf.ReadId(CONF_LISTVIEW_C_NO,        35l));\r
+       this->list_ctrl->InsertColumn(10,_("Comment"),       wxLIST_FORMAT_LEFT,   this->conf.ReadId(CONF_LISTVIEW_C_COMMENT,   35l));\r
        g_nSortColumn = this->conf.ReadId(CONF_LISTVIEW_S_COLUMN, 9l);\r
        g_fSortAscend = this->conf.ReadId(CONF_LISTVIEW_S_ASCEND, true);\r
 \r
@@ -294,7 +296,7 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
        if (mkDlg.cbOpenAfter->IsChecked())\r
        {\r
                // 作成先を開く。\r
-               ::wxExecute(DIR_APP + swInfo.fnDestinationDirectory.GetFullPath());\r
+               ::wxExecute(DIR_APP + QuoteString(swInfo.fnDestinationDirectory.GetFullPath()));\r
        }\r
 \r
        if (mkDlg.cbExitAfter->IsChecked())\r
@@ -322,20 +324,15 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
                this->conf.WriteHistory(CONF_HISTORY_PATH, fd.GetDirectory());\r
                this->fnArchive = wxFileName(fd.GetPath());\r
        }\r
-       this->OnArcClose(e);\r
 \r
        // 進捗ダイアログ表示。\r
        ProcessDialog procDlg;\r
        procDlg.Show(true);\r
 \r
-       // TPIを読み込み、最初のコールバックを送信\r
+       // DnD以外で書庫を開く場合、TPIを読み込み\r
        TPI_PROCESSINFO piInfo;\r
-       piInfo.eMessage = TPI_MESSAGE_STATUS;\r
-       piInfo.eStatus = 0x1000;\r
-       piInfo.nProcessedSize = 0;\r
-       piInfo.fiInfo.fnFileName = this->fnArchive;\r
-       piInfo.fiInfo.nUnpackedSize = e.GetExtraLong() != 0 ? e.GetExtraLong() : this->LoadTPI(this->fnArchive.GetFullPath());\r
-       if (piInfo.fiInfo.nUnpackedSize == 0)\r
+       piInfo.fiInfo.nUnpackedSize = e.GetExtraLong();\r
+       if (e.GetInt() != 1 && ! this->LoadTPI(this->fnArchive.GetFullPath(), & piInfo.fiInfo.nUnpackedSize))\r
        {\r
                procDlg.Show(false);\r
                tpi.FreeLibrary();\r
@@ -351,20 +348,17 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
                }\r
                return;\r
        }\r
+\r
+       // 最初のコールバックを送信。\r
+       piInfo.eMessage = TPI_MESSAGE_STATUS;\r
+       piInfo.eStatus = 0x1000;\r
+       piInfo.nProcessedSize = 0;\r
+       piInfo.fiInfo.fnFileName = this->fnArchive;\r
        procDlg.CallbackProc(TPI_NOTIFY_COMMON, & piInfo);\r
 \r
        // 配列のサイズを確保。\r
        this->fileinfo.Alloc(piInfo.fiInfo.nUnpackedSize);\r
 \r
-       // 書庫を開く。\r
-       if (! tpi.OpenArchive(this->fnArchive.GetFullPath()))\r
-       {\r
-               procDlg.Show(false);\r
-               tpi.FreeLibrary();\r
-               this->ErrorCheck(tpi.nErrorCode, wxT("OpenArchive"));\r
-               return;\r
-       }\r
-\r
        // 履歴に追加。\r
        this->conf.WriteHistory(CONF_HISTORY_PATH, this->fnArchive.GetPath());\r
        this->conf.WriteHistory(CONF_HISTORY_NAME, this->fnArchive.GetFullName());\r
@@ -439,7 +433,7 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
                        // 情報を保存してカウントアップ。\r
                        this->fileinfo.Add(piInfo.fiInfo);\r
                }\r
-               while (tpi.GetFileInformation(& piInfo.fiInfo, false));\r
+               while (tpi.GetFileInformation(& piInfo.fiInfo));\r
        }\r
 \r
        // GetFileInformationがエラー終了した場合。\r
@@ -463,8 +457,8 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
 \r
        // ステータスバー設定。\r
        this->statusbar->SetStatusText(this->aiArchive.fiInfo.szTypeName, 0);\r
-       this->statusbar->SetStatusText(wxString::Format(_("%d file(s)"), this->fileinfo.GetCount()), 1);\r
-       this->statusbar->SetStatusText(wxString::Format(_("%dB -> %dB"), this->aiArchive.nUnpackedSize, this->aiArchive.nPackedSize), 2);\r
+       this->statusbar->SetStatusText(wxString::Format(_("%u file(s)"), this->fileinfo.GetCount()), 1);\r
+       this->statusbar->SetStatusText(wxString::Format(wxString("%" wxLongLongFmtSpec "uB -> %" wxLongLongFmtSpec "uB"), this->aiArchive.nUnpackedSize, this->aiArchive.nPackedSize), 2);\r
        this->statusbar->SetStatusText(wxString::Format(wxT("%3.1f%%"), this->aiArchive.wCompressRatio / 10.0), 3);\r
        this->statusbar->SetStatusText(this->fnArchive.GetFullPath(), 4);\r
 \r
@@ -487,7 +481,7 @@ void MainFrame::OnArcClose(wxCommandEvent& e)
        // ツリービュー・リストビュー設定。\r
        this->tree_ctrl->DeleteAllItems();\r
        this->list_ctrl->DeleteAllItems();\r
-       this->list_ctrl->showFileInfo.Clear();\r
+       this->list_ctrl->apShowFile.Clear();\r
 \r
        // ツールバー・メニューバー設定。\r
        SetMenuToolState("Arc_Close",   false);\r
@@ -582,7 +576,7 @@ void MainFrame::OnArcAdd(wxCommandEvent& e)
        if (mkDlg.cbOpenAfter->IsChecked())\r
        {\r
                // 作成先を開く。\r
-               ::wxExecute(DIR_APP + swInfo.fnDestinationDirectory.GetFullPath());\r
+               ::wxExecute(DIR_APP + QuoteString(swInfo.fnDestinationDirectory.GetFullPath()));\r
        }\r
 \r
        if (mkDlg.cbExitAfter->IsChecked())\r
@@ -719,7 +713,7 @@ void MainFrame::OnArcExtract(wxCommandEvent& e)
                if (mkDlg.cbOpenAfter->IsChecked())\r
                {\r
                        // 展開先を開く。\r
-                       ::wxExecute(DIR_APP + swInfo.fnDestinationDirectory.GetFullPath());\r
+                       ::wxExecute(DIR_APP + QuoteString(swInfo.fnDestinationDirectory.GetFullPath()));\r
                }\r
 \r
                if (mkDlg.cbExitAfter->IsChecked())\r
@@ -739,7 +733,7 @@ void MainFrame::OnArcExtract(wxCommandEvent& e)
                        {\r
 #ifdef __LINUX__\r
                                // Linuxでは引用符で囲む必要がある。\r
-                               ::wxExecute(ftFile->GetOpenCommand(wxT('"') + asFiles[0] + wxT('"')), wxEXEC_SYNC);\r
+                               ::wxExecute(ftFile->GetOpenCommand(QuoteString(asFiles[0])), wxEXEC_SYNC);\r
 #else\r
                                ::wxExecute(ftFile->GetOpenCommand(asFiles[0]), wxEXEC_SYNC);\r
 #endif\r
@@ -914,7 +908,7 @@ void MainFrame::OnTreeChanged(wxTreeEvent& e)
        // ツリービューからパスを取得。\r
        wxString szNodePath = TreeView_GetItemPath(this->tree_ctrl, e.GetItem());\r
        // リストビューを初期化。\r
-       this->list_ctrl->showFileInfo.Clear();\r
+       this->list_ctrl->apShowFile.Clear();\r
        this->list_ctrl->DeleteAllItems();\r
        g_hIconLL.RemoveAll();\r
        g_hIconLS.RemoveAll();\r
@@ -949,13 +943,13 @@ void MainFrame::OnTreeChanged(wxTreeEvent& e)
                                continue;\r
                        }\r
 \r
-                       this->list_ctrl->showFileInfo.Add(this->fileinfo[i]);\r
+                       this->list_ctrl->apShowFile.Add(& this->fileinfo[i]);\r
                }\r
        }\r
 \r
        // ソートして表示。\r
-       this->list_ctrl->showFileInfo.Sort(& ListCtrlCompareProc);\r
-       this->list_ctrl->SetItemCount(this->list_ctrl->showFileInfo.GetCount());\r
+       this->list_ctrl->apShowFile.Sort(& ListCtrlCompareProc);\r
+       this->list_ctrl->SetItemCount(this->list_ctrl->apShowFile.GetCount());\r
 }\r
 \r
 void MainFrame::OnTreeBeginDrag(wxTreeEvent& e)\r
@@ -1001,18 +995,21 @@ void MainFrame::OnFilter(wxCommandEvent&)
 \r
 // イベントハンドラ以外。\r
 \r
-wxULongLong_t MainFrame::LoadTPI(wxString szFileName)\r
+bool MainFrame::LoadTPI(const wxString & szFileName, wxULongLong_t * llFileCount)\r
 {\r
+       // 書庫を開いていれば閉じておく。\r
+       wxCommandEvent e;\r
+       this->OnArcClose(e);\r
+\r
        // TPIを読み込み。\r
        wxDir fs(L_DIR_B_LIB);\r
-       wxULongLong_t llFileCount = 0;\r
        wxString szTPIName;\r
        if (fs.GetFirst(& szTPIName, wxT("*" TPI_EXT)))\r
        {\r
                do\r
                {\r
                        // 初期化。\r
-                       if (! tpi.InitLibrary(L_DIR_B_LIB + szTPIName, szFileName, 0))\r
+                       if (! tpi.InitLibrary(L_DIR_B_LIB + szTPIName, szFileName))\r
                        {\r
                                tpi.FreeLibrary();\r
                                continue;\r
@@ -1022,20 +1019,20 @@ wxULongLong_t MainFrame::LoadTPI(wxString szFileName)
                        tpi.SetCallbackProc(TPICallbackProc);\r
 \r
                        // 対応確認。\r
-                       if (! tpi.CheckArchive(szFileName, & llFileCount) || llFileCount == 0)\r
+                       if (! tpi.OpenArchive(szFileName, llFileCount))\r
                        {\r
                                tpi.FreeLibrary();\r
-                               llFileCount = 0;\r
+                               llFileCount = 0;\r
                                continue;\r
                        }\r
-                       break;\r
+                       return true;\r
                }\r
                while (fs.GetNext(& szTPIName));\r
        }\r
-       return llFileCount;\r
+       return false;\r
 }\r
 \r
-int MainFrame::ErrorCheck(int nErrorCode, wxString szAPIName)\r
+int MainFrame::ErrorCheck(int nErrorCode, const wxString & szAPIName)\r
 {\r
        switch (nErrorCode)\r
        {\r