[mythtv] [PATCH] Activate/deactivate recording schedule UPDATE

Kevin Kuphal kuphal at dls.net
Sat Jan 8 18:46:00 EST 2005


I forgot the addition to the database from the last patch.  Full patch 
attached fixed.

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	8 Jan 2005 23:43:10 -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 inactive 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	8 Jan 2005 23:43:10 -0000
@@ -64,6 +64,7 @@
 
     hasAirDate = false;
     repeat = false;
+    inactive = false;
 
     seriesid = "";
     programid = "";
@@ -140,6 +141,7 @@
 
     hasAirDate = other.hasAirDate;
     repeat = other.repeat;
+    inactive = other.inactive;
 
     seriesid = other.seriesid;
     programid = other.programid;
@@ -1877,6 +1879,8 @@
         return QObject::tr("K", "RecStatusChar");
     case rsTunerBusy:
         return QObject::tr("B", "RecStatusChar");
+    case rsInactive:
+        return QObject::tr("i", "RecStatusChar");
     default:
         return "-";
     }
@@ -1922,6 +1926,8 @@
             return QObject::tr("Tuner Busy");
         case rsRepeat:
             return QObject::tr("Repeat");            
+        case rsInactive:
+            return QObject::tr("Inactive");
         default:
             return QObject::tr("Unknown");
         }
@@ -1990,6 +1996,9 @@
         case rsRepeat:
             message += QObject::tr("this episode is a repeat.");
             break;            
+        case rsInactive:
+            message += QObject::tr("this recording schedule is inactive.");
+            break;
         case rsTooManyRecordings:
             message += QObject::tr("too many recordings of this program have "
                                    "already been recorded.");
@@ -2600,6 +2609,7 @@
              recstatus == rsCurrentRecording ||
              recstatus == rsEarlierShowing ||
              recstatus == rsRepeat ||
+             recstatus == rsInactive ||
              recstatus == rsLaterShowing))
         {
             diag.AddButton(QObject::tr("Record anyway"));
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	8 Jan 2005 23:43:10 -0000
@@ -72,7 +72,7 @@
     rsConflict = 7,
     rsLaterShowing = 8,
     rsRepeat = 9,
-    //rsUnused = 10,
+    rsInactive = 10,
     rsLowDiskSpace = 11,
     rsTunerBusy = 12
 };
@@ -252,6 +252,7 @@
     
     bool hasAirDate;
     bool repeat;
+    bool inactive;
 
     int spread;
     int startCol;
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	8 Jan 2005 23:43:11 -0000
@@ -38,6 +38,7 @@
     m_dialog = NULL;
     recpriority = NULL;
     recgroup = NULL;
+    inactive = NULL;
     searchType = "";
     searchForWhat = "";
         
@@ -699,6 +700,8 @@
 
     recgroup->fillSelections(db);    
     recgroup->setValue("Default");
+
+    inactive->setValue(0);
 }
 
 void ScheduledRecording::setProgram(ProgramInfo *proginfo, QSqlDatabase* db)
@@ -753,6 +756,7 @@
     endoffset->setChanged();
     recpriority->setChanged();
     recgroup->setChanged();
+    inactive->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	8 Jan 2005 23:43:11 -0000
@@ -15,7 +15,7 @@
 class RootSRGroup;
 class RecOptDialog;
 
-
+class SRInactive;
 class SRRecordingType;
 class SRRecSearchType;
 class SRProfileSelector;
@@ -114,6 +114,7 @@
 
     static void signalChange(QSqlDatabase* db);
     
+    void setInactiveObj(SRInactive* val) {inactive = val;}
     void setRecTypeObj(SRRecordingType* val) {type = val;}
     void setSearchTypeObj(SRRecSearchType* val) {search = val;}
     void setProfileObj( SRProfileSelector* val) {profile = val;}
@@ -173,6 +174,7 @@
     };
 
     ID* id;
+    class SRInactive* inactive;
     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	8 Jan 2005 23:43:11 -0000
