Go to the documentation of this file.
21 return str.isEmpty() ?
"" : str;
31 m_findid(QDate(1970, 1, 1).daysTo(
MythDate::
current().toLocalTime().date())
64 query.
prepare(
"SELECT type, search, "
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, "
74 "FROM record WHERE recordid = :RECORDID ;");
98 (query.
value(6).toInt());
161 query.
value(30).toString() :
"";
219 const QString& forwhat, QString joininfo,
225 query.
prepare(
"SELECT recordid FROM record WHERE "
226 "search = :SEARCH AND description LIKE :FORWHAT");
233 rid = query.
value(0).toInt();
256 QString ltitle = QString(
"%1 (%2)").arg(textname, searchType);
266 .dayOfWeek() + 1) % 7;
268 m_findid = QDate(1970, 1, 1).daysTo(
279 const QString& category,
280 const QString& categoryType)
282 QString lcategory = category.isEmpty() ?
"Default" : category;
283 QString lcategoryType = categoryType.isEmpty() ?
"Default" : categoryType;
286 query.
prepare(
"SELECT recordid, category, "
287 " (category = :TITLE1) AS titlematch, "
288 " (category = :CAT1) AS catmatch, "
289 " (category = :CATTYPE1) AS typematch "
291 "WHERE type = :TEMPLATE AND "
292 " (category IN (:TITLE2, :CAT2, :CATTYPE2) "
293 " OR category = 'Default') "
294 "ORDER BY titlematch DESC, catmatch DESC, typematch DESC"
301 query.
bindValue(
":CATTYPE1", lcategoryType);
302 query.
bindValue(
":CATTYPE2", lcategoryType);
315 bool result =
Load(
true);
326 if (category.compare(tr(
"Default"), Qt::CaseInsensitive) == 0)
328 category =
"Default";
329 m_title = tr(
"Default (Template)");
335 m_title = tr(
"%1 (Template)").arg(category);
350 QString forwhat, QString joininfo)
359 QString ltitle = QString(
"%1 (%2)").arg(textname, tr(
"Power Search"));
394 QString sql =
"SET type = :TYPE, search = :SEARCHTYPE, "
395 "recpriority = :RECPRIORITY, prefinput = :INPUT, "
396 "startoffset = :STARTOFFSET, endoffset = :ENDOFFSET, "
397 "dupmethod = :DUPMETHOD, dupin = :DUPIN, "
398 "filter = :FILTER, autoextend = :AUTOEXTEND, "
399 "inactive = :INACTIVE, profile = :RECPROFILE, "
400 "recgroup = :RECGROUP, "
401 "recgroupid = :RECGROUPID, "
402 "storagegroup = :STORAGEGROUP, "
403 "playgroup = :PLAYGROUP, autoexpire = :AUTOEXPIRE, "
404 "maxepisodes = :MAXEPISODES, maxnewest = :MAXNEWEST, "
405 "autocommflag = :AUTOCOMMFLAG, "
406 "autotranscode = :AUTOTRANSCODE, "
407 "transcoder = :TRANSCODER, autouserjob1 = :AUTOUSERJOB1, "
408 "autouserjob2 = :AUTOUSERJOB2, "
409 "autouserjob3 = :AUTOUSERJOB3, "
410 "autouserjob4 = :AUTOUSERJOB4, "
411 "autometadata = :AUTOMETADATA, "
412 "parentid = :PARENTID, title = :TITLE, "
413 "subtitle = :SUBTITLE, season = :SEASON, episode = :EPISODE, "
414 "description = :DESCRIPTION, category = :CATEGORY, "
415 "starttime = :STARTTIME, startdate = :STARTDATE, "
416 "endtime = :ENDTIME, enddate = :ENDDATE, seriesid = :SERIESID, "
417 "programid = :PROGRAMID, inetref = :INETREF, chanid = :CHANID, "
418 "station = :STATION, findday = :FINDDAY, "
419 "findtime = :FINDTIME, findid = :FINDID, "
420 "next_record = :NEXTREC, last_record = :LASTREC, "
421 "last_delete = :LASTDELETE, avg_delay = :AVGDELAY ";
426 sqlquery = QString(
"UPDATE %1 %2 WHERE recordid = :RECORDID;")
431 sqlquery = QString(
"INSERT INTO %1 %2;").arg(
m_recordTable, sql);
506 QString(
"SaveRule %1").arg(
m_title));
517 query.
prepare(
"DELETE FROM record WHERE recordid = :RECORDID");
525 query.
prepare(
"DELETE FROM oldfind WHERE recordid = :RECORDID");
534 query.
prepare(
"DELETE FROM program WHERE manualid = :RECORDID");
544 QString(
"DeleteRule %1").arg(
m_title));
556 if (
m_title ==
"Default (Template)")
558 infoMap[
"title"] = tr(
"Default (Template)");
559 infoMap[
"sorttitle"] = tr(
"Default (Template)");
569 infoMap[
"season"] = QString::number(
m_season);
570 infoMap[
"episode"] = QString::number(
m_episode);
573 infoMap[
"category"] = tr(
"Default",
"category");
578 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
587 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
600 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
604 static const QTimeZone utc(QTimeZone::UTC);
609 int seconds = startts.secsTo(endts);
610 int minutes = seconds / 60;
611 int hours = minutes / 60;
612 minutes = minutes % 60;
614 infoMap[
"lenmins"] = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
617 QString minstring = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
620 QString hourstring = QCoreApplication::translate(
"(Common)",
"%n hour(s)",
626 infoMap[
"lentime"] = QCoreApplication::translate(
"(Common)",
"%1 %2",
627 "Hours and minutes").arg(hourstring, minstring);
631 infoMap[
"lentime"] = minstring;
639 infoMap[
"shorttimedate"] =
646 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
658 findfrom = QString(
"%1, %2")
662 infoMap[
"subtitle"] = tr(
"(%1 or later) %3",
663 "e.g. (Sunday or later) program "
693 infoMap[
"template"] = tr(
"Default",
"Default template");
706 query.
prepare(
"SELECT GET_LOCK(:LOCK, 2);");
707 query.
bindValue(
":LOCK",
"DiffSchedule");
714 query.
prepare(QString(
"DROP TABLE IF EXISTS %1;").arg(table));
721 query.
prepare(QString(
"CREATE TABLE %1 SELECT * FROM record;")
729 query.
prepare(QString(
"ALTER TABLE %1 MODIFY recordid int(10) "
730 "UNSIGNED NOT NULL AUTO_INCREMENT primary key;")
735 "auto-increment", query);
746 query.
prepare(
"SELECT RELEASE_LOCK(:LOCK);");
747 query.
bindValue(
":LOCK",
"DiffSchedule");
780 .dayOfWeek() + 1) % 7;
782 m_findid = QDate(1970, 1, 1).daysTo(
791 QDate epoch(1970, 1, 1);
811 query.
prepare(
"SELECT SUM(1 << filterid) FROM recordfilter "
812 "WHERE filterid >= 0 AND filterid < :NUMFILTERS AND "
813 " TRIM(clause) <> '' AND newruledefault <> 0");
824 return query.
value(0).toUInt();
829 QString searchTypeString;
834 searchTypeString =
"";
837 searchTypeString = tr(
"Power Search");
840 searchTypeString = tr(
"Title Search");
843 searchTypeString = tr(
"Keyword Search");
846 searchTypeString = tr(
"People Search");
849 searchTypeString = tr(
"Unknown Search");
853 return searchTypeString;
861 query.
prepare(
"SELECT category "
863 "WHERE type = :TEMPLATE "
864 "ORDER BY category = 'Default' DESC, category"
875 result << query.
value(0).toString();
882 bool isOverride =
false;
898 msg = QString(
"Invalid recording type.");
902 bool isNormal =
false;
903 bool isSearch =
false;
904 bool isManual =
false;
920 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 > (8 * 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.");
QString GetSortTitle(void) const
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
void ToMap(InfoMap &infoMap, uint date_format=0) const
QVariant lastInsertId()
Return the id of the last inserted row.
QVariant value(int i) const
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)
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
bool IsValid(QString &msg) const
QString doTitle(const QString &title) const
Create the sortable form of an title string.
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
Time for timeslot rules.
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.
QSqlError lastError(void) const
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.
bool LoadTemplate(const QString &title, const QString &category="Default", const QString &categoryType="Default")
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.
AutoExtendType m_autoExtend
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.
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