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>
This commit is contained in:
Fred Gleason
2022-02-12 11:54:28 -05:00
parent b778114266
commit 1fd581a442
7 changed files with 237 additions and 6 deletions

View File

@@ -22881,3 +22881,6 @@
2022-01-10 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug that caused rdimport(1) to fail to apply the
'<playGain>' tag when processing RDXL metadata.
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).

View File

@@ -2,7 +2,7 @@
##
## Automake.am for rivendell/lib
##
## (C) Copyright 2002-2021 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
@@ -98,6 +98,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdconfig.cpp rdconfig.h\
rdcopyaudio.cpp rdcopyaudio.h\
rdcoreapplication.cpp rdcoreapplication.h\
rdcsv.cpp rdcsv.h\
rdcueedit.cpp rdcueedit.h\
rdcueeditdialog.cpp rdcueeditdialog.h\
rdcut.cpp rdcut.h\

View File

@@ -2,7 +2,7 @@
#
# The lib/ QMake project file for Rivendell.
#
# (C) Copyright 2003-2021 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2003-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
@@ -70,6 +70,7 @@ SOURCES += rdcombobox.cpp
SOURCES += rdconf.cpp
SOURCES += rdconfig.cpp
SOURCES += rdcoreapplication.cpp
SOURCES += rdcsv.cpp
SOURCES += rdcueedit.cpp
SOURCES += rdcueeditdialog.cpp
SOURCES += rdcut.cpp
@@ -259,6 +260,7 @@ HEADERS += rdcombobox.h
HEADERS += rdconf.h
HEADERS += rdconfig.h
HEADERS += rdcoreapplication.h
HEADERS += rdcsv.h
HEADERS += rdcueedit.h
HEADERS += rdcueeditdialog.h
HEADERS += rdcut_dialog.h

50
lib/rdcsv.cpp Normal file
View File

@@ -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::asprintf("%d",val),last);
}
QString RDCsvField(unsigned val,bool last)
{
return RDCsvField(QString::asprintf("%u",val),last);
}

31
lib/rdcsv.h Normal file
View File

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

View File

@@ -2,7 +2,7 @@
//
// List and Generate Log Reports
//
// (C) Copyright 2002-2021 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>
#include <rdconf.h>
#include <rdcsv.h>
#include <rddatedialog.h>
#include <rdreport.h>
#include <rdtextfile.h>
@@ -57,7 +58,8 @@ 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(0,tr("Log Listing"));
list_reports_box->insertItem(1,tr("Log Exception Report"));
list_reports_box->insertItem(1,tr("Log Listing (CSV)"));
list_reports_box->insertItem(2,tr("Log Exception Report"));
QLabel *list_reports_label=new QLabel(tr("Type:"),this);
list_reports_label->setGeometry(10,10,35,19);
list_reports_label->setFont(labelFont());
@@ -138,7 +140,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,143 @@ 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_model->lineCount();i++) {
logline=list_model->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_model->validate(report,date);

View File

@@ -2,7 +2,7 @@
//
// List and Generate Log Reports
//
// (C) Copyright 2002-2021 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
@@ -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;