Go to the documentation of this file.
19 return str.isEmpty() ?
"" : str;
29 m_findid(QDate(1970, 1, 1).daysTo(
MythDate::
current().toLocalTime().date())
62 query.
prepare(
"SELECT type, search, "
63 "recpriority, prefinput, startoffset, endoffset, dupmethod, dupin, "
64 "inactive, profile, recgroup, storagegroup, playgroup, autoexpire, "
65 "maxepisodes, maxnewest, autocommflag, autotranscode, transcoder, "
66 "autouserjob1, autouserjob2, autouserjob3, autouserjob4, "
67 "autometadata, parentid, title, subtitle, description, season, episode, "
68 "category, starttime, startdate, endtime, enddate, seriesid, programid, "
69 "inetref, chanid, station, findday, findtime, findid, "
70 "next_record, last_record, last_delete, avg_delay, filter, recgroupid, "
72 "FROM record WHERE recordid = :RECORDID ;");
96 (query.
value(6).toInt());
159 query.
value(30).toString() :
"";
215 const QString& forwhat, QString joininfo,
221 query.
prepare(
"SELECT recordid FROM record WHERE "
222 "search = :SEARCH AND description LIKE :FORWHAT");
229 rid = query.
value(0).toInt();
252 QString ltitle = QString(
"%1 (%2)").arg(textname, searchType);
262 .dayOfWeek() + 1) % 7;
264 m_findid = QDate(1970, 1, 1).daysTo(
275 const QString& category,
276 const QString& categoryType)
278 QString lcategory = category.isEmpty() ?
"Default" : category;
279 QString lcategoryType = categoryType.isEmpty() ?
"Default" : categoryType;
282 query.
prepare(
"SELECT recordid, category, "
283 " (category = :TITLE1) AS titlematch, "
284 " (category = :CAT1) AS catmatch, "
285 " (category = :CATTYPE1) AS typematch "
287 "WHERE type = :TEMPLATE AND "
288 " (category IN (:TITLE2, :CAT2, :CATTYPE2) "
289 " OR category = 'Default') "
290 "ORDER BY titlematch DESC, catmatch DESC, typematch DESC"
297 query.
bindValue(
":CATTYPE1", lcategoryType);
298 query.
bindValue(
":CATTYPE2", lcategoryType);
311 bool result =
Load(
true);
322 if (category.compare(tr(
"Default"), Qt::CaseInsensitive) == 0)
324 category =
"Default";
325 m_title = tr(
"Default (Template)");
331 m_title = tr(
"%1 (Template)").arg(category);
346 QString forwhat, QString joininfo)
355 QString ltitle = QString(
"%1 (%2)").arg(textname, tr(
"Power Search"));
390 QString sql =
"SET type = :TYPE, search = :SEARCHTYPE, "
391 "recpriority = :RECPRIORITY, prefinput = :INPUT, "
392 "startoffset = :STARTOFFSET, endoffset = :ENDOFFSET, "
393 "dupmethod = :DUPMETHOD, dupin = :DUPIN, "
394 "filter = :FILTER, autoextend = :AUTOEXTEND, "
395 "inactive = :INACTIVE, profile = :RECPROFILE, "
396 "recgroup = :RECGROUP, "
397 "recgroupid = :RECGROUPID, "
398 "storagegroup = :STORAGEGROUP, "
399 "playgroup = :PLAYGROUP, autoexpire = :AUTOEXPIRE, "
400 "maxepisodes = :MAXEPISODES, maxnewest = :MAXNEWEST, "
401 "autocommflag = :AUTOCOMMFLAG, "
402 "autotranscode = :AUTOTRANSCODE, "
403 "transcoder = :TRANSCODER, autouserjob1 = :AUTOUSERJOB1, "
404 "autouserjob2 = :AUTOUSERJOB2, "
405 "autouserjob3 = :AUTOUSERJOB3, "
406 "autouserjob4 = :AUTOUSERJOB4, "
407 "autometadata = :AUTOMETADATA, "
408 "parentid = :PARENTID, title = :TITLE, "
409 "subtitle = :SUBTITLE, season = :SEASON, episode = :EPISODE, "
410 "description = :DESCRIPTION, category = :CATEGORY, "
411 "starttime = :STARTTIME, startdate = :STARTDATE, "
412 "endtime = :ENDTIME, enddate = :ENDDATE, seriesid = :SERIESID, "
413 "programid = :PROGRAMID, inetref = :INETREF, chanid = :CHANID, "
414 "station = :STATION, findday = :FINDDAY, "
415 "findtime = :FINDTIME, findid = :FINDID, "
416 "next_record = :NEXTREC, last_record = :LASTREC, "
417 "last_delete = :LASTDELETE, avg_delay = :AVGDELAY ";
422 sqlquery = QString(
"UPDATE %1 %2 WHERE recordid = :RECORDID;")
427 sqlquery = QString(
"INSERT INTO %1 %2;").arg(
m_recordTable, sql);
502 QString(
"SaveRule %1").arg(
m_title));
513 query.
prepare(
"DELETE FROM record WHERE recordid = :RECORDID");
521 query.
prepare(
"DELETE FROM oldfind WHERE recordid = :RECORDID");
530 query.
prepare(
"DELETE FROM program WHERE manualid = :RECORDID");
540 QString(
"DeleteRule %1").arg(
m_title));
552 if (
m_title ==
"Default (Template)")
554 infoMap[
"title"] = tr(
"Default (Template)");
555 infoMap[
"sorttitle"] = tr(
"Default (Template)");
565 infoMap[
"season"] = QString::number(
m_season);
566 infoMap[
"episode"] = QString::number(
m_episode);
569 infoMap[
"category"] = tr(
"Default",
"category");
591 int seconds = startts.secsTo(endts);
592 int minutes = seconds / 60;
593 int hours = minutes / 60;
594 minutes = minutes % 60;
596 infoMap[
"lenmins"] = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
599 QString minstring = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
602 QString hourstring = QCoreApplication::translate(
"(Common)",
"%n hour(s)",
608 infoMap[
"lentime"] = QCoreApplication::translate(
"(Common)",
"%1 %2",
609 "Hours and minutes").arg(hourstring, minstring);
612 infoMap[
"lentime"] = minstring;
619 infoMap[
"shorttimedate"] =
633 findfrom = QString(
"%1, %2")
637 infoMap[
"subtitle"] = tr(
"(%1 or later) %3",
638 "e.g. (Sunday or later) program "
668 infoMap[
"template"] = tr(
"Default",
"Default template");
681 query.
prepare(
"SELECT GET_LOCK(:LOCK, 2);");
682 query.
bindValue(
":LOCK",
"DiffSchedule");
689 query.
prepare(QString(
"DROP TABLE IF EXISTS %1;").arg(table));
696 query.
prepare(QString(
"CREATE TABLE %1 SELECT * FROM record;")
704 query.
prepare(QString(
"ALTER TABLE %1 MODIFY recordid int(10) "
705 "UNSIGNED NOT NULL AUTO_INCREMENT primary key;")
710 "auto-increment", query);
721 query.
prepare(
"SELECT RELEASE_LOCK(:LOCK);");
722 query.
bindValue(
":LOCK",
"DiffSchedule");
755 .dayOfWeek() + 1) % 7;
757 m_findid = QDate(1970, 1, 1).daysTo(
766 QDate epoch(1970, 1, 1);
786 query.
prepare(
"SELECT SUM(1 << filterid) FROM recordfilter "
787 "WHERE filterid >= 0 AND filterid < :NUMFILTERS AND "
788 " TRIM(clause) <> '' AND newruledefault <> 0");
799 return query.
value(0).toUInt();
804 QString searchTypeString;
809 searchTypeString =
"";
812 searchTypeString = tr(
"Power Search");
815 searchTypeString = tr(
"Title Search");
818 searchTypeString = tr(
"Keyword Search");
821 searchTypeString = tr(
"People Search");
824 searchTypeString = tr(
"Unknown Search");
828 return searchTypeString;
836 query.
prepare(
"SELECT category "
838 "WHERE type = :TEMPLATE "
839 "ORDER BY category = 'Default' DESC, category"
850 result << query.
value(0).toString();
857 bool isOverride =
false;
873 msg = QString(
"Invalid recording type.");
877 bool isNormal =
false;
878 bool isSearch =
false;
879 bool isManual =
false;
895 msg = QString(
"Invalid search type.");
905 msg = QString(
"Invalid recording type/search type.");
912 msg = QString(
"Invalid parentID/override.");
918 msg = QString(
"Invalid title.");
925 query.
prepare(QString(
"SELECT NULL FROM (program, channel) "
930 msg = QString(
"Invalid custom search values.");
938 msg = QString(
"Invalid search value.");
948 msg = QString(
"Invalid start/end date/time.");
953 if (secsto <= 0 || secsto > (8 * 3600))
955 msg = QString(
"Invalid duration.");
961 msg = QString(
"Invalid channel.");
966 if (m_findday < 0 || m_findday > 6 || !
m_findtime.isValid())
968 msg = QString(
"Invalid find values.");
972 if (m_recPriority < -99 || m_recPriority > 99)
974 msg = QString(
"Invalid priority.");
978 if (m_startOffset < -480 || m_startOffset > 480 ||
979 m_endOffset < -480 || m_endOffset > 480)
981 msg = QString(
"Invalid start/end offset.");
987 msg = QString(
"Invalid preferred input.");
994 msg = QString(
"Invalid filter value.");
1001 msg = QString(
"Invalid group value.");
1007 msg = QString(
"Invalid max episodes value.");
1013 msg = QString(
"Invalid duplicate scope.");
1020 msg = QString(
"Invalid duplicate method.");
1026 msg = QString(
"Invalid transcoder value.");
1032 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
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.
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