Go to the documentation of this file.
62 LOG(VB_GENERAL, LOG_ERR,
63 "CustomPriority, theme is missing required elements");
93 QString quoteTitle = baseTitle;
94 quoteTitle.replace(
"\'",
"\'\'");
100 rule.
priority = QString().setNum(1);
103 QVariant::fromValue(rule));
106 result.
prepare(
"SELECT priorityname, recpriority, selectclause "
107 "FROM powerpriority ORDER BY priorityname;");
112 while (result.
next())
114 QString trimTitle = result.
value(0).toString();
117 rule.
title = trimTitle;
122 QVariant::fromValue(rule));
124 if (trimTitle == baseTitle)
153 QMap<QString, QString> examples;
154 examples.insert(tr(
"Modify priority for an input (Input priority)"),
155 "capturecard.cardid = 1");
156 examples.insert(tr(
"Modify priority for every card on a host"),
157 "capturecard.hostname = 'mythbox'");
158 examples.insert(tr(
"Only one specific channel ID (Channel priority)"),
159 "channel.chanid = '1003' ");
160 examples.insert(tr(
"Only a certain channel number"),
161 "channel.channum = '3' ");
162 examples.insert(tr(
"Only channels that carry a specific station"),
163 "channel.callsign = 'ESPN' ");
164 examples.insert(tr(
"Match related callsigns"),
165 "channel.callsign LIKE 'HBO%' ");
166 examples.insert(tr(
"Only channels marked as commercial free"),
167 QString(
"channel.commmethod = %1 ")
169 examples.insert(tr(
"Modify priority for a station on an input"),
170 "channel.callsign = 'ESPN' AND capturecard.cardid = 2");
171 examples.insert(tr(
"Priority for all matching titles"),
172 "program.title LIKE 'CSI: %' ");
173 examples.insert(tr(
"Only shows marked as HDTV"),
174 "program.hdtv > 0 ");
175 examples.insert(tr(
"Close Captioned priority"),
176 "program.closecaptioned > 0 ");
177 examples.insert(tr(
"New episodes only"),
178 "program.previouslyshown = 0 ");
179 examples.insert(tr(
"Modify unidentified episodes"),
180 "program.generic = 0 ");
181 examples.insert(tr(
"First showing of each episode"),
182 "program.first > 0 ");
183 examples.insert(tr(
"Last showing of each episode"),
184 "program.last > 0 ");
185 examples.insert(tr(
"Priority for any show with End Late time"),
186 "RECTABLE.endoffset > 0 ");
187 examples.insert(tr(
"Priority for a category"),
188 "program.category = 'Reality' ");
189 examples.insert(QString(
"%1 ('movie', 'series', 'sports', 'tvshow')")
190 .arg(tr(
"Priority for a category type")),
191 "program.category_type = 'sports' ");
192 examples.insert(tr(
"Modify priority by star rating (0.0 to 1.0 for "
194 "program.stars >= 0.75 ");
195 examples.insert(tr(
"Priority when shown once (complete example)"),
196 "program.first > 0 AND program.last > 0");
197 examples.insert(tr(
"Prefer a host for a storage group (complete example)"),
198 QString(
"RECTABLE.storagegroup = 'Archive' "
199 "AND capturecard.hostname = 'mythbox' "));
200 examples.insert(tr(
"Priority for HD shows under two hours (complete "
202 "program.hdtv > 0 AND program.starttime > "
203 "DATE_SUB(program.endtime, INTERVAL 2 HOUR) ");
204 examples.insert(tr(
"Priority for movies by the year of release (complete "
206 "program.category_type = 'movie' "
207 "AND program.airdate >= 2006 ");
208 examples.insert(tr(
"Prefer movies when shown at night (complete example)"),
209 "program.category_type = 'movie' "
210 "AND HOUR(program.starttime) < 6 ");
211 examples.insert(tr(
"Prefer a host for live sports with overtime (complete "
213 "RECTABLE.endoffset > 0 "
214 "AND program.category = 'Sports event' "
215 "AND capturecard.hostname = 'mythbox' ");
216 examples.insert(tr(
"Avoid poor signal quality (complete example)"),
217 "capturecard.cardid = 1 AND "
218 "channel.channum IN (3, 5, 39, 66) ");
220 QMapIterator<QString, QString> it(examples);
225 QVariant::fromValue(it.value()));
264 static const QRegularExpression kNonWhiteSpaceRE {
"\\S" };
265 if (desc.contains(kNonWhiteSpaceRE))
267 clause += item->
GetData().toString();
289 query.
prepare(
"DELETE FROM powerpriority WHERE priorityname = :NAME;");
295 query.
prepare(
"INSERT INTO powerpriority "
296 "(priorityname, recpriority, selectclause) "
297 "VALUES(:NAME,:VALUE,:CLAUSE);");
316 query.
prepare(
"DELETE FROM powerpriority "
317 "WHERE priorityname=:NAME;");
337 msg =
"Power Priority rules do not reqiure a leading \"AND\"";
339 else if (desc.contains(
';'))
341 msg =
"Power Priority rules cannot include semicolon ( ; ) ";
342 msg +=
"statement terminators.";
346 QString qstr = QString(
"SELECT (%1) FROM (recordmatch, record, "
347 "program, channel, capturecard, "
348 "oldrecorded) WHERE NULL").arg(desc);
351 int i = qstr.indexOf(
"RECTABLE");
353 qstr = qstr.replace(i, strlen(
"RECTABLE"),
"record");
365 msg = tr(
"An error was found when checking") +
":\n\n";
367 msg +=
"\n\n" + tr(
"The database error was") +
":\n";
385 QString ttable =
"powerpriority_tmp";
391 thequery =
"SELECT GET_LOCK(:LOCK, 2);";
393 query.
bindValue(
":LOCK",
"DiffSchedule");
397 QString(
"DB Error (Obtaining lock in testRecording): \n"
398 "Query was: %1 \nError was: %2 \n")
401 LOG(VB_GENERAL, LOG_ERR, msg);
405 thequery = QString(
"DROP TABLE IF EXISTS %1;").arg(ttable);
410 QString(
"DB Error (deleting old table in testRecording): \n"
411 "Query was: %1 \nError was: %2 \n")
414 LOG(VB_GENERAL, LOG_ERR, msg);
418 thequery = QString(
"CREATE TABLE %1 SELECT * FROM powerpriority;")
424 QString(
"DB Error (create new table): \n"
425 "Query was: %1 \nError was: %2 \n")
428 LOG(VB_GENERAL, LOG_ERR, msg);
432 query.
prepare(QString(
"DELETE FROM %1 WHERE priorityname = :NAME;")
439 thequery = QString(
"INSERT INTO %1 "
440 "(priorityname, recpriority, selectclause) "
441 "VALUES(:NAME,:VALUE,:CLAUSE);").arg(ttable);
450 QString ltitle = tr(
"Power Priority");
462 thequery =
"SELECT RELEASE_LOCK(:LOCK);";
464 query.
bindValue(
":LOCK",
"DiffSchedule");
468 QString(
"DB Error (free lock): \n"
469 "Query was: %1 \nError was: %2 \n")
472 LOG(VB_GENERAL, LOG_ERR, msg);
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
MythUIButton * m_deleteButton
QSqlQuery wrapper that fetches a DB connection from the connection pool.
MythScreenStack * GetMainStack()
void SetMaxLength(int length)
MythUIButton * m_cancelButton
static const QRegularExpression kReSearchTypeName
MythUITextEdit * m_descriptionEdit
static QString DBErrorMessage(const QSqlError &err)
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
QVariant value(int i) const
static const QRegularExpression kReLeadingAnd
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
A text entry and edit widget.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythUIButton * m_testButton
Screen in which all other widgets are contained and rendered.
MythUITextEdit * m_titleEdit
QString GetText(void) const
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
void addListener(QObject *listener)
Add a listener to the observable.
void SetValue(int val) override
void SetText(const QString &text, bool moveCursor=true)
MSqlDatabase Info, used by MSqlQuery. Do not use directly.
bool SetFocusWidget(MythUIType *widget=nullptr)
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
QString GetTitle(void) const
static void DBError(const QString &where, const MSqlQuery &query)
void BuildFocusList(void)
void loadExampleRules(void)
static MSqlQueryInfo SchedCon()
Returns dedicated connection. (Required for using temporary SQL tables.)
void SetEnabled(bool enable)
CustomPriority(MythScreenStack *parent, ProgramInfo *proginfo=nullptr)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void ruleChanged(MythUIButtonListItem *item)
static void ReschedulePlace(const QString &why)
QSqlError lastError(void) const
MythUIButtonList * m_ruleList
Holds information on recordings and videos.
QString executedQuery(void) const
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
MythUIButton * m_installButton
void installClicked(void)
MythMainWindow * GetMythMainWindow(void)
A widget for offering a range of numerical values where only the the bounding values and interval are...
~CustomPriority() override
MythUIButton * m_addButton
MythUIButtonList * m_clauseList
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
void removeListener(QObject *listener)
Remove a listener to the observable.
MythUISpinBox * m_prioritySpin
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.