From c821a7e172d0dd43c93454c241706e1dee711d56 Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Sun, 27 Sep 2009 11:30:29 +0000 Subject: [PATCH] * Fix commandline support, I have no idea what the !OnInit block was after OnInit(), I removed it and everthing works as expected. * Add -x switch for dumping the report to report.xml Unfortunatly this causes a flicker of the reporter as we need to create the main frame in order to gather some desktop metrics. Originally committed to SVN as r3597. --- aegisub/reporter/main.cpp | 29 +++++++++++++++++++++++------ aegisub/reporter/report.cpp | 10 +++------- aegisub/reporter/report.h | 7 ++++++- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/aegisub/reporter/main.cpp b/aegisub/reporter/main.cpp index 551da32f3..6a72afe2e 100644 --- a/aegisub/reporter/main.cpp +++ b/aegisub/reporter/main.cpp @@ -41,26 +41,34 @@ /// @brief Init the reporter. bool Reporter::OnInit() { - if ( !wxApp::OnInit() ) - return false; +// if ( !wxApp::OnInit() ) +// return false; wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, _("Reporter")); + static const wxCmdLineEntryDesc cmdLineDesc[] = { - { wxCMD_LINE_SWITCH, "c", "crash", "Launch in crash mode.", wxCMD_LINE_VAL_NONE, NULL }, - { wxCMD_LINE_SWITCH, "r", "report", "Launch in Report mode.", wxCMD_LINE_VAL_NONE, NULL }, - { wxCMD_LINE_SWITCH, "h", "help", "This help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, + { wxCMD_LINE_SWITCH, "c", "crash", "Launch in crash mode.", wxCMD_LINE_VAL_NONE, NULL }, + { wxCMD_LINE_SWITCH, "r", "report", "Launch in Report mode.", wxCMD_LINE_VAL_NONE, NULL }, + { wxCMD_LINE_SWITCH, "x", "xml", "Dump XML file", wxCMD_LINE_VAL_NONE, NULL }, + { wxCMD_LINE_SWITCH, "h", "help", "This help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, NULL} }; + wxCmdLineParser parser(cmdLineDesc, argc, argv); + + parser.SetLogo("Aegisub Reporter version x.x"); + parser.SetCmdLine(argc, argv); switch ( parser.Parse() ) { case -1: + return false; break; // Help case 0: break; // OK default: wxLogMessage(_T("Syntax error.")); + return false; break; } @@ -78,10 +86,19 @@ bool Reporter::OnInit() setlocale(LC_NUMERIC, "C"); setlocale(LC_CTYPE, "C"); + mFrame *frame = new mFrame(_("Aegisub Reporter")); + Report *r = new Report; + + if (parser.Found("x")) { + r->Save("report.xml"); + wxPrintf("Report saved to report.xml\n"); + return false; + } + + SetTopWindow(frame); - Report *r = new Report; frame->SetReport(r); return true; diff --git a/aegisub/reporter/report.cpp b/aegisub/reporter/report.cpp index 4b95fb789..6e3ae89b9 100644 --- a/aegisub/reporter/report.cpp +++ b/aegisub/reporter/report.cpp @@ -186,16 +186,12 @@ void Report::ProcessNode(wxXmlNode *node, wxString *text, wxListView *listView) } } -/// @brief Fill wxListView with report contents. -/// @param listview wxListview to fill. + void Report::Fill(wxString *text, wxListView *listView) { listView->InsertColumn(0, _("Entry"), wxLIST_FORMAT_RIGHT); listView->InsertColumn(1, _("Text"), wxLIST_FORMAT_LEFT, 100); - -//wxString *text = new wxString(); - ProcessNode(doc.report, text, listView); listView->SetColumnWidth(0, wxLIST_AUTOSIZE); @@ -204,6 +200,6 @@ void Report::Fill(wxString *text, wxListView *listView) { } /// @brief Return Report as Text for the Clipboard. -wxString Report::AsText() { - return "not implimented."; +void Report::Save(wxString file) { + doc.doc->Save(file); } diff --git a/aegisub/reporter/report.h b/aegisub/reporter/report.h index 3a98352ef..a80739dcc 100644 --- a/aegisub/reporter/report.h +++ b/aegisub/reporter/report.h @@ -33,8 +33,13 @@ public: Report(); ~Report() {}; + /// Fill wxListView with report contents. + /// @param text pointer to text buffer + /// @param listview wxListview to fill void Fill(wxString *text, wxListView *listView); - wxString AsText(); + + /// Save XML report to a file. + void Save(wxString file); private: /// Comparison callback for nameMap.