21 return str.isEmpty() ?
"" : str;
31 m_findid(QDate(1970, 1, 1).daysTo(
MythDate::
current().toLocalTime().date())
63 query.
prepare(
"SELECT type, search, "
64 "recpriority, prefinput, startoffset, endoffset, dupmethod, dupin, "
65 "inactive, profile, recgroup, storagegroup, playgroup, autoexpire, "
66 "maxepisodes, maxnewest, autocommflag, autotranscode, transcoder, "
67 "autouserjob1, autouserjob2, autouserjob3, autouserjob4, "
68 "autometadata, parentid, title, subtitle, description, season, episode, "
69 "category, starttime, startdate, endtime, enddate, seriesid, programid, "
70 "inetref, chanid, station, findday, findtime, findid, "
71 "next_record, last_record, last_delete, avg_delay, filter, recgroupid, "
73 "FROM record WHERE recordid = :RECORDID ;");
97 (query.
value(6).toInt());
160 query.
value(30).toString() :
"";
218 const QString& forwhat, QString joininfo,
224 query.
prepare(
"SELECT recordid FROM record WHERE "
225 "search = :SEARCH AND description LIKE :FORWHAT");
232 rid = query.
value(0).toInt();
255 QString ltitle = QString(
"%1 (%2)").arg(textname, searchType);
265 .dayOfWeek() + 1) % 7;
267 m_findid = QDate(1970, 1, 1).daysTo(
278 const QString& category,
279 const QString& categoryType)
281 QString lcategory = category.isEmpty() ?
"Default" : category;
282 QString lcategoryType = categoryType.isEmpty() ?
"Default" : categoryType;
285 query.
prepare(
"SELECT recordid, category, "
286 " (category = :TITLE1) AS titlematch, "
287 " (category = :CAT1) AS catmatch, "
288 " (category = :CATTYPE1) AS typematch "
290 "WHERE type = :TEMPLATE AND "
291 " (category IN (:TITLE2, :CAT2, :CATTYPE2) "
292 " OR category = 'Default') "
293 "ORDER BY titlematch DESC, catmatch DESC, typematch DESC"
300 query.
bindValue(
":CATTYPE1", lcategoryType);
301 query.
bindValue(
":CATTYPE2", lcategoryType);
314 bool result =
Load(
true);
325 if (category.compare(tr(
"Default"), Qt::CaseInsensitive) == 0)
327 category =
"Default";
328 m_title = tr(
"Default (Template)");
334 m_title = tr(
"%1 (Template)").arg(category);
349 QString forwhat, QString joininfo)
358 QString ltitle = QString(
"%1 (%2)").arg(textname, tr(
"Power Search"));
393 QString sql =
"SET type = :TYPE, search = :SEARCHTYPE, "
394 "recpriority = :RECPRIORITY, prefinput = :INPUT, "
395 "startoffset = :STARTOFFSET, endoffset = :ENDOFFSET, "
396 "dupmethod = :DUPMETHOD, dupin = :DUPIN, "
397 "filter = :FILTER, autoextend = :AUTOEXTEND, "
398 "inactive = :INACTIVE, profile = :RECPROFILE, "
399 "recgroup = :RECGROUP, "
400 "recgroupid = :RECGROUPID, "
401 "storagegroup = :STORAGEGROUP, "
402 "playgroup = :PLAYGROUP, autoexpire = :AUTOEXPIRE, "
403 "maxepisodes = :MAXEPISODES, maxnewest = :MAXNEWEST, "
404 "autocommflag = :AUTOCOMMFLAG, "
405 "autotranscode = :AUTOTRANSCODE, "
406 "transcoder = :TRANSCODER, autouserjob1 = :AUTOUSERJOB1, "
407 "autouserjob2 = :AUTOUSERJOB2, "
408 "autouserjob3 = :AUTOUSERJOB3, "
409 "autouserjob4 = :AUTOUSERJOB4, "
410 "autometadata = :AUTOMETADATA, "
411 "parentid = :PARENTID, title = :TITLE, "
412 "subtitle = :SUBTITLE, season = :SEASON, episode = :EPISODE, "
413 "description = :DESCRIPTION, category = :CATEGORY, "
414 "starttime = :STARTTIME, startdate = :STARTDATE, "
415 "endtime = :ENDTIME, enddate = :ENDDATE, seriesid = :SERIESID, "
416 "programid = :PROGRAMID, inetref = :INETREF, chanid = :CHANID, "
417 "station = :STATION, findday = :FINDDAY, "
418 "findtime = :FINDTIME, findid = :FINDID, "
419 "next_record = :NEXTREC, last_record = :LASTREC, "
420 "last_delete = :LASTDELETE, avg_delay = :AVGDELAY ";
425 sqlquery = QString(
"UPDATE %1 %2 WHERE recordid = :RECORDID;")
430 sqlquery = QString(
"INSERT INTO %1 %2;").arg(
m_recordTable, sql);
505 QString(
"SaveRule %1").arg(
m_title));
516 query.
prepare(
"DELETE FROM record WHERE recordid = :RECORDID");
524 query.
prepare(
"DELETE FROM oldfind WHERE recordid = :RECORDID");
533 query.
prepare(
"DELETE FROM program WHERE manualid = :RECORDID");
543 QString(
"DeleteRule %1").arg(
m_title));
555 if (
m_title ==
"Default (Template)")
557 infoMap[
"title"] = tr(
"Default (Template)");
558 infoMap[
"sorttitle"] = tr(
"Default (Template)");
568 infoMap[
"season"] = QString::number(
m_season);
569 infoMap[
"episode"] = QString::number(
m_episode);
572 infoMap[
"category"] = tr(
"Default",
"category");
577#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
586#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
599#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
603 static const QTimeZone utc(QTimeZone::UTC);
608 int seconds = startts.secsTo(endts);
609 int minutes = seconds / 60;
610 int hours = minutes / 60;
611 minutes = minutes % 60;
613 infoMap[
"lenmins"] = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
616 QString minstring = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
619 QString hourstring = QCoreApplication::translate(
"(Common)",
"%n hour(s)",
625 infoMap[
"lentime"] = QCoreApplication::translate(
"(Common)",
"%1 %2",
626 "Hours and minutes").arg(hourstring, minstring);
630 infoMap[
"lentime"] = minstring;
638 infoMap[
"shorttimedate"] =
645#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
657 findfrom = QString(
"%1, %2")
661 infoMap[
"subtitle"] = tr(
"(%1 or later) %3",
662 "e.g. (Sunday or later) program "
692 infoMap[
"template"] = tr(
"Default",
"Default template");
705 query.
prepare(
"SELECT GET_LOCK(:LOCK, 2);");
706 query.
bindValue(
":LOCK",
"DiffSchedule");
713 query.
prepare(QString(
"DROP TABLE IF EXISTS %1;").arg(table));
720 query.
prepare(QString(
"CREATE TABLE %1 SELECT * FROM record;")
728 query.
prepare(QString(
"ALTER TABLE %1 MODIFY recordid int(10) "
729 "UNSIGNED NOT NULL AUTO_INCREMENT primary key;")
734 "auto-increment", query);
745 query.
prepare(
"SELECT RELEASE_LOCK(:LOCK);");
746 query.
bindValue(
":LOCK",
"DiffSchedule");
779 .dayOfWeek() + 1) % 7;
781 m_findid = QDate(1970, 1, 1).daysTo(
790 QDate epoch(1970, 1, 1);
810 query.
prepare(
"SELECT SUM(1 << filterid) FROM recordfilter "
811 "WHERE filterid >= 0 AND filterid < :NUMFILTERS AND "
812 " TRIM(clause) <> '' AND newruledefault <> 0");
823 return query.
value(0).toUInt();
828 QString searchTypeString;
833 searchTypeString =
"";
836 searchTypeString = tr(
"Power Search");
839 searchTypeString = tr(
"Title Search");
842 searchTypeString = tr(
"Keyword Search");
845 searchTypeString = tr(
"People Search");
848 searchTypeString = tr(
"Unknown Search");
852 return searchTypeString;
860 query.
prepare(
"SELECT category "
862 "WHERE type = :TEMPLATE "
863 "ORDER BY category = 'Default' DESC, category"
874 result << query.
value(0).toString();
881 bool isOverride =
false;
897 msg = QString(
"Invalid recording type.");
901 bool isNormal =
false;
902 bool isSearch =
false;
903 bool isManual =
false;
919 msg = QString(
"Invalid search type.");
930 msg = QString(
"Invalid recording type/search type.");
937 msg = QString(
"Invalid parentID/override.");
944 msg = QString(
"Invalid Inactive Override.");
950 msg = QString(
"Invalid title.");
958 msg = QString(
"Invalid SQL, contains semicolon");
962 query.
prepare(QString(
"SELECT NULL FROM (program, channel, oldrecorded AS oldrecstatus) "
963 "%1 WHERE %2 LIMIT 5")
967 msg = QString(
"Invalid SQL Where clause." + query.
lastError().databaseText());
975 msg = QString(
"Invalid search value.");
985 msg = QString(
"Invalid start/end date/time.");
988#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
992 static const QTimeZone utc(QTimeZone::UTC);
996 if (secsto <= 0 || secsto > (24 * 3600))
998 msg = QString(
"Invalid duration.");
1004 msg = QString(
"Invalid channel.");
1010 && (m_findday < 0 || m_findday > 6 || !
m_findtime.isValid()) )
1012 msg = QString(
"Invalid find values.");
1016 if (m_recPriority < -99 || m_recPriority > 99)
1018 msg = QString(
"Invalid priority.");
1022 if (m_startOffset < -480 || m_startOffset > 480 ||
1023 m_endOffset < -480 || m_endOffset > 480)
1025 msg = QString(
"Invalid start/end offset.");
1031 msg = QString(
"Invalid preferred input.");
1038 msg = QString(
"Invalid filter value.");
1045 msg = QString(
"Invalid group value.");
1051 msg = QString(
"Invalid max episodes value.");
1057 msg = QString(
"Invalid duplicate scope.");
1064 msg = QString(
"Invalid duplicate method.");
1070 msg = QString(
"Invalid transcoder value.");
1076 msg = QString(
"Invalid auto extend value.");
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
QSqlError lastError(void) const
QVariant value(int i) const
static MSqlQueryInfo SchedCon()
Returns dedicated connection. (Required for using temporary SQL tables.)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
QVariant lastInsertId()
Return the id of the last inserted row.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
static QString GetInitialName(const ProgramInfo *pi)
Holds information on recordings and videos.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
uint GetRecordingRuleID(void) const
QString GetSeriesID(void) const
QString GetCategoryTypeString(void) const
Returns catType as a string.
uint GetEpisode(void) const
QString GetProgramID(void) const
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
QString GetInetRef(void) const
QString GetSortSubtitle(void) const
QString GetDescription(void) const
QString GetTitle(void) const
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
uint GetFindID(void) const
QString GetSortTitle(void) const
QString GetSubtitle(void) const
QString GetCategory(void) const
uint GetSeason(void) const
QString GetChannelSchedulingID(void) const
This is the unique programming identifier of a channel.
static QString GetRecgroupString(uint recGroupID)
Temporary helper during transition from string to ID.
bool MakeTemplate(QString category)
void UseTempTable(bool usetemp, const QString &table="record_tmp")
int m_findday
Day of the week for once per week etc.
bool LoadTemplate(const QString &title, const QString &category="Default", const QString &categoryType="Default")
RecSearchType m_searchType
bool ModifyPowerSearchByID(int rid, const QString &textname, QString forwhat, QString joininfo="")
bool LoadByProgram(const ProgramInfo *proginfo)
bool IsValid(QString &msg) const
static unsigned GetDefaultFilter(void)
QTime m_findtime
Time for timeslot rules.
QDateTime m_nextRecording
static QString SearchTypeToString(RecSearchType searchType)
bool LoadBySearch(RecSearchType lsearch, const QString &textname, const QString &forwhat, QString joininfo="", ProgramInfo *pginfo=nullptr)
Load a recording rule based on search parameters.
int m_recordID
Unique Recording Rule ID.
RecordingDupInType m_dupIn
void ToMap(InfoMap &infoMap, uint date_format=0) const
void ensureSortFields(void)
Ensure that the sortTitle and sortSubtitle fields are set.
bool m_isInactive
Recording rule is enabled?
static QStringList GetTemplateNames(void)
bool Save(bool sendSig=true)
RecordingDupMethodType m_dupMethod
const ProgramInfo * m_progInfo
bool Load(bool asTemplate=false)
Load a single rule from the recorded table.
bool Delete(bool sendSig=true)
bool m_autoMetadataLookup
static const int kNumFilters
AutoExtendType m_autoExtend
static void RescheduleMatch(uint recordid, uint sourceid, uint mplexid, const QDateTime &maxstarttime, const QString &why)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
std::shared_ptr< MythSortHelper > getMythSortHelper(void)
Get a pointer to the MythSortHelper singleton.
QHash< QString, QString > InfoMap
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
@ kDateTimeFull
Default local time.
@ kSimplify
Do Today/Yesterday/Tomorrow transform.
@ kDateFull
Default local time.
@ kDateTimeShort
Default local time.
@ kTime
Default local time.
@ kAddYear
Add year to string if not included.
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
static QString null_to_empty(const QString &str)