Browse Source

2022-02-12 Fred Gleason <fredg@paravelsystems.com>

* Added CSV generation routines in 'lib/rdcsv.[cpp|h]'.
	* Added a 'Log Listing (CSV)' report to rdlogedit(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
pull/849/head
Fred Gleason 1 year ago
parent
commit
a46f839b95
  1. 3
      ChangeLog
  2. 1
      lib/Makefile.am
  3. 2
      lib/lib.pro
  4. 50
      lib/rdcsv.cpp
  5. 31
      lib/rdcsv.h
  6. 154
      rdlogedit/list_reports.cpp
  7. 1
      rdlogedit/list_reports.h
  8. 12
      rdlogedit/rdlogedit_cs.ts
  9. 12
      rdlogedit/rdlogedit_de.ts
  10. 12
      rdlogedit/rdlogedit_es.ts
  11. 12
      rdlogedit/rdlogedit_fr.ts
  12. 12
      rdlogedit/rdlogedit_nb.ts
  13. 12
      rdlogedit/rdlogedit_nn.ts
  14. 12
      rdlogedit/rdlogedit_pt_BR.ts

3
ChangeLog

@ -20830,3 +20830,6 @@
2021-12-17 Fred Gleason <fredg@paravelsystems.com>
* Added a 'graceTime' field to the return XML for the 'ListLog'
WebAPI call.
2022-02-12 Fred Gleason <fredg@paravelsystems.com>
* Added CSV generation routines in 'lib/rdcsv.[cpp|h]'.
* Added a 'Log Listing (CSV)' report to rdlogedit(1).

1
lib/Makefile.am

@ -96,6 +96,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdconf.cpp rdconf.h\
rdconfig.cpp rdconfig.h\
rdcopyaudio.cpp rdcopyaudio.h\
rdcsv.cpp rdscv.h\
rdcueedit.cpp rdcueedit.h\
rdcueeditdialog.cpp rdcueeditdialog.h\
rdcut.cpp rdcut.h\

2
lib/lib.pro

@ -66,6 +66,7 @@ SOURCES += rdcmd_switch.cpp
SOURCES += rdcombobox.cpp
SOURCES += rdconf.cpp
SOURCES += rdconfig.cpp
SOURCES += rdcsv.cpp
SOURCES += rdcueedit.cpp
SOURCES += rdcueeditdialog.cpp
SOURCES += rdcut.cpp
@ -211,6 +212,7 @@ HEADERS += rdcmd_switch.h
HEADERS += rdcombobox.h
HEADERS += rdconf.h
HEADERS += rdconfig.h
HEADERS += rdcsv.h
HEADERS += rdcueedit.h
HEADERS += rdcueeditdialog.h
HEADERS += rdcut_dialog.h

50
lib/rdcsv.cpp

@ -0,0 +1,50 @@
// rdcsv.cpp
//
// Routines for generating CSV files
//
// (C) Copyright 2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include "rdcsv.h"
QString RDCsvField(const QString &val,bool last)
{
QString ret=val;
if(val.contains(",")||val.contains("\"")) {
ret="\""+ret.replace("\"","\"\"")+"\"";
}
if(last) {
ret+="\r\n";
}
else {
ret+=",";
}
return ret;
}
QString RDCsvField(int val,bool last)
{
return RDCsvField(QString().sprintf("%d",val),last);
}
QString RDCsvField(unsigned val,bool last)
{
return RDCsvField(QString().sprintf("%u",val),last);
}

31
lib/rdcsv.h

@ -0,0 +1,31 @@
// rdcsv.h
//
// Routines for generating CSV files
//
// (C) Copyright 2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDCSV_H
#define RDCSV_H
#include <QString>
QString RDCsvField(const QString &val="",bool last=false);
QString RDCsvField(int val,bool last=false);
QString RDCsvField(unsigned val,bool last=false);
#endif // RDCSV_H

154
rdlogedit/list_reports.cpp

@ -2,7 +2,7 @@
//
// List and Generate Log Reports
//
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -22,6 +22,7 @@
#include <qpushbutton.h>
#include <rdconf.h>
#include <rdcsv.h>
#include <rddatedialog.h>
#include <rdreport.h>
#include <rdtextfile.h>
@ -57,6 +58,7 @@ ListReports::ListReports(const QString &logname,const QString &description,
list_reports_box=new QComboBox(this);
list_reports_box->setGeometry(50,10,sizeHint().width()-60,19);
list_reports_box->insertItem(tr("Log Listing"));
list_reports_box->insertItem(tr("Log Listing (CSV)"));
list_reports_box->insertItem(tr("Log Exception Report"));
QLabel *list_reports_label=
new QLabel(list_reports_box,tr("Type:"),this);
@ -139,7 +141,11 @@ void ListReports::generateData()
GenerateLogReport(&report);
break;
case 1: // XLoad Report
case 1: // Event Report
GenerateLogCsvReport(&report);
break;
case 2: // XLoad Report
GenerateExceptionReport(&report,list_date_edit->date());
break;
@ -288,6 +294,150 @@ void ListReports::GenerateLogReport(QString *report)
}
void ListReports::GenerateLogCsvReport(QString *report)
{
RDLogLine *logline;
//
// Column Names
//
*report+=RDCsvField("TYPE");
*report+=RDCsvField("START_TIME");
*report+=RDCsvField("TIME_TYPE");
*report+=RDCsvField("TRANS_TYPE");
*report+=RDCsvField("CART_NUMBER");
*report+=RDCsvField("GROUP_NAME");
*report+=RDCsvField("LENGTH");
*report+=RDCsvField("TITLE");
*report+=RDCsvField("ARTIST");
*report+=RDCsvField("CLIENT");
*report+=RDCsvField("AGENCY");
*report+=RDCsvField("ALBUM");
*report+=RDCsvField("LABEL");
*report+=RDCsvField("CONDUCTOR");
*report+=RDCsvField("COMPOSER");
*report+=RDCsvField("PUBLISHER");
*report+=RDCsvField("USER_DEFINED");
*report+=RDCsvField("SONG_ID");
*report+=RDCsvField("USAGE_CODE");
*report+=RDCsvField("SOURCE");
*report+=RDCsvField("EXT_DATA");
*report+=RDCsvField("EXT_EVENT_ID");
*report+=RDCsvField("EXT_ANNC_TYPE");
*report+=RDCsvField("LINE_ID");
*report+=RDCsvField("LINE",true);
for(int i=0;i<list_events->size();i++) {
logline=list_events->logLine(i);
//
// Event Type
//
*report+=RDCsvField(RDLogLine::typeText(logline->type()));
//
// Time
//
if(logline->startTime(RDLogLine::Imported).isNull()||
(logline->startTime(RDLogLine::Imported)==QTime(0,0,0,0))) {
*report+=RDCsvField();
}
else {
*report+=RDCsvField(logline->startTime(RDLogLine::Imported).
toString("hh:mm:ss"));
}
if(logline->timeType()==RDLogLine::Hard) {
*report+=RDCsvField("Hard");
}
else {
*report+=RDCsvField("Relative");
}
//
// Transition Type
//
*report+=RDCsvField(RDLogLine::transText(logline->transType()));
switch(logline->type()) {
case RDLogLine::Cart:
case RDLogLine::Macro:
*report+=RDCsvField(logline->cartNumber());
*report+=RDCsvField(logline->groupName());
*report+=RDCsvField(RDGetTimeLength(logline->forcedLength(),false,false));
*report+=RDCsvField(logline->title());
*report+=RDCsvField(logline->artist());
break;
case RDLogLine::Marker:
case RDLogLine::Track:
*report+=RDCsvField();
*report+=RDCsvField();
*report+=RDCsvField(":00");
*report+=RDCsvField(logline->markerComment());
*report+=RDCsvField();
break;
case RDLogLine::TrafficLink:
*report+=RDCsvField();
*report+=RDCsvField();
*report+=RDCsvField(":00");
*report+=RDCsvField(tr("Traffic Import"));
*report+=RDCsvField();
break;
case RDLogLine::MusicLink:
*report+=RDCsvField();
*report+=RDCsvField();
*report+=RDCsvField(":00");
*report+=RDCsvField(tr("Music Import"));
*report+=RDCsvField();
break;
case RDLogLine::Chain:
*report+=RDCsvField();
*report+=RDCsvField();
*report+=RDCsvField();
*report+=RDCsvField(logline->markerLabel());
*report+=RDCsvField();
break;
case RDLogLine::OpenBracket:
case RDLogLine::CloseBracket:
case RDLogLine::UnknownType:
*report+=RDCsvField();
*report+=RDCsvField();
*report+=RDCsvField();
*report+=RDCsvField();
*report+=RDCsvField();
break;
}
*report+=RDCsvField(logline->client());
*report+=RDCsvField(logline->agency());
*report+=RDCsvField(logline->album());
*report+=RDCsvField(logline->label());
*report+=RDCsvField(logline->conductor());
*report+=RDCsvField(logline->composer());
*report+=RDCsvField(logline->publisher());
*report+=RDCsvField(logline->userDefined());
*report+=RDCsvField(logline->songId());
*report+=RDCsvField(RDCart::usageText(logline->usageCode()));
*report+=RDCsvField(RDLogLine::sourceText(logline->source()));
*report+=RDCsvField(logline->extData());
*report+=RDCsvField(logline->extEventId());
*report+=RDCsvField(logline->extAnncType());
*report+=RDCsvField(logline->id());
*report+=RDCsvField(i,true);
}
}
void ListReports::GenerateExceptionReport(QString *report,const QDate &date)
{
int errs=list_events->validate(report,date);

1
rdlogedit/list_reports.h

@ -47,6 +47,7 @@ class ListReports : public RDDialog
private:
void GenerateLogReport(QString *report);
void GenerateLogCsvReport(QString *report);
void GenerateExceptionReport(QString *report,const QDate &date);
QComboBox *list_reports_box;
QString list_log_name;

12
rdlogedit/rdlogedit_cs.ts

@ -814,6 +814,18 @@ vybrané služby!</translation>
<source>Reports</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Listing (CSV)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Traffic Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Music Import</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWidget</name>

12
rdlogedit/rdlogedit_de.ts

@ -814,6 +814,18 @@ Gruppe des ausgewählten Service!</translation>
<source>Reports</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Listing (CSV)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Traffic Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Music Import</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWidget</name>

12
rdlogedit/rdlogedit_es.ts

@ -814,6 +814,18 @@ desactivado para el servicio especificado!</translation>
<source>Reports</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Listing (CSV)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Traffic Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Music Import</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWidget</name>

12
rdlogedit/rdlogedit_fr.ts

@ -503,6 +503,18 @@ group for the specified service!</source>
<source>Reports</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Listing (CSV)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Traffic Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Music Import</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWidget</name>

12
rdlogedit/rdlogedit_nb.ts

@ -828,6 +828,18 @@ som er skrudd av for denne tenesta!</translation>
<source>Reports</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Listing (CSV)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Traffic Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Music Import</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWidget</name>

12
rdlogedit/rdlogedit_nn.ts

@ -828,6 +828,18 @@ som er skrudd av for denne tenesta!</translation>
<source>Reports</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Listing (CSV)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Traffic Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Music Import</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWidget</name>

12
rdlogedit/rdlogedit_pt_BR.ts

@ -816,6 +816,18 @@ Ação se Evento anterior estiver sendo executado</translation>
<source>Reports</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Listing (CSV)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Traffic Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Music Import</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWidget</name>

Loading…
Cancel
Save