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

* Rewrote the 'Cart Data Dump (CSV)' report in rdlibrary(1) to
	use the CSV generation routines in 'lib/rdcsv.[cpp|h]'.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2022-02-12 12:07:19 -05:00
parent 1fd581a442
commit 6dd815a570
3 changed files with 137 additions and 88 deletions

View File

@ -22884,3 +22884,6 @@
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).
2022-02-12 Fred Gleason <fredg@paravelsystems.com>
* Rewrote the 'Cart Data Dump (CSV)' report in rdlibrary(1) to
use the CSV generation routines in 'lib/rdcsv.[cpp|h]'.

View File

@ -2,7 +2,7 @@
//
// List RDLibrary 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
@ -21,6 +21,7 @@
#include <QPushButton>
#include <rdconf.h>
#include <rdcsv.h>
#include <rdreport.h>
#include <rdtextfile.h>
@ -502,6 +503,58 @@ void ListReports::GenerateCartDumpCsv(QString *report,bool prepend_names)
schedcode=list_schedcode;
}
//
// Generate Rows
//
/*
if(list_type_filter.isEmpty()) {
return;
}
sql=QString("select ")+
"CART.NUMBER,"+ // 00
"CART.TYPE,"+ // 01
"CUTS.CUT_NAME,"+ // 02
"CART.GROUP_NAME,"+ // 03
"CART.TITLE,"+ // 04
"CART.ARTIST,"+ // 05
"CART.ALBUM,"+ // 06
"CART.YEAR,"+ // 07
"CUTS.ISRC,"+ // 08
"CUTS.ISCI,"+ // 09
"CART.LABEL,"+ // 10
"CART.CLIENT,"+ // 11
"CART.AGENCY,"+ // 12
"CART.PUBLISHER,"+ // 13
"CART.COMPOSER,"+ // 14
"CART.CONDUCTOR,"+ // 15
"CART.SONG_ID,"+ // 16
"CART.USER_DEFINED,"+ // 17
"CUTS.DESCRIPTION,"+ // 18
"CUTS.OUTCUE,"+ // 19
"CUTS.LENGTH,"+ // 20
"CUTS.START_POINT,"+ // 21
"CUTS.END_POINT,"+ // 22
"CUTS.SEGUE_START_POINT,"+ // 23
"CUTS.SEGUE_END_POINT,"+ // 24
"CUTS.HOOK_START_POINT,"+ // 25
"CUTS.HOOK_END_POINT,"+ // 26
"CUTS.TALK_START_POINT,"+ // 27
"CUTS.TALK_END_POINT,"+ // 28
"CUTS.FADEUP_POINT,"+ // 29
"CUTS.FADEDOWN_POINT "+ // 30
"from CART left join CUTS "+
"on CART.NUMBER=CUTS.CART_NUMBER ";
if(list_group==QString("ALL")) {
sql+=RDAllCartSearchText(list_filter,schedcode,rda->user()->name(),true)+" && "+
list_type_filter+" order by CART.NUMBER,CUTS.CUT_NAME";
}
else {
sql+=RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+
list_type_filter+" order by CART.NUMBER,CUTS.CUT_NAME";
}
q=new RDSqlQuery(sql);
*/
//
// Generate Rows
//
@ -547,39 +600,39 @@ void ListReports::GenerateCartDumpCsv(QString *report,bool prepend_names)
// Prepend Field Names
//
if(prepend_names) {
*report=QString("CART_NUMBER,")+ // 00
"CUT_NUMBER,"+ // 01
"TYPE,"+ // 02
"GROUP_NAME,"+ // 03
"TITLE,"+ // 04
"ARTIST,"+ // 05
"ALBUM,"+ // 06
"YEAR,"+ // 07
"ISRC,"+ // 08
"ISCI,"+ // 09
"LABEL,"+ // 10
"CLIENT,"+ // 11
"AGENCY,"+ // 12
"PUBLISHER,"+ // 13
"COMPOSER,"+ // 14
"CONDUCTOR,"+ // 15
"SONG_ID,"+ // 16
"USER_DEFINED,"+ // 17
"DESCRIPTION,"+ // 18
"OUTCUE,"+ // 19
"FILENAME,LENGTH,"+ // 20
"START_POINT,"+ // 21
"END_POINT,"+ // 22
"SEGUE_START_POINT,"+ // 23
"SEGUE_END_POINT,"+ // 24
"HOOK_START_POINT,"+ // 25
"HOOK_END_POINT,"+ // 26
"TALK_START_POINT,"+ // 27
"TALK_END_POINT,"+ // 28
"FADEUP_POINT,"+ // 29
"FADEDOWN_POINT,"+ // 30
"SCHED_CODES"; // 31
*report+="\n";
*report=RDCsvField("CART_NUMBER"); // 00
*report+=RDCsvField("CUT_NUMBER"); // 01
*report+=RDCsvField("TYPE"); // 02
*report+=RDCsvField("GROUP_NAME"); // 03
*report+=RDCsvField("TITLE"); // 04
*report+=RDCsvField("ARTIST"); // 05
*report+=RDCsvField("ALBUM"); // 06
*report+=RDCsvField("YEAR"); // 07
*report+=RDCsvField("ISRC"); // 08
*report+=RDCsvField("ISCI"); // 09
*report+=RDCsvField("LABEL"); // 10
*report+=RDCsvField("CLIENT"); // 11
*report+=RDCsvField("AGENCY"); // 12
*report+=RDCsvField("PUBLISHER"); // 13
*report+=RDCsvField("COMPOSER"); // 14
*report+=RDCsvField("CONDUCTOR"); // 15
*report+=RDCsvField("SONG_ID"); // 16
*report+=RDCsvField("USER_DEFINED"); // 17
*report+=RDCsvField("DESCRIPTION"); // 18
*report+=RDCsvField("OUTCUE"); // 19
*report+=RDCsvField("FILENAME"); // 20
*report+=RDCsvField("LENGTH"); // 21
*report+=RDCsvField("START_POINT"); // 22
*report+=RDCsvField("END_POINT"); // 23
*report+=RDCsvField("SEGUE_START_POINT"); // 24
*report+=RDCsvField("SEGUE_END_POINT"); // 25
*report+=RDCsvField("HOOK_START_POINT"); // 26
*report+=RDCsvField("HOOK_END_POINT"); // 27
*report+=RDCsvField("TALK_START_POINT"); // 28
*report+=RDCsvField("TALK_END_POINT"); // 29
*report+=RDCsvField("FADEUP_POINT"); // 30
*report+=RDCsvField("FADEDOWN_POINT"); // 31
*report+=RDCsvField("SCHED_CODES",true); // 32
}
//
@ -587,65 +640,66 @@ void ListReports::GenerateCartDumpCsv(QString *report,bool prepend_names)
//
while(q->next()) {
RDCart::Type type=(RDCart::Type)q->value(1).toInt();
*report+=QString::asprintf("%u,",q->value(0).toUInt());
*report+=RDCsvField(q->value(0).toUInt());
if(type==RDCart::Macro) {
*report+="0,macro,";
*report+=RDCsvField(0);
*report+=RDCsvField("macro");
}
else {
*report+=QString::asprintf("%u,",RDCut::cutNumber(q->value(2).toString()));
*report+="audio,";
*report+=RDCsvField(RDCut::cutNumber(q->value(2).toString()));
*report+=RDCsvField("audio");
}
*report+=CsvField(q->value(3).toString())+",";
*report+=CsvField(q->value(4).toString())+",";
*report+=CsvField(q->value(5).toString())+",";
*report+=CsvField(q->value(6).toString())+",";
*report+=CsvField(q->value(7).toDate().toString("yyyy"))+",";
*report+=CsvField(q->value(8).toString())+",";
*report+=CsvField(q->value(9).toString())+",";
*report+=CsvField(q->value(10).toString())+",";
*report+=CsvField(q->value(11).toString())+",";
*report+=CsvField(q->value(12).toString())+",";
*report+=CsvField(q->value(13).toString())+",";
*report+=CsvField(q->value(14).toString())+",";
*report+=CsvField(q->value(15).toString())+",";
*report+=CsvField(q->value(16).toString())+",";
*report+=CsvField(q->value(17).toString())+",";
*report+=CsvField(q->value(18).toString())+",";
*report+=CsvField(q->value(19).toString())+",";
*report+=RDCsvField(q->value(3).toString());
*report+=RDCsvField(q->value(4).toString());
*report+=RDCsvField(q->value(5).toString());
*report+=RDCsvField(q->value(6).toString());
*report+=RDCsvField(q->value(7).toDate().toString("yyyy"));
*report+=RDCsvField(q->value(8).toString());
*report+=RDCsvField(q->value(9).toString());
*report+=RDCsvField(q->value(10).toString());
*report+=RDCsvField(q->value(11).toString());
*report+=RDCsvField(q->value(12).toString());
*report+=RDCsvField(q->value(13).toString());
*report+=RDCsvField(q->value(14).toString());
*report+=RDCsvField(q->value(15).toString());
*report+=RDCsvField(q->value(16).toString());
*report+=RDCsvField(q->value(17).toString());
*report+=RDCsvField(q->value(18).toString());
*report+=RDCsvField(q->value(19).toString());
if(type==RDCart::Macro) {
*report+=",";
*report+=RDCsvField();
}
else {
*report+=CsvField(q->value(2).toString()+".wav")+",";
*report+=RDCsvField(q->value(2).toString()+".wav");
}
*report+=
RDGetTimeLength(q->value(20).toInt(),false,false).trimmed()+",";
RDCsvField(RDGetTimeLength(q->value(20).toInt(),false,false).trimmed());
if(type==RDCart::Macro) {
*report+="-1,";
*report+="-1,";
*report+="-1,";
*report+="-1,";
*report+="-1,";
*report+="-1,";
*report+="-1,";
*report+="-1,";
*report+="-1,";
*report+="-1,";
*report+=RDCsvField(-1);
*report+=RDCsvField(-1);
*report+=RDCsvField(-1);
*report+=RDCsvField(-1);
*report+=RDCsvField(-1);
*report+=RDCsvField(-1);
*report+=RDCsvField(-1);
*report+=RDCsvField(-1);
*report+=RDCsvField(-1);
*report+=RDCsvField(-1);
}
else {
*report+=QString::asprintf("%d,",q->value(21).toInt());
*report+=QString::asprintf("%d,",q->value(22).toInt());
*report+=QString::asprintf("%d,",q->value(23).toInt());
*report+=QString::asprintf("%d,",q->value(24).toInt());
*report+=QString::asprintf("%d,",q->value(25).toInt());
*report+=QString::asprintf("%d,",q->value(26).toInt());
*report+=QString::asprintf("%d,",q->value(27).toInt());
*report+=QString::asprintf("%d,",q->value(28).toInt());
*report+=QString::asprintf("%d,",q->value(29).toInt());
*report+=QString::asprintf("%d,",q->value(30).toInt());
*report+=RDCsvField(q->value(21).toInt());
*report+=RDCsvField(q->value(22).toInt());
*report+=RDCsvField(q->value(23).toInt());
*report+=RDCsvField(q->value(24).toInt());
*report+=RDCsvField(q->value(25).toInt());
*report+=RDCsvField(q->value(26).toInt());
*report+=RDCsvField(q->value(27).toInt());
*report+=RDCsvField(q->value(28).toInt());
*report+=RDCsvField(q->value(29).toInt());
*report+=RDCsvField(q->value(30).toInt());
}
sql=QString("select SCHED_CODE from CART_SCHED_CODES where ")+
QString::asprintf("CART_NUMBER=%u",q->value(0).toUInt());
QString().sprintf("CART_NUMBER=%u",q->value(0).toUInt());
QString schedcodes="";
q1=new RDSqlQuery(sql);
while(q1->next()) {
@ -654,14 +708,7 @@ void ListReports::GenerateCartDumpCsv(QString *report,bool prepend_names)
if(schedcodes.right(1)=="|") {
schedcodes=schedcodes.left(schedcodes.length()-1);
}
*report+=CsvField(schedcodes);
*report+=RDCsvField(schedcodes,true);
delete q1;
*report+="\n";
}
}
QString ListReports::CsvField(QString str) const
{
return "\""+str.replace("\"","\"\"")+"\"";
}

View File

@ -46,7 +46,6 @@ class ListReports : public RDDialog
void GenerateCartReport(QString *report);
void GenerateCutReport(QString *report);
void GenerateCartDumpCsv(QString *report,bool prepend_names);
QString CsvField(QString str) const;
QLabel *list_reports_label;
QComboBox *list_reports_box;
QCheckBox *list_fieldnames_check;