2020-12-27 Fred Gleason <fredg@paravelsystems.com>

* Removed the 'RDLogEvent' class.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2020-12-27 17:20:58 -05:00
parent b72b9f08c2
commit ca7ead3ea3
37 changed files with 357 additions and 2231 deletions

View File

@ -20754,3 +20754,5 @@
2020-12-27 Fred Gleason <fredg@paravelsystems.com>
* Refactored 'ListLogs' dialog in rdairplay(1) to use
'RDLogListModel'.
2020-12-27 Fred Gleason <fredg@paravelsystems.com>
* Removed the 'RDLogEvent' class.

View File

@ -162,7 +162,6 @@ dist_librd_la_SOURCES = dbversion.h\
rdlivewiredestination.cpp rdlivewiredestination.h\
rdlivewiresource.cpp rdlivewiresource.h\
rdlog.cpp rdlog.h\
rdlog_event.cpp rdlog_event.h\
rdlog_icons.cpp rdlog_icons.h\
rdlog_line.cpp rdlog_line.h\
rdlogedit_conf.cpp rdlogedit_conf.h\

View File

@ -116,7 +116,6 @@ SOURCES += rdlistselector.cpp
SOURCES += rdlistview.cpp
SOURCES += rdlistviewitem.cpp
SOURCES += rdlog.cpp
SOURCES += rdlog_event.cpp
SOURCES += rdlog_icons.cpp
SOURCES += rdlog_line.cpp
SOURCES += rdlogedit_conf.cpp
@ -262,7 +261,6 @@ HEADERS += rdlistselector.h
HEADERS += rdlistview.h
HEADERS += rdlistviewitem.h
HEADERS += rdlog.h
HEADERS += rdlog_event.h
HEADERS += rdlog_icons.h
HEADERS += rdlog_line.h
HEADERS += rdlogedit_conf.h

View File

