[mythtv] [PATCH] Pause a recording schedule
Kevin Kuphal
kuphal at dls.net
Fri Dec 3 05:48:36 UTC 2004
This patch adds support to pause a recording schedule by pressing PAUSE
or PLAYBACK (usually bound to the Pause key) while on the Set Priorities
screen. This adds a new recording state of rsPaused which excludes
itself from being recorded.
This allows you to temporarily pause a recording schedule to exclude it
from any scheduling. Useful for quickly getting a series of recordings
out of the way without permanently modifying any other settings of the
schedule. A paused schedule is indicated by adding [PAUSED] to the
title display on the priorities screen and paused epiosdes are denoted
with "p" in the Upcoming Episodes screen.
The only thing about this patch that might be unusual is that my local
tree also has modified files from the MaxEpisodes/Watch Recordings patch
I submitted which overlapped some files. I think I cleaned out all the
other lines but I did not that since I bumped the db version previously,
this patch assumes that bump to already be in place when modifying the
db version again.
Kevin
-------------- next part --------------
Index: mythtv/libs/libmythtv/dbcheck.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/dbcheck.cpp,v
retrieving revision 1.67
diff -n -u -r1.67 dbcheck.cpp
--- mythtv/libs/libmythtv/dbcheck.cpp 13 Oct 2004 01:49:55 -0000 1.67
+++ mythtv/libs/libmythtv/dbcheck.cpp 3 Dec 2004 05:36:56 -0000
@@ -8,7 +8,7 @@
#include "mythcontext.h"
-const QString currentDatabaseVersion = "1059";
+const QString currentDatabaseVersion = "1060";
void UpdateDBVersionNumber(const QString &newnumber)
{
@@ -1051,6 +1051,22 @@
};
performActualUpdate(updates, "1058", dbver);
}
if (dbver == "1058")
{
const QString updates[] = {
"ALTER TABLE recorded ADD COLUMN preserve TINYINT(1) NOT NULL DEFAULT 0;",
""
};
performActualUpdate(updates, "1059", dbver);
}
+ if (dbver == "1059")
+ {
+ const QString updates[] = {
+"ALTER TABLE record ADD COLUMN paused TINYINT(1) NOT NULL DEFAULT 0;",
+""
+};
+ performActualUpdate(updates, "1060", dbver);
+ }
}
void InitializeDatabase(void)
Index: mythtv/libs/libmythtv/programinfo.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.cpp,v
retrieving revision 1.165
diff -n -u -r1.165 programinfo.cpp
--- mythtv/libs/libmythtv/programinfo.cpp 20 Oct 2004 07:25:37 -0000 1.165
+++ mythtv/libs/libmythtv/programinfo.cpp 3 Dec 2004 05:36:57 -0000
@@ -63,9 +63,11 @@
hasAirDate = false;
repeat = false;
+ paused = false;
@@ -135,15 +137,17 @@
hasAirDate = other.hasAirDate;
repeat = other.repeat;
+ paused = other.paused;
@@ -1837,6 +1903,8 @@
return QObject::tr("K", "RecStatusChar");
case rsTunerBusy:
return QObject::tr("B", "RecStatusChar");
+ case rsPaused:
+ return QObject::tr("p", "RecStatusChar");
default:
return "-";
}
@@ -1882,6 +1950,8 @@
return QObject::tr("Tuner Busy");
case rsRepeat:
return QObject::tr("Repeat");
+ case rsPaused:
+ return QObject::tr("Paused");
default:
return QObject::tr("Unknown");
}
@@ -1950,6 +2020,9 @@
case rsRepeat:
message += QObject::tr("this episode is a repeat.");
break;
+ case rsPaused:
+ message += QObject::tr("this recording schedule is paused.");
+ break;
case rsTooManyRecordings:
message += QObject::tr("too many recordings of this program have "
"already been recorded.");
@@ -2527,6 +2600,7 @@
recstatus == rsCurrentRecording ||
recstatus == rsEarlierShowing ||
recstatus == rsRepeat ||
+ recstatus == rsPaused ||
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.89
diff -n -u -r1.89 programinfo.h
--- mythtv/libs/libmythtv/programinfo.h 8 Oct 2004 04:23:36 -0000 1.89
+++ mythtv/libs/libmythtv/programinfo.h 3 Dec 2004 05:36:57 -0000
@@ -72,7 +72,7 @@
rsConflict = 7,
rsLaterShowing = 8,
rsRepeat = 9,
- //rsUnused = 10,
+ rsPaused = 10,
rsLowDiskSpace = 11,
rsTunerBusy = 12
};
@@ -267,6 +272,7 @@
int cardid;
bool shareable;
bool conflictfixed;
+ bool paused;
QString schedulerid;
Index: mythtv/programs/mythbackend/scheduler.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/scheduler.cpp,v
retrieving revision 1.119
diff -n -u -r1.119 scheduler.cpp
--- mythtv/programs/mythbackend/scheduler.cpp 19 Oct 2004 07:37:31 -0000 1.119
+++ mythtv/programs/mythbackend/scheduler.cpp 3 Dec 2004 05:36:57 -0000
@@ -1329,7 +1329,7 @@
"channel.commfree, capturecard.cardid, "
"cardinput.cardinputid, UPPER(cardinput.shareable) = 'Y' AS shareable, "
"program.seriesid, program.programid, "
-"program.stars, program.originalairdate "
+"program.stars, program.originalairdate, record.paused "
"FROM record, program ") + fromclauses[clause] + QString(
@@ -1472,6 +1472,7 @@
else
p->originalAirDate = QDate::fromString(result.value(30).toString(), Qt::ISODate);
+ p->paused = result.value(31).toInt();
if (!recTypeRecPriorityMap.contains(p->rectype))
recTypeRecPriorityMap[p->rectype] =
@@ -1535,7 +1536,7 @@
{
if (p->dupin == kDupsNewEpi && p->repeat)
p->recstatus = rsRepeat;
-
+
if (((p->dupin & kDupsInOldRecorded) || (p->dupin == kDupsNewEpi)) &&
result.value(10).toInt())
p->recstatus = rsPreviousRecording;
@@ -1545,6 +1546,9 @@
p->recstatus = rsCurrentRecording;
}
+ if (p->paused)
+ p->recstatus = rsPaused;
+
tmpList.push_back(p);
}
Index: mythtv/programs/mythfrontend/programrecpriority.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/programrecpriority.cpp,v
retrieving revision 1.35
diff -n -u -r1.35 programrecpriority.cpp
--- mythtv/programs/mythfrontend/programrecpriority.cpp 12 Sep 2004 23:21:14 -0000 1.35
+++ mythtv/programs/mythfrontend/programrecpriority.cpp 3 Dec 2004 05:36:57 -0000
@@ -186,6 +186,8 @@
changeRecPriority(1);
else if (action == "LEFT")
changeRecPriority(-1);
+ else if ((action == "PAUSE") || (action == "PLAYBACK"))
+ pause();
else if (action == "ESCAPE")
{
saveRecPriority();
@@ -427,6 +429,65 @@
inList = 0;
}
+void ProgramRecPriority::pause(void)
+{
+ if (!curitem)
+ return;
+
+ ProgramRecPriorityInfo *rec = curitem;
+
+ MythContext::KickDatabase(db);
+
+ if (rec)
+ {
+ QString thequery;
+
+ thequery = QString("SELECT paused FROM record WHERE recordid = %1")
+ .arg(rec->recordid);
+
+ QSqlQuery query = db->exec(thequery);
+
+ int paused = 0;
+ if (query.isActive())
+ if (query.numRowsAffected() > 0)
+ {
+ query.next();
+ paused = query.value(0).toInt();
+ if (paused)
+ paused = 0;
+ else
+ paused = 1;
+
+ QString theupdatequery;
+ theupdatequery = QString("UPDATE record SET paused = %1 WHERE recordid = %2")
+ .arg(paused).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->paused = paused;
+ } else
+ MythContext::DBError("Update recording schedule paused query", uquery);
+
+ }
+
+ QPainter p(this);
+ updateInfo(&p);
+ update(fullRect);
+ }
+}
+
void ProgramRecPriority::edit(void)
{
if (!curitem)
@@ -629,7 +690,8 @@
// it all at once than once per program)
QString query = QString("SELECT record.title, record.chanid, "
"record.starttime, record.startdate, "
- "record.type, channel.recpriority "
+ "record.type, channel.recpriority, "
+ "record.paused "
"FROM record "
"LEFT JOIN channel ON "
"(record.chanid = channel.chanid);");
@@ -651,6 +713,7 @@
RecordingType recType = (RecordingType)result.value(4).toInt();
int channelRecPriority = result.value(5).toInt();
int recTypeRecPriority = rtRecPriors[recType-1];
+ int paused = result.value(6).toInt();
// this is so kludgy
// since we key off of title+chanid+startts we have
@@ -684,6 +747,7 @@
progInfo->channelRecPriority = channelRecPriority;
progInfo->recTypeRecPriority = recTypeRecPriority;
progInfo->recType = recType;
+ progInfo->paused = paused;
matches++;
break;
}
@@ -882,6 +946,9 @@
ltype->SetItemCurrent(cnt);
}
+ if (progInfo->paused)
+ tempSubTitle += " [PAUSED]";
+
ltype->SetItemText(cnt, 1, tempSubTitle);
if (progRecPriority >= 0)
Index: mythtv/programs/mythfrontend/programrecpriority.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/programrecpriority.h,v
retrieving revision 1.10
diff -n -u -r1.10 programrecpriority.h
--- mythtv/programs/mythfrontend/programrecpriority.h 12 Sep 2004 23:21:14 -0000 1.10
+++ mythtv/programs/mythfrontend/programrecpriority.h 3 Dec 2004 05:36:57 -0000
@@ -47,6 +47,7 @@
void changeRecPriority(int howMuch);
void saveRecPriority(void);
void edit();
+ void pause();
void upcoming();
protected:
More information about the mythtv-dev
mailing list