[mythtv] [PATCH] alternate behaviour for show delete

Kai Fritzowsky mythtv-dev at blackhole.hadinet.de
Mon Apr 18 18:58:52 UTC 2005


This patch implements the alternate behaviour for show delete as proposed by
Brad Templeton:

First of all: It's fully optional. You may switch it on if you like it or leave
it off.

If switched on, "Yes, delete it" will add 1000 to the autoexpire value,
"Yes, and allow re-record" will add 2000 to the autoexpire value. If the
autoexpire value is 1000 or above, the program will not be shown in the
program listing any more. However, it's possible to undelete it or
immediatly delete it under "Manage Recordings/Delete Recordings".

It's working great here and I'd very much like to see it in the CVS. If I am
missing something, I'd be happy to fix it in a way everybody can live with.

/Kai

PS: Brad and others: I will post another patch based on this one, that
    enables user control of the autoexpire priority.
-------------- next part --------------
Index: libs/libmythtv/programinfo.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.cpp,v
retrieving revision 1.203
diff -r1.203 programinfo.cpp
1309c1309
< void ProgramInfo::SetAutoExpire(bool autoExpire)
---
> void ProgramInfo::SetAutoExpire(long long autoExpire)
1326c1326
< bool ProgramInfo::GetAutoExpireFromRecorded()
---
> long long ProgramInfo::GetAutoExpireFromRecorded()
1339c1339
<         return query.value(0).toBool();
---
>         return query.value(0).toLongLong();
1342c1342
<     return false;
---
>     return 0;
Index: libs/libmythtv/programinfo.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.h,v
retrieving revision 1.102
diff -r1.102 programinfo.h
157c157
<     void SetAutoExpire(bool autoExpire);
---
>     void SetAutoExpire(long long autoExpire);
159c159
<     bool GetAutoExpireFromRecorded();
---
>     long long GetAutoExpireFromRecorded();
Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.193
diff -r1.193 mainserver.cpp
484c484,498
<                 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))
766,767c780,784
<                        "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";
Index: programs/mythfrontend/globalsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/globalsettings.cpp,v
retrieving revision 1.239
diff -r1.239 globalsettings.cpp
946a947,957
> 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;
> }
> 
2796a2808
>     gen2->addChild(SoftDeletePrompt());
Index: programs/mythfrontend/playbackbox.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/playbackbox.cpp,v
retrieving revision 1.204
diff -r1.204 playbackbox.cpp
1806a1807,1808
>     long long autoExpire = delitem->GetAutoExpireFromRecorded();
>     int softDelete = gContext->GetNumSetting("SoftDelete",0);
1808c1810,1823
<     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;
>     default:
>       break;
>     }
> 
>     if ((!softDelete || autoExpire < 1000) &&
>         (types == EndOfRecording || types == DeleteRecording) &&
2703a2719,2777
> 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::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);
> }
> 
2705a2780,2786
>     if (gContext->GetNumSetting("SoftDelete",0) &&
>         delitem && delitem->GetAutoExpireFromRecorded() < 1000)
>     {
>         changeAutoExpire(1000);
>         return;
>     }
> 
2719a2801,2807
>     if (gContext->GetNumSetting("SoftDelete",0) &&
>         delitem && delitem->GetAutoExpireFromRecorded() < 1000)
>     {
>         changeAutoExpire(2000);
>         return;
>     }
> 
Index: programs/mythfrontend/playbackbox.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/playbackbox.h,v
retrieving revision 1.67
diff -r1.67 playbackbox.h
74a75
>     void doUndelete();
79a81
>     void changeAutoExpire(int amount);


More information about the mythtv-dev mailing list