* 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.
This commit is contained in:
Amar Takhar 2009-09-27 11:30:29 +00:00
parent 38d5f06821
commit c821a7e172
3 changed files with 32 additions and 14 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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.