StatusText was missing a few strings. I wrote some macros to keep the
enums, values, and strings in sync with each other. If the
preprocessor tricks falls into the category of Stupid Preprocessor
Ticks, then just do the simple thing and add the appropriate case
statements ...

Also, changed the order of the JobQueue display on the myth status
page from "ORDER BY starttime" to "ORDER BY inserttime". This sorts
the jobqueue display in the order that things will be done, in case
jobs were scheduled later after the fact and not in the order they
were originally recorded ...

--Rob
Index: libs/libmythtv/jobqueue.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/jobqueue.cpp,v
retrieving revision 1.24
diff -u -r1.24 jobqueue.cpp
--- libs/libmythtv/jobqueue.cpp 3 May 2005 20:19:32 -0000       1.24
+++ libs/libmythtv/jobqueue.cpp 5 May 2005 23:32:13 -0000
@@ -523,9 +523,9 @@
     if (! (tmpStatus & JOB_DONE) && (tmpCmd & JOB_STOP))
         return false;
     query.prepare("INSERT jobqueue (chanid, starttime, inserttime, type, "
-                         "status, hostname, args, comment, flags) "
+                         "status, statustime, hostname, args, comment, flags) "
                      "VALUES (:CHANID, :STARTTIME, now(), :JOBTYPE, :STATUS, "
-                         ":HOST, :ARGS, :COMMENT, :FLAGS);");
+                         "now(), :HOST, :ARGS, :COMMENT, :FLAGS);");
 
     query.bindValue(":CHANID", chanid);
     query.bindValue(":STARTTIME", startts);
@@ -960,19 +960,11 @@
 {
     switch (status)
     {
-        case JOB_QUEUED:    return tr("Queued");
-        case JOB_PENDING:   return tr("Pending");
-        case JOB_STARTING:  return tr("Starting");
-        case JOB_RUNNING:   return tr("Running");
-        case JOB_PAUSED:    return tr("Paused");
-        case JOB_STOPPING:  return tr("Stopping");
-        case JOB_DONE:      return tr("Done (Invalid status!)");
-        case JOB_FINISHED:  return tr("Finished");
-        case JOB_ABORTED:   return tr("Aborted");
-        case JOB_ERRORED:   return tr("Errored");
-        case JOB_CANCELLED: return tr("Cancelled");
+#define JOBSTATUS_STATUSTEXT(A,B,C) case A: return tr(C);
+        JOBSTATUS_MAP(JOBSTATUS_STATUSTEXT)
+        default: break;
     }
-    return tr("Undefined");
+    return QString("Undefined(%1)").arg(status);
 }
 
 int JobQueue::GetJobsInQueue(QMap<int, JobQueueEntry> &jobs, int findJobs)
@@ -991,7 +983,7 @@
                       "j.args, j.comment, r.endtime "
                   "FROM jobqueue j, recorded r "
                   "WHERE j.chanid = r.chanid AND j.starttime = r.starttime "
-                  "ORDER BY j.starttime, j.chanid, j.id;");
+                  "ORDER BY j.inserttime, j.chanid, j.id;");
 
     if (!query.exec() || !query.isActive())
     {
Index: libs/libmythtv/jobqueue.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/jobqueue.h,v
retrieving revision 1.8
diff -u -r1.8 jobqueue.h
--- libs/libmythtv/jobqueue.h   27 Mar 2005 23:53:21 -0000      1.8
+++ libs/libmythtv/jobqueue.h   5 May 2005 23:32:13 -0000
@@ -13,26 +13,31 @@
 
 using namespace std;
 
-// When Updating this enum, also update the JobQueue::StatusText() method.
-enum JobStatus {
-    JOB_QUEUED        = 0x0001,
-    JOB_PENDING       = 0x0002,
-    JOB_STARTING      = 0x0003,
-    JOB_RUNNING       = 0x0004,
-    JOB_STOPPING      = 0x0005,
-    JOB_PAUSED        = 0x0006,
-    JOB_RETRY         = 0x0007,
-    JOB_ERRORING      = 0x0008,
-    JOB_ABORTING      = 0x0009,
-
-    // JOB_DONE is a mask to indicate the job is done no matter what the status
-    JOB_DONE          = 0x0100,
-    JOB_FINISHED      = 0x0110,
-    JOB_ABORTED       = 0x0120,
-    JOB_ERRORED       = 0x0130,
-    JOB_CANCELLED     = 0x0140,
+// Strings are used by JobQueue::StatusText()
+#define JOBSTATUS_MAP(F) \
+    F(JOB_UNKNOWN,      0x0000, "Unknown") \
+    F(JOB_QUEUED,       0x0001, "Queued") \
+    F(JOB_PENDING,      0x0002, "Pending") \
+    F(JOB_STARTING,     0x0003, "Starting") \
+    F(JOB_RUNNING,      0x0004, "Running") \
+    F(JOB_STOPPING,     0x0005, "Stopping") \
+    F(JOB_PAUSED,       0x0006, "Paused") \
+    F(JOB_RETRY,        0x0007, "Retrying") \
+    F(JOB_ERRORING,     0x0008, "Erroring") \
+    F(JOB_ABORTING,     0x0009, "Aborting") \
+    /* \
+     * JOB_DONE is a mask to indicate the job is done no matter what the \
+     * status \
+     */ \
+    F(JOB_DONE,         0x0100, "Done (Invalid status!)") \
+    F(JOB_FINISHED,     0x0110, "Finished") \
+    F(JOB_ABORTED,      0x0120, "Aborted") \
+    F(JOB_ERRORED,      0x0130, "Errored") \
+    F(JOB_CANCELLED,    0x0140, "Cancelled") \
 
-    JOB_UNKNOWN       = 0x0000
+enum JobStatus {
+#define JOBSTATUS_ENUM(A,B,C)   A = B ,
+    JOBSTATUS_MAP(JOBSTATUS_ENUM)
 };
 
 enum JobCmds {

Attachment: signature.asc
Description: Digital signature

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

Reply via email to