From cad1a88a7b5826ce2a03f4853a5c204c066a8ec4 Mon Sep 17 00:00:00 2001
From: Klaus Schmidinger <vdr@tvdr.de>
Date: Sun, 15 Jan 2006 13:44:55 +0100
Subject: The status markers in the "Schedule" menu are now only updated if a
 submenu is closed in which a timer has been modified

---
 HISTORY  |  2 ++
 menu.c   | 28 +++++++++++++++++++---------
 timers.c | 12 ++++++------
 timers.h | 11 ++++++-----
 vdr.c    |  5 +++--
 5 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/HISTORY b/HISTORY
index 1364c2cd..d24c8da1 100644
--- a/HISTORY
+++ b/HISTORY
@@ -4181,3 +4181,5 @@ Video Disk Recorder Revision History
   This can be used to find reruns of a given show, or the episodes of a series.
   Note that if there are many channels in your channels.conf, displaying the
   "All events on all channels" page may take a while.
+- The status markers in the "Schedule" menu are now only updated if a submenu is
+  closed in which a timer has been modified, which speeds up closing submenus.
diff --git a/menu.c b/menu.c
index af9cebf8..ba0a7a03 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: menu.c 1.394 2006/01/15 12:46:07 kls Exp $
+ * $Id: menu.c 1.395 2006/01/15 13:35:05 kls Exp $
  */
 
 #include "menu.h"
@@ -1030,6 +1030,7 @@ class cMenuWhatsOn : public cOsdMenu {
 private:
   bool now;
   int helpKeys;
+  int timerState;
   eOSState Record(void);
   eOSState Switch(void);
   static int currentChannel;
@@ -1052,6 +1053,8 @@ cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentCha
 {
   now = Now;
   helpKeys = -1;
+  timerState = 0;
+  Timers.Modified(timerState);
   for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) {
       if (!Channel->GroupSep()) {
          const cSchedule *Schedule = Schedules->GetSchedule(Channel);
@@ -1069,10 +1072,12 @@ cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentCha
 bool cMenuWhatsOn::Update(void)
 {
   bool result = false;
-  for (cOsdItem *item = First(); item; item = Next(item)) {
-      if (((cMenuScheduleItem *)item)->Update())
-         result = true;
-      }
+  if (Timers.Modified(timerState)) {
+     for (cOsdItem *item = First(); item; item = Next(item)) {
+         if (((cMenuScheduleItem *)item)->Update())
+            result = true;
+         }
+     }
   return result;
 }
 
@@ -1188,6 +1193,7 @@ private:
   bool now, next;
   int otherChannel;
   int helpKeys;
+  int timerState;
   eOSState Number(void);
   eOSState Record(void);
   eOSState Switch(void);
@@ -1209,6 +1215,8 @@ cMenuSchedule::cMenuSchedule(void)
   now = next = false;
   otherChannel = 0;
   helpKeys = -1;
+  timerState = 0;
+  Timers.Modified(timerState);
   cMenuScheduleItem::SetSortMode(cMenuScheduleItem::ssmAllThis);
   cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
   if (channel) {
@@ -1306,10 +1314,12 @@ void cMenuSchedule::PrepareScheduleAllAll(const cEvent *Event, const cChannel *C
 bool cMenuSchedule::Update(void)
 {
   bool result = false;
-  for (cOsdItem *item = First(); item; item = Next(item)) {
-      if (((cMenuScheduleItem *)item)->Update())
-         result = true;
-      }
+  if (Timers.Modified(timerState)) {
+     for (cOsdItem *item = First(); item; item = Next(item)) {
+         if (((cMenuScheduleItem *)item)->Update())
+            result = true;
+         }
+     }
   return result;
 }
 
diff --git a/timers.c b/timers.c
index 19672672..a168cc1d 100644
--- a/timers.c
+++ b/timers.c
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: timers.c 1.42 2006/01/14 14:56:11 kls Exp $
+ * $Id: timers.c 1.43 2006/01/15 13:31:11 kls Exp $
  */
 
 #include "timers.h"
@@ -515,7 +515,7 @@ cTimers Timers;
 
 cTimers::cTimers(void)
 {
-  modified = false;
+  state = 0;
   beingEdited = 0;;
   lastSetEvents = 0;
 }
@@ -574,13 +574,13 @@ cTimer *cTimers::GetNextActiveTimer(void)
 
 void cTimers::SetModified(void)
 {
-  modified = true;
+  state++;
 }
 
-bool cTimers::Modified(void)
+bool cTimers::Modified(int &State)
 {
-  bool Result = modified;
-  modified = false;
+  bool Result = state != State;
+  State = state;
   return Result;
 }
 
diff --git a/timers.h b/timers.h
index 4ad28bb4..73b951d1 100644
--- a/timers.h
+++ b/timers.h
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: timers.h 1.23 2006/01/06 14:13:17 kls Exp $
+ * $Id: timers.h 1.24 2006/01/15 13:29:44 kls Exp $
  */
 
 #ifndef __TIMERS_H
@@ -96,7 +96,7 @@ public:
 
 class cTimers : public cConfig<cTimer> {
 private:
-  bool modified;
+  int state;
   int beingEdited;
   time_t lastSetEvents;
 public:
@@ -109,9 +109,10 @@ public:
   void IncBeingEdited(void) { beingEdited++; }
   void DecBeingEdited(void) { if (!--beingEdited) lastSetEvents = 0; }
   void SetModified(void);
-  bool Modified(void);
-      ///< Returns true if any of the timers have been modified.
-      ///< Calling this function resets the 'modified' flag to false.
+  bool Modified(int &State);
+      ///< Returns true if any of the timers have been modified, which
+      ///< is detected by State being different than the internal state.
+      ///< Upon return the internal state will be stored in State.
   void SetEvents(void);
   void DeleteExpired(void);
   };
diff --git a/vdr.c b/vdr.c
index 906c4219..bd4f9504 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
  *
  * The project's page is at http://www.cadsoft.de/vdr
  *
- * $Id: vdr.c 1.237 2006/01/14 10:20:50 kls Exp $
+ * $Id: vdr.c 1.238 2006/01/15 13:31:57 kls Exp $
  */
 
 #include <getopt.h>
@@ -690,9 +690,10 @@ int main(int argc, char *argv[])
         if (!Channels.BeingEdited() && !Timers.BeingEdited()) {
            int modified = Channels.Modified();
            static time_t ChannelSaveTimeout = 0;
+           static int TimerState = 0;
            // Channels and timers need to be stored in a consistent manner,
            // therefore if one of them is changed, we save both.
-           if (modified == CHANNELSMOD_USER || Timers.Modified())
+           if (modified == CHANNELSMOD_USER || Timers.Modified(TimerState))
               ChannelSaveTimeout = 1; // triggers an immediate save
            else if (modified && !ChannelSaveTimeout)
               ChannelSaveTimeout = time(NULL) + CHANNELSAVEDELTA;
-- 
cgit v1.2.3