[mythtv] [PATCH] alternate behaviour for show delete

Kai Fritzowsky mythtv-dev at blackhole.hadinet.de
Mon Apr 18 20:05:03 UTC 2005


On Mon, Apr 18, 2005 at 02:40:20PM -0500, Robert Kulagowski wrote:
> You should resend as a diff -u

Right. Sorry. Here it is.

/Kai
-------------- next part --------------
Index: libs/libmythtv/programinfo.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.cpp,v
retrieving revision 1.203
diff -u -r1.203 programinfo.cpp
--- libs/libmythtv/programinfo.cpp	10 Apr 2005 05:28:53 -0000	1.203
+++ libs/libmythtv/programinfo.cpp	18 Apr 2005 20:03:24 -0000
@@ -1306,7 +1306,7 @@
         MythContext::DBError("PreserveEpisode update", query);
 }
 
-void ProgramInfo::SetAutoExpire(bool autoExpire)
+void ProgramInfo::SetAutoExpire(long long autoExpire)
 {
     MSqlQuery query(MSqlQuery::InitCon());
 
@@ -1323,7 +1323,7 @@
                              query);
 }
 
-bool ProgramInfo::GetAutoExpireFromRecorded()
+long long ProgramInfo::GetAutoExpireFromRecorded()
 {
     MSqlQuery query(MSqlQuery::InitCon());
 
@@ -1336,10 +1336,10 @@
     if (query.exec() && query.isActive() && query.size() > 0)
     {
         query.next();
-        return query.value(0).toBool();
+        return query.value(0).toLongLong();
     }
 
-    return false;
+    return 0;
 }
 
 bool ProgramInfo::GetPreserveEpisodeFromRecorded()
Index: libs/libmythtv/programinfo.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.h,v
retrieving revision 1.102
diff -u -r1.102 programinfo.h
--- libs/libmythtv/programinfo.h	4 Apr 2005 04:14:33 -0000	1.102
+++ libs/libmythtv/programinfo.h	18 Apr 2005 20:03:24 -0000
@@ -154,9 +154,9 @@
     // 1 = flagged, 2 = processing
     void SetCommFlagged(int flag);
     bool IsCommProcessing();
-    void SetAutoExpire(bool autoExpire);
+    void SetAutoExpire(long long autoExpire);
     void SetPreserveEpisode(bool preserveEpisode);
-    bool GetAutoExpireFromRecorded();
+    long long GetAutoExpireFromRecorded();
     bool GetPreserveEpisodeFromRecorded();
 
     bool UsesMaxEpisodes();
Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.193
diff -u -r1.193 mainserver.cpp
--- programs/mythbackend/mainserver.cpp	13 Apr 2005 21:04:28 -0000	1.193
+++ programs/mythbackend/mainserver.cpp	18 Apr 2005 20:03:31 -0000
@@ -481,7 +481,21 @@
                                                                      startts);
             if (pinfo)
             {
-                if (gContext->GetNumSetting("RerecordAutoExpired", 0))
+                long long autoExpire = pinfo->GetAutoExpireFromRecorded();
+                int softDelete = gContext->GetNumSetting("SoftDelete",0);
+
+                // if softDelete is enabled:
+                //    1 <= autoExpire <=  999: normal behaviour
+                // 1000 <= autoExpire <= 1999: delete, no re-record
+                // 2000 <= autoExpire <= 2999: delete, allow re-record
+
+                if (softDelete && autoExpire >= 1000)
+                {
+                    if (autoExpire >= 2000)
+                    {
+                        pinfo->DeleteHistory();
+                    }
+                } else if (gContext->GetNumSetting("RerecordAutoExpired", 0))
                     pinfo->DeleteHistory();
                 DoHandleDeleteRecording(pinfo, NULL);
             }
@@ -763,8 +777,12 @@
                        "FROM recorded "
                        "LEFT JOIN record ON recorded.recordid = record.recordid "
                        "LEFT JOIN channel ON recorded.chanid = channel.chanid "
-                       "WHERE recorded.deletepending = 0 "
-                       "ORDER BY recorded.starttime";
+                       "WHERE recorded.deletepending = 0 ";
+    if (type == "Play")
+    {
+        thequery += "AND recorded.autoexpire < 1000 ";
+    }
+    thequery += "ORDER BY recorded.starttime";
 
     if (type == "Delete")
         thequery += " DESC";
Index: programs/mythfrontend/globalsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/globalsettings.cpp,v
retrieving revision 1.239
diff -u -r1.239 globalsettings.cpp
--- programs/mythfrontend/globalsettings.cpp	13 Apr 2005 18:57:11 -0000	1.239
+++ programs/mythfrontend/globalsettings.cpp	18 Apr 2005 20:03:38 -0000
@@ -944,6 +944,17 @@
     return gc;
 }
 
