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

* Added a 'setcomment' command to rdclilogedit(1).
	* Added a 'setlabel' command to rdclilogedit(1).
This commit is contained in:
Fred Gleason 2016-07-21 14:43:17 -04:00
parent e0f1b180d6
commit 933b318eb1
5 changed files with 107 additions and 1 deletions

View File

@ -15346,3 +15346,6 @@
* Added a 'addchain' command to rdclilogedit(1). * Added a 'addchain' command to rdclilogedit(1).
* Added a 'addmarker' command to rdclilogedit(1). * Added a 'addmarker' command to rdclilogedit(1).
* Added a 'addtrack' command to rdclilogedit(1). * Added a 'addtrack' command to rdclilogedit(1).
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
* Added a 'setcomment' command to rdclilogedit(1).
* Added a 'setlabel' command to rdclilogedit(1).

View File

@ -28,7 +28,8 @@ void MainObject::Help(const QStringList &cmds) const
printf("\n"); printf("\n");
printf("The following commands are available:\n"); printf("The following commands are available:\n");
printf("?, addcart, addchain, addmarker, addtrack, bye, exit, help, list, listlogs,\n"); printf("?, addcart, addchain, addmarker, addtrack, bye, exit, help, list, listlogs,\n");
printf("load, quit, remove, save, saveas, setcart, settime, settrans, unload\n"); printf("load, quit, remove, save, saveas, setcart, setcomment, setlabel, settime\n");
printf("settrans, unload\n");
printf("\n"); printf("\n");
printf("Enter \"? <cmd-name>\" for specific help.\n"); printf("Enter \"? <cmd-name>\" for specific help.\n");
printf("\n"); printf("\n");
@ -132,6 +133,22 @@ void MainObject::Help(const QStringList &cmds) const
printf("\n"); printf("\n");
processed=true; processed=true;
} }
if(verb=="setcomment") {
printf("\n");
printf(" setcomment <line> <str>\n");
printf("\n");
printf("Set the marker or track event's \"Comment\" field at line <line> to <str>.\n");
printf("\n");
processed=true;
}
if(verb=="setlabel") {
printf("\n");
printf(" setlabel <line> <str>\n");
printf("\n");
printf("Set the chain-to or marker event's \"Label\" field at line <line> to <str>.\n");
printf("\n");
processed=true;
}
if(verb=="settime") { if(verb=="settime") {
printf("\n"); printf("\n");
printf(" settime <line> hard|none <time>\n"); printf(" settime <line> hard|none <time>\n");

View File

@ -236,6 +236,56 @@ void MainObject::Setcart(int line,unsigned cartnum)
} }
void MainObject::Setcomment(int line,const QString &str)
{
if(edit_user->arrangeLog()) {
RDLogLine *logline=edit_log_event->logLine(line);
if(logline!=NULL) {
if((logline->type()==RDLogLine::Marker)||
(logline->type()==RDLogLine::Track)) {
logline->setMarkerComment(str);
edit_log_event->refresh(line);
edit_modified=true;
}
else {
fprintf(stderr,"setcomment: incompatible event type\n");
}
}
else {
fprintf(stderr,"setcomment: no such line\n");
}
}
else {
fprintf(stderr,"setcomment: insufficient privileges [Rearrange Log Items]\n");
}
}
void MainObject::Setlabel(int line,const QString &str)
{
if(edit_user->arrangeLog()) {
RDLogLine *logline=edit_log_event->logLine(line);
if(logline!=NULL) {
if((logline->type()==RDLogLine::Chain)||
(logline->type()==RDLogLine::Marker)) {
logline->setMarkerLabel(str);
edit_log_event->refresh(line);
edit_modified=true;
}
else {
fprintf(stderr,"setlabel: incompatible event type\n");
}
}
else {
fprintf(stderr,"setlabel: no such line\n");
}
}
else {
fprintf(stderr,"setlabel: insufficient privileges [Rearrange Log Items]\n");
}
}
void MainObject::Settime(int line,RDLogLine::TimeType type,const QTime &time) void MainObject::Settime(int line,RDLogLine::TimeType type,const QTime &time)
{ {
edit_log_event->logLine(line)->setTimeType(type); edit_log_event->logLine(line)->setTimeType(type);

View File

@ -339,6 +339,40 @@ void MainObject::DispatchCommand(QString cmd)
processed=true; processed=true;
} }
if(verb=="setcomment") {
if(cmds.size()>=3) {
line=cmds[1].toInt(&ok);
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
cmds.remove(cmds.begin());
cmds.remove(cmds.begin());
Setcomment(line,cmds.join(" "));
}
else {
fprintf(stderr,"setcomment: invalid line number\n");
}
}
else {
fprintf(stderr,"setcomment: invalid command arguments\n");
}
processed=true;
}
if(verb=="setlabel") {
if(cmds.size()==3) {
line=cmds[1].toInt(&ok);
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
Setlabel(line,cmds[2]);
}
else {
fprintf(stderr,"setlabel: invalid line number\n");
}
}
else {
fprintf(stderr,"setlabel: invalid command arguments\n");
}
processed=true;
}
if(verb=="settime") { if(verb=="settime") {
if(cmds.size()>=3) { if(cmds.size()>=3) {
line=cmds[1].toInt(&ok); line=cmds[1].toInt(&ok);

View File

@ -58,6 +58,8 @@ class MainObject : public QObject
void Save(); void Save();
void Saveas(const QString &logname); void Saveas(const QString &logname);
void Setcart(int line,unsigned cartnum); void Setcart(int line,unsigned cartnum);
void Setcomment(int line,const QString &str);
void Setlabel(int line,const QString &str);
void Settime(int line,RDLogLine::TimeType type,const QTime &time=QTime()); void Settime(int line,RDLogLine::TimeType type,const QTime &time=QTime());
void Settrans(int line,RDLogLine::TransType type); void Settrans(int line,RDLogLine::TransType type);
void Unload(); void Unload();