Diff
Not logged in

Differences From:

File src/timeline.c part of check-in [fcabd4774c] - Improvements to the CLI timeline display. When an update fails due to multiple descendents, show all of the descendents in timeline format. by drh on 2007-09-13 03:52:04. Also file src/timeline.c part of check-in [f76192b245] - Pulled the latest CLI, website, and sqlite changes into the importer branch. by aku on 2007-09-17 01:00:32. [view]

To:

File src/timeline.c part of check-in [5e2392307d] - Turn tags into properties. Allow properties to control background color on timelines. Still experimental. by drh on 2007-09-22 01:40:39. [view]

@@ -86,8 +86,9 @@
 **    4.  User
 **    5.  Number of non-merge children
 **    6.  Number of parents
 **    7.  True if is a leaf
+**    8.  background color
 */
 void www_print_timeline(
   Stmt *pQuery,
   int *pFirstEvent,
@@ -97,8 +98,9 @@
  ){
   char zPrevDate[20];
   int cnt = 0;
   zPrevDate[0] = 0;
+
   db_multi_exec(
      "CREATE TEMP TABLE IF NOT EXISTS seen(rid INTEGER PRIMARY KEY);"
      "DELETE FROM seen;"
   );
@@ -108,8 +110,9 @@
     const char *zUuid = db_column_text(pQuery, 1);
     int nPChild = db_column_int(pQuery, 5);
     int nParent = db_column_int(pQuery, 6);
     int isLeaf = db_column_int(pQuery, 7);
+    const char *zBgClr = db_column_text(pQuery, 8);
     const char *zDate = db_column_text(pQuery, 2);
     if( cnt==0 && pFirstEvent ){
       *pFirstEvent = rid;
     }
@@ -134,9 +137,13 @@
     @ <tr>
     @ <td valign="top">%s(&zDate[11])</td>
     @ <td width="20" align="center" valign="top">
     @ <font id="m%d(rid)" size="+1" color="white">*</font></td>
-    @ <td valign="top" align="left">
+    if( zBgClr && zBgClr[0] ){
+      @ <td valign="top" align="left" bgcolor="%h(zBgClr)">
+    }else{
+      @ <td valign="top" align="left">
+    }
     hyperlink_to_uuid_with_mouseover(zUuid, "xin", "xout", rid);
     if( nParent>1 ){
       @ <b>Merge</b>
     }
@@ -207,15 +214,18 @@
   int relatedEvents = P("r")!=0;
   int afterFlag = P("a")!=0;
   int firstEvent;
   int lastEvent;
+  int clr1, clr2;     /* Tag IDs for specifying background colors */
 
   /* To view the timeline, must have permission to read project data.
   */
   login_check_credentials();
   if( !g.okRead ){ login_needed(); return; }
 
   style_header("Timeline");
+  clr1 = db_int(0, "SELECT tagid FROM tag WHERE tagname='br-bg-color'");
+  clr2 = db_int(0, "SELECT tagid FROM tag WHERE tagname='bg-color'");
   if( !g.okHistory &&
       db_exists("SELECT 1 FROM user"
                 " WHERE login='anonymous'"
                 "   AND cap LIKE '%%h%%'") ){
@@ -225,11 +235,14 @@
   zSQL = mprintf(
     "SELECT blob.rid, uuid, datetime(event.mtime,'localtime'), comment, user,"
     "       (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim=1),"
     "       (SELECT count(*) FROM plink WHERE cid=blob.rid),"
-    "       NOT EXISTS (SELECT 1 FROM plink WHERE pid=blob.rid)"
-    "  FROM event, blob"
-    " WHERE event.type='ci' AND blob.rid=event.objid"
+    "       NOT EXISTS (SELECT 1 FROM plink WHERE pid=blob.rid),"
+    "       (SELECT value FROM tagxref WHERE rid=blob.rid AND tagid=%d"
+    "        UNION ALL"
+    "        SELECT value FROM tagxref WHERE rid=blob.rid AND tagid=%d)"
+    "  FROM event JOIN blob"
+    " WHERE event.type='ci' AND blob.rid=event.objid", clr2, clr1
   );
   if( zUser ){
     zSQL = mprintf("%z AND event.user=%Q", zSQL, zUser);
   }