[mythtv] [PATCH] Configure default views for Watch Recordings

Kevin Kuphal kuphal at dls.net
Fri Apr 22 05:53:13 UTC 2005


This patch consolidates a few settings into a single combo box to 
configure the Default View for the Watch Recording screen.  Instead of 
checking the box to use Categories in setup and only being able to 
change to Recording Groups from in the Watch Recordings screen, this 
patch adds the following default views:

Titles only
Titles and Categories
Titles, Categories, and Recording Groups
Titles and Recording Groups
Categories only
Categories and Recording Groups
Recording Groups only

I also modified the wording on the "Recording Group view" options to 
refer to "Display filter" since it more accurately describes the 
function.   The filter combo box  now always show categories as options 
for filtering in both setup and from the MENU item since the display of 
categories as groupings can be changed dynamically. 

This combination allows maximum flexibility to show any grouping on the 
left while allowing filtering of the records on recording group or category.

Kevin
-------------- next part --------------
Index: mythtv/programs/mythfrontend/globalsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/globalsettings.cpp,v
retrieving revision 1.239
diff -n -u -r1.239 globalsettings.cpp
--- mythtv/programs/mythfrontend/globalsettings.cpp	13 Apr 2005 18:57:11 -0000	1.239
+++ mythtv/programs/mythfrontend/globalsettings.cpp	22 Apr 2005 05:48:42 -0000
@@ -221,7 +221,7 @@
 static HostComboBox *DisplayRecGroup()
 {
     HostComboBox *gc = new HostComboBox("DisplayRecGroup");
-    gc->setLabel(QObject::tr("Default Recording Group to display"));
+    gc->setLabel(QObject::tr("Default group filter to apply"));
 
     gc->addSelection(QObject::tr("All Programs"), QString("All Programs"));
     gc->addSelection(QObject::tr("Default"), QString("Default"));
@@ -237,7 +237,16 @@
                 gc->addSelection(recgroup, recgroup);
             }
 
