[mythtv] [PATCH] Favorite recording schedules

Kevin Kuphal kuphal at dls.net
Sun Jan 16 18:39:53 EST 2005


This patch adds a flag to a recording schedule to mark it as a 
favorite.  Favorite schedules show their recordings under All Programs, 
their Title, and now under a new heading "Favorites".  This allows for 
certain schedules to be more easily picked out from the Watch Recordings 
screen.  We recording alot of kids shows and I have found this to be a 
great way to mark my programs to find them easier than scrolling through 
the extensive title list.  The ability to filter the view to a  single 
category has never worked well for us because our programs fall into 
many different categories. 

The favorite designator is checked under the scheduling options for the 
recording schedule.  There might be a better place for it but it seemed 
the most logical for now.

Kevin
-------------- next part --------------
Index: mythtv/libs/libmythtv/dbcheck.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/dbcheck.cpp,v
retrieving revision 1.70
diff -n -u -r1.70 dbcheck.cpp
--- mythtv/libs/libmythtv/dbcheck.cpp	28 Dec 2004 22:09:12 -0000	1.70
+++ mythtv/libs/libmythtv/dbcheck.cpp	16 Jan 2005 23:26:25 -0000
@@ -8,7 +8,7 @@
 
 #include "mythcontext.h"
 
-const QString currentDatabaseVersion = "1060";
+const QString currentDatabaseVersion = "1061";
 
 void UpdateDBVersionNumber(const QString &newnumber)
 {
@@ -1069,6 +1069,15 @@
 };
         performActualUpdate(updates, "1060", dbver);
     }
+
+    if (dbver == "1060")
+    {
+        const QString updates[] = {
+"ALTER TABLE record ADD COLUMN favorite TINYINT(1) NOT NULL DEFAULT 0;",
+""
+};
+        performActualUpdate(updates, "1061", dbver);
+    }
 }
 
 void InitializeDatabase(void)
Index: mythtv/libs/libmythtv/programinfo.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.cpp,v
retrieving revision 1.182
diff -n -u -r1.182 programinfo.cpp
--- mythtv/libs/libmythtv/programinfo.cpp	1 Jan 2005 19:07:12 -0000	1.182
+++ mythtv/libs/libmythtv/programinfo.cpp	16 Jan 2005 23:26:26 -0000
@@ -42,7 +42,7 @@
     recendts = startts;
     originalAirDate = startts.date();
     lastmodified = startts;
-
+    favorite = false;
 
     recstatus = rsUnknown;
     savedrecstatus = rsUnknown;
@@ -118,6 +119,7 @@
     lastmodified = other.lastmodified;
     spread = other.spread;
     startCol = other.startCol;
+    favorite = other.favorite;
 
     recstatus = other.recstatus;
     savedrecstatus = other.savedrecstatus;
@@ -198,7 +202,7 @@
     DATETIME_TO_LIST(endts)
     STR_TO_LIST(QString::null) // dummy place holder
     INT_TO_LIST(shareable)
-    INT_TO_LIST(0);            // dummy place holder
+    INT_TO_LIST(favorite);            // dummy place holder
     STR_TO_LIST(hostname)
     INT_TO_LIST(sourceid)
     INT_TO_LIST(cardid)
@@ -277,7 +281,7 @@
     DATETIME_FROM_LIST(endts)
     NEXT_STR() // dummy place holder
     INT_FROM_LIST(shareable)
-    NEXT_STR() // dummy place holder
+    INT_FROM_LIST(favorite)
     STR_FROM_LIST(hostname)
     INT_FROM_LIST(sourceid)
     INT_FROM_LIST(cardid)
Index: mythtv/libs/libmythtv/programinfo.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.h,v
retrieving revision 1.94
diff -n -u -r1.94 programinfo.h
--- mythtv/libs/libmythtv/programinfo.h	24 Dec 2004 23:24:07 -0000	1.94
+++ mythtv/libs/libmythtv/programinfo.h	16 Jan 2005 23:26:26 -0000
@@ -249,9 +249,12 @@
 
     QDate originalAirDate;
     QDateTime lastmodified;
+  
+    bool favorite;
     
     bool hasAirDate;
     bool repeat;
Index: mythtv/libs/libmythtv/scheduledrecording.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/scheduledrecording.cpp,v
retrieving revision 1.124
diff -n -u -r1.124 scheduledrecording.cpp
--- mythtv/libs/libmythtv/scheduledrecording.cpp	25 Nov 2004 21:23:52 -0000	1.124
+++ mythtv/libs/libmythtv/scheduledrecording.cpp	16 Jan 2005 23:26:26 -0000
@@ -38,6 +38,8 @@
     m_dialog = NULL;
     recpriority = NULL;
     recgroup = NULL;
+    favorite = NULL;
     searchType = "";
     searchForWhat = "";
         
@@ -699,6 +701,9 @@
 
     recgroup->fillSelections(db);    
     recgroup->setValue("Default");
+
+    favorite->setValue(0);
 }
 
 void ScheduledRecording::setProgram(ProgramInfo *proginfo, QSqlDatabase* db)
@@ -753,6 +758,8 @@
     endoffset->setChanged();
     recpriority->setChanged();
     recgroup->setChanged();
+    favorite->setChanged();
 }
 
 
