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() :
"";
217 const QString& forwhat, QString joininfo,
223 query.
prepare(
"SELECT recordid FROM record WHERE "
224 "search = :SEARCH AND description LIKE :FORWHAT");
231 rid = query.
value(0).toInt();
254 QString ltitle = QString(
"%1 (%2)").arg(textname, searchType);
264 .dayOfWeek() + 1) % 7;
266 m_findid = QDate(1970, 1, 1).daysTo(
277 const QString& category,
278 const QString& categoryType)
280 QString lcategory = category.isEmpty() ?
"Default" : category;
281 QString lcategoryType = categoryType.isEmpty() ?
"Default" : categoryType;
284 query.
prepare(
"SELECT recordid, category, "
285 " (category = :TITLE1) AS titlematch, "
286 " (category = :CAT1) AS catmatch, "
287 " (category = :CATTYPE1) AS typematch "
289 "WHERE type = :TEMPLATE AND "
290 " (category IN (:TITLE2, :CAT2, :CATTYPE2) "
291 " OR category = 'Default') "
292 "ORDER BY titlematch DESC, catmatch DESC, typematch DESC"
299 query.
bindValue(
":CATTYPE1", lcategoryType);
300 query.
bindValue(
":CATTYPE2", lcategoryType);
313 bool result =
Load(
true);
324 if (category.compare(tr(
"Default"), Qt::CaseInsensitive) == 0)
326 category =
"Default";
327 m_title = tr(
"Default (Template)");
333 m_title = tr(
"%1 (Template)").arg(category);
348 QString forwhat, QString joininfo)
357 QString ltitle = QString(
"%1 (%2)").arg(textname, tr(
"Power Search"));
392 QString sql =
"SET type = :TYPE, search = :SEARCHTYPE, "
393 "recpriority = :RECPRIORITY, prefinput = :INPUT, "
394 "startoffset = :STARTOFFSET, endoffset = :ENDOFFSET, "
395 "dupmethod = :DUPMETHOD, dupin = :DUPIN, "
396 "filter = :FILTER, autoextend = :AUTOEXTEND, "
397 "inactive = :INACTIVE, profile = :RECPROFILE, "
398 "recgroup = :RECGROUP, "
399 "recgroupid = :RECGROUPID, "
400 "storagegroup = :STORAGEGROUP, "
401 "playgroup = :PLAYGROUP, autoexpire = :AUTOEXPIRE, "
402 "maxepisodes = :MAXEPISODES, maxnewest = :MAXNEWEST, "
403 "autocommflag = :AUTOCOMMFLAG, "
404 "autotranscode = :AUTOTRANSCODE, "
405 "transcoder = :TRANSCODER, autouserjob1 = :AUTOUSERJOB1, "
406 "autouserjob2 = :AUTOUSERJOB2, "
407 "autouserjob3 = :AUTOUSERJOB3, "
408 "autouserjob4 = :AUTOUSERJOB4, "
409 "autometadata = :AUTOMETADATA, "
410 "parentid = :PARENTID, title = :TITLE, "
411 "subtitle = :SUBTITLE, season = :SEASON, episode = :EPISODE, "
412 "description = :DESCRIPTION, category = :CATEGORY, "
413 "starttime = :STARTTIME, startdate = :STARTDATE, "
414 "endtime = :ENDTIME, enddate = :ENDDATE, seriesid = :SERIESID, "
415 "programid = :PROGRAMID, inetref = :INETREF, chanid = :CHANID, "
416 "station = :STATION, findday = :FINDDAY, "
417 "findtime = :FINDTIME, findid = :FINDID, "
418 "next_record = :NEXTREC, last_record = :LASTREC, "
419 "last_delete = :LASTDELETE, avg_delay = :AVGDELAY ";
424 sqlquery = QString(
"UPDATE %1 %2 WHERE recordid = :RECORDID;")
429 sqlquery = QString(
"INSERT INTO %1 %2;").arg(
m_recordTable, sql);
504 QString(
"SaveRule %1").arg(
m_title));
515 query.
prepare(
"DELETE FROM record WHERE recordid = :RECORDID");
523 query.
prepare(
"DELETE FROM oldfind WHERE recordid = :RECORDID");
532 query.
prepare(
"DELETE FROM program WHERE manualid = :RECORDID");
542 QString(
"DeleteRule %1").arg(
m_title));
554 if (
m_title ==
"Default (Template)")
556 infoMap[
"title"] = tr(
"Default (Template)");
557 infoMap[
"sorttitle"] = tr(
"Default (Template)");
567 infoMap[
"season"] = QString::number(
m_season);
568 infoMap[
"episode"] = QString::number(
m_episode);
571 infoMap[
"category"] = tr(
"Default",
"category");
593 int seconds = startts.secsTo(endts);
594 int minutes = seconds / 60;
595 int hours = minutes / 60;
596 minutes = minutes % 60;
598 infoMap[
"lenmins"] = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
601 QString minstring = QCoreApplication::translate(
"(Common)",
"%n minute(s)",
604 QString hourstring = QCoreApplication::translate(
"(Common)",
"%n hour(s)",
610 infoMap[
"lentime"] = QCoreApplication::translate(
"(Common)",
"%1 %2",
611 "Hours and minutes").arg(hourstring, minstring);
615 infoMap[
"lentime"] = minstring;
623 infoMap[
"shorttimedate"] =
637 findfrom = QString(
"%1, %2")
641 infoMap[
"subtitle"] = tr(
"(%1 or later) %3",
642 "e.g. (Sunday or later) program "
672 infoMap[
"template"] = tr(
"Default",
"Default template");
685 query.
prepare(
"SELECT GET_LOCK(:LOCK, 2);");
686 query.
bindValue(
":LOCK",
"DiffSchedule");
693 query.
prepare(QString(
"DROP TABLE IF EXISTS %1;").arg(table));
700 query.
prepare(QString(
"CREATE TABLE %1 SELECT * FROM record;")
708 query.
prepare(QString(
"ALTER TABLE %1 MODIFY recordid int(10) "
709 "UNSIGNED NOT NULL AUTO_INCREMENT primary key;")
714 "auto-increment", query);
725 query.
prepare(
"SELECT RELEASE_LOCK(:LOCK);");
726 query.
bindValue(
":LOCK",
"DiffSchedule");
759 .dayOfWeek() + 1) % 7;
761 m_findid = QDate(1970, 1, 1).daysTo(
770 QDate epoch(1970, 1, 1);
790 query.
prepare(
"SELECT SUM(1 << filterid) FROM recordfilter "
791 "WHERE filterid >= 0 AND filterid < :NUMFILTERS AND "
792 " TRIM(clause) <> '' AND newruledefault <> 0");
803 return query.
value(0).toUInt();
808 QString searchTypeString;
813 searchTypeString =
"";
816 searchTypeString = tr(
"Power Search");
819 searchTypeString = tr(
"Title Search");
822 searchTypeString = tr(
"Keyword Search");
825 searchTypeString = tr(
"People Search");
828 searchTypeString = tr(
"Unknown Search");
832 return searchTypeString;
840 query.
prepare(
"SELECT category "
842 "WHERE type = :TEMPLATE "
843 "ORDER BY category = 'Default' DESC, category"
854 result << query.
value(0).toString();
861 bool isOverride =
false;
877 msg = QString(
"Invalid recording type.");
881 bool isNormal =
false;
882 bool isSearch =
false;
883 bool isManual =
false;
899 msg = QString(
"Invalid search type.");
909 msg = QString(
"Invalid recording type/search type.");
916 msg = QString(
"Invalid parentID/override.");
923 msg = QString(
"Invalid Inactive Override.");
929 msg = QString(
"Invalid title.");
937 msg = QString(
"Invalid SQL, contains semicolon");
941 query.
prepare(QString(
"SELECT NULL FROM (program, channel, oldrecorded AS oldrecstatus) "
942 "%1 WHERE %2 LIMIT 5")
946 msg = QString(
"Invalid SQL Where clause." + query.
lastError().databaseText());
954 msg = QString(
"Invalid search value.");
964 msg = QString(
"Invalid start/end date/time.");
969 if (secsto <= 0 || secsto > (8 * 3600))
971 msg = QString(
"Invalid duration.");
977 msg = QString(
"Invalid channel.");
983 && (m_findday < 0 || m_findday > 6 || !
m_findtime.isValid()) )
985 msg = QString(
"Invalid find values.");
989 if (m_recPriority < -99 || m_recPriority > 99)
991 msg = QString(
"Invalid priority.");
995 if (m_startOffset < -480 || m_startOffset > 480 ||
996 m_endOffset < -480 || m_endOffset > 480)
998 msg = QString(
"Invalid start/end offset.");
1004 msg = QString(
"Invalid preferred input.");
1011 msg = QString(
"Invalid filter value.");
1018 msg = QString(
"Invalid group value.");
1024 msg = QString(
"Invalid max episodes value.");
1030 msg = QString(
"Invalid duplicate scope.");
1037 msg = QString(
"Invalid duplicate method.");
1043 msg = QString(
"Invalid transcoder value.");
1049 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