mirror of
				https://github.com/ElvishArtisan/rivendell.git
				synced 2025-10-31 14:13:52 +01:00 
			
		
		
		
	2016-07-21 Fred Gleason <fredg@paravelsystems.com>
* Added a 'new' command to rdclilogedit(1).
This commit is contained in:
		| @@ -15358,3 +15358,5 @@ | ||||
| 	'utils/rdclilogedit/parser.cpp'. | ||||
| 2016-07-21 Fred Gleason <fredg@paravelsystems.com> | ||||
| 	* 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("The following commands are available:\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("\n"); | ||||
|     printf("Enter \"? <cmd-name>\" for specific help.\n"); | ||||
| @@ -101,6 +101,14 @@ void MainObject::Help(const QStringList &cmds) const | ||||
|       printf("\n"); | ||||
|       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") { | ||||
|       printf("\n"); | ||||
|       printf("  remove <line>\n"); | ||||
|   | ||||
| @@ -102,6 +102,7 @@ void MainObject::ListLogs() const | ||||
|  | ||||
| void MainObject::Load(const QString &logname) | ||||
| { | ||||
|   printf("LOAD\n"); | ||||
|   if(edit_log!=NULL) { | ||||
|     delete edit_log; | ||||
|     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) | ||||
| { | ||||
|   edit_log_event->remove(line,1); | ||||
| @@ -220,10 +241,15 @@ void MainObject::Remove(int line) | ||||
|  | ||||
| void MainObject::Save() | ||||
| { | ||||
|   edit_log_event->save(); | ||||
|   edit_log-> | ||||
|     setModifiedDatetime(QDateTime(QDate::currentDate(),QTime::currentTime())); | ||||
|   edit_modified=false; | ||||
|   if(edit_new_log) { | ||||
|     Saveas(edit_log->name()); | ||||
|   } | ||||
|   else { | ||||
|     edit_log_event->save(); | ||||
|     edit_log-> | ||||
|       setModifiedDatetime(QDateTime(QDate::currentDate(),QTime::currentTime())); | ||||
|     edit_modified=false; | ||||
|   } | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -234,15 +260,33 @@ void MainObject::Saveas(const QString &logname) | ||||
|  | ||||
|   RDLog *log=new RDLog(logname); | ||||
|   if(!log->exists()) { | ||||
|     sql=QString("insert into LOGS set ")+ | ||||
|       "NAME=\""+RDEscapeString(logname)+"\","+ | ||||
|       "TYPE=0,"+ | ||||
|       "DESCRIPTION=\""+"Copy of "+RDEscapeString(edit_log->name())+"\","+ | ||||
|       "ORIGIN_USER=\""+RDEscapeString(edit_user->name())+"\","+ | ||||
|       "ORIGIN_DATETIME=now(),"+ | ||||
|       "LINK_DATETIME=now(),"+ | ||||
|       "MODIFIED_DATETIME=now(),"+ | ||||
|       "SERVICE=\""+edit_log->service()+"\""; | ||||
|     if(edit_log->exists()) { | ||||
|       sql=QString("insert into LOGS set ")+ | ||||
| 	"NAME=\""+RDEscapeString(logname)+"\","+ | ||||
| 	"TYPE=0,"+ | ||||
| 	"DESCRIPTION=\""+"Copy of "+RDEscapeString(edit_log->name())+"\","+ | ||||
| 	"ORIGIN_USER=\""+RDEscapeString(edit_user->name())+"\","+ | ||||
| 	"ORIGIN_DATETIME=now(),"+ | ||||
| 	"LINK_DATETIME=now(),"+ | ||||
| 	"MODIFIED_DATETIME=now(),"+ | ||||
| 	"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); | ||||
|     delete q; | ||||
|     RDCreateLogTable(RDLog::tableName(logname)); | ||||
| @@ -251,6 +295,7 @@ void MainObject::Saveas(const QString &logname) | ||||
|     delete edit_log; | ||||
|     edit_log=log; | ||||
|     edit_modified=false; | ||||
|     edit_new_log=false; | ||||
|   } | ||||
|   else { | ||||
|     fprintf(stderr,"saveas: log already exists\n"); | ||||
| @@ -337,6 +382,7 @@ void MainObject::Settrans(int line,RDLogLine::TransType type) | ||||
|  | ||||
| void MainObject::Unload() | ||||
| { | ||||
|   printf("UNLOAD\n"); | ||||
|   if(edit_log!=NULL) { | ||||
|     delete edit_log; | ||||
|     edit_log=NULL; | ||||
|   | ||||
| @@ -80,6 +80,21 @@ void MainObject::DispatchCommand(QString cmd) | ||||
|     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 | ||||
|   // | ||||
|   | ||||
| @@ -40,6 +40,7 @@ MainObject::MainObject(QObject *parent) | ||||
|   edit_log=NULL; | ||||
|   edit_log_event=NULL; | ||||
|   edit_modified=false; | ||||
|   edit_new_log=false; | ||||
|  | ||||
|   // | ||||
|   // Read Command Options | ||||
|   | ||||
| @@ -52,6 +52,7 @@ class MainObject : public QObject | ||||
|   void ListLogs() const; | ||||
|   void Load(const QString &logname); | ||||
|   void List(); | ||||
|   void New(const QString &logname); | ||||
|   void Remove(int line); | ||||
|   void Save(); | ||||
|   void Saveas(const QString &logname); | ||||
| @@ -67,6 +68,7 @@ class MainObject : public QObject | ||||
|   void PrintPrompt() const; | ||||
|   QString edit_accum; | ||||
|   bool edit_modified; | ||||
|   bool edit_new_log; | ||||
|   RDLog *edit_log; | ||||
|   RDLogEvent *edit_log_event; | ||||
|   RDUser *edit_user; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user