From c9545460bbab9d5c3e54ee63fb0ddb7cb6ff087d Mon Sep 17 00:00:00 2001
From: Roger Siddons <dizygotheca@ntlworld.com>
Date: Sat, 11 Oct 2014 18:18:47 +0100
Subject: [PATCH] Upcoming: Add Active filter


diff --git a/mythtv/programs/mythfrontend/viewscheduled.cpp b/mythtv/programs/mythfrontend/viewscheduled.cpp
index 72dbe3c..efd82f4 100644
--- a/mythtv/programs/mythfrontend/viewscheduled.cpp
+++ b/mythtv/programs/mythfrontend/viewscheduled.cpp
@@ -36,7 +36,7 @@ ViewScheduled::ViewScheduled(MythScreenStack *parent, TV* player, bool showTV)
                m_conflictDate(QDate()),
                m_schedulesList(NULL),
                m_groupList(NULL),
-               m_showAll(!gCoreContext->GetNumSetting("ViewSchedShowLevel", 0)),
+               m_showState(static_cast<ShowStatusType>(gCoreContext->GetNumSetting("ViewSchedShowLevel", 0))),
                m_inEvent(false),
                m_inFill(false),
                m_needFill(false),
@@ -56,7 +56,7 @@ ViewScheduled::ViewScheduled(MythScreenStack *parent, TV* player, bool showTV)
 ViewScheduled::~ViewScheduled()
 {
     gCoreContext->removeListener(this);
-    gCoreContext->SaveSetting("ViewSchedShowLevel", !m_showAll);
+    gCoreContext->SaveSetting("ViewSchedShowLevel", m_showState);
 
     // if we have a player, we need to tell we are done
     if (m_player)
@@ -178,11 +178,37 @@ bool ViewScheduled::keyPressEvent(QKeyEvent *event)
         else if (action == ACTION_CHANNELSEARCH)
             ShowChannelSearch();
         else if (action == "1")
-            setShowAll(true);
+            setShowState(ssShowAll);
         else if (action == "2")
-            setShowAll(false);
-        else if (action == "PREVVIEW" || action == "NEXTVIEW")
-            setShowAll(!m_showAll);
+            setShowState(ssShowImportant);
+        else if (action == "3")
+            setShowState(ssShowActive);
+        else if (action == "PREVVIEW")
+            switch (m_showState)
+            {
+            case ssShowAll:
+                setShowState(ssShowActive);
+                break;
+            case ssShowActive:
+                setShowState(ssShowImportant);
+                break;
+            case ssShowImportant:
+            default: // reset invalid states
+                setShowState(ssShowAll);
+            }
+        else if (action == "NEXTVIEW")
+            switch (m_showState)
+            {
+            case ssShowAll:
+                setShowState(ssShowImportant);
+                break;
+            case ssShowImportant:
+                setShowState(ssShowActive);
+                break;
+            case ssShowActive:
+            default: // reset invalid states
+                setShowState(ssShowAll);
+            }
         else if (action == "VIEWCARD")
             viewCards();
         else if (action == "VIEWINPUT")
@@ -204,37 +230,32 @@ bool ViewScheduled::keyPressEvent(QKeyEvent *event)
 
 void ViewScheduled::ShowMenu(void)
 {
-    QString label = tr("Options");
+    MythMenu *showmenu = new MythMenu(tr("Show"), this, "showmenu");
+    showmenu->AddItem(tr("All"));
+    showmenu->AddItem(tr("Important"));
+    showmenu->AddItem(tr("Active"));
+
+    MythMenu *menu = new MythMenu(tr("Options"), this, "menu");
+
+    menu->AddItem(tr("Show"), NULL, showmenu);
+    menu->AddItem(tr("Program Details"));
+    menu->AddItem(tr("Program Guide"));
+    menu->AddItem(tr("Channel Search"));
+    menu->AddItem(tr("Upcoming by Title"));
+    menu->AddItem(tr("Upcoming Scheduled"));
+    menu->AddItem(tr("Previously Recorded"));
+    menu->AddItem(tr("Custom Edit"));
+    menu->AddItem(tr("Delete Rule"));
+    menu->AddItem(tr("Show Cards"));
+    menu->AddItem(tr("Show Inputs"));
 
     MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
-    MythDialogBox *menuPopup = new MythDialogBox(label, popupStack,
-                                                 "menuPopup");
+    MythDialogBox *menuPopup = new MythDialogBox(menu, popupStack, "menuPopup");
 
     if (menuPopup->Create())
-    {
-        menuPopup->SetReturnEvent(this, "menu");
-
-        if (m_showAll)
-            menuPopup->AddButton(tr("Show Important"));
-        else
-            menuPopup->AddButton(tr("Show All"));
-        menuPopup->AddButton(tr("Program Details"));
-        menuPopup->AddButton(tr("Program Guide"));
-        menuPopup->AddButton(tr("Channel Search"));
-        menuPopup->AddButton(tr("Upcoming by title"));
-        menuPopup->AddButton(tr("Upcoming scheduled"));
-        menuPopup->AddButton(tr("Previously Recorded"));
-        menuPopup->AddButton(tr("Custom Edit"));
-        menuPopup->AddButton(tr("Delete Rule"));
-        menuPopup->AddButton(tr("Show Cards"));
-        menuPopup->AddButton(tr("Show Inputs"));
-
         popupStack->AddScreen(menuPopup);
-    }
     else
-    {
         delete menuPopup;
-    }
 }
 
 void ViewScheduled::LoadList(bool useExistingData)
@@ -288,15 +309,16 @@ void ViewScheduled::LoadList(bool useExistingData)
              recstatus == rsRecording ||
              recstatus == rsTuning ||
              recstatus == rsFailing) &&