@ -914,7 +914,7 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
}
bool RDEventLine::linkLog(RDLogEvent *e,RDLog *log,const QString &svcname,
bool RDEventLine::linkLog(RDLogModel *e,RDLog *log,const QString &svcname,
RDLogLine *link_logline,const QString &track_str,
const QString &label_cart,const QString &track_cart,
QString *errors)
@ -949,11 +949,11 @@ bool RDEventLine::linkLog(RDLogEvent *e,RDLog *log,const QString &svcname,
// Insert Parent Link
//
if(log->includeImportMarkers()) {
e->insert(e->size(),1);
e->insert(e->lineCount(),1);
logline=new RDLogLine();
*logline=*link_logline;
logline->setId(e->nextId());
*(e->logLine(e->size()-1))=*logline;
*(e->logLine(e->lineCount()-1))=*logline;
delete logline;
logline=NULL;
@ -1024,8 +1024,8 @@ bool RDEventLine::linkLog(RDLogEvent *e,RDLog *log,const QString &svcname,
//
if(q->value(8).toUInt()==RDLogLine::TrafficLink) {
if((!event_nested_event.isEmpty()&&(event_nested_event!=event_name))) {
e->insert(e->size(),1);
logline=e->logLine(e->size()-1);
e->insert(e->lineCount(),1);
logline=e->logLine(e->lineCount()-1);
logline->setId(e->nextId());
logline->setStartTime(RDLogLine::Logged,time);
logline->setType(RDLogLine::TrafficLink);
@ -1046,8 +1046,8 @@ bool RDEventLine::linkLog(RDLogEvent *e,RDLog *log,const QString &svcname,
// Voicetrack Marker
//
if(q->value(8).toUInt()==RDLogLine::Track) {
e->insert(e->size(),1);
logline=e->logLine(e->size()-1);
e->insert(e->lineCount(),1);
logline=e->logLine(e->lineCount()-1);
logline->setId(e->nextId());
logline->setStartTime(RDLogLine::Logged,time);
logline->setType(RDLogLine::Track);
@ -1068,8 +1068,8 @@ bool RDEventLine::linkLog(RDLogEvent *e,RDLog *log,const QString &svcname,
// Label/Note Cart
//
if(q->value(8).toUInt()==RDLogLine::Marker) {
e->insert(e->size(),1);
logline=e->logLine(e->size()-1);
e->insert(e->lineCount(),1);
logline=e->logLine(e->lineCount()-1);
logline->setId(e->nextId());
logline->setStartTime(RDLogLine::Logged,time);
logline->setType(RDLogLine::Marker);
@ -1090,8 +1090,8 @@ bool RDEventLine::linkLog(RDLogEvent *e,RDLog *log,const QString &svcname,
// Cart
//
if(q->value(8).toUInt()==RDLogLine::Cart) {
e->insert(e->size(),1);
logline=e->logLine(e->size()-1);
e->insert(e->lineCount(),1);
logline=e->logLine(e->lineCount()-1);
logline->setId(e->nextId());
logline->setSource(event_src);
logline->
@ -1166,8 +1166,8 @@ bool RDEventLine::linkLog(RDLogEvent *e,RDLog *log,const QString &svcname,
while(q->next()&&(fill_start_time<=time)) {
if((time.addMSecs(q->value(1).toInt())<=end_time)&&
(time.addMSecs(q->value(1).toInt())>time)) {
e->insert(e->size(),1);
logline=e->logLine(e->size()-1);
e->insert(e->lineCount(),1);
logline=e->logLine(e->lineCount()-1);
logline->setId(e->nextId());
logline->setStartTime(RDLogLine::Logged,time);
logline->setType(RDLogLine::Cart);

View File

@ -23,7 +23,7 @@
#include <qdatetime.h>
#include <rdlog_event.h>
#include <rdlogmodel.h>
#include <rdeventimportlist.h>
#include <rdlog.h>
#include <rdlog_line.h>
@ -78,7 +78,7 @@ class RDEventLine
bool save(RDConfig *config);
bool generateLog(QString logname,const QString &svcname,
QString *errors,QString clockname);
bool linkLog(RDLogEvent *e,RDLog *log,const QString &svcname,
bool linkLog(RDLogModel *e,RDLog *log,const QString &svcname,
RDLogLine *link_logline,const QString &track_str,
const QString &label_cart,const QString &track_cart,
QString *errors);

View File

@ -40,7 +40,6 @@
#include "rdfeed.h"
#include "rdlibrary_conf.h"
#include "rdlog.h"
#include "rdlog_event.h"
#include "rdpodcast.h"
#include "rdrenderer.h"
#include "rdtempdirectory.h"
@ -1440,7 +1439,7 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
QString err_msg;
RDRenderer *renderer=NULL;
RDSettings *settings=NULL;
RDLogEvent *log_event=NULL;
RDLogModel *log_model=NULL;
feed_render_start_line=start_line;
feed_render_end_line=end_line;
@ -1451,11 +1450,11 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
//
// Open Log
//
log_event=new RDLogEvent(logname);
log_event->load();
if(!log_event->exists()) {
log_model=new RDLogModel(logname,false,this);
log_model->load();
if(!log_model->exists()) {
*err=RDFeed::ErrorNoLog;
delete log_event;
delete log_model;
return 0;
}
@ -1476,12 +1475,12 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
connect(renderer,SIGNAL(lineStarted(int,int)),
this,SLOT(renderLineStartedData(int,int)));
if(!renderer->renderToFile(tmpfile,log_event,settings,start_time,stop_at_stop,
if(!renderer->renderToFile(tmpfile,log_model,settings,start_time,stop_at_stop,
&err_msg,start_line,end_line)) {
*err=RDFeed::ErrorRenderError;
delete renderer;
delete settings;
delete log_event;
delete log_model;
unlink(tmpfile);
return 0;
}
@ -1493,7 +1492,7 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
//
QFile f(tmpfile);
unsigned cast_id=
CreateCast(&destfile,f.size(),log_event->length(0,log_event->size()));
CreateCast(&destfile,f.size(),log_model->length(0,log_model->lineCount()));
RDPodcast *cast=new RDPodcast(feed_config,cast_id);
SavePodcast(cast_id,tmpfile);
unlink(tmpfile);
@ -1516,7 +1515,7 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
cast->setItemTitle(log->description());
}
cast->setItemImageId(defaultItemImageId());
cast->setAudioTime(log_event->length(start_line,1+end_line));
cast->setAudioTime(log_model->length(start_line,1+end_line));
delete log;
postXml();
@ -1525,7 +1524,7 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
delete cast;
delete settings;
delete log_event;
delete log_model;
unlink(tmpfile);
return cast_id;

View File

@ -2,7 +2,7 @@
//
// Abstract a Rivendell Log.
//
// (C) Copyright 2002-2003,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2020 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
@ -457,9 +457,9 @@ int RDLog::removeTracks(RDStation *station,RDUser *user,RDConfig *config) const
}
RDLogEvent *RDLog::createLogEvent() const
RDLogModel *RDLog::createLogEvent() const
{
return new RDLogEvent(name());
return new RDLogModel(name(),false);
}

View File

@ -2,7 +2,7 @@
//
// Abstract a Rivendell Log
//
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2020 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,7 +22,7 @@
#define RDLOG_H
#include <rdconfig.h>
#include <rdlog_event.h>
#include <rdlogmodel.h>
#include <rduser.h>
#include <rdstation.h>
@ -76,7 +76,7 @@ class RDLog
bool remove(RDStation *station,RDUser *user,RDConfig *config) const;
void updateTracks();
int removeTracks(RDStation *station,RDUser *user,RDConfig *config) const;
RDLogEvent *createLogEvent() const;
RDLogModel *createLogEvent() const;
QString xml() const;
static bool create(const QString &name,const QString &svc_name,
const QDate &air_date,const QString &user_name,

File diff suppressed because it is too large Load Diff

View File

@ -1,87 +0,0 @@
// rdlog_event.h
//
// Abstract Rivendell Log Events
//
// (C) Copyright 2002-2020 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
// 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 <vector>
#include <qdatetime.h>
#include <qsqldatabase.h>
#include <rdconfig.h>
#include <rdlog_line.h>
#ifndef RDLOG_EVENT_H
#define RDLOG_EVENT_H
#define INSERT_STEP_SIZE 500
class RDLogEvent
{
public:
RDLogEvent(QString logname="");
~RDLogEvent();
bool exists();
bool exists(int line);
bool exists(const QTime &hard_time,int except_line=-1);
QString logName() const;
void setLogName(QString logname);
QString serviceName() const;
int load(bool track_ptrs=false);
void saveModified(RDConfig *config,bool update_tracks=true);
void save(RDConfig *config,bool update_tracks=true,int line=-1);
int append(const QString &logname,bool track_ptrs=false);
int validate(QString *report,const QDate &date);
void clear();
void refresh(int line);
int size() const;
void insert(int line,int num_lines,bool preserve_trans=false);
void remove(int line,int num_lines,bool preserve_trans=false);
void move(int from_line,int to_line);
void copy(int from_line,int to_line);
int length(int from_line,int to_line,QTime *sched_time=NULL);
int lengthToStop(int from_line,QTime *sched_time=NULL);
bool blockLength(int *nominal_length,int *actual_length,int line);
QTime blockStartTime(int line);
RDLogLine *logLine(int line) const;
void setLogLine(int line,RDLogLine *ll);
RDLogLine *loglineById(int id, bool ignore_holdovers=false) const;
int lineById(int id, bool ignore_holdovers=false) const;
int lineByStartHour(int hour,RDLogLine::StartTimeType type) const;
int lineByStartHour(int hour) const;
int nextTimeStart(QTime after);
RDLogLine::TransType nextTransType(int);
void removeCustomTransition(int line);
int nextId() const;
int nextLinkId() const;
QString xml() const;
private:
int LoadLines(const QString &logname,int id_offset,bool track_ptrs);
void SaveLine(int line);
void InsertLines(QString values);
void InsertLineValues(QString *query, int line);
void LoadNowNext(unsigned from_line);
QString log_name;
QString log_service_name;
int log_max_id;
std::vector<RDLogLine *> log_line;
};
#endif // RDLOG_LINE_H

View File

@ -30,13 +30,15 @@
RDLogModel::RDLogModel(const QString &logname,bool read_only,QObject *parent)
: QAbstractTableModel(parent)
{
d_log_name=logname;
d_read_only=read_only;
MakeModel();
/*
d_fms=NULL;
d_bold_fms=NULL;
d_log_icons=new RDLogIcons();
d_start_time_style=RDLogModel::Scheduled;
d_log_name=logname;
d_read_only=read_only;
d_max_id=0;
//
@ -87,6 +89,16 @@ RDLogModel::RDLogModel(const QString &logname,bool read_only,QObject *parent)
d_headers.push_back(tr("Count"));
d_alignments.push_back(right);
*/
}
RDLogModel::RDLogModel(QObject *parent)
: QAbstractTableModel(parent)
{
d_read_only=false;
MakeModel();
}
@ -1598,3 +1610,62 @@ QColor RDLogModel::backgroundColor(int line,RDLogLine *ll) const
{
return d_palette.color(QPalette::Base);
}
void RDLogModel::MakeModel()
{
d_fms=NULL;
d_bold_fms=NULL;
d_log_icons=new RDLogIcons();
d_start_time_style=RDLogModel::Scheduled;
d_max_id=0;
//
// Column Attributes
//
unsigned left=Qt::AlignLeft|Qt::AlignVCenter;
unsigned center=Qt::AlignCenter;
unsigned right=Qt::AlignRight|Qt::AlignVCenter;
d_headers.push_back(tr("Start Time"));
d_alignments.push_back(right);
d_headers.push_back(tr("Trans"));
d_alignments.push_back(center);
d_headers.push_back(tr("Cart"));
d_alignments.push_back(center);
d_headers.push_back(tr("Group"));
d_alignments.push_back(center);
d_headers.push_back(tr("Length"));
d_alignments.push_back(right);
d_headers.push_back(tr("Title"));
d_alignments.push_back(left);
d_headers.push_back(tr("Artist"));
d_alignments.push_back(left);
d_headers.push_back(tr("Client"));
d_alignments.push_back(left);
d_headers.push_back(tr("Agency"));
d_alignments.push_back(left);
d_headers.push_back(tr("Label"));
d_alignments.push_back(left);
d_headers.push_back(tr("Source"));
d_alignments.push_back(left);
d_headers.push_back(tr("Ext Data"));
d_alignments.push_back(left);
d_headers.push_back(tr("Line ID"));
d_alignments.push_back(right);
d_headers.push_back(tr("Count"));
d_alignments.push_back(right);
}

View File

@ -27,7 +27,6 @@
#include <QList>
#include <QPalette>
#include <rdlog_event.h>
#include <rdlog_icons.h>
#include <rdnotification.h>
@ -37,6 +36,7 @@ class RDLogModel : public QAbstractTableModel
public:
enum StartTimeStyle {Estimated=0,Scheduled=1};
RDLogModel(const QString &logname,bool read_only,QObject *parent=0);
RDLogModel(QObject *parent=0);
~RDLogModel();
QPalette palette();
void setPalette(const QPalette &pal);
@ -98,6 +98,7 @@ class RDLogModel : public QAbstractTableModel
void InsertLines(QString values);
void InsertLineValues(QString *query, int line);
void LoadNowNext(unsigned from_line);
void MakeModel();
QPalette d_palette;
QFont d_font;
QFontMetrics *d_fms;

View File

@ -41,7 +41,7 @@
//#define SHOW_METER_SLOTS
RDLogPlay::RDLogPlay(int id,RDEventPlayer *player,QObject *parent)
: QObject(parent),RDLogEvent("")
: RDLogModel(parent)
{
//
// Initialize Data Structures
@ -228,7 +228,7 @@ void RDLogPlay::setOpMode(RDAirPlayConf::OpMode mode)
void RDLogPlay::setLogName(QString name)
{
if(logName()!=name) {
RDLogEvent::setLogName(name);
RDLogModel::setLogName(name);
emit renamed();
rda->airplayConf()->setCurrentLog(play_id,name);
}
@ -524,11 +524,11 @@ void RDLogPlay::load()
// Remove All Idle Events
//
if((running=runningEvents(lines))==0) {
remove(0,size(),false);
remove(0,lineCount(),false);
}
else {
if(lines[running-1]<(size()-1)) {
remove(lines[running-1]+1,size()-lines[running-1]-1,false);
if(lines[running-1]<(lineCount()-1)) {
remove(lines[running-1]+1,lineCount()-lines[running-1]-1,false);
}
for(int i=running-1;i>0;i--) {
remove(lines[i-1]+1,lines[i]-lines[i-1]-1,false);
@ -541,20 +541,20 @@ void RDLogPlay::load()
// Note that events left in the log are holdovers from a previous log.
// Their IDs may clash with those of events in the log we will now load,
// and it may be appropriate to ignore them in that case.
for(int i = 0, ilim = size(); i != ilim; ++i)
for(int i = 0, ilim = lineCount(); i != ilim; ++i)
logLine(i)->setHoldover(true);
//
// Load Events
//
RDLogEvent::load();
RDLogModel::load();
play_rescan_pos=0;
if(play_timescaling_available) {
for(int i=0;i<size();i++) {
for(int i=0;i<lineCount();i++) {
logLine(i)->setTimescalingActive(logLine(i)->enforceLength());
}
}
RefreshEvents(0,size());
RefreshEvents(0,lineCount());
RDLog *log=new RDLog(logName());
play_svc_name=log->service();
delete log;
@ -565,7 +565,7 @@ void RDLogPlay::load()
SetTransTimer();
emit transportChanged();
UpdatePostPoint();
if((running>0)&&(size()>running)) {
if((running>0)&&(lineCount()>running)) {
makeNext(running);
}
@ -587,21 +587,20 @@ void RDLogPlay::load()
void RDLogPlay::append(const QString &log_name)
{
int old_size=size();
int old_size=lineCount();
if(size()==0) {
// setLogName(RDLog::tableName(log_name));
if(lineCount()==0) {
load();
return;
}
RDLogEvent::append(log_name);
RDLogModel::append(log_name);
if(play_timescaling_available) {
for(int i=old_size;i<size();i++) {
for(int i=old_size;i<lineCount();i++) {
logLine(i)->setTimescalingActive(logLine(i)->enforceLength());
}
}
RefreshEvents(old_size,size()-old_size);
RefreshEvents(old_size,lineCount()-old_size);
UpdateStartTimes(old_size);
emit reloaded();
SetTransTimer();
@ -628,7 +627,7 @@ bool RDLogPlay::refresh()
return true;
}
emit refreshStatusChanged(true);
if((size()==0)||(play_log==NULL)) {
if((lineCount()==0)||(play_log==NULL)) {
emit refreshStatusChanged(false);
emit refreshabilityChanged(false);
return true;
@ -637,7 +636,7 @@ bool RDLogPlay::refresh()
//
// Load the Updated Log
//
RDLogEvent *e=new RDLogEvent();
RDLogModel *e=new RDLogModel();
e->setLogName(logName());
e->load();
play_modified_datetime=play_log->modifiedDatetime();
@ -665,7 +664,7 @@ bool RDLogPlay::refresh()
//
// Pass 1: Finished or Active Events
//
for(int i=0;i<size();i++) {
for(int i=0;i<lineCount();i++) {
d=logLine(i);
if(d->status()!=RDLogLine::Scheduled) {
if((!d->isHoldover()) && (s=e->loglineById(d->id()))!=NULL) {
@ -683,7 +682,7 @@ bool RDLogPlay::refresh()
//
// Pass 2: Purge Deleted Events
//
for(int i=size()-1;i>=0;i--) {
for(int i=lineCount()-1;i>=0;i--) {
if(logLine(i)->pass()==0) {
remove(i,1,false,true);
}
@ -691,7 +690,7 @@ bool RDLogPlay::refresh()
// Find first non-holdover event, where start-of-log
// new events should be added:
for(int i=0;i<e->size();i++) {
for(int i=0;i<e->lineCount();i++) {
if(logLine(i)!=NULL) {
if(logLine(i)->isHoldover()) {
++first_non_holdover;
@ -705,7 +704,7 @@ bool RDLogPlay::refresh()
//
// Pass 3: Add New Events
//
for(int i=0;i<e->size();i++) {
for(int i=0;i<e->lineCount();i++) {
s=e->logLine(i);
if(s->pass()==0) {
if((prev_line=(i-1))<0) { // First Event
@ -724,7 +723,7 @@ bool RDLogPlay::refresh()
//
// Pass 4: Delete Orphaned Past Playouts
//
for(int i=size()-1;i>=0;i--) {
for(int i=lineCount()-1;i>=0;i--) {
d=logLine(i);
if((d->status()==RDLogLine::Finished)&&(d->pass()!=2)) {
remove(i,1,false,true);
@ -752,10 +751,10 @@ bool RDLogPlay::refresh()
// Clean Up
//
delete e;
for(int i=0;i<size();i++) {
for(int i=0;i<lineCount();i++) {
logLine(i)->clearPass();
}
RefreshEvents(0,size());
RefreshEvents(0,lineCount());
UpdateStartTimes(next_line);
UpdatePostPoint();
SetTransTimer();
@ -774,7 +773,7 @@ bool RDLogPlay::refresh()
void RDLogPlay::save(int line)
{
RDLogEvent::save(rda->config(),line);
RDLogModel::save(rda->config(),line);
if(play_log!=NULL) {
delete play_log;
}
@ -821,7 +820,7 @@ void RDLogPlay::insert(int line,int cartnum,RDLogLine::TransType next_type,
RDPlayDeck *playdeck;
int mod_line=-1;
if(line<(size()-1)) {
if(line<(lineCount()-1)) {
if(logLine(line)->hasCustomTransition()) {
mod_line=line+1;
}
@ -841,9 +840,9 @@ void RDLogPlay::insert(int line,int cartnum,RDLogLine::TransType next_type,
if(play_macro_deck->line()>=0) {
play_macro_deck->setLine(play_macro_deck->line()+1);
}
RDLogEvent::insert(line,1);
RDLogModel::insert(line,1);
if((logline=logLine(line))==NULL) {
RDLogEvent::remove(line,1);
RDLogModel::remove(line,1);
return;
}
if(nextLine()>line) {
@ -874,7 +873,7 @@ void RDLogPlay::insert(int line,RDLogLine *l,bool update,bool preserv_custom_tra
RDPlayDeck *playdeck;
int mod_line=-1;
if(line<(size()-1)) {
if(line<(lineCount()-1)) {
if(logLine(line)->hasCustomTransition()) {
mod_line=line+1;
}
@ -894,9 +893,9 @@ void RDLogPlay::insert(int line,RDLogLine *l,bool update,bool preserv_custom_tra
if(play_macro_deck->line()>=0) {
play_macro_deck->setLine(play_macro_deck->line()+1);
}
RDLogEvent::insert(line,1,preserv_custom_transition);
RDLogModel::insert(line,1,preserv_custom_transition);
if((logline=logLine(line))==NULL) {
RDLogEvent::remove(line,1);
RDLogModel::remove(line,1);
return;
}
*logline=*l;
@ -922,16 +921,17 @@ void RDLogPlay::insert(int line,RDLogLine *l,bool update,bool preserv_custom_tra
}
void RDLogPlay::remove(int line,int num_lines,bool update,bool preserv_custom_transition)
void RDLogPlay::remove(int line,int num_lines,bool update,
bool preserv_custom_transition)
{
RDPlayDeck *playdeck;
RDLogLine *logline;
int mod_line=-1;
if((num_lines==0)||(line<0)||(line>=size())) {
if((num_lines==0)||(line<0)||(line>=lineCount())) {
return;
}
if((line+num_lines)<(size()-1)) {
if((line+num_lines)<(lineCount()-1)) {
if(logLine(line+num_lines)->hasCustomTransition()) {
mod_line=line;
}
@ -966,13 +966,13 @@ void RDLogPlay::remove(int line,int num_lines,bool update,bool preserv_custom_tr
play_macro_deck->setLine(play_macro_deck->line()-num_lines);
}
RDLogEvent::remove(line,num_lines,preserv_custom_transition);
RDLogModel::remove(line,num_lines,preserv_custom_transition);
if(update) {
if(nextLine()>line) {
makeNext(nextLine()-num_lines);
}
UpdateStartTimes(line);
if(size()==0) {
if(lineCount()==0) {
emit reloaded();
}
if(mod_line>=0) {
@ -993,7 +993,7 @@ void RDLogPlay::move(int from_line,int to_line)
RDPlayDeck *playdeck;
int mod_line[2]={-1,-1};
if(from_line<(size()-1)) {
if(from_line<(lineCount()-1)) {
if(logLine(from_line+1)->hasCustomTransition()) {
if(from_line<to_line) {
mod_line[0]=from_line;
@ -1003,7 +1003,7 @@ void RDLogPlay::move(int from_line,int to_line)
}
}
}
if(to_line<size()) {
if(to_line<lineCount()) {
if(logLine(to_line)->hasCustomTransition()) {
if(from_line>to_line) {
mod_line[1]=to_line;
@ -1049,7 +1049,7 @@ void RDLogPlay::move(int from_line,int to_line)
if(to_line>from_line) {
offset=1;
}
RDLogEvent::move(from_line,to_line);
RDLogModel::move(from_line,to_line);
if(from_line>to_line) {
UpdateStartTimes(to_line);
}
@ -1091,7 +1091,7 @@ void RDLogPlay::copy(int from_line,int to_line,RDLogLine::TransType type)
int RDLogPlay::topLine()
{
for(int i=0;i<size();i++) {
for(int i=0;i<lineCount();i++) {
if((logLine(i)->status()==RDLogLine::Playing)||
(logLine(i)->status()==RDLogLine::Finishing)||
(logLine(i)->status()==RDLogLine::Paused)) {
@ -1134,7 +1134,7 @@ int RDLogPlay::nextLine(int line)
}
// End of FIXME
for(int i=line+1;i<size();i++) {
for(int i=line+1;i<lineCount();i++) {
if(logLine(i)->status()==RDLogLine::Scheduled) {
return i;
}
@ -1185,7 +1185,7 @@ void RDLogPlay::transportEvents(int line[])
for(int i=0;i<TRANSPORT_QUANTITY;i++) {
line[i]=-1;
}
if((start<0)||(size()==0)) {
if((start<0)||(lineCount()==0)) {
return;
}
@ -1197,7 +1197,7 @@ void RDLogPlay::transportEvents(int line[])
if((logline=logLine(start))==NULL) {
return;
}
for(int i=start;i<size();i++) {
for(int i=start;i<lineCount();i++) {
if((logline=logLine(i))==NULL) {
return;
}
@ -1225,7 +1225,7 @@ int RDLogPlay::runningEvents(int *lines, bool include_paused)
int table[TRANSPORT_QUANTITY];
bool changed=true;
if(size()==0) {
if(lineCount()==0) {
return 0;
}
for(int i=0;i<TRANSPORT_QUANTITY;i++) {
@ -1239,7 +1239,7 @@ int RDLogPlay::runningEvents(int *lines, bool include_paused)
// Build Running Event List
//
if(include_paused) {
for(int i=0;i<size();i++) {
for(int i=0;i<lineCount();i++) {
if((logLine(i)->status()==RDLogLine::Playing)||
(logLine(i)->status()==RDLogLine::Finishing)||
(logLine(i)->status()==RDLogLine::Paused)) {
@ -1251,7 +1251,7 @@ int RDLogPlay::runningEvents(int *lines, bool include_paused)
}
}
else {
for(int i=0;i<size();i++) {
for(int i=0;i<lineCount();i++) {
if((logLine(i)->status()==RDLogLine::Playing)||
(logLine(i)->status()==RDLogLine::Finishing)) {
events[count++]=i;
@ -1702,7 +1702,7 @@ void RDLogPlay::notificationReceivedData(RDNotification *notify)
if(notify->type()==RDNotification::CartType) {
unsigned cartnum=notify->id().toUInt();
for(int i=0;i<size();i++) {
for(int i=0;i<lineCount();i++) {
if((ll=logLine(i))!=NULL) {
if((ll->cartNumber()==cartnum)&&(ll->status()==RDLogLine::Scheduled)&&
((ll->type()==RDLogLine::Cart)||(ll->type()==RDLogLine::Macro))) {
@ -2060,7 +2060,8 @@ bool RDLogPlay::StartEvent(int line,RDLogLine::TransType trans_type,
default:
break;
}
while((play_next_line<size())&&((logline=logLine(play_next_line))!=NULL)) {
while((play_next_line<lineCount())&&((logline=logLine(play_next_line))!=
NULL)) {
if((logline->state()==RDLogLine::Ok)||
(logline->state()==RDLogLine::NoCart)||
(logline->state()==RDLogLine::NoCut)) {
@ -2182,7 +2183,7 @@ void RDLogPlay::UpdateStartTimes(int line)
else {
line=play_next_line;
}
for(int i=line;i<size();i++) {
for(int i=line;i<lineCount();i++) {
if((logline=logLine(i))!=NULL) {
if((next_logline=logLine(nextLine(i)))!=NULL) {
next_trans=next_logline->transType();
@ -2259,7 +2260,7 @@ void RDLogPlay::FinishEvent(int line)
return;
}
if((play_op_mode==RDAirPlayConf::Auto)&&
(logline->id()!=-1)&&(play_next_line<size())) {
(logline->id()!=-1)&&(play_next_line<lineCount())) {
if(play_next_line>=0) {
if(logline->transType()==RDLogLine::Play) {
StartEvent(play_next_line,RDLogLine::Play,0,RDLogLine::StartPlay);
@ -2350,7 +2351,7 @@ QTime RDLogPlay::GetNextStop(int line)
return QTime();
}
for(int i=line;i<size();i++) {
for(int i=line;i<lineCount();i++) {
if((status(i)==RDLogLine::Playing)||
(status(i)==RDLogLine::Finishing)) {
if((logLine(i)->type()==RDLogLine::Cart)&&
@ -2417,7 +2418,8 @@ void RDLogPlay::UpdatePostPoint(int line)
offset=0;
}
else {
if((line<size())&&(play_trans_line>=0)&&(play_trans_line<size())) {
if((line<lineCount())&&(play_trans_line>=0)&&
(play_trans_line<lineCount())) {
post_line=play_trans_line;
post_time=logLine(post_line)->startTime(RDLogLine::Logged);
offset=length(line,post_line)-QTime::currentTime().msecsTo(post_time)-
@ -2452,7 +2454,8 @@ void RDLogPlay::AdvanceActiveEvent()
}
}
else {
if(line<(size()-1)) {
//if(line<(size()-1)) {
if(line<(lineCount())) {
RDLogLine *logline;
if((logline=logLine(line+1))!=NULL) {
trans=logLine(line+1)->transType();
@ -2502,7 +2505,7 @@ void RDLogPlay::SetTransTimer(QTime current_time,bool stop)
}
}
play_trans_line=-1;
for(int i=0;i<size();i++) {
for(int i=0;i<lineCount();i++) {
if((logline=logLine(i))!=NULL) {
if((logline->timeType()==RDLogLine::Hard)&&
((logline->status()==RDLogLine::Scheduled)||
@ -2583,7 +2586,7 @@ bool RDLogPlay::GetNextPlayable(int *line,bool skip_meta,bool forced_start)
RDLogLine::TransType next_type=RDLogLine::Play;
int skipped=0;
for(int i=*line;i<size();i++) {
for(int i=*line;i<lineCount();i++) {
if((logline=logLine(i))==NULL) {
return false;
}
@ -2840,14 +2843,14 @@ bool RDLogPlay::ClearBlock(int start_line)
{
RDLogLine::Status status;
for(int i=start_line;i<size();i++) {
for(int i=start_line;i<lineCount();i++) {
status=logLine(i)->status();
if((status!=RDLogLine::Scheduled)&&(status!=RDLogLine::Finished)) {
remove(start_line,i-start_line);
return true;
}
}
remove(start_line,size()-start_line);
remove(start_line,lineCount()-start_line);
return false;
}
@ -2924,12 +2927,12 @@ void RDLogPlay::SendNowNext()
// Get NEXT Event
//
logline[1]=NULL;
for(int i=nextLine();i<size();i++) {
for(int i=nextLine();i<lineCount();i++) {
if((ll=logLine(i))!=NULL) {
if((ll->status()==RDLogLine::Scheduled)&&
logLine(i)->nowNextEnabled()&&(!logLine(i)->asyncronous())) {
logline[1]=logLine(i);
i=size();
i=lineCount();
}
}
}

View File

@ -2,7 +2,7 @@
//
// Rivendell Log Playout Machine
//
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2020 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
@ -23,17 +23,17 @@
#include <vector>
#include <qobject.h>
#include <qsignalmapper.h>
#include <qtimer.h>
#include <qdatetime.h>
#include <QDateTime>
#include <QObject>
#include <QSignalMapper>
#include <QTimer>
#include <rd.h>
#include <rdairplay_conf.h>
#include <rdapplication.h>
#include <rdevent_player.h>
#include <rdlog.h>
#include <rdlog_event.h>
#include <rdlogmodel.h>
#include <rdmacro_event.h>
#include <rdplay_deck.h>
#include <rdsimpleplayer.h>
@ -48,7 +48,7 @@
#define LOGPLAY_RESCAN_INTERVAL 5000
#define LOGPLAY_RESCAN_SIZE 30
class RDLogPlay : public QObject,public RDLogEvent
class RDLogPlay : public RDLogModel
{
Q_OBJECT
public:

View File

@ -91,8 +91,6 @@ void __RDRenderLogLine::setRamp(RDLogLine::TransType next_trans,int segue_gain)
if((next_trans==RDLogLine::Segue)&&(segueStartPoint()>=0)) {
ll_ramp_rate=((double)segue_gain)/
((double)FramesFromMsec(segueEndPoint()-segueStartPoint()));
//ll_ramp_rate=((double)RD_FADE_DEPTH)/
// ((double)FramesFromMsec(segueEndPoint()-segueStartPoint()));
}
}
@ -245,72 +243,6 @@ RDRenderer::~RDRenderer()
}
bool RDRenderer::renderToFile(const QString &outfile,RDLogEvent *log,
RDSettings *s,const QTime &start_time,
bool ignore_stops,QString *err_msg,
int first_line,int last_line,
const QTime &first_time,const QTime &last_time)
{
QString temp_output_filename;
char tempdir[PATH_MAX];
bool ok=false;
FILE *f=NULL;
bool ret;
//
// Verify Destination
//
if((f=fopen(outfile,"w"))==NULL) {
*err_msg=tr("unable to open output file")+" ["+QString(strerror(errno))+"]";
return false;
}
fclose(f);
if(((s->format()!=RDSettings::Pcm16)&&(s->format()!=RDSettings::Pcm24))||
(s->normalizationLevel()!=0)) {
ProgressMessage("Pass 1 of 2");
render_total_passes=2;
//
// Get Temporary File
//
strncpy(tempdir,RDTempDirectory::basePath()+"/rdrenderXXXXXX",PATH_MAX);
temp_output_filename=QString(mkdtemp(tempdir))+"/log.wav";
ProgressMessage(tr("Using temporary file")+" \""+temp_output_filename+"\".");
//
// Render It
//
if(!Render(temp_output_filename,log,s,start_time,ignore_stops,err_msg,
first_line,last_line,first_time,last_time)) {
return false;
}
//
// Convert It
//
ProgressMessage(tr("Pass 2 of 2"));
ProgressMessage(tr("Writing output file"));
ok=ConvertAudio(temp_output_filename,outfile,s,err_msg);
DeleteTempFile(temp_output_filename);
emit lineStarted(log->size()+1,log->size()+1);
if(!ok) {
return false;
}
}
else {
ProgressMessage(tr("Pass 1 of 1"));
render_total_passes=1;
ret=Render(outfile,log,s,start_time,ignore_stops,err_msg,
first_line,last_line,first_time,last_time);
emit lineStarted(log->size(),log->size());
return ret;
}
return true;
}
bool RDRenderer::renderToFile(const QString &outfile,RDLogModel *model,
RDSettings *s,const QTime &start_time,
bool ignore_stops,QString *err_msg,
@ -377,79 +309,6 @@ bool RDRenderer::renderToFile(const QString &outfile,RDLogModel *model,
}
bool RDRenderer::renderToCart(unsigned cartnum,int cutnum,RDLogEvent *log,
RDSettings *s,const QTime &start_time,
bool ignore_stops,QString *err_msg,
int first_line,int last_line,
const QTime &first_time,const QTime &last_time)
{
QString temp_output_filename;
char tempdir[PATH_MAX];
bool ok=false;
if(first_line<0) {
first_line=0;
}
if(last_line<0) {
last_line=log->size();
}
//
// Check that we won't overflow the 32 bit BWF structures
// when we go to import the rendered log back into the audio store
//
if((double)log->length(first_line,last_line-1)/1000.0>=
(1073741824.0/((double)s->channels()*(double)s->sampleRate()))) {
*err_msg=tr("Rendered log is too long!");
return false;
}
ProgressMessage(tr("Pass 1 of 2"));
render_total_passes=2;
//
// Verify Destination
//
if(!RDCart::exists(cartnum)) {
*err_msg=tr("no such cart");
return false;
}
if(!RDCut::exists(cartnum,cutnum)) {
*err_msg=tr("no such cut");
return false;
}
//
// Get Temporary File
//
strncpy(tempdir,RDTempDirectory::basePath()+"/rdrenderXXXXXX",PATH_MAX);
temp_output_filename=QString(mkdtemp(tempdir))+"/log.wav";
ProgressMessage(tr("Using temporary file")+" \""+temp_output_filename+"\".");
//
// Render It
//
if(!Render(temp_output_filename,log,s,start_time,ignore_stops,err_msg,
first_line,last_line,first_time,last_time)) {
return false;
}
//
// Convert It
//
ProgressMessage(tr("Pass 2 of 2"));
ProgressMessage(tr("Importing cart"));
ok=ImportCart(temp_output_filename,cartnum,cutnum,s->channels(),err_msg);
DeleteTempFile(temp_output_filename);
emit lineStarted(log->size()+1,log->size()+1);
if(!ok) {
return false;
}
return true;
}
bool RDRenderer::renderToCart(unsigned cartnum,int cutnum,RDLogModel *model,
RDSettings *s,const QTime &start_time,
bool ignore_stops,QString *err_msg,
@ -535,177 +394,6 @@ void RDRenderer::abort()
}
bool RDRenderer::Render(const QString &outfile,RDLogEvent *log,RDSettings *s,
const QTime &start_time,bool ignore_stops,
QString *err_msg,int first_line,int last_line,
const QTime &first_time,const QTime &last_time)
{
float *pcm=NULL;
QString temp_output_filename;
QTime current_time;
render_warnings.clear();
render_abort=false;
if(start_time.isNull()) {
current_time=QTime::currentTime();
}
else {
current_time=start_time;
}
//
// Open Output File
//
SF_INFO sf_info;
SNDFILE *sf_out;
memset(&sf_info,0,sizeof(sf_info));
sf_info.samplerate=rda->system()->sampleRate();
sf_info.channels=s->channels();
if(s->format()==RDSettings::Pcm16) {
sf_info.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
}
else {
sf_info.format=SF_FORMAT_WAV|SF_FORMAT_PCM_24;
}
sf_out=sf_open(outfile,SFM_WRITE,&sf_info);
if(sf_out==NULL) {
fprintf(stderr,"rdrender: unable to open output file [%s]\n",
sf_strerror(sf_out));
return 1;
}
//
// Initialize the log
//
std::vector<__RDRenderLogLine *> lls;
for(int i=0;i<log->size();i++) {
lls.push_back(new __RDRenderLogLine(log->logLine(i),s->channels()));
if(ignore_stops&&(lls.back()->transType()==RDLogLine::Stop)) {
lls.back()->setTransType(RDLogLine::Play);
}
if((!first_time.isNull())&&
(lls.back()->timeType()==RDLogLine::Hard)&&
(first_line==-1)&&
(lls.back()->startTime(RDLogLine::Imported)==first_time)) {
first_line=i;
}
if((!last_time.isNull())&&
(lls.back()->timeType()==RDLogLine::Hard)&&
(last_line==-1)&&
(lls.back()->startTime(RDLogLine::Imported)==last_time)) {
last_line=i;
}
}
if((!first_time.isNull())&&(first_line==-1)) {
*err_msg+=tr("first-time event not found");
}
if((!last_time.isNull())&&(last_line==-1)) {
if(!err_msg->isEmpty()) {
*err_msg+=", ";
}
*err_msg+=tr("last-time event not found");
}
if(!err_msg->isEmpty()) {
return false;
}
lls.push_back(new __RDRenderLogLine(new RDLogLine(),s->channels()));
lls.back()->setTransType(RDLogLine::Play);
if((!first_time.isNull())&&(first_line==-1)) {
first_line=log->size();
}
//
// Iterate through it
//
for(unsigned i=0;i<lls.size();i++) {
if(render_abort) {
emit lineStarted(log->size()+render_total_passes-1,
log->size()+render_total_passes-1);
*err_msg+="Render aborted.\n";
sf_close(sf_out);
return false;
}
emit lineStarted(i,log->size()+render_total_passes-1);
if(((first_line==-1)||(first_line<=(int)i))&&
((last_line==-1)||(last_line>=(int)i))) {
if(lls.at(i)->transType()==RDLogLine::Stop) {
ProgressMessage(current_time,i,tr("STOP")+" ",lls.at(i)->summary());
render_warnings.
push_back(tr("log render halted at line")+QString().sprintf(" %d ",i)+
tr("due to STOP"));
break;
}
if(lls.at(i)->open(current_time)) {
ProgressMessage(current_time,i,
RDLogLine::transText(lls.at(i)->transType()),
QString().sprintf(" cart %06u [",lls.at(i)->cartNumber())+
lls.at(i)->title()+"]");
sf_count_t frames=0;
if((lls.at(i+1)->transType()==RDLogLine::Segue)&&
(lls.at(i)->segueStartPoint()>=0)) {
if(lls.at(i)->segueStartPoint()>lls.at(i)->startPoint()) {
frames=FramesFromMsec(lls.at(i)->segueStartPoint()-
lls.at(i)->startPoint());
current_time=
current_time.addMSecs(lls.at(i)->segueStartPoint()-
lls.at(i)->startPoint());
}
else {
frames=0;
}
}
else {
if(lls.at(i)->endPoint()>lls.at(i)->startPoint()) {
frames=FramesFromMsec(lls.at(i)->endPoint()-
lls.at(i)->startPoint());
current_time=current_time.addMSecs(lls.at(i)->endPoint()-
lls.at(i)->startPoint());
}
else {
frames=0;
}
}
pcm=new float[frames*s->channels()];
memset(pcm,0,frames*s->channels()*sizeof(float));
for(unsigned j=0;j<i;j++) {
Sum(pcm,lls.at(j),frames,s->channels());
}
Sum(pcm,lls.at(i),frames,s->channels());
sf_writef_float(sf_out,pcm,frames);
delete pcm;
pcm=NULL;
lls.at(i)->setRamp(lls.at(i+1)->transType(),lls.at(i)->segueGain());
}
else {
if(i<(lls.size()-1)) {
if(lls.at(i)->type()==RDLogLine::Cart) {
ProgressMessage(current_time,i,tr("FAIL"),lls.at(i)->summary()+
" ("+tr("NO AUDIO AVAILABLE")+")");
render_warnings.
push_back(lls.at(i)->summary()+tr("at line")+
QString().sprintf(" %d ",i)+
tr("failed to play (NO AUDIO AVAILABLE)"));
}
else {
ProgressMessage(current_time,i,tr("SKIP"),lls.at(i)->summary());
}
}
else {
ProgressMessage(current_time,lls.size()-1,
tr("STOP"),tr("--- end of log ---"));
}
}
}
}
sf_close(sf_out);
return true;
}
bool RDRenderer::Render(const QString &outfile,RDLogModel *model,RDSettings *s,
const QTime &start_time,bool ignore_stops,
QString *err_msg,int first_line,int last_line,

View File

@ -2,7 +2,7 @@
//
// Render a Rivendell log to a single audio object.
//
// (C) Copyright 2017-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2017-2020 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
@ -28,7 +28,6 @@
#include <qobject.h>
#include <qstringlist.h>
#include <rdlog_event.h>
#include <rdlogmodel.h>
#include <rdsettings.h>
@ -71,21 +70,11 @@ class RDRenderer : public QObject
public:
RDRenderer(QObject *parent=0);
~RDRenderer();
bool renderToFile(const QString &outfile,RDLogEvent *log,RDSettings *s,
const QTime &start_time,bool ignore_stops,
QString *err_msg,int first_line,int last_line,
const QTime &first_time=QTime(),
const QTime &last_time=QTime());
bool renderToFile(const QString &outfile,RDLogModel *model,RDSettings *s,
const QTime &start_time,bool ignore_stops,
QString *err_msg,int first_line,int last_line,
const QTime &first_time=QTime(),
const QTime &last_time=QTime());
bool renderToCart(unsigned cartnum,int cutnum,RDLogEvent *log,RDSettings *s,
const QTime &start_time,bool ignore_stops,
QString *err_msg,int first_line,int last_line,
const QTime &first_time=QTime(),
const QTime &last_time=QTime());
bool renderToCart(unsigned cartnum,int cutnum,RDLogModel *model,RDSettings *s,
const QTime &start_time,bool ignore_stops,
QString *err_msg,int first_line,int last_line,
@ -101,10 +90,6 @@ class RDRenderer : public QObject
void lineStarted(int linno,int totallines);
private:
bool Render(const QString &outfile,RDLogEvent *log,RDSettings *s,
const QTime &start_time,bool ignore_stops,
QString *err_msg,int first_line,int last_line,
const QTime &first_time,const QTime &last_time);
bool Render(const QString &outfile,RDLogModel *model,RDSettings *s,
const QTime &start_time,bool ignore_stops,
QString *err_msg,int first_line,int last_line,

View File

@ -33,7 +33,6 @@
#include <rdairplay_conf.h>
#include <rdcartdrag.h>
#include <rdlog_line.h>
#include <rdlog_event.h>
#include <rdplaymeter.h>
#include <rdplay_deck.h>
#include <rdslotoptions.h>

View File

@ -28,6 +28,7 @@
#include "rd.h"
#include "rdescape_string.h"
#include "rdlog.h"
#include "rdlogmodel.h"
#include "rdsvc.h"
#include "rdweb.h"
@ -922,8 +923,8 @@ bool RDSvc::linkLog(RDSvc::ImportSource src,const QDate &date,
RDSqlQuery *q;
QString autofill_errors;
QTime prev_start_time;
RDLogEvent *src_event=NULL;
RDLogEvent *dest_event=NULL;
RDLogModel *src_model=NULL;
RDLogModel *dst_model=NULL;
RDLogLine *logline=NULL;
*err_msg="";
@ -989,27 +990,27 @@ bool RDSvc::linkLog(RDSvc::ImportSource src,const QDate &date,
//
// Iterate Through the Log
//
src_event=new RDLogEvent(logname);
dest_event=new RDLogEvent(logname);
src_event->load();
for(int i=0;i<src_event->size();i++) {
logline=src_event->logLine(i);
src_model=new RDLogModel(logname,true,this);
dst_model=new RDLogModel(logname,true,this);
src_model->load();
for(int i=0;i<src_model->lineCount();i++) {
logline=src_model->logLine(i);
if(logline->type()==src_type) {
RDEventLine *e=new RDEventLine(svc_station);
e->setName(logline->linkEventName());
e->load();
e->linkLog(dest_event,log,svc_name,logline,track_str,label_cart,
e->linkLog(dst_model,log,svc_name,logline,track_str,label_cart,
track_cart,&autofill_errors);
delete e;
emit generationProgress(1+(24*current_link++)/total_links);
}
else {
dest_event->insert(dest_event->size(),1,true);
*(dest_event->logLine(dest_event->size()-1))=*logline;
dest_event->logLine(dest_event->size()-1)->setId(dest_event->nextId());
dst_model->insert(dst_model->lineCount(),1,true);
*(dst_model->logLine(dst_model->lineCount()-1))=*logline;
dst_model->logLine(dst_model->lineCount()-1)->setId(dst_model->nextId());
}
}
dest_event->save(svc_config);
dst_model->save(svc_config);
//
// Update the Log Link Status
@ -1029,7 +1030,7 @@ bool RDSvc::linkLog(RDSvc::ImportSource src,const QDate &date,
//
QString cartname;
QString missing_report;
dest_event->validate(&missing_report,date);
dst_model->validate(&missing_report,date);
bool event=false;
QString link_report=tr("The following events were not placed:\n");
sql=QString("select ")+
@ -1108,8 +1109,8 @@ bool RDSvc::linkLog(RDSvc::ImportSource src,const QDate &date,
// Clean Up
//
emit generationProgress(24);
delete src_event;
delete dest_event;
delete src_model;
delete dst_model;
sql=QString("delete from IMPORTER_LINES where ")+
"STATION_NAME=\""+RDEscapeString(svc_station->name())+"\" && "+
@ -1142,21 +1143,21 @@ bool RDSvc::clearLogLinks(RDSvc::ImportSource src,const QString &logname,
break;
}
RDLogEvent *src_event=new RDLogEvent(logname);
RDLogEvent *dest_event=new RDLogEvent(logname);
src_event->load();
RDLogModel *src_model=new RDLogModel(logname,false,this);
RDLogModel *dst_model=new RDLogModel(logname,false,this);
src_model->load();
RDLogLine *logline=NULL;
for(int i=0;i<src_event->size();i++) {
logline=src_event->logLine(i);
for(int i=0;i<src_model->lineCount();i++) {
logline=src_model->logLine(i);
if((logline->linkId()<0)||(logline->source()!=event_source)) {
dest_event->insert(dest_event->size(),1,true);
*(dest_event->logLine(dest_event->size()-1))=*logline;
dest_event->logLine(dest_event->size()-1)->setId(dest_event->nextId());
dst_model->insert(dst_model->lineCount(),1,true);
*(dst_model->logLine(dst_model->lineCount()-1))=*logline;
dst_model->logLine(dst_model->lineCount()-1)->setId(dst_model->nextId());
}
}
dest_event->save(svc_config);
delete src_event;
delete dest_event;
dst_model->save(svc_config);
delete src_model;
delete dst_model;
RDLog *log=new RDLog(logname);
if(src==RDSvc::Traffic) {
@ -1793,9 +1794,8 @@ QString RDSvc::MakeErrorLine(int indent,unsigned lineno,const QString &msg)
bool RDSvc::ResolveInlineEvents(const QString &logname,QString *err_msg)
const
{
RDLogEvent *evt=NULL;
RDLogModel *model=NULL;
RDLogLine *logline=NULL;
QTime start;
QTime end;
@ -1805,11 +1805,11 @@ bool RDSvc::ResolveInlineEvents(const QString &logname,QString *err_msg)
switch(subEventInheritance()) {
case RDSvc::ParentEvent:
evt=new RDLogEvent(logname);
evt->load();
model=new RDLogModel(logname,false,this);
model->load();
ok=true;
for(int i=0;i<evt->size();i++) {
logline=evt->logLine(i);
for(int i=0;i<model->lineCount();i++) {
logline=model->logLine(i);
if(logline->type()==RDLogLine::MusicLink) {
start=logline->linkStartTime();
end=logline->linkStartTime().addSecs(logline->linkLength());
@ -1847,8 +1847,8 @@ bool RDSvc::ResolveInlineEvents(const QString &logname,QString *err_msg)
delete q;
}
}
delete evt;
evt=NULL;
delete model;
model=NULL;
if(!ok) {
return false;

View File

@ -2,7 +2,7 @@
//
// Abstract a Rivendell Service
//
// (C) Copyright 2002-2004,2016-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2020 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
@ -121,7 +121,7 @@ class RDSvc : public QObject
QString *label_cart,QString *track_cart);
bool CheckId(std::vector<int> *v,int value);
QString MakeErrorLine(int indent,unsigned lineno,const QString &msg) const;
bool ResolveInlineEvents(const QString &logname,QString *err_msg) const;
bool ResolveInlineEvents(const QString &logname,QString *err_msg);
QString svc_name;
RDStation *svc_station;
RDConfig *svc_config;

View File

@ -299,7 +299,7 @@ void ButtonLog::startButton(int id)
int line=log_line_box[id]->line();
RDLogLine *logline=log_log->logLine(line);
if(line<0) {
line=log_log->size();
line=log_log->lineCount();
}
switch(log_start_button[id]->mode()) {
case StartButton::Stop:
@ -345,7 +345,7 @@ void ButtonLog::pauseButtonHotkey(int id)
{
int line=log_line_box[id]->line();
if (line<0) {
line=log_log->size();
line=log_log->lineCount();
}
if (log_start_button[id]->mode() == StartButton::Play) {
log_log->pause(line);
@ -356,7 +356,7 @@ void ButtonLog::stopButtonHotkey(int id)
{
int line=log_line_box[id]->line();
if (line<0) {
line=log_log->size();
line=log_log->lineCount();
}
log_log->stop(line);
}

View File

@ -904,10 +904,10 @@ void ListLog::logInsertedData(int line)
{
bool appended=false;
if(line>=list_log->size()) {
line=list_log->size()-1;
if(line>=list_log->lineCount()) {
line=list_log->lineCount()-1;
}
if(line>=list_log->size()-1) {
if(line>=list_log->lineCount()-1) {
appended=true;
}
int count;
@ -1008,7 +1008,7 @@ void ListLog::selectionChangedData()
}
if(item->text(15).toInt()>=0) {
list_endtime_edit->setText(RDGetTimeLength(list_log->
length(item->text(15).toInt(),list_log->size()),true,false));
length(item->text(15).toInt(),list_log->lineCount()),true,false));
list_stoptime_label->setText(tr("Next Stop:"));
int stoplen=list_log->lengthToStop(item->text(15).toInt());
if(stoplen>=0) {
@ -1071,8 +1071,8 @@ void ListLog::RefreshList()
l=new RDListViewItem(list_log_list);
l->setText(5,tr("--- end of log ---"));
l->setText(15,QString().sprintf("%d",END_MARKER_ID));
l->setText(14,QString().sprintf("%d",list_log->size()));
for(int i=list_log->size()-1;i>=0;i--) {
l->setText(14,QString().sprintf("%d",list_log->lineCount()));
for(int i=list_log->lineCount()-1;i>=0;i--) {
if((logline=list_log->logLine(i))!=NULL) {
l=new RDListViewItem(list_log_list);
logline->setListViewItem(l);
@ -1460,7 +1460,7 @@ void ListLog::UpdateColor(int line,bool next)
void ListLog::SetColor()
{
for(int i=0;i<list_log->size();i++) {
for(int i=0;i<list_log->lineCount();i++) {
UpdateColor(i);
}
}

View File

@ -132,7 +132,7 @@ void MainWidget::RunLocalMacros(RDMacro *rml)
air_log[rml->arg(0).toInt()-1]->load();
}
if(rml->argQuantity()==3) { // Start Log
if(rml->arg(2).toInt()<air_log[rml->arg(0).toInt()-1]->size()) {
if(rml->arg(2).toInt()<air_log[rml->arg(0).toInt()-1]->lineCount()) {
if(rml->arg(2).toInt()>=0) { // Unconditional start
air_log[rml->arg(0).toInt()-1]->play(rml->arg(2).toInt(),
RDLogLine::StartMacro);
@ -140,11 +140,11 @@ void MainWidget::RunLocalMacros(RDMacro *rml)
if(rml->arg(2).toInt()==-2) { // Start if trans type allows
// Find first non-running event
bool found=false;
for(int i=0;i<air_log[rml->arg(0).toInt()-1]->size();i++) {
for(int i=0;i<air_log[rml->arg(0).toInt()-1]->lineCount();i++) {
if((logline=air_log[rml->arg(0).toInt()-1]->logLine(i))!=NULL) {
if(logline->status()==RDLogLine::Scheduled) {
found=true;
i=air_log[rml->arg(0).toInt()-1]->size();
i=air_log[rml->arg(0).toInt()-1]->lineCount();
}
}
}
@ -212,7 +212,7 @@ void MainWidget::RunLocalMacros(RDMacro *rml)
return;
}
if((rml->arg(1).toInt()<0)||
(rml->arg(1).toInt()>=air_log[rml->arg(0).toInt()-1]->size())) {
(rml->arg(1).toInt()>=air_log[rml->arg(0).toInt()-1]->lineCount())) {
if(rml->echoRequested()) {
rml->acknowledge(false);
rda->ripc()->sendRml(rml);
@ -339,7 +339,7 @@ void MainWidget::RunLocalMacros(RDMacro *rml)
return;
}
if((rml->arg(1).toInt()<0)||
(rml->arg(1).toInt()>=air_log[rml->arg(0).toInt()-1]->size())) {
(rml->arg(1).toInt()>=air_log[rml->arg(0).toInt()-1]->lineCount())) {
if(rml->echoRequested()) {
rml->acknowledge(false);
rda->ripc()->sendRml(rml);
@ -842,10 +842,10 @@ void MainWidget::RunLocalMacros(RDMacro *rml)
}
else {
air_log[mach-1]->
insert(air_log[mach-1]->size(),
insert(air_log[mach-1]->lineCount(),
rml->arg(1).toUInt(),RDLogLine::NoTrans,trans);
air_log[mach-1]->
makeNext(air_log[mach-1]->size()-1);
makeNext(air_log[mach-1]->lineCount()-1);
}
if(rml->echoRequested()) {
rml->acknowledge(true);

View File

@ -28,7 +28,6 @@
#include <rdairplay_conf.h>
#include <rdcartdrag.h>
#include <rdlog_line.h>
#include <rdlog_event.h>
#include <rdwidget.h>
//

View File

@ -1268,7 +1268,7 @@ void MainWidget::logReloadedData(int log)
rml.setAddress(addr);
rml.setEchoRequested(false);
if(air_start_line[log]<air_log[log]->size()) {
if(air_start_line[log]<air_log[log]->lineCount()) {
rml.setCommand(RDMacro::MN); // Make Next
rml.addArg(log+1);
rml.addArg(air_start_line[log]);
@ -1443,11 +1443,11 @@ void MainWidget::selectClickedData(int id,int line,RDLogLine::Status status)
case StartButton::AddTo:
if(line<0) {
air_log[id]->
insert(air_log[id]->size(),air_add_cart,RDLogLine::Play,
insert(air_log[id]->lineCount(),air_add_cart,RDLogLine::Play,
rda->airplayConf()->defaultTransType());
air_log[id]->logLine(air_log[id]->size()-1)->
air_log[id]->logLine(air_log[id]->lineCount()-1)->
setTransType(rda->airplayConf()->defaultTransType());
air_log_list[id]->refresh(air_log[id]->size()-1);
air_log_list[id]->refresh(air_log[id]->lineCount()-1);
}
else {
air_log[id]->
@ -1483,8 +1483,8 @@ void MainWidget::selectClickedData(int id,int line,RDLogLine::Status status)
case StartButton::MoveTo:
if(air_source_id==id) {
if(line<0) {
air_log[id]->move(air_copy_line,air_log[id]->size());
air_log_list[id]->refresh(air_log[id]->size()-1);
air_log[id]->move(air_copy_line,air_log[id]->lineCount());
air_log_list[id]->refresh(air_log[id]->lineCount()-1);
}
else {
if(line>air_copy_line) {
@ -1498,8 +1498,8 @@ void MainWidget::selectClickedData(int id,int line,RDLogLine::Status status)
air_log[air_source_id]->remove(air_copy_line,1);
if(line<0) {
air_log[id]->
insert(air_log[id]->size(),air_add_cart,RDLogLine::Play);
air_log_list[id]->refresh(air_log[id]->size()-1);
insert(air_log[id]->lineCount(),air_add_cart,RDLogLine::Play);
air_log_list[id]->refresh(air_log[id]->lineCount()-1);
}
else {
air_log[id]->
@ -1525,7 +1525,7 @@ void MainWidget::selectClickedData(int id,int line,RDLogLine::Status status)
case StartButton::CopyTo:
if(air_source_id==id) {
if(line<0) {
air_log[id]->copy(air_copy_line,air_log[id]->size(),
air_log[id]->copy(air_copy_line,air_log[id]->lineCount(),
rda->airplayConf()->defaultTransType());
}
else {
@ -1535,12 +1535,12 @@ void MainWidget::selectClickedData(int id,int line,RDLogLine::Status status)
}
else {
if(line<0) {
air_log[id]->insert(air_log[id]->size(),air_add_cart,
air_log[id]->insert(air_log[id]->lineCount(),air_add_cart,
rda->airplayConf()->defaultTransType(),
rda->airplayConf()->defaultTransType());
air_log[id]->logLine(air_log[id]->size()-1)->
air_log[id]->logLine(air_log[id]->lineCount()-1)->
setTransType(rda->airplayConf()->defaultTransType());
air_log_list[id]->refresh(air_log[id]->size()-1);
air_log_list[id]->refresh(air_log[id]->lineCount()-1);
}
else {
air_log[id]->
@ -1608,11 +1608,11 @@ void MainWidget::cartDroppedData(int id,int line,RDLogLine *ll)
else {
if(line<0) {
air_log[id]->
insert(air_log[id]->size(),ll->cartNumber(),RDLogLine::Play,
insert(air_log[id]->lineCount(),ll->cartNumber(),RDLogLine::Play,
rda->airplayConf()->defaultTransType());
air_log[id]->logLine(air_log[id]->size()-1)->
air_log[id]->logLine(air_log[id]->lineCount()-1)->
setTransType(rda->airplayConf()->defaultTransType());
air_log_list[id]->refresh(air_log[id]->size()-1);
air_log_list[id]->refresh(air_log[id]->lineCount()-1);
}
else {
air_log[id]->

View File

@ -26,8 +26,7 @@
#include <qpixmap.h>
#include <q3popupmenu.h>
#include <rdlistview.h>
#include <rdlog_event.h>
#include <rdlistviewitem.h>
class ClockListView : public RDListView
{

View File

@ -27,7 +27,6 @@
#include <rdapplication.h>
#include <rddatedecode.h>
#include <rdlog.h>
#include <rdlog_event.h>
#include <rdreport.h>
#include <rdsvc.h>

View File

@ -339,9 +339,9 @@ void GenerateLog::createData()
//
// Generate Exception Report
//
RDLogEvent *event=new RDLogEvent(logname);
event->load();
if((event->validate(&report,gen_date_edit->date())==0)&&
RDLogModel *model=new RDLogModel(logname,false,this);
model->load();
if((model->validate(&report,gen_date_edit->date())==0)&&
unused_report.isEmpty()) {
QMessageBox::information(this,tr("No Errors"),\
tr("No broken rules or validation exceptions found."));
@ -357,7 +357,7 @@ void GenerateLog::createData()
RDTextFile(report+"\n"+unused_report);
}
delete event;
delete model;
UpdateControls();
}

View File

@ -109,13 +109,13 @@ void LogObject::userData()
//
// Generate Exception Report
//
RDLogEvent *event=new RDLogEvent(logname);
event->load();
if((event->validate(&report,start_date)!=0)||
RDLogModel *model=new RDLogModel(logname,false,this);
model->load();
if((model->validate(&report,start_date)!=0)||
(!unused_report.isEmpty())) {
printf("%s\n\n%s",(const char*)report,(const char*)unused_report);
}
delete event;
delete model;
}
//

View File

@ -79,7 +79,7 @@ void MainObject::rmlReceivedData(RDMacro *rml)
rml->arg(0).toInt());
}
if(rml->argQuantity()==3) { // Start Log
if(rml->arg(2).toInt()<air_logs[index]->size()) {
if(rml->arg(2).toInt()<air_logs[index]->lineCount()) {
if(rml->arg(2).toInt()>=0) { // Unconditional start
if(air_logs[index]->play(rml->arg(2).toInt(),RDLogLine::StartMacro)) {
rda->syslog(LOG_INFO,"started log machine %d at line %d",
@ -98,11 +98,11 @@ void MainObject::rmlReceivedData(RDMacro *rml)
if(rml->arg(2).toInt()==-2) { // Start if trans type allows
// Find first non-running event
bool found=false;
for(int i=0;i<air_logs[index]->size();i++) {
for(int i=0;i<air_logs[index]->lineCount();i++) {
if((logline=air_logs[index]->logLine(i))!=NULL) {
if(logline->status()==RDLogLine::Scheduled) {
found=true;
i=air_logs[index]->size();
i=air_logs[index]->lineCount();
}
}
}
@ -183,7 +183,7 @@ void MainObject::rmlReceivedData(RDMacro *rml)
return;
}
if((rml->arg(1).toInt()<0)||
(rml->arg(1).toInt()>=air_logs[index]->size())) {
(rml->arg(1).toInt()>=air_logs[index]->lineCount())) {
if(rml->echoRequested()) {
rml->acknowledge(false);
rda->ripc()->sendRml(rml);
@ -215,7 +215,7 @@ void MainObject::rmlReceivedData(RDMacro *rml)
return;
}
if((rml->arg(1).toInt()<0)||
(rml->arg(1).toInt()>=air_logs[index]->size())) {
(rml->arg(1).toInt()>=air_logs[index]->lineCount())) {
if(rml->echoRequested()) {
rml->acknowledge(false);
rda->ripc()->sendRml(rml);
@ -493,11 +493,11 @@ void MainObject::rmlReceivedData(RDMacro *rml)
rml->arg(1).toUInt(),next_line,rml->arg(0).toInt());
}
else {
air_logs[index]->insert(air_logs[index]->size(),
air_logs[index]->insert(air_logs[index]->lineCount(),
rml->arg(1).toUInt(),RDLogLine::Play);
air_logs[index]->makeNext(air_logs[index]->size()-1);
air_logs[index]->makeNext(air_logs[index]->lineCount()-1);
rda->syslog(LOG_INFO,"inserted cart %06u at line %d on log machine %d",
rml->arg(1).toUInt(),air_logs[index]->size()-1,
rml->arg(1).toUInt(),air_logs[index]->lineCount()-1,
rml->arg(0).toInt());
}
if(rml->echoRequested()) {

View File

@ -276,7 +276,7 @@ void MainObject::logReloadedData(int log)
rml.setAddress(addr);
rml.setEchoRequested(false);
if(air_start_lines[log]<air_logs[log]->size()) {
if(air_start_lines[log]<air_logs[log]->lineCount()) {
rml.setCommand(RDMacro::MN); // Make Next
rml.addArg(mach+1);
rml.addArg(air_start_lines[log]);

View File

@ -2,7 +2,7 @@
//
// A command-line log editor for Rivendell
//
// (C) Copyright 2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2016-2020 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
@ -27,62 +27,62 @@
void MainObject::Addcart(int line,unsigned cartnum)
{
if(line>edit_log_event->size()) {
line=edit_log_event->size();
if(line>edit_log_model->lineCount()) {
line=edit_log_model->lineCount();
}
edit_log_event->insert(line,1);
edit_log_event->logLine(line)->
edit_log_model->insert(line,1);
edit_log_model->logLine(line)->
setTransType(rda->airplayConf()->defaultTransType());
edit_log_event->logLine(line)->setFadeupGain(-3000);
edit_log_event->logLine(line)->setFadedownGain(-3000);
edit_log_event->logLine(line)->setCartNumber(cartnum);
edit_log_event->refresh(line);
edit_log_model->logLine(line)->setFadeupGain(-3000);
edit_log_model->logLine(line)->setFadedownGain(-3000);
edit_log_model->logLine(line)->setCartNumber(cartnum);
edit_log_model->refresh(line);
edit_modified=true;
}
void MainObject::Addchain(int line,const QString &logname)
{
if(line>edit_log_event->size()) {
line=edit_log_event->size();
if(line>edit_log_model->lineCount()) {
line=edit_log_model->lineCount();
}
edit_log_event->insert(line,1);
edit_log_event->logLine(line)->setType(RDLogLine::Chain);
edit_log_event->logLine(line)->
edit_log_model->insert(line,1);
edit_log_model->logLine(line)->setType(RDLogLine::Chain);
edit_log_model->logLine(line)->
setTransType(rda->airplayConf()->defaultTransType());
edit_log_event->logLine(line)->setMarkerLabel(logname);
edit_log_event->refresh(line);
edit_log_model->logLine(line)->setMarkerLabel(logname);
edit_log_model->refresh(line);
edit_modified=true;
}
void MainObject::Addmarker(int line)
{
if(line>edit_log_event->size()) {
line=edit_log_event->size();
if(line>edit_log_model->lineCount()) {
line=edit_log_model->lineCount();
}
edit_log_event->insert(line,1);
edit_log_event->logLine(line)->setType(RDLogLine::Marker);
edit_log_event->logLine(line)->
edit_log_model->insert(line,1);
edit_log_model->logLine(line)->setType(RDLogLine::Marker);
edit_log_model->logLine(line)->
setTransType(rda->airplayConf()->defaultTransType());
edit_log_event->logLine(line)->setMarkerLabel(tr("Label"));
edit_log_event->logLine(line)->setMarkerComment(tr("Marker Comment"));
edit_log_event->refresh(line);
edit_log_model->logLine(line)->setMarkerLabel(tr("Label"));
edit_log_model->logLine(line)->setMarkerComment(tr("Marker Comment"));
edit_log_model->refresh(line);
edit_modified=true;
}
void MainObject::Addtrack(int line)
{
if(line>edit_log_event->size()) {
line=edit_log_event->size();
if(line>edit_log_model->lineCount()) {
line=edit_log_model->lineCount();
}
edit_log_event->insert(line,1);
edit_log_event->logLine(line)->setType(RDLogLine::Track);
edit_log_event->logLine(line)->
edit_log_model->insert(line,1);
edit_log_model->logLine(line)->setType(RDLogLine::Track);
edit_log_model->logLine(line)->
setTransType(rda->airplayConf()->defaultTransType());
edit_log_event->logLine(line)->setMarkerComment(tr("Voice Track"));
edit_log_event->refresh(line);
edit_log_model->logLine(line)->setMarkerComment(tr("Voice Track"));
edit_log_model->refresh(line);
edit_modified=true;
}
@ -171,10 +171,10 @@ void MainObject::Header() const
void MainObject::List()
{
for(int i=0;i<edit_log_event->size();i++) {
printf("%4d %s\n",i,(const char *)ListLine(edit_log_event,i));
for(int i=0;i<edit_log_model->lineCount();i++) {
printf("%4d %s\n",i,(const char *)ListLine(edit_log_model,i));
}
printf("%4d --- end of log ---\n",edit_log_event->size());
printf("%4d --- end of log ---\n",edit_log_model->lineCount());
}
@ -215,9 +215,9 @@ void MainObject::Load(QString logname)
delete edit_log;
edit_log=NULL;
}
if(edit_log_event!=NULL) {
delete edit_log_event;
edit_log_event=NULL;
if(edit_log_model!=NULL) {
delete edit_log_model;
edit_log_model=NULL;
}
if(edit_log_lock!=NULL) {
delete edit_log_lock;
@ -250,8 +250,8 @@ void MainObject::Load(QString logname)
edit_log=new RDLog(logname);
if(edit_log->exists()) {
edit_log_event=new RDLogEvent(logname);
edit_log_event->load();
edit_log_model=new RDLogModel(logname,false,this);
edit_log_model->load();
edit_description=edit_log->description();
edit_service=edit_log->service();
edit_start_date=edit_log->startDate();
@ -268,10 +268,10 @@ void MainObject::Load(QString logname)
}
QString MainObject::ListLine(RDLogEvent *evt,int line) const
QString MainObject::ListLine(RDLogModel *model,int line) const
{
QString ret="";
RDLogLine *logline=evt->logLine(line);
RDLogLine *logline=model->logLine(line);
switch(logline->timeType()) {
case RDLogLine::Hard:
@ -282,7 +282,7 @@ QString MainObject::ListLine(RDLogEvent *evt,int line) const
case RDLogLine::Relative:
ret+=QString().
sprintf(" %s ",(const char *)evt->blockStartTime(line).
sprintf(" %s ",(const char *)model->blockStartTime(line).
toString("hh:mm:ss"));
break;
@ -354,15 +354,15 @@ void MainObject::New(const QString &logname)
if(edit_log!=NULL) {
delete edit_log;
}
if(edit_log_event!=NULL) {
delete edit_log_event;
if(edit_log_model!=NULL) {
delete edit_log_model;
}
if(edit_log_lock!=NULL) {
delete edit_log_lock;
}
edit_log=new RDLog(logname);
if(!edit_log->exists()) {
edit_log_event=new RDLogEvent(logname);
edit_log_model=new RDLogModel(logname,false,this);
edit_description=logname+" log";
sql=QString("select NAME from SERVICES");
q=new RDSqlQuery(sql);
@ -391,14 +391,14 @@ void MainObject::New(const QString &logname)
void MainObject::Remove(int line)
{
edit_log_event->remove(line,1);
edit_log_model->remove(line,1);
edit_modified=true;
}
void MainObject::Save()
{
edit_log_event->save(rda->config());
edit_log_model->save(rda->config());
edit_log->setDescription(edit_description);
edit_log->setStartDate(edit_start_date);
edit_log->setEndDate(edit_end_date);
@ -434,8 +434,8 @@ void MainObject::Saveas(const QString &logname)
"SERVICE=\""+RDEscapeString(edit_service)+"\"";
q=new RDSqlQuery(sql);
delete q;
edit_log_event->setLogName(logname);
edit_log_event->save(rda->config());
edit_log_model->setLogName(logname);
edit_log_model->save(rda->config());
delete edit_log;
edit_log=log;
edit_modified=false;
@ -457,12 +457,12 @@ void MainObject::Setautorefresh(bool state)
void MainObject::Setcart(int line,unsigned cartnum)
{
RDLogLine *logline=edit_log_event->logLine(line);
RDLogLine *logline=edit_log_model->logLine(line);
if(logline!=NULL) {
if((logline->type()==RDLogLine::Cart)||
(logline->type()==RDLogLine::Macro)) {
logline->setCartNumber(cartnum);
edit_log_event->refresh(line);
edit_log_model->refresh(line);
edit_modified=true;
}
else {
@ -477,12 +477,12 @@ void MainObject::Setcart(int line,unsigned cartnum)
void MainObject::Setcomment(int line,const QString &str)
{
RDLogLine *logline=edit_log_event->logLine(line);
RDLogLine *logline=edit_log_model->logLine(line);
if(logline!=NULL) {
if((logline->type()==RDLogLine::Marker)||
(logline->type()==RDLogLine::Track)) {
logline->setMarkerComment(str);
edit_log_event->refresh(line);
edit_log_model->refresh(line);
edit_modified=true;
}
else {
@ -511,12 +511,12 @@ void MainObject::Setenddate(const QDate &date)
void MainObject::Setlabel(int line,const QString &str)
{
RDLogLine *logline=edit_log_event->logLine(line);
RDLogLine *logline=edit_log_model->logLine(line);
if(logline!=NULL) {
if((logline->type()==RDLogLine::Chain)||
(logline->type()==RDLogLine::Marker)) {
logline->setMarkerLabel(str);
edit_log_event->refresh(line);
edit_log_model->refresh(line);
edit_modified=true;
}
else {
@ -553,16 +553,16 @@ void MainObject::Setservice(const QString &str)
void MainObject::Settime(int line,RDLogLine::TimeType type,const QTime &time)
{
edit_log_event->logLine(line)->setTimeType(type);
edit_log_event->logLine(line)->setStartTime(RDLogLine::Logged,time);
edit_log_model->logLine(line)->setTimeType(type);
edit_log_model->logLine(line)->setStartTime(RDLogLine::Logged,time);
edit_modified=true;
}
void MainObject::Settrans(int line,RDLogLine::TransType type)
{
edit_log_event->logLine(line)->setTransType(type);
edit_log_event->refresh(line);
edit_log_model->logLine(line)->setTransType(type);
edit_log_model->refresh(line);
edit_modified=true;
}
@ -580,9 +580,9 @@ void MainObject::Unload()
delete edit_log;
edit_log=NULL;
}
if(edit_log_event!=NULL) {
delete edit_log_event;
edit_log_event=NULL;
if(edit_log_model!=NULL) {
delete edit_log_model;
edit_log_model=NULL;
}
if(edit_log_lock!=NULL) {
delete edit_log_lock;

View File

@ -2,7 +2,7 @@
//
// A command-line log editor for Rivendell
//
// (C) Copyright 2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2016-2020 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
@ -124,7 +124,7 @@ void MainObject::DispatchCommand(QString cmd)
//
// These need a log loaded
//
if((processed)||(edit_log_event!=NULL)) {
if((processed)||(edit_log_model!=NULL)) {
if(verb=="addcart") {
if(rda->user()->addtoLog()) {
if(cmds.size()==3) {
@ -229,7 +229,7 @@ void MainObject::DispatchCommand(QString cmd)
if(rda->user()->removefromLog()) {
if(cmds.size()==2) {
line=cmds[1].toInt(&ok);
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
if(ok&&(line>=0)&&(line<edit_log_model->lineCount())) {
Remove(line);
}
else {
@ -306,7 +306,7 @@ void MainObject::DispatchCommand(QString cmd)
if(rda->user()->arrangeLog()) {
if(cmds.size()==3) {
line=cmds[1].toInt(&ok);
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
if(ok&&(line>=0)&&(line<edit_log_model->lineCount())) {
unsigned cartnum=cmds[2].toUInt(&ok);
if(ok&&(cartnum<=RD_MAX_CART_NUMBER)) {
Setcart(line,cartnum);
@ -334,7 +334,7 @@ void MainObject::DispatchCommand(QString cmd)
if(rda->user()->arrangeLog()) {
if(cmds.size()>=3) {
line=cmds[1].toInt(&ok);
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
if(ok&&(line>=0)&&(line<edit_log_model->lineCount())) {
cmds.remove(cmds.begin());
cmds.remove(cmds.begin());
Setcomment(line,cmds.join(" "));
@ -402,7 +402,7 @@ void MainObject::DispatchCommand(QString cmd)
if(rda->user()->arrangeLog()) {
if(cmds.size()==3) {
line=cmds[1].toInt(&ok);
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
if(ok&&(line>=0)&&(line<edit_log_model->lineCount())) {
Setlabel(line,cmds[2]);
}
else {
@ -494,7 +494,7 @@ void MainObject::DispatchCommand(QString cmd)
if(rda->user()->arrangeLog()) {
if(cmds.size()>=3) {
line=cmds[1].toInt(&ok);
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
if(ok&&(line>=0)&&(line<edit_log_model->lineCount())) {
RDLogLine::TimeType ttype=RDLogLine::NoTime;
if(cmds[2].lower()=="hard") {
ttype=RDLogLine::Hard;
@ -546,7 +546,7 @@ void MainObject::DispatchCommand(QString cmd)
if(rda->user()->arrangeLog()) {
if(cmds.size()==3) {
line=cmds[1].toInt(&ok);
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
if(ok&&(line>=0)&&(line<edit_log_model->lineCount())) {
RDLogLine::TransType trans=RDLogLine::NoTrans;
if(cmds[2].lower()=="play") {
trans=RDLogLine::Play;

View File

@ -2,7 +2,7 @@
//
// A command-line log editor for Rivendell
//
// (C) Copyright 2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2016-2020 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
@ -43,7 +43,7 @@ MainObject::MainObject(QObject *parent)
edit_quiet_option=false;
edit_log=NULL;
edit_log_event=NULL;
edit_log_model=NULL;
edit_modified=false;
edit_log_lock=NULL;

View File

@ -2,7 +2,7 @@
//
// A Command-line log editor for Rivendell
//
// (C) Copyright 2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2016-2020 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
@ -26,7 +26,6 @@
#include <rdcut.h>
#include <rddb.h>
#include <rdlog.h>
#include <rdlog_event.h>
#include <rdloglock.h>
#include <rdnotification.h>
@ -72,14 +71,14 @@ class MainObject : public QObject
bool TryLock(RDLogLock *lock,const QString &logname);
void OverwriteError(const QString &cmd) const;
void DispatchCommand(QString cmd);
QString ListLine(RDLogEvent *evt,int line) const;
QString ListLine(RDLogModel *model,int line) const;
void PrintPrompt() const;
void SendNotification(RDNotification::Action action,const QString &logname);
bool edit_quiet_option;
QString edit_accum;
bool edit_modified;
RDLog *edit_log;
RDLogEvent *edit_log_event;
RDLogModel *edit_log_model;
QString edit_description;
QString edit_service;
QDate edit_start_date;

View File

@ -1,266 +0,0 @@
// mainloop.cpp
//
// Render a Rivendell log.
//
// (C) Copyright 2017 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
// 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 <errno.h>
#include <math.h>
#include <stdio.h>
#include <vector>
#include <rdcart.h>
#include <rdcut.h>
#include <rdconf.h>
#include <rdlog.h>
#include <rdlog_event.h>
#include <rdlog_line.h>
#include "rdrender.h"
int MainObject::MainLoop()
{
float *pcm=NULL;
QTime current_time=render_start_time;
QString warnings="";
//
// Open Log
//
RDLog *log=new RDLog(render_logname);
if(!log->exists()) {
fprintf(stderr,"rdrender: no such log\n");
return 1;
}
RDLogEvent *log_event=new RDLogEvent(RDLog::tableName(render_logname));
log_event->load();
//
// Open Output File
//
SF_INFO sf_info;
SNDFILE *sf_out;
FILE *f;
char tempdir[PATH_MAX];
memset(&sf_info,0,sizeof(sf_info));
sf_info.samplerate=render_system->sampleRate();
sf_info.channels=render_channels;
if(render_settings.format()==RDSettings::Pcm16) {
sf_info.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
}
else {
sf_info.format=SF_FORMAT_WAV|SF_FORMAT_PCM_24;
}
if(render_settings_modified||render_to_file.isEmpty()) {
//
// 2nd pass will be needed, so just create a placeholder for now
// and then output to a temp file
//
Verbose("Pass 1 of 2");
if(!render_to_file.isEmpty()) {
if((f=fopen(render_to_file,"w"))==NULL) {
fprintf(stderr,"rdrender: unable to open output file [%s]\n",
strerror(errno));
return 1;
}
fclose(f);
}
strncpy(tempdir,RDTempDir()+"/rdrenderXXXXXX",PATH_MAX);
render_temp_output_filename=QString(mkdtemp(tempdir))+"/log.wav";
sf_out=sf_open(render_temp_output_filename,SFM_WRITE,&sf_info);
if(sf_out==NULL) {
fprintf(stderr,"rdrender: unable to open temporary file \"%s\" [%s]\n",
(const char *)render_temp_output_filename,
sf_strerror(sf_out));
return 1;
}
Verbose("Using temporary file \""+render_temp_output_filename+"\".");
}
else {
Verbose("Pass 1 of 1");
sf_out=sf_open(render_to_file,SFM_WRITE,&sf_info);
if(sf_out==NULL) {
fprintf(stderr,"rdrender: unable to open output file [%s]\n",
sf_strerror(sf_out));
return 1;
}
}
//
// Initialize the log
//
std::vector<LogLine *> lls;
for(int i=0;i<log_event->size();i++) {
lls.push_back(new LogLine(log_event->logLine(i),render_user,render_station,
render_system,render_config,render_channels));
if(render_ignore_stops&&(lls.back()->transType()==RDLogLine::Stop)) {
lls.back()->setTransType(RDLogLine::Play);
}
if((!render_first_time.isNull())&&
(lls.back()->timeType()==RDLogLine::Hard)&&
(render_first_line==-1)&&
(lls.back()->startTime(RDLogLine::Imported)==render_first_time)) {
render_first_line=i;
}
if((!render_last_time.isNull())&&
(lls.back()->timeType()==RDLogLine::Hard)&&
(render_last_line==-1)&&
(lls.back()->startTime(RDLogLine::Imported)==render_last_time)) {
render_last_line=i;
}
}
QString time_errs="";
if((!render_first_time.isNull())&&(render_first_line==-1)) {
time_errs+="--first-time event not found";
}
if((!render_last_time.isNull())&&(render_last_line==-1)) {
if(!time_errs.isEmpty()) {
time_errs+=", ";
}
time_errs+="--last-time event not found";
}
if(!time_errs.isEmpty()) {
fprintf(stderr,"rdrender: %s\n",(const char *)time_errs);
return 1;
}
lls.push_back(new LogLine(new RDLogLine(),render_user,render_station,
render_system,render_config,render_channels));
lls.back()->setTransType(RDLogLine::Play);
if((!render_first_time.isNull())&&(render_first_line==-1)) {
render_first_line=log_event->size();
}
//
// Iterate through it
//
for(unsigned i=0;i<lls.size();i++) {
if(((render_first_line==-1)||(render_first_line<=(int)i))&&
((render_last_line==-1)||(render_last_line>(int)i))) {
if(lls.at(i)->transType()==RDLogLine::Stop) {
Verbose(current_time,i,"STOP ",lls.at(i)->summary());
warnings+=
QString().sprintf("log render halted at line %d due to STOP\n",i);
break;
}
if(lls.at(i)->open(current_time)) {
Verbose(current_time,i,RDLogLine::transText(lls.at(i)->transType()),
QString().sprintf(" cart %06u [",lls.at(i)->cartNumber())+
lls.at(i)->title()+"]");
sf_count_t frames=0;
if((lls.at(i+1)->transType()==RDLogLine::Segue)&&
(lls.at(i)->cut()->segueStartPoint()>=0)) {
frames=FramesFromMsec(lls.at(i)->cut()->segueStartPoint()-
lls.at(i)->cut()->startPoint());
current_time=current_time.addMSecs(lls.at(i)->cut()->segueStartPoint()-
lls.at(i)->cut()->startPoint());
}
else {
frames=FramesFromMsec(lls.at(i)->cut()->endPoint()-
lls.at(i)->cut()->startPoint());
current_time=current_time.addMSecs(lls.at(i)->cut()->endPoint()-
lls.at(i)->cut()->startPoint());
}
pcm=new float[frames*render_channels];
memset(pcm,0,frames*render_channels);
for(unsigned j=0;j<i;j++) {
Sum(pcm,lls.at(j),frames);
}
Sum(pcm,lls.at(i),frames);
sf_writef_float(sf_out,pcm,frames);
delete pcm;
pcm=NULL;
lls.at(i)->setRamp(lls.at(i+1)->transType());
}
else {
if(i<(lls.size()-1)) {
if(lls.at(i)->type()==RDLogLine::Cart) {
Verbose(current_time,i,"FAIL",lls.at(i)->summary()+
" (NO AUDIO AVAILABLE)");
warnings+=
lls.at(i)->summary()+QString().
sprintf("at line %d failed to play (NO AUDIO AVAILABLE)\n",i);
}
else {
Verbose(current_time,i,"SKIP",lls.at(i)->summary());
}
}
else {
Verbose(current_time,lls.size()-1,"STOP","--- end of log ---");
}
}
}
}
sf_close(sf_out);
//
// Process 2nd Pass
//
if(render_settings_modified||render_to_file.isEmpty()) {
QString err_msg;
bool ok=false;
Verbose("Pass 2 of 2");
if(!render_to_file.isEmpty()) {
Verbose("Writing output file");
ok=ConvertAudio(render_temp_output_filename,render_to_file,
&render_settings,&err_msg);
DeleteCutFile(render_temp_output_filename);
if(!ok) {
fprintf(stderr,"rdrender: unable to convert output [%s]\n",
(const char *)err_msg);
return 1;
}
}
else {
Verbose("Importing cart");
ok=ImportCart(render_temp_output_filename,render_cart_number,
render_cut_number,&err_msg);
DeleteCutFile(render_temp_output_filename);
if(!ok) {
fprintf(stderr,"rdrender: unable to import to cart [%s]\n",
(const char *)err_msg);
return 1;
}
}
}
fprintf(stderr,"%s",(const char *)warnings);
fflush(stderr);
return 0;
}
void MainObject::Sum(float *pcm_out,LogLine *ll,sf_count_t frames)
{
if(ll->handle()!=NULL) {
float *pcm=new float[frames*render_channels];
memset(pcm,0,frames*render_channels);
sf_count_t n=sf_readf_float(ll->handle(),pcm,frames);
for(sf_count_t i=0;i<n;i+=render_channels) {
double ratio=exp10(((double)i*ll->rampRate()+ll->rampLevel())/2000.0);
for(sf_count_t j=0;j<render_channels;j++) {
pcm_out[i*render_channels+j]+=ratio*pcm[i*render_channels+j];
}
}
ll->setRampLevel((double)n*ll->rampRate()+ll->rampLevel());
if(n<frames) {
ll->close();
}
delete pcm;
}
}

View File

@ -2,7 +2,7 @@
//
// Render a Rivendell log.
//
// (C) Copyright 2017-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2017-2020 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
@ -289,8 +289,8 @@ void MainObject::userData()
fprintf(stderr,"rdrender: no such log\n");
exit(1);
}
RDLogEvent *log_event=new RDLogEvent(render_logname);
log_event->load();
RDLogModel *log_model=new RDLogModel(render_logname,false,this);
log_model->load();
//
// Render It
@ -300,7 +300,7 @@ void MainObject::userData()
connect(r,SIGNAL(progressMessageSent(const QString &)),
this,SLOT(printProgressMessage(const QString &)));
if(render_to_file.isEmpty()) {
if(!r->renderToCart(render_cart_number,render_cut_number,log_event,
if(!r->renderToCart(render_cart_number,render_cut_number,log_model,
&render_settings,render_start_time,
render_ignore_stops,&err_msg,render_first_line,
render_last_line,render_first_time,render_last_time)) {
@ -309,7 +309,7 @@ void MainObject::userData()
}
}
else {
if(!r->renderToFile(render_to_file,log_event,&render_settings,
if(!r->renderToFile(render_to_file,log_model,&render_settings,
render_start_time,render_ignore_stops,
&err_msg,render_first_line,render_last_line,
render_first_time,render_last_time)) {

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- Log services
//
// (C) Copyright 2013-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2013-2020 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
@ -30,9 +30,9 @@
#include <rdescape_string.h>
#include <rdformpost.h>
#include <rdlog.h>
#include <rdlog_event.h>
#include <rdlog_line.h>
#include <rdloglock.h>
#include <rdlogmodel.h>
#include <rduser.h>
#include <rdweb.h>
@ -224,8 +224,8 @@ void Xport::ListLog()
//
// Generate Log Listing
//
RDLogEvent *log_event=log->createLogEvent();
log_event->load(true);
RDLogModel *log_model=log->createLogEvent();
log_model->load(true);
//
// Process Request
@ -233,7 +233,7 @@ void Xport::ListLog()
printf("Content-type: application/xml\n");
printf("Status: 200\n\n");
printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
printf("%s\n",(const char *)log_event->xml().utf8());
printf("%s\n",(const char *)log_model->xml().utf8());
Exit(0);
}
@ -291,10 +291,10 @@ void Xport::SaveLog()
//
// Logline Data
//
RDLogEvent *logevt=new RDLogEvent(log_name);
RDLogModel *logmodel=new RDLogModel(log_name,false,this);
for(int i=0;i<line_quantity;i++) {
logevt->insert(i,1);
RDLogLine *ll=logevt->logLine(i);
logmodel->insert(i,1);
RDLogLine *ll=logmodel->logLine(i);
QString line=QString().sprintf("LINE%d",i);
QString str;
int integer1;
@ -514,7 +514,7 @@ void Xport::SaveLog()
log->setStartDate(start_date);
log->setEndDate(end_date);
log->setModifiedDatetime(QDateTime::currentDateTime());
logevt->save(rda->config());
logmodel->save(rda->config());
SendNotification(RDNotification::LogType,RDNotification::ModifyAction,
QVariant(log->name()));
RDLogLock::clearLock(lock_guid);
@ -532,7 +532,7 @@ void Xport::SaveLog()
log->setStartDate(start_date);
log->setEndDate(end_date);
log->setModifiedDatetime(QDateTime::currentDateTime());
logevt->save(rda->config());
logmodel->save(rda->config());
SendNotification(RDNotification::LogType,RDNotification::ModifyAction,
QVariant(log->name()));
}
@ -540,7 +540,7 @@ void Xport::SaveLog()
XmlExit("invalid log lock",400);
}
}
XmlExit(QString().sprintf("OK Saved %d events",logevt->size()),
XmlExit(QString().sprintf("OK Saved %d events",logmodel->lineCount()),
200,"logs.cpp",LINE_NUMBER);
}