User can now choose to hide or display floors that contain no rooms
authorDave West <davew@uncensored.citadel.org>
Sat, 27 Oct 2007 20:43:31 +0000 (20:43 +0000)
committerDave West <davew@uncensored.citadel.org>
Sat, 27 Oct 2007 20:43:31 +0000 (20:43 +0000)
visible to them.

webcit/preferences.c
webcit/roomops.c
webcit/webcit.h

index a83f8c878299a31fa8508313269cef88ca8894fc..70068cb5d4800e223508d768c1a89e1416111571 100644 (file)
@@ -409,6 +409,30 @@ void display_preferences(void)
        wprintf("\">");
        wprintf("</td></tr>");
 
+       /**
+        * Show empty floors?
+        */
+
+       get_preference("emptyfloors", buf, sizeof buf);
+       if (buf[0] == 0) strcpy(buf, "no");
+       wprintf("<tr class=\"odd\"><td>");
+       wprintf(_("Show empty floors"));
+       wprintf("</td><td>");
+
+       wprintf("<input type=\"radio\" name=\"emptyfloors\" VALUE=\"yes\"");
+       if (!strcasecmp(buf, "yes")) wprintf(" checked");
+       wprintf(">");
+       wprintf(_("Yes"));
+       wprintf("</input>&nbsp;&nbsp;&nbsp;");
+
+       wprintf("<input type=\"radio\" name=\"emptyfloors\" VALUE=\"no\"");
+       if (!strcasecmp(buf, "no")) wprintf(" checked");
+       wprintf(">");
+       wprintf(_("No"));
+       wprintf("</input>\n");
+
+       wprintf("</td></tr>\n");
+
        /** end table */
        wprintf("</table>\n");
 
@@ -464,6 +488,7 @@ void set_preferences(void)
        set_preference("daystart", bstr("daystart"), 0);
        set_preference("dayend", bstr("dayend"), 0);
        set_preference("default_header_charset", bstr("default_header_charset"), 0);
+       set_preference("emptyfloors", bstr("emptyfloors"), 0);
 
        euid_escapize(ebuf, bstr("signature"));
        set_preference("signature", ebuf, 1);
index 565a37f379dfe3a53951742780b6bec0fd345f7e..a7790c034b6e435460f974f8518cfdc011bdf569 100644 (file)
@@ -3069,7 +3069,8 @@ void list_all_rooms_by_floor(char *viewpref) {
        int ra_flags = 0;
        int flags = 0;
        int num_floors = 1;     /** add an extra one for private folders */
-
+       char buf2[SIZ];
+       
        /** If our cached folder list is very old, burn it. */
        if (WC->cache_fold != NULL) {
                if ((time(NULL) - WC->cache_timestamp) > 300) {
@@ -3138,9 +3139,33 @@ void list_all_rooms_by_floor(char *viewpref) {
                                fold[max_folders].floor,
                                fold[max_folders].is_mailbox);
                fold[max_folders].selectable = 1;
+               /* Increase the room count for the associtaed floor */
+               if (fold[max_folders].is_mailbox)
+                       fold[0].num_rooms++;
+               else
+                       fold[fold[max_folders].floor+1].num_rooms++;
                ++max_folders;
        }
-
+       
+       /*
+        * Remove any floors that don't have rooms
+        */
+       get_preference("emptyfloors", buf2, sizeof buf2);
+       if (buf2[0]==0 || (strcasecmp(buf2, "no") == 0))
+       {
+               for (i=0; i<num_floors; i++)
+               {
+                       if (fold[i].num_rooms == 0) {
+                               for (j=i; j<max_folders; j++) {
+                                       memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
+                               }
+                               max_folders--;
+                               num_floors--;
+                               i--;
+                       }
+               }
+       }
+       
        /** Bubble-sort the folder list */
        for (i=0; i<max_folders; ++i) {
                for (j=0; j<(max_folders-1)-i; ++j) {
index 29854963e8690b9403957187768889106381a16c..5f4c3ccdc03b8cb262cc03c3c9d48fbb261672ef 100644 (file)
@@ -315,6 +315,7 @@ struct folder {
        int is_mailbox; /**< is it a mailbox?  */
        int selectable; /**< can we select it ??? */
        int view;       /**< whats its default view? inbox/calendar.... */
+       int num_rooms;  /**< If this is a floor, how many rooms does it have */
 };
 
 /**