2016-07-20 Fred Gleason <fredg@paravelsystems.com>

* Added a 'settime' command to rdclilogedit(1) in
	'utils/rdclilogedit/rdclilogedit.cpp' and
	'utils/rdclilogedit/rdclilogedit.h'.
This commit is contained in:
Fred Gleason
2016-07-20 19:29:23 -04:00
parent 42d9286fd8
commit 27e674544c
4 changed files with 75 additions and 1 deletions

View File

@@ -28,7 +28,7 @@ void MainObject::Help(const QStringList &cmds) const
printf("\n");
printf("The following commands are available:\n");
printf("?, addcart, bye, exit, help, list, listlogs, load, quit, remove,\n");
printf("save, saveas, setcart, unload\n");
printf("save, saveas, setcart, settime, settrans, unload\n");
printf("\n");
printf("Enter \"? <cmd-name>\" for specific help.\n");
printf("\n");
@@ -108,6 +108,16 @@ void MainObject::Help(const QStringList &cmds) const
printf("\n");
processed=true;
}
if(verb=="settime") {
printf("\n");
printf(" settime <line> hard|none <time>\n");
printf("\n");
printf("Set the start time type and value of the event at line <line>.\n");
printf("The <time> parameter is in format \"HH:MM:SS\", and is optional when\n");
printf("when setting \"none\".\n");
printf("\n");
processed=true;
}
if(verb=="settrans") {
printf("\n");
printf(" settrans <line> play|segue|stop\n");

View File

@@ -32,6 +32,7 @@
#include <rdconf.h>
#include <rdcreate_log.h>
#include <rdescape_string.h>
#include <rdweb.h>
#include "rdclilogedit.h"
@@ -305,6 +306,17 @@ void MainObject::Setcart(int line,unsigned cartnum)
}
void MainObject::Settime(int line,RDLogLine::TimeType type,const QTime &time)
{
if(edit_log_event==NULL) {
fprintf(stderr,"settime: no log loaded\n");
return;
}
edit_log_event->logLine(line)->setTimeType(type);
edit_log_event->logLine(line)->setStartTime(RDLogLine::Logged,time);
}
void MainObject::Settrans(int line,RDLogLine::TransType type)
{
edit_log_event->logLine(line)->setTransType(type);
@@ -331,6 +343,7 @@ void MainObject::DispatchCommand(const QString &cmd)
QString verb=cmds[0].lower();
bool processed=false;
int line;
QTime time;
bool ok=false;
if(verb=="addcart") {
@@ -440,6 +453,52 @@ void MainObject::DispatchCommand(const QString &cmd)
processed=true;
}
if(verb=="settime") {
if(cmds.size()>=3) {
line=cmds[1].toInt(&ok);
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
RDLogLine::TimeType ttype=RDLogLine::NoTime;
if(cmds[2].lower()=="hard") {
ttype=RDLogLine::Hard;
}
if(cmds[2].lower()=="none") {
ttype=RDLogLine::Relative;
}
switch(ttype) {
case RDLogLine::Hard:
if(cmds.size()>=4) {
time=RDGetWebTime(cmds[3],&ok);
if(ok) {
Settime(line,ttype,time);
}
else {
fprintf(stderr,"settime: invalid time value\n");
}
}
else {
fprintf(stderr,"settime: missing time value\n");
}
break;
case RDLogLine::Relative:
Settime(line,ttype);
break;
case RDLogLine::NoTime:
fprintf(stderr,"settime: invalid time type\n");
break;
}
}
else {
fprintf(stderr,"settime: invalid line number\n");
}
}
else {
fprintf(stderr,"settime: invalid command arguments\n");
}
processed=true;
}
if(verb=="settrans") {
if(cmds.size()==3) {
line=cmds[1].toInt(&ok);

View File

@@ -55,6 +55,7 @@ class MainObject : public QObject
void Save();
void Saveas(const QString &logname);
void Setcart(int line,unsigned cartnum);
void Settime(int line,RDLogLine::TimeType type,const QTime &time=QTime());
void Settrans(int line,RDLogLine::TransType type);
void Unload();
void DispatchCommand(const QString &cmd);