Index: mythtv/libs/libmythtv/scheduledrecording.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/scheduledrecording.h,v
retrieving revision 1.46
diff -n -u -r1.46 scheduledrecording.h
--- mythtv/libs/libmythtv/scheduledrecording.h	22 Oct 2004 19:14:03 -0000	1.46
+++ mythtv/libs/libmythtv/scheduledrecording.h	16 Jan 2005 23:26:26 -0000
@@ -15,7 +15,8 @@
 class RootSRGroup;
 class RecOptDialog;
 
-
+class SRFavorite;
 class SRRecordingType;
 class SRRecSearchType;
 class SRProfileSelector;
@@ -114,6 +115,8 @@
 
     static void signalChange(QSqlDatabase* db);
     
+    void setFavoriteObj(SRFavorite* val) {favorite = val;}
     void setRecTypeObj(SRRecordingType* val) {type = val;}
     void setSearchTypeObj(SRRecSearchType* val) {search = val;}
     void setProfileObj( SRProfileSelector* val) {profile = val;}
@@ -173,6 +176,8 @@
     };
 
     ID* id;
+    class SRFavorite* favorite;
     class SRRecordingType* type;
     class SRRecSearchType* search;
     class SRProfileSelector* profile;
Index: mythtv/libs/libmythtv/sr_items.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/sr_items.cpp,v
retrieving revision 1.16
diff -n -u -r1.16 sr_items.cpp
--- mythtv/libs/libmythtv/sr_items.cpp	8 Dec 2004 17:41:45 -0000	1.16
+++ mythtv/libs/libmythtv/sr_items.cpp	16 Jan 2005 23:26:26 -0000
@@ -11,6 +11,12 @@
                                        _parent, "schedOpts"),
                      schedRec(_rec)
 {
+    favorite = new SRFavorite(_rec, this, _parentList);
+    addItem(favorite->getItem(), -1);
+
     recPriority = new SRRecPriority(_rec, this, _parentList);
     addItem(recPriority->getItem(), -1);
 
Index: mythtv/libs/libmythtv/sr_items.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/sr_items.h,v
retrieving revision 1.22
diff -n -u -r1.22 sr_items.h
--- mythtv/libs/libmythtv/sr_items.h	9 Jan 2005 17:59:11 -0000	1.22
+++ mythtv/libs/libmythtv/sr_items.h	16 Jan 2005 23:26:26 -0000
@@ -318,6 +318,8 @@
     protected:
 
         friend class SRRootGroup;
+        class SRFavorite* favorite;
         class SRRecPriority* recPriority;
         class SRStartOffset* startOffset;
         class SREndOffset* endOffset;
@@ -591,7 +593,29 @@
         }
 };
 
+class SRFavorite: public SRBoolSetting
+{
+    public:
+        SRFavorite(ScheduledRecording& _parent, ManagedListGroup* _group, ManagedList* _list)
+                    : SRBoolSetting(_parent, QObject::tr("This recording schedule is marked as a favorite"), 
+                                     QObject::tr("This recording schedule is not marked as a favorite"),
+                                    "favoriteItem", "favorite", _group, _list )
+        {
+            _parent.setFavoriteObj(this);
+        }
+};
 
 class SRMaxNewest: public SRBoolSetting
 {
Index: mythtv/programs/mythfrontend/playbackbox.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/playbackbox.cpp,v
retrieving revision 1.180
diff -n -u -r1.180 playbackbox.cpp
--- mythtv/programs/mythfrontend/playbackbox.cpp	24 Dec 2004 23:24:07 -0000	1.180
+++ mythtv/programs/mythfrontend/playbackbox.cpp	16 Jan 2005 23:26:28 -0000
@@ -931,14 +931,14 @@
                 tempCurrent = RemoteGetRecordingStatus(tempInfo, overrectime,
                                                      underrectime);
 
-                if (titleList[titleIndex] == "")
+                if ((titleList[titleIndex] == "") || (titleList[titleIndex] == "-Favorites"))
                     tempSubTitle = tempInfo->title; 
                 else
                     tempSubTitle = tempInfo->subtitle;
                 if (tempSubTitle.stripWhiteSpace().length() == 0)
                     tempSubTitle = tempInfo->title;
                 if ((tempInfo->subtitle).stripWhiteSpace().length() > 0 
-                    && titleList[titleIndex] == "")
+                    && ((titleList[titleIndex] == "") || (titleList[titleIndex] == "-Favorites")))
                 {
                     tempSubTitle = tempSubTitle + " - \"" + 
                         tempInfo->subtitle + "\"";
@@ -1124,6 +1124,7 @@
     // Clear autoDelete for the "all" list since it will share the
     // objects with the title lists.
     progLists[""].setAutoDelete(false);
+    progLists["-Favorites"].setAutoDelete(false);
 
     fillRecGroupPasswordCache();
 
@@ -1136,6 +1137,7 @@
     if (infoList)
     {
         sortedList[""] = "";
+        sortedList["-Favorites"] = "-Favorites";
         vector<ProgramInfo *>::iterator i = infoList->begin();
         for ( ; i != infoList->end(); i++)
         {
@@ -1148,6 +1150,7 @@
                  ( !recGroupPwCache.contains(p->recgroup))))
             {
                 progLists[""].prepend(p);
+                if (p->favorite) progLists["-Favorites"].prepend(p);
                 progLists[p->title].prepend(p);
                 sTitle = p->title;
                 sTitle.remove(prefixes);


More information about the mythtv-dev mailing list