@@ -11,6 +11,9 @@
                                        _parent, "schedOpts"),
                      schedRec(_rec)
 {
+    inactive = new SRInactive(_rec, this, _parentList);
+    addItem(inactive->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.21
diff -n -u -r1.21 sr_items.h
--- mythtv/libs/libmythtv/sr_items.h	8 Dec 2004 17:41:45 -0000	1.21
+++ mythtv/libs/libmythtv/sr_items.h	8 Jan 2005 23:43:11 -0000
@@ -318,6 +318,7 @@
     protected:
 
         friend class SRRootGroup;
+        class SRInactive* inactive;
         class SRRecPriority* recPriority;
         class SRStartOffset* startOffset;
         class SREndOffset* endOffset;
@@ -591,7 +592,17 @@
         }
 };
 
-
+class SRInactive: public SRBoolSetting
+{
+    public:
+        SRInactive(ScheduledRecording& _parent, ManagedListGroup* _group, ManagedList* _list)
+                    : SRBoolSetting(_parent, QObject::tr("This recording schedule is inactive"), 
+                                     QObject::tr("This recording schedule is active"),
+                                    "inactiveItem", "inactive", _group, _list )
+        {
+            _parent.setInactiveObj(this);
+        }
+};
 
 class SRMaxNewest: public SRBoolSetting
 {
Index: mythtv/programs/mythbackend/scheduler.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/scheduler.cpp,v
retrieving revision 1.124
diff -n -u -r1.124 scheduler.cpp
--- mythtv/programs/mythbackend/scheduler.cpp	29 Dec 2004 21:46:19 -0000	1.124
+++ mythtv/programs/mythbackend/scheduler.cpp	8 Jan 2005 23:43:11 -0000
@@ -1385,7 +1385,7 @@
 "channel.commfree, capturecard.cardid, "
 "cardinput.cardinputid, UPPER(cardinput.shareable) = 'Y' AS shareable, "
 "program.seriesid, program.programid, program.category_type, "
-"program.airdate, program.stars, program.originalairdate "
+"program.airdate, program.stars, program.originalairdate, record.inactive "
 
 "FROM record, program ") + fromclauses[clause] + QString(
 
@@ -1538,6 +1538,7 @@
         else
             p->originalAirDate = QDate::fromString(result.value(30).toString(), Qt::ISODate);
 
+        p->inactive = result.value(33).toInt();
 
         if (!recTypeRecPriorityMap.contains(p->rectype))
             recTypeRecPriorityMap[p->rectype] = 
@@ -1605,6 +1606,10 @@
                 result.value(14).toInt())
                 p->recstatus = rsCurrentRecording;
         }
+
+        if (p->inactive)
+            p->recstatus = rsInactive;
+
         tmpList.push_back(p);
     }
 
Index: mythtv/programs/mythfrontend/programrecpriority.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/programrecpriority.cpp,v
retrieving revision 1.40
diff -n -u -r1.40 programrecpriority.cpp
--- mythtv/programs/mythfrontend/programrecpriority.cpp	25 Nov 2004 23:28:45 -0000	1.40
+++ mythtv/programs/mythfrontend/programrecpriority.cpp	8 Jan 2005 23:43:11 -0000
@@ -186,6 +186,8 @@
                 changeRecPriority(1);
             else if (action == "LEFT")
                 changeRecPriority(-1);
+            else if ((action == "PAUSED") || (action == "PLAYBACK"))
+                deactivate();
             else if (action == "ESCAPE")
             {
                 saveRecPriority();
@@ -470,7 +472,7 @@
             recid = rec->getRecordID(db);
 
         thequery = QString(
-                   "SELECT recpriority, type FROM record WHERE recordid = %1;")
+                   "SELECT recpriority, type, inactive FROM record WHERE recordid = %1;")
                            .arg(recid);
         QSqlQuery query = db->exec(thequery);
 
@@ -480,6 +482,7 @@
                 query.next();
                 int recPriority = query.value(0).toInt();
                 int rectype = query.value(1).toInt();
+                int inactive = query.value(2).toInt();
 
                 int cnt;
                 QMap<QString, ProgramRecPriorityInfo>::Iterator it;
@@ -511,6 +514,9 @@
                 QString key = progInfo->MakeUniqueKey(); 
                 origRecPriorityData[key] = progInfo->recpriority;
 
