mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-13 06:03:37 +02:00
2018-08-01 Fred Gleason <fredg@paravelsystems.com>
* Modified as-played reports to work correctly with UTF-8 strings.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Export a Rivendell Cut Report.
|
||||
//
|
||||
// (C) Copyright 2002-2017 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2018 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
|
||||
@@ -36,17 +36,19 @@ bool RDReport::ExportCutLog(const QString &filename,const QDate &startdate,
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
FILE *f;
|
||||
QString cut;
|
||||
QString str;
|
||||
QString cart_fmt;
|
||||
QString cart_num;
|
||||
|
||||
QFile file(filename);
|
||||
if((f=fopen((const char *)filename,"w"))==NULL) {
|
||||
QFile *file=new QFile(filename);
|
||||
if(!file->open(IO_WriteOnly|IO_Truncate)) {
|
||||
report_error_code=RDReport::ErrorCantOpen;
|
||||
delete file;
|
||||
return false;
|
||||
}
|
||||
QTextStream *strm=new QTextStream(file);
|
||||
strm->setEncoding(QTextStream::UnicodeUTF8);
|
||||
if(useLeadingZeros()) {
|
||||
cart_fmt=QString().sprintf("%%0%uu",cartDigits());
|
||||
}
|
||||
@@ -78,21 +80,16 @@ bool RDReport::ExportCutLog(const QString &filename,const QDate &startdate,
|
||||
// Write File Header
|
||||
//
|
||||
if(startdate==enddate) {
|
||||
fprintf(f," Rivendell RDAirPlay Cut Report for %s\n",
|
||||
(const char *)startdate.toString("MM/dd/yyyy"));
|
||||
*strm << Center(QString("Rivendell RDAirPlay Cut Report for ")+
|
||||
startdate.toString("MM/dd/yyyy"),75);
|
||||
}
|
||||
else {
|
||||
fprintf(f," Rivendell RDAirPlay Cut Report for %s - %s\n",
|
||||
(const char *)startdate.toString("MM/dd/yyyy"),
|
||||
(const char *)enddate.toString("MM/dd/yyyy"));
|
||||
*strm << Center(QString("Rivendell RDAirPlay Cut Report for ")+
|
||||
startdate.toString("MM/dd/yyyy")+" - "+
|
||||
enddate.toString("MM/dd/yyyy"),75)+"\n";
|
||||
}
|
||||
str=QString().sprintf("%s -- %s\n",(const char *)name(),
|
||||
(const char *)description());
|
||||
for(unsigned i=0;i<(80-str.length())/2;i++) {
|
||||
fprintf(f," ");
|
||||
}
|
||||
fprintf(f,"%s\n",(const char *)str);
|
||||
fprintf(f,"--Time-- -Cart- --Title---------------- Cut --Description------- -Len-\n");
|
||||
*strm << Center(name()+" -- "+description(),75)+"\n";
|
||||
*strm << "--Time-- -Cart- --Title---------------- Cut --Description------- -Len-\n";
|
||||
|
||||
//
|
||||
// Write Data Rows
|
||||
@@ -115,18 +112,17 @@ bool RDReport::ExportCutLog(const QString &filename,const QDate &startdate,
|
||||
if(desc.isEmpty()) {
|
||||
desc=" ";
|
||||
}
|
||||
fprintf(f,"%8s %6s %-23s %3s %-20s %5s",
|
||||
(const char *)q->value(2).toTime().toString("hh:mm:ss"),
|
||||
(const char *)cart_num,
|
||||
(const char *)q->value(8).toString().left(23),
|
||||
(const char *)cut,
|
||||
(const char *)desc.left(20),
|
||||
(const char *)RDGetTimeLength(q->value(9).toInt(),true,false).
|
||||
right(5));
|
||||
fprintf(f,"\n");
|
||||
*strm << q->value(2).toTime().toString("hh:mm:ss")+" ";
|
||||
*strm << cart_num+" ";
|
||||
*strm << LeftJustify(q->value(8).toString(),23)+" ";
|
||||
*strm << cut+" ";
|
||||
*strm << LeftJustify(desc,20)+" ";
|
||||
*strm << RDGetTimeLength(q->value(9).toInt(),true,false).right(5);
|
||||
*strm << "\n";
|
||||
}
|
||||
delete q;
|
||||
fclose(f);
|
||||
delete strm;
|
||||
delete file;
|
||||
report_error_code=RDReport::ErrorOk;
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user