+static GlobalCheckBox *SoftDeletePrompt()
+{
+    GlobalCheckBox *bc = new GlobalCheckBox("SoftDelete");
+    bc->setLabel(QObject::tr("Soft delete"));
+    bc->setValue(false);
+    bc->setHelpText(QObject::tr("If enabled, delete will mark the recording "
+                    "for autoexpire and hide it from the recordings list "
+                    "instead of deleting it immediately."));
+    return bc;
+}
+
 static HostCheckBox *GeneratePreviewPixmaps()
 {
     HostCheckBox *gc = new HostCheckBox("GeneratePreviewPixmaps");
@@ -2794,6 +2805,7 @@
     gen2->setLabel(QObject::tr("General playback (part 2)"));
     gen2->addChild(PlaybackExitPrompt());
     gen2->addChild(EndOfRecordingExitPrompt());
+    gen2->addChild(SoftDeletePrompt());
     gen2->addChild(ClearSavedPosition());
     gen2->addChild(AltClearSavedPosition());
     gen2->addChild(UsePicControls());
Index: programs/mythfrontend/playbackbox.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/playbackbox.cpp,v
retrieving revision 1.204
diff -u -r1.204 playbackbox.cpp
--- programs/mythfrontend/playbackbox.cpp	11 Apr 2005 23:00:40 -0000	1.204
+++ programs/mythfrontend/playbackbox.cpp	18 Apr 2005 20:03:44 -0000
@@ -1804,8 +1804,23 @@
 
     QString tmpmessage;
     const char *tmpslot = NULL;
+    long long autoExpire = delitem->GetAutoExpireFromRecorded();
+    int softDelete = gContext->GetNumSetting("SoftDelete",0);
 
-    if ((types == EndOfRecording || types == DeleteRecording) &&
+    switch (types)
+    {
+        case DeleteRecording:
+             if (autoExpire >= 1000)
+       	     {
+                 tmpmessage = tr("No, undelete it");
+                 tmpslot = SLOT(doUndelete());
+                 popup->addButton(tmpmessage, this, tmpslot);
+             }
+             break;
+    }
+
+    if ((!softDelete || autoExpire < 1000) &&
+        (types == EndOfRecording || types == DeleteRecording) &&
         (program->IsSameProgram(*program)))
     {
         if (types == EndOfRecording)
@@ -2701,8 +2716,84 @@
     playList.clear();
 }
 
+void PlaybackBox::changeAutoExpire(int amount)
+{
+    if (!expectingPopup)
+        return;
+
+    cancelPopup();
+
+    long aeVal = delitem->GetAutoExpireFromRecorded();
+    long newAEVal = aeVal + amount;
+    if (newAEVal < 0)
+    {
+        newAEVal = 0;
+    }
+    delitem->SetAutoExpire(newAEVal);
+
+    ProgramInfo *tmpItem = findMatchingProg(delitem);
+    if (tmpItem)
+    {
+        if (newAEVal)
+        {
+            tmpItem->programflags |= FL_AUTOEXP;
+        } else {
+            tmpItem->programflags &= ~FL_AUTOEXP;
+        }
+    }
+
+    delete delitem;
+    delitem = NULL;
+
+    state = kChanging;
+    if ((newAEVal >= 1000 && aeVal < 1000) ||
+        (newAEVal < 1000 && aeVal >= 1000))
+    {
+        connected = FillList();
+        update(fullRect);
+    } else {
+        update(listRect);
+    }
+}
+
+void PlaybackBox::incAutoExpire(void)
+{
+    changeAutoExpire(1);
+}
+
+void PlaybackBox::decAutoExpire(void)
+{
+    changeAutoExpire(-1);
+}
+
+void PlaybackBox::doUndelete(void)
+{
+    if (!expectingPopup && delitem)
+        return;
+
+    cancelPopup();
+
+    long long aeVal = delitem->GetAutoExpireFromRecorded();
+    aeVal %= 1000;
+    delitem->SetAutoExpire(aeVal);
+
+    delete delitem;
+    delitem = NULL;
+
+    state = kChanging;
+
+    update(listRect);
+}
+
 void PlaybackBox::doDelete(void)
 {
+    if (gContext->GetNumSetting("SoftDelete",0) &&
+        delitem && delitem->GetAutoExpireFromRecorded() < 1000)
+    {
+        changeAutoExpire(1000);
+        return;
+    }
+
     if (!expectingPopup)
         return;
 
@@ -2717,6 +2808,13 @@
 
 void PlaybackBox::doDeleteForgetHistory(void)
 {
+    if (gContext->GetNumSetting("SoftDelete",0) &&
+        delitem && delitem->GetAutoExpireFromRecorded() < 1000)
+    {
+        changeAutoExpire(2000);
+        return;
+    }
+
     if (!expectingPopup)
         return;
 
Index: programs/mythfrontend/playbackbox.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/playbackbox.h,v
retrieving revision 1.67
diff -u -r1.67 playbackbox.h
--- programs/mythfrontend/playbackbox.h	13 Mar 2005 18:06:42 -0000	1.67
+++ programs/mythfrontend/playbackbox.h	18 Apr 2005 20:03:45 -0000
@@ -72,11 +72,13 @@
 
     void askDelete();
     void doDelete();
+    void doUndelete();
     void doDeleteForgetHistory();
     void noDelete();
 
     void doAutoExpire();
     void noAutoExpire();
+    void changeAutoExpire(int amount);
     void doPreserveEpisode();
     void noPreserveEpisode();
 


More information about the mythtv-dev mailing list