Go to the documentation of this file.
21 return str.isEmpty() ?
"" : str;
31 m_findid(QDate(1970, 1, 1).daysTo(
MythDate::
current().toLocalTime().date())
65 "recpriority, prefinput, startoffset, endoffset, dupmethod, dupin, "
66 "inactive, profile, recgroup, storagegroup, playgroup, autoexpire, "
67 "maxepisodes, maxnewest, autocommflag, autotranscode, transcoder, "
68 "autouserjob1, autouserjob2, autouserjob3, autouserjob4, "
69 "autometadata, parentid, title, subtitle, description, season, episode, "
70 "category, starttime, startdate, endtime, enddate, seriesid, programid, "
71 "inetref, chanid, station, findday, findtime, findid, "
72 "next_record, last_record, last_delete, avg_delay, filter, recgroupid "
73 "FROM record WHERE recordid = :RECORDID ;");
214 const QString& forwhat, QString joininfo,
221 "search = :SEARCH AND description LIKE :FORWHAT");
251 QString ltitle = QString(
"%1 (%2)").arg(textname).arg(searchType);
261 .dayOfWeek() + 1) % 7;
263 m_findid = QDate(1970, 1, 1).daysTo(
276 QString lcategoryType = categoryType.isEmpty() ?
"Default" : categoryType;
280 " (category = :CAT1) AS catmatch, "
281 " (category = :CATTYPE1) AS typematch "
283 "WHERE type = :TEMPLATE AND "
284 " (category = :CAT2 OR category = :CATTYPE2 "
285 " OR category = 'Default') "
286 "ORDER BY catmatch DESC, typematch DESC"
305 bool result =
Load(
true);
316 if (
category.compare(tr(
"Default"), Qt::CaseInsensitive) == 0)
319 m_title = tr(
"Default (Template)");
340 QString forwhat, QString joininfo)
349 QString ltitle = QString(
"%1 (%2)").arg(textname)
350 .arg(tr(
"Power Search"));
385 QString sql =
"SET type = :TYPE, search = :SEARCHTYPE, "
386 "recpriority = :RECPRIORITY, prefinput = :INPUT, "
387 "startoffset = :STARTOFFSET, endoffset = :ENDOFFSET, "
388 "dupmethod = :DUPMETHOD, dupin = :DUPIN, "
390 "inactive = :INACTIVE, profile = :RECPROFILE, "
391 "recgroup = :RECGROUP, "
392 "recgroupid = :RECGROUPID, "
393 "storagegroup = :STORAGEGROUP, "
394 "playgroup = :PLAYGROUP, autoexpire = :AUTOEXPIRE, "
395 "maxepisodes = :MAXEPISODES, maxnewest = :MAXNEWEST, "
396 "autocommflag = :AUTOCOMMFLAG, "
397 "autotranscode = :AUTOTRANSCODE, "
398 "transcoder = :TRANSCODER, autouserjob1 = :AUTOUSERJOB1, "
399 "autouserjob2 = :AUTOUSERJOB2, "
400 "autouserjob3 = :AUTOUSERJOB3, "
401 "autouserjob4 = :AUTOUSERJOB4, "
402 "autometadata = :AUTOMETADATA, "
403 "parentid = :PARENTID, title = :TITLE, "
404 "subtitle = :SUBTITLE, season = :SEASON, episode = :EPISODE, "
405 "description = :DESCRIPTION, category = :CATEGORY, "
406 "starttime = :STARTTIME, startdate = :STARTDATE, "
407 "endtime = :ENDTIME, enddate = :ENDDATE, seriesid = :SERIESID, "
408 "programid = :PROGRAMID, inetref = :INETREF, chanid = :CHANID, "
409 "station = :STATION, findday = :FINDDAY, "
410 "findtime = :FINDTIME, findid = :FINDID, "
411 "next_record = :NEXTREC, last_record = :LASTREC, "
412 "last_delete = :LASTDELETE, avg_delay = :AVGDELAY ";
417 sqlquery = QString(
"UPDATE %1 %2 WHERE recordid = :RECORDID;")
422 sqlquery = QString(
"INSERT INTO %1 %2;").arg(
m_recordTable).arg(sql);
507 query.
prepare(
"DELETE FROM record WHERE recordid = :RECORDID");
515 query.
prepare(
"DELETE FROM oldfind WHERE recordid = :RECORDID");
524 query.
prepare(
"DELETE FROM program WHERE manualid = :RECORDID");
546 if (
m_title ==
"Default (Template)")
548 infoMap[
"title"] = tr(
"Default (Template)");
549 infoMap[
"sorttitle"] = tr(
"Default (Template)");
559 infoMap[
"season"] = QString::number(
m_season);
560 infoMap[
"episode"] = QString::number(
m_episode);
563 infoMap[
"category"] = tr(
"Default",
"category");
585 int seconds = startts.secsTo(endts);
586 int minutes = seconds / 60;
587 int hours = minutes / 60;
588 minutes = minutes % 60;
590 infoMap[
"lenmins"] = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
593 QString minstring = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
596 QString hourstring = QCoreApplication::translate(
"(Common)",
"%n hour(s)",
602 infoMap[
"lentime"] = QCoreApplication::translate(
"(Common)",
"%1 %2",
603 "Hours and minutes").arg(hourstring).arg(minstring);
606 infoMap[
"lentime"] = minstring;
613 infoMap[
"shorttimedate"] =
627 findfrom = QString(
"%1, %2")
631 infoMap[
"subtitle"] = tr(
"(%1 or later) %3",
632 "e.g. (Sunday or later) program "
633 "subtitle").arg(findfrom)
662 infoMap[
"template"] = tr(
"Default",
"Default template");
690 query.
prepare(QString(
"CREATE TABLE %1 SELECT * FROM record;")
698 query.
prepare(QString(
"ALTER TABLE %1 MODIFY recordid int(10) "
699 "UNSIGNED NOT NULL AUTO_INCREMENT primary key;")
704 "auto-increment",
query);
749 .dayOfWeek() + 1) % 7;
751 m_findid = QDate(1970, 1, 1).daysTo(
760 QDate epoch(1970, 1, 1);
780 query.
prepare(
"SELECT SUM(1 << filterid) FROM recordfilter "
781 "WHERE filterid >= 0 AND filterid < :NUMFILTERS AND "
782 " TRIM(clause) <> '' AND newruledefault <> 0");
798 QString searchTypeString;
803 searchTypeString =
"";
806 searchTypeString = tr(
"Power Search");
809 searchTypeString = tr(
"Title Search");
812 searchTypeString = tr(
"Keyword Search");
815 searchTypeString = tr(
"People Search");
818 searchTypeString = tr(
"Unknown Search");
822 return searchTypeString;
832 "WHERE type = :TEMPLATE "
833 "ORDER BY category = 'Default' DESC, category"
851 bool isOverride =
false;
867 msg = QString(
"Invalid recording type.");
871 bool isNormal =
false;
872 bool isSearch =
false;
873 bool isManual =
false;
889 msg = QString(
"Invalid search type.");
899 msg = QString(
"Invalid recording type/search type.");
906 msg = QString(
"Invalid parentID/override.");
912 msg = QString(
"Invalid title.");
919 query.
prepare(QString(
"SELECT NULL FROM (program, channel) "
924 msg = QString(
"Invalid custom search values.");
932 msg = QString(
"Invalid search value.");
942 msg = QString(
"Invalid start/end date/time.");
947 if (secsto <= 0 || secsto > (8 * 3600))
949 msg = QString(
"Invalid duration.");
955 msg = QString(
"Invalid channel.");
960 if (m_findday < 0 || m_findday > 6 || !
m_findtime.isValid())
962 msg = QString(
"Invalid find values.");
966 if (m_recPriority < -99 || m_recPriority > 99)
968 msg = QString(
"Invalid priority.");
972 if (m_startOffset < -480 || m_startOffset > 480 ||
973 m_endOffset < -480 || m_endOffset > 480)
975 msg = QString(
"Invalid start/end offset.");
981 msg = QString(
"Invalid preferred input.");
988 msg = QString(
"Invalid filter value.");
995 msg = QString(
"Invalid group value.");
1001 msg = QString(
"Invalid max episodes value.");
1007 msg = QString(
"Invalid duplicate scope.");
1014 msg = QString(
"Invalid duplicate method.");
1020 msg = QString(
"Invalid transcoder value.");
QString GetSortTitle(void) const
bool LoadTemplate(const QString &category, const QString &categoryType="Default")
bool LoadByProgram(const ProgramInfo *proginfo)
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool ModifyPowerSearchByID(int rid, const QString &textname, QString forwhat, QString joininfo="")
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
std::shared_ptr< MythSortHelper > getMythSortHelper(void)
Get a pointer to the MythSortHelper singleton.
bool Save(bool sendSig=true)
QDateTime m_nextRecording
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
static QString GetInitialName(const ProgramInfo *pi)
static unsigned GetDefaultFilter(void)
const ProgramInfo * m_progInfo
QVariant lastInsertId()
Return the id of the last inserted row.
QVariant value(int i) const
arg(title).arg(filename).arg(doDelete))
QString GetChannelSchedulingID(void) const
This is the unique programming identifier of a channel.
QString GetCategory(void) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
static const int kNumFilters
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
RecordingDupInType m_dupIn
bool m_isInactive
Recording rule is enabled?
@ kDateTimeShort
Default local time.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
QHash< QString, QString > InfoMap
bool Load(bool asTemplate=false)
Load a single rule from the recorded table.
QString GetInetRef(void) const
static QStringList GetTemplateNames(void)
QString toString(MarkTypes type)
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
bool IsValid(QString &msg) const
static QString GetRecgroupString(uint recGroupID)
Temporary helper during transition from string to ID.
QString GetTitle(void) const
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
QString GetDescription(void) const
static void DBError(const QString &where, const MSqlQuery &query)
QTime m_findtime
callsign?
RecSearchType m_searchType
void UseTempTable(bool usetemp, const QString &table="record_tmp")
static MSqlQueryInfo SchedCon()
Returns dedicated connection. (Required for using temporary SQL tables.)
int m_findday
Day of the week for once per week etc.
uint GetFindID(void) const
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
QString GetSeriesID(void) const
bool MakeTemplate(QString category)
QString GetSortSubtitle(void) const
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
@ kSimplify
Do Today/Yesterday/Tomorrow transform.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
uint GetEpisode(void) const
Holds information on recordings and videos.
void ToMap(InfoMap &infoMap) const
int m_recordID
Unique Recording Rule ID.
@ kAddYear
Add year to string if not included.
uint GetSeason(void) const
RecordingDupMethodType m_dupMethod
QString GetCategoryTypeString(void) const
Returns catType as a string.
void ensureSortFields(void)
Ensure that the sortTitle and sortSubtitle fields are set.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
bool Delete(bool sendSig=true)
@ kDateFull
Default local time.
QString GetProgramID(void) const
@ kDateTimeFull
Default local time.
@ kTime
Default local time.
uint GetRecordingRuleID(void) const
static void RescheduleMatch(uint recordid, uint sourceid, uint mplexid, const QDateTime &maxstarttime, const QString &why)
bool LoadBySearch(RecSearchType lsearch, const QString &textname, const QString &forwhat, QString joininfo="", ProgramInfo *pginfo=nullptr)
Load a recording rule based on search parameters.
MSqlQuery query(MSqlQuery::InitCon())
bool m_autoMetadataLookup
static QString null_to_empty(const QString &str)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
static QString SearchTypeToString(RecSearchType searchType)
QString GetSubtitle(void) const