-    gc->setHelpText(QObject::tr("Default Recording Group to display "
+    query.prepare("SELECT DISTINCT category from recorded;");
+
+    if (query.exec() && query.isActive() && query.size() > 0)
+        while (query.next())
+        {
+            QString key = QString::fromUtf8(query.value(0).toString());
+            gc->addSelection(key, key);
+        }
+
+    gc->setHelpText(QObject::tr("Default group filter to apply "
                     "on the View Recordings screen."));
     return gc;
 }
@@ -245,23 +254,30 @@
 static HostCheckBox *RememberRecGroup()
 {
     HostCheckBox *gc = new HostCheckBox("RememberRecGroup");
-    gc->setLabel(QObject::tr("Save current Recording Group view when changed"));
+    gc->setLabel(QObject::tr("Save current group filter when changed"));
     gc->setValue(true);
-    gc->setHelpText(QObject::tr("Remember the last selected Recording "
-                    "Group instead of displaying the Default group "
+    gc->setHelpText(QObject::tr("Remember the last selected filter "
+                    "instead of displaying the default filter "
                     "whenever you enter the playback screen."));
 
     return gc;
 }
 
-static HostCheckBox *UseCategoriesAsRecGroups()
+static HostComboBox *DefaultView()
 {
-    HostCheckBox *gc = new HostCheckBox("UseCategoriesAsRecGroups");
-    gc->setLabel(QObject::tr("Use program categories as display groups"));
-    gc->setValue(false);
-    gc->setHelpText(QObject::tr("Add the list of program categories to the "
-                    "list of Recording Groups used for display.  Only programs "
-                    "in non-password protected groups will be listed."));
+    HostComboBox *gc = new HostComboBox("DisplayGroupDefaultView");
+    gc->setLabel(QObject::tr("Default View"));
+
+    gc->addSelection(QObject::tr("Show Titles only"), "0");
+    gc->addSelection(QObject::tr("Show Titles and Categories"), "1");
+    gc->addSelection(QObject::tr("Show Titles, Categories, and Recording Groups"), "2");
+    gc->addSelection(QObject::tr("Show Titles and Recording Groups"), "3");
+    gc->addSelection(QObject::tr("Show Categories only"), "4");
+    gc->addSelection(QObject::tr("Show Categories and Recording Groups"), "5");
+    gc->addSelection(QObject::tr("Show Recording Groups only"), "6");
+
+    gc->setHelpText(QObject::tr("Select what type of grouping to show on the Watch Recordings screen "
+                    "by default."));
 
     return gc;
 }
@@ -269,10 +285,10 @@
 static HostCheckBox *UseGroupNameAsAllPrograms()
 {
     HostCheckBox *gc = new HostCheckBox("DispRecGroupAsAllProg");
-    gc->setLabel(QObject::tr("Show group name instead of \"All Programs\""));
+    gc->setLabel(QObject::tr("Show filter name instead of \"All Programs\""));
     gc->setValue(false);
-    gc->setHelpText(QObject::tr("Use the name of the display group currently "
-                    "being shown in place of the term \"All Programs\" in the "
+    gc->setHelpText(QObject::tr("Use the name of the display filter currently "
+                    "applied in place of the term \"All Programs\" in the "
                     "playback screen."));
     return gc;
 }
@@ -2818,8 +2834,9 @@
     pbox2->addChild(AllRecGroupPassword());
     pbox2->addChild(DisplayRecGroup());
     pbox2->addChild(RememberRecGroup());
-    pbox2->addChild(UseCategoriesAsRecGroups());
+//    pbox2->addChild(UseCategoriesAsRecGroups());
     pbox2->addChild(UseGroupNameAsAllPrograms());
+    pbox2->addChild(DefaultView());
     addChild(pbox2);
 
     addChild(new HwDecSettings());
Index: mythtv/programs/mythfrontend/playbackbox.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/playbackbox.cpp,v
retrieving revision 1.204
diff -n -u -r1.204 playbackbox.cpp
--- mythtv/programs/mythfrontend/playbackbox.cpp	11 Apr 2005 23:00:40 -0000	1.204
+++ mythtv/programs/mythfrontend/playbackbox.cpp	22 Apr 2005 05:48:42 -0000
@@ -125,7 +125,14 @@
     curitem = NULL;
     delitem = NULL;
  
+    // titleView controls showing titles in group list
     titleView = true;
+  
+    // useCategories controls showing categories in group list
+    useCategories = false;
+
+    // useRecGroups controls showing of recording groups in group list
+    useRecGroups = false;
 
     if (gContext->GetNumSetting("UseArrowAccels", 1))
         arrowAccel = true;
@@ -156,6 +163,8 @@
     else
         recGroupType[recGroup] = "recgroup";
 
+    setDefaultView(gContext->GetNumSetting("DisplayGroupDefaultView",0));
+
     fullRect = QRect(0, 0, size().width(), size().height());
     listRect = QRect(0, 0, 0, 0);
     infoRect = QRect(0, 0, 0, 0);
@@ -255,6 +264,20 @@
         delete delitem;
 }
 
+void PlaybackBox::setDefaultView(int defaultView)
+{
+    switch (defaultView)
+    {
+        case TitlesOnly: titleView = true; useCategories = false; useRecGroups = false; break; 
+        case TitlesCategories: titleView = true; useCategories = true; useRecGroups = false; break;
+        case TitlesCategoriesRecGroups: titleView = true; useCategories = true; useRecGroups = true; break;
+        case TitlesRecGroups: titleView = true; useCategories = false; useRecGroups = true; break;
+        case Categories: titleView = false; useCategories = true; useRecGroups = false; break;
+        case CategoriesRecGroups: titleView = false; useCategories = true; useRecGroups = true; break;
+        case RecGroups: titleView = false; useCategories = false; useRecGroups = true; break;
+    }
+}
+
 /* blocks until playing has stopped */
 void PlaybackBox::killPlayerSafe(void)
 {
@@ -1207,28 +1230,31 @@
                  (p->category == recGroup ) &&
                  ( !recGroupPwCache.contains(p->recgroup))))
             {
+                if ((titleView) || (useCategories) || (useRecGroups))
+                    progLists[""].prepend(p);
+
                 if (titleView) // Normal title view 
                 {
-                    progLists[""].prepend(p);
                     progLists[p->title].prepend(p);
                     sTitle = p->title;
                     sTitle.remove(prefixes);
                     sortedList[sTitle] = p->title;
                 } 
-                else 
+                if (useRecGroups) // Show recording groups
                 { 
-                    progLists[""].prepend(p);
                     progLists[p->recgroup].prepend(p);
                     sortedList[p->recgroup] = p->recgroup;
-                    // If categories are used as recording groups...
-                    if (gContext->GetNumSetting("UseCategoriesAsRecGroups"))
-                    {
-                        // Recording groups and categories overlap so set flag
-                        progLists[p->category].setAutoDelete(false);
-                        progLists[p->category].prepend(p);
-                        sortedList[p->category] = p->category;
-                    }
+                    // If another view is also used, unset autodelete as another group will do it
+                    if ((useCategories) || (titleView)) progLists[p->recgroup].setAutoDelete(false);
                 }
+                if (useCategories) // Show categories
+                {
+                    progLists[p->category].prepend(p);
+                    sortedList[p->category] = p->category;
+                    // If another view is also used, unset autodelete as another group will do it
+                    if ((useRecGroups) || (titleView)) progLists[p->category].setAutoDelete(false);
+                }
+		
             }
             else
                 delete p;
@@ -1251,8 +1277,8 @@
 
     QString episodeSort = gContext->GetSetting("PlayBoxEpisodeSort", "Date");
 
-    if (titleView)
-    {
+//    if (titleView)
+//    {
         if (episodeSort == "OrigAirDate")
         {
             QMap<QString, ProgramList>::Iterator Iprog;
@@ -1272,7 +1298,7 @@
                     Iprog.data().Sort(comp_programid);
             }
         }
-    }
+//    }
     
     // Try to find our old place in the title list.  Scan the new
     // titles backwards until we find where we were or go past.  This
@@ -1308,12 +1334,14 @@
         {
             p = l->at(i);
 
-            if (episodeSort == "OrigAirDate" && titleView && titleIndex > 0)
+            // if (episodeSort == "OrigAirDate" && titleView && titleIndex > 0)
+            if (episodeSort == "OrigAirDate" && titleIndex > 0)
             {
                 if (oldoriginalAirDate > p->originalAirDate)
                     break;
             }
-            else if (episodeSort == "Id" && titleView && titleIndex > 0)
+            // else if (episodeSort == "Id" && titleView && titleIndex > 0)
+            else if (episodeSort == "Id" && titleIndex > 0)
             {
                 if (oldprogramid > p->programid)
                     break;
@@ -1584,20 +1612,16 @@
                                   MythPopupBox::Large, false);
     label->setAlignment(Qt::AlignCenter | Qt::WordBreak);
 
-    QButton *topButton = popup->addButton(tr("Change Group View"), this,
+    QButton *topButton = popup->addButton(tr("Change Group Filter"), this,
                      SLOT(showRecGroupChooser()));
 
+    popup->addButton(tr("Change Group View"), this,
+                     SLOT(showViewChanger()));
+
     if (recGroupType[recGroup] == "recgroup")
         popup->addButton(tr("Change Group Password"), this,
                          SLOT(showRecGroupPasswordChanger()));
 
-    if (titleView)
-        popup->addButton(tr("Show group list as recording groups"), this,
-                         SLOT(toggleTitleView()));
-    else
-        popup->addButton(tr("Show group list as titles"), this,
-                         SLOT(toggleTitleView()));
-
     if (playList.count())
     {
         popup->addButton(tr("Playlist options"), this,
@@ -1607,17 +1631,9 @@
     {
         if (inTitle)
         {
-            if (titleView)
-            {
-                popup->addButton(
-                    tr("Add this Category/Title Group to Playlist"), this,
-                       SLOT(togglePlayListTitle()));
-            }
-            else 
-            {
-                popup->addButton(tr("Add this Recording Group to Playlist"),
-                                 this, SLOT(togglePlayListTitle()));
-            }
+            popup->addButton(
+                tr("Add this Group to Playlist"), this,
+                   SLOT(togglePlayListTitle()));
         }
         else 
         {
@@ -3308,6 +3324,73 @@
     setActiveWindow();
 }
 
+void PlaybackBox::showViewChanger(void)
+{
+    if (!expectingPopup)
+        return;
+
+    cancelPopup();
+
+
+    MythPopupBox tmpPopup(gContext->GetMainWindow(),
+                                              true, popupForeground,
+                                              popupBackground, popupHighlight,
+                                              "change group view");
+    choosePopup = &tmpPopup;
+
+    QLabel *label = choosePopup->addLabel(tr("Change Group View"),
+                                  MythPopupBox::Large, false);
+    label->setAlignment(Qt::AlignCenter | Qt::WordBreak);
+
+    QStringList views;
+
+    views += tr("Show Titles only");
+    views += tr("Show Titles and Categories");
+    views += tr("Show Titles, Categories, and Recording Groups");
+    views += tr("Show Titles and Recording Groups");
+    views += tr("Show Categories only");
+    views += tr("Show Categories and Recording Groups");
+    views += tr("Show Recording Groups only");
+
+    chooseComboBox = new MythComboBox(false, choosePopup);
+    chooseComboBox->insertStringList(views);
+    chooseComboBox->setAcceptOnSelect(true);
+    choosePopup->addWidget(chooseComboBox);
+
+    connect(chooseComboBox, SIGNAL(accepted(int)), this,
+            SLOT(chooseSetGroupView()));
+
+    chooseComboBox->setFocus();
+    choosePopup->ExecPopup();
+
+    delete chooseComboBox;
+    chooseComboBox = NULL;
+
+    skipUpdate = false;
+    skipCnt = 2;
+    update(fullRect);
+
+    setActiveWindow();
+}
+
+void PlaybackBox::chooseSetGroupView(void)
+{
+    if (!chooseComboBox)
+        return;
+
+    setDefaultView(chooseComboBox->currentItem());
+
+    inTitle = gContext->GetNumSetting("PlaybackBoxStartInTitle", 0);
+    titleIndex = 0;
+    progIndex = 0;
+    playList.clear();
+
+    connected = FillList();
+    skipUpdate = false;
+    update(fullRect);
+    choosePopup->done(0);
+}
+
 void PlaybackBox::showRecGroupChooser(void)
 {
     if (expectingPopup)
@@ -3361,8 +3444,8 @@
             }
         }
 
-    if (gContext->GetNumSetting("UseCategoriesAsRecGroups"))
-    {
+//    if (useCategories)
+//    {
         query.prepare("SELECT DISTINCT category from recorded;");
 
         if (query.exec() && query.isActive() && query.size() > 0)
@@ -3377,7 +3460,7 @@
                         recGroupType[key] = "category";
                 }
             }
-    }
+//    }
 
     if (recGroup != "All Programs")
     {
Index: mythtv/programs/mythfrontend/playbackbox.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/playbackbox.h,v
retrieving revision 1.67
diff -n -u -r1.67 playbackbox.h
--- mythtv/programs/mythfrontend/playbackbox.h	13 Mar 2005 18:06:42 -0000	1.67
+++ mythtv/programs/mythfrontend/playbackbox.h	22 Apr 2005 05:48:42 -0000
@@ -26,6 +26,8 @@
     Q_OBJECT
   public:
     typedef enum { Play, Delete } BoxType;
+    typedef enum { TitlesOnly, TitlesCategories, TitlesCategoriesRecGroups, 
+                   TitlesRecGroups, Categories, CategoriesRecGroups, RecGroups } ViewType;
 
     PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0);
    ~PlaybackBox(void);
@@ -89,6 +91,7 @@
 
     void chooseComboBoxChanged(void);
     void chooseSetViewGroup(void);
+    void chooseSetGroupView(void);
     void changeComboBoxChanged(void);
     void changeSetRecGroup(void);
     void changeRecGroupPassword();
@@ -121,6 +124,7 @@
     void togglePlayListItem(void);
     void playSelectedPlaylist(bool random);
     void doPlayList(void);
+    void showViewChanger(void);
   protected:
     void paintEvent(QPaintEvent *);
     void keyPressEvent(QKeyEvent *e);
@@ -292,6 +296,10 @@
 
     bool playingSomething;
     bool titleView;
+
+    bool useRecGroups;
+    bool useCategories;
+    void setDefaultView(int defaultView);
 };
 
 #endif


More information about the mythtv-dev mailing list