-            (m_showAll ||
+            (m_showState == ssShowAll ||
              (recstatus >= rsFailing &&
               recstatus <= rsWillRecord) ||
-             recstatus == rsDontRecord ||
-             (recstatus == rsTooManyRecordings &&
-              ++toomanycounts[pginfo->GetRecordingRuleID()] <= 1) ||
-             (recstatus > rsTooManyRecordings &&
-              recstatus != rsRepeat &&
-              recstatus != rsNeverRecord)))
+             (m_showState == ssShowImportant &&
+              (recstatus == rsDontRecord ||
+               (recstatus == rsTooManyRecordings &&
+                ++toomanycounts[pginfo->GetRecordingRuleID()] <= 1) ||
+              (recstatus > rsTooManyRecordings &&
+               recstatus != rsRepeat &&
+               recstatus != rsNeverRecord)))))
         {
             m_cardref[pginfo->GetCardID()]++;
             if (pginfo->GetCardID() > m_maxcard)
@@ -502,10 +524,19 @@ void ViewScheduled::FillList()
     MythUIText *filterText = dynamic_cast<MythUIText*>(GetChild("filter"));
     if (filterText)
     {
-        if (m_showAll)
+        switch (m_showState) {
+        case ssShowAll:
             filterText->SetText(tr("All"));
-        else
+            break;
+        case ssShowImportant:
             filterText->SetText(tr("Important"));
+            break;
+        case ssShowActive:
+            filterText->SetText(tr("Active"));
+            break;
+        default:
+            filterText->SetText("");
+        }
     }
 }
 
@@ -566,9 +597,9 @@ void ViewScheduled::deleteRule()
         delete okPopup;
 }
 
-void ViewScheduled::setShowAll(bool all)
+void ViewScheduled::setShowState(ShowStatusType state)
 {
-    m_showAll = all;
+    m_showState = state;
     m_needFill = true;
 }
 
@@ -654,17 +685,26 @@ void ViewScheduled::customEvent(QEvent *event)
 
             EmbedTVWindow();
         }
-        else if (resultid == "menu")
+        else if (resultid == "showmenu")
         {
-            if (resulttext == tr("Show Important"))
+            if (resulttext == tr("All"))
+            {
+                setShowState(ssShowAll);
+            }
+            else if (resulttext == tr("Important"))
             {
-                setShowAll(false);
+                setShowState(ssShowImportant);
             }
-            else if (resulttext == tr("Show All"))
+            else if (resulttext == tr("Active"))
             {
-                setShowAll(true);
+                setShowState(ssShowActive);
             }
-            else if (resulttext == tr("Program Details"))
+            if (m_needFill)
+                LoadList();
+        }
+        else if (resultid == "menu")
+        {
+			if (resulttext == tr("Program Details"))
             {
                 ShowDetails();
             }
@@ -676,11 +716,11 @@ void ViewScheduled::customEvent(QEvent *event)
             {
                 ShowChannelSearch();
             }
-            else if (resulttext == tr("Upcoming by title"))
+            else if (resulttext == tr("Upcoming by Title"))
             {
                 ShowUpcoming();
             }
-            else if (resulttext == tr("Upcoming scheduled"))
+            else if (resulttext == tr("Upcoming Scheduled"))
             {
                 ShowUpcomingScheduled();
             }
diff --git a/mythtv/programs/mythfrontend/viewscheduled.h b/mythtv/programs/mythfrontend/viewscheduled.h
index 611eb7a..347e072 100644
--- a/mythtv/programs/mythfrontend/viewscheduled.h
+++ b/mythtv/programs/mythfrontend/viewscheduled.h
@@ -52,9 +52,16 @@ class ViewScheduled : public ScheduleCommon
     virtual ProgramInfo *GetCurrentProgram(void) const;
 
   private:
+    typedef enum
+    {
+        ssShowAll       = 0,
+        ssShowImportant = 1,
+        ssShowActive    = 2,
+    } ShowStatusType;
+
     void FillList(void);
     void LoadList(bool useExistingData = false);
-    void setShowAll(bool all);
+    void setShowState(ShowStatusType state);
     void viewCards(void);
     void viewInputs(void);
 
@@ -68,7 +75,7 @@ class ViewScheduled : public ScheduleCommon
     MythUIButtonList *m_schedulesList;
     MythUIButtonList *m_groupList;
 
-    bool m_showAll;
+    ShowStatusType m_showState;
 
     bool m_inEvent;
     bool m_inFill;
-- 
1.9.1

