mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-08-02 17:09:28 +02:00
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
* Added a 'new' command to rdclilogedit(1).
This commit is contained in:
parent
fb5010fa98
commit
93538cc483
@ -15358,3 +15358,5 @@
|
|||||||
'utils/rdclilogedit/parser.cpp'.
|
'utils/rdclilogedit/parser.cpp'.
|
||||||
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
|
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Refactored rdclilogedit(1) to use synchronous input.
|
* Refactored rdclilogedit(1) to use synchronous input.
|
||||||
|
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added a 'new' command to rdclilogedit(1).
|
||||||
|
@ -28,7 +28,7 @@ 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, setcomment, setlabel, settime\n");
|
printf("load, new, quit, remove, save, saveas, setcart, setcomment, setlabel, settime\n");
|
||||||
printf("settrans, unload\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");
|
||||||
@ -101,6 +101,14 @@ void MainObject::Help(const QStringList &cmds) const
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
processed=true;
|
processed=true;
|
||||||
}
|
}
|
||||||
|
if(verb=="new") {
|
||||||
|
printf("\n");
|
||||||
|
printf(" new <log-name>\n");
|
||||||
|
printf("\n");
|
||||||
|
printf("Create a new, empty log called <log-name> in the edit buffer.\n");
|
||||||
|
printf("\n");
|
||||||
|
processed=true;
|
||||||
|
}
|
||||||
if(verb=="remove") {
|
if(verb=="remove") {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" remove <line>\n");
|
printf(" remove <line>\n");
|
||||||
|
@ -102,6 +102,7 @@ void MainObject::ListLogs() const
|
|||||||
|
|
||||||
void MainObject::Load(const QString &logname)
|
void MainObject::Load(const QString &logname)
|
||||||
{
|
{
|
||||||
|
printf("LOAD\n");
|
||||||
if(edit_log!=NULL) {
|
if(edit_log!=NULL) {
|
||||||
delete edit_log;
|
delete edit_log;
|
||||||
edit_log=NULL;
|
edit_log=NULL;
|
||||||
@ -211,6 +212,26 @@ QString MainObject::ListLine(RDLogEvent *evt,int line) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainObject::New(const QString &logname)
|
||||||
|
{
|
||||||
|
if(edit_log!=NULL) {
|
||||||
|
delete edit_log;
|
||||||
|
}
|
||||||
|
if(edit_log_event!=NULL) {
|
||||||
|
delete edit_log_event;
|
||||||
|
}
|
||||||
|
edit_log=new RDLog(logname);
|
||||||
|
if(!edit_log->exists()) {
|
||||||
|
edit_log_event=new RDLogEvent(RDLog::tableName(logname));
|
||||||
|
edit_new_log=true;
|
||||||
|
edit_modified=false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr,"new: log already exists\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainObject::Remove(int line)
|
void MainObject::Remove(int line)
|
||||||
{
|
{
|
||||||
edit_log_event->remove(line,1);
|
edit_log_event->remove(line,1);
|
||||||
@ -220,10 +241,15 @@ void MainObject::Remove(int line)
|
|||||||
|
|
||||||
void MainObject::Save()
|
void MainObject::Save()
|
||||||
{
|
{
|
||||||
|
if(edit_new_log) {
|
||||||
|
Saveas(edit_log->name());
|
||||||
|
}
|
||||||
|
else {
|
||||||
edit_log_event->save();
|
edit_log_event->save();
|
||||||
edit_log->
|
edit_log->
|
||||||
setModifiedDatetime(QDateTime(QDate::currentDate(),QTime::currentTime()));
|
setModifiedDatetime(QDateTime(QDate::currentDate(),QTime::currentTime()));
|
||||||
edit_modified=false;
|
edit_modified=false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,6 +260,7 @@ void MainObject::Saveas(const QString &logname)
|
|||||||
|
|
||||||
RDLog *log=new RDLog(logname);
|
RDLog *log=new RDLog(logname);
|
||||||
if(!log->exists()) {
|
if(!log->exists()) {
|
||||||
|
if(edit_log->exists()) {
|
||||||
sql=QString("insert into LOGS set ")+
|
sql=QString("insert into LOGS set ")+
|
||||||
"NAME=\""+RDEscapeString(logname)+"\","+
|
"NAME=\""+RDEscapeString(logname)+"\","+
|
||||||
"TYPE=0,"+
|
"TYPE=0,"+
|
||||||
@ -243,6 +270,23 @@ void MainObject::Saveas(const QString &logname)
|
|||||||
"LINK_DATETIME=now(),"+
|
"LINK_DATETIME=now(),"+
|
||||||
"MODIFIED_DATETIME=now(),"+
|
"MODIFIED_DATETIME=now(),"+
|
||||||
"SERVICE=\""+edit_log->service()+"\"";
|
"SERVICE=\""+edit_log->service()+"\"";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sql=QString("select NAME from SERVICES");
|
||||||
|
q=new RDSqlQuery(sql);
|
||||||
|
if(q->first()) {
|
||||||
|
sql=QString("insert into LOGS set ")+
|
||||||
|
"NAME=\""+RDEscapeString(logname)+"\","+
|
||||||
|
"TYPE=0,"+
|
||||||
|
"DESCRIPTION=\""+RDEscapeString(logname+" log")+"\","+
|
||||||
|
"ORIGIN_USER=\""+RDEscapeString(edit_user->name())+"\","+
|
||||||
|
"ORIGIN_DATETIME=now(),"+
|
||||||
|
"LINK_DATETIME=now(),"+
|
||||||
|
"MODIFIED_DATETIME=now(),"+
|
||||||
|
"SERVICE=\""+RDEscapeString(q->value(0).toString())+"\"";
|
||||||
|
}
|
||||||
|
delete q;
|
||||||
|
}
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
delete q;
|
delete q;
|
||||||
RDCreateLogTable(RDLog::tableName(logname));
|
RDCreateLogTable(RDLog::tableName(logname));
|
||||||
@ -251,6 +295,7 @@ void MainObject::Saveas(const QString &logname)
|
|||||||
delete edit_log;
|
delete edit_log;
|
||||||
edit_log=log;
|
edit_log=log;
|
||||||
edit_modified=false;
|
edit_modified=false;
|
||||||
|
edit_new_log=false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr,"saveas: log already exists\n");
|
fprintf(stderr,"saveas: log already exists\n");
|
||||||
@ -337,6 +382,7 @@ void MainObject::Settrans(int line,RDLogLine::TransType type)
|
|||||||
|
|
||||||
void MainObject::Unload()
|
void MainObject::Unload()
|
||||||
{
|
{
|
||||||
|
printf("UNLOAD\n");
|
||||||
if(edit_log!=NULL) {
|
if(edit_log!=NULL) {
|
||||||
delete edit_log;
|
delete edit_log;
|
||||||
edit_log=NULL;
|
edit_log=NULL;
|
||||||
|
@ -80,6 +80,21 @@ void MainObject::DispatchCommand(QString cmd)
|
|||||||
processed=true;
|
processed=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(verb=="new") {
|
||||||
|
if(overwrite) {
|
||||||
|
if(cmds.size()==2) {
|
||||||
|
New(cmds[1]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr,"new: invalid command arguments\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
OverwriteError("new");
|
||||||
|
}
|
||||||
|
processed=true;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// These need a log loaded
|
// These need a log loaded
|
||||||
//
|
//
|
||||||
|
@ -40,6 +40,7 @@ MainObject::MainObject(QObject *parent)
|
|||||||
edit_log=NULL;
|
edit_log=NULL;
|
||||||
edit_log_event=NULL;
|
edit_log_event=NULL;
|
||||||
edit_modified=false;
|
edit_modified=false;
|
||||||
|
edit_new_log=false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read Command Options
|
// Read Command Options
|
||||||
|
@ -52,6 +52,7 @@ class MainObject : public QObject
|
|||||||
void ListLogs() const;
|
void ListLogs() const;
|
||||||
void Load(const QString &logname);
|
void Load(const QString &logname);
|
||||||
void List();
|
void List();
|
||||||
|
void New(const QString &logname);
|
||||||
void Remove(int line);
|
void Remove(int line);
|
||||||
void Save();
|
void Save();
|
||||||
void Saveas(const QString &logname);
|
void Saveas(const QString &logname);
|
||||||
@ -67,6 +68,7 @@ class MainObject : public QObject
|
|||||||
void PrintPrompt() const;
|
void PrintPrompt() const;
|
||||||
QString edit_accum;
|
QString edit_accum;
|
||||||
bool edit_modified;
|
bool edit_modified;
|
||||||
|
bool edit_new_log;
|
||||||
RDLog *edit_log;
|
RDLog *edit_log;
|
||||||
RDLogEvent *edit_log_event;
|
RDLogEvent *edit_log_event;
|
||||||
RDUser *edit_user;
|
RDUser *edit_user;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user