+                // also set the active/inactive state
+                progInfo->inactive = inactive;
+
                 SortList();
             }
             else
@@ -545,6 +551,64 @@
     }
 }
 
+void ProgramRecPriority::deactivate(void)
+{
+    if (!curitem)
+        return;
+
+    ProgramRecPriorityInfo *rec = curitem;
+
+    MythContext::KickDatabase(db);
+
+    if (rec)
+    {
+        QString thequery;
+
+        thequery = QString("SELECT inactive FROM record WHERE recordid = %1")
+                           .arg(rec->recordid);
+
+        QSqlQuery query = db->exec(thequery);
+
+        int inactive = 0;
+        if (query.isActive())
+            if (query.numRowsAffected() > 0)
+            {
+                query.next();
+                inactive = query.value(0).toInt();
+                if (inactive)
+                    inactive = 0;
+                else
+                    inactive = 1;
+
+                QString theupdatequery;
+                theupdatequery = QString("UPDATE record SET inactive = %1 WHERE recordid = %2")
+                                         .arg(inactive).arg(rec->recordid);
+
+                QSqlQuery uquery = db->exec(theupdatequery);
+
+                if (uquery.isActive())
+                {
+                    ScheduledRecording::signalChange(db);
+                    int cnt;
+                    QMap<QString, ProgramRecPriorityInfo>::Iterator it;
+                    ProgramRecPriorityInfo *progInfo;
+
+                    // iterate through programData till we hit the line where
+                    // the cursor currently is
+                    for (cnt = 0, it = programData.begin(); cnt < inList+inData;
+                         cnt++, ++it);
+                    progInfo = &(it.data());
+                    progInfo->inactive = inactive;
+                } else
+                    MythContext::DBError("Update recording schedule inactive query", uquery);
+            }
+
+        QPainter p(this);
+        updateInfo(&p);
+        update(fullRect);
+    }
+}
+
 void ProgramRecPriority::upcoming(void)
 {
     if (!curitem)
@@ -642,7 +706,8 @@
     // it all at once than once per program)
     QString query = QString("SELECT recordid, record.title, record.chanid, "
                             "record.starttime, record.startdate, "
-                            "record.type, channel.recpriority "
+                            "record.type, channel.recpriority,  "
+                            "record.inactive "
                             "FROM record "
                             "LEFT JOIN channel ON "
                             "(record.chanid = channel.chanid);");
@@ -665,6 +730,7 @@
             RecordingType recType = (RecordingType)result.value(5).toInt();
             int channelRecPriority = result.value(6).toInt();
             int recTypeRecPriority = rtRecPriors[recType-1];
+            int inactive = result.value(7).toInt();
 
             if (recType == kAllRecord || recType == kFindOneRecord)
                 channelRecPriority = 0;
@@ -684,6 +750,7 @@
                     progInfo->channelRecPriority = channelRecPriority;
                     progInfo->recTypeRecPriority = recTypeRecPriority;
                     progInfo->recType = recType;
+                    progInfo->inactive = inactive;
                     matches++;
                     break;
                 }
@@ -925,6 +992,9 @@
                             ltype->SetItemCurrent(cnt);
                         }
 
+                        if (progInfo->inactive)
+                            ltype->EnableForcedFont(cnt, "inactive");
+
                         ltype->SetItemText(cnt, 1, progInfo->RecTypeChar());
                         ltype->SetItemText(cnt, 2, tempSubTitle);
 
Index: mythtv/programs/mythfrontend/programrecpriority.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/programrecpriority.h,v
retrieving revision 1.11
diff -n -u -r1.11 programrecpriority.h
--- mythtv/programs/mythfrontend/programrecpriority.h	17 Nov 2004 23:36:29 -0000	1.11
+++ mythtv/programs/mythfrontend/programrecpriority.h	8 Jan 2005 23:43:11 -0000
@@ -48,6 +48,7 @@
     void changeRecPriority(int howMuch);
     void saveRecPriority(void);
     void edit();
+    void deactivate();
     void upcoming();
 
   protected:


More information about the mythtv-dev mailing list