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)
148 QMap<QString, QString> examples;
149 examples.insert(tr(
"Modify priority for an input (Input priority)"),
150 "capturecard.cardid = 1");
151 examples.insert(tr(
"Modify priority for every card on a host"),
152 "capturecard.hostname = 'mythbox'");
153 examples.insert(tr(
"Only one specific channel ID (Channel priority)"),
154 "channel.chanid = '1003' ");
155 examples.insert(tr(
"Only a certain channel number"),
156 "channel.channum = '3' ");
157 examples.insert(tr(
"Only channels that carry a specific station"),
158 "channel.callsign = 'ESPN' ");
159 examples.insert(tr(
"Match related callsigns"),
160 "channel.callsign LIKE 'HBO%' ");
161 examples.insert(tr(
"Only channels marked as commercial free"),
162 QString(
"channel.commmethod = %1 ")
164 examples.insert(tr(
"Modify priority for a station on an input"),
165 "channel.callsign = 'ESPN' AND capturecard.cardid = 2");
166 examples.insert(tr(
"Priority for all matching titles"),
167 "program.title LIKE 'CSI: %' ");
168 examples.insert(tr(
"Only shows marked as HDTV"),
169 "program.hdtv > 0 ");
170 examples.insert(tr(
"Close Captioned priority"),
171 "program.closecaptioned > 0 ");
172 examples.insert(tr(
"New episodes only"),
173 "program.previouslyshown = 0 ");
174 examples.insert(tr(
"Modify unidentified episodes"),
175 "program.generic = 0 ");
176 examples.insert(tr(
"First showing of each episode"),
177 "program.first > 0 ");
178 examples.insert(tr(
"Last showing of each episode"),
179 "program.last > 0 ");
180 examples.insert(tr(
"Priority for any show with End Late time"),
181 "RECTABLE.endoffset > 0 ");
182 examples.insert(tr(
"Priority for a category"),
183 "program.category = 'Reality' ");
184 examples.insert(QString(
"%1 ('movie', 'series', 'sports', 'tvshow')")
185 .arg(tr(
"Priority for a category type")),
186 "program.category_type = 'sports' ");
187 examples.insert(tr(
"Modify priority by star rating (0.0 to 1.0 for "
189 "program.stars >= 0.75 ");
190 examples.insert(tr(
"Priority when shown once (complete example)"),
191 "program.first > 0 AND program.last > 0");
192 examples.insert(tr(
"Prefer a host for a storage group (complete example)"),
193 QString(
"RECTABLE.storagegroup = 'Archive' "
194 "AND capturecard.hostname = 'mythbox' "));
195 examples.insert(tr(
"Priority for HD shows under two hours (complete "
197 "program.hdtv > 0 AND program.starttime > "
198 "DATE_SUB(program.endtime, INTERVAL 2 HOUR) ");
199 examples.insert(tr(
"Priority for movies by the year of release (complete "
201 "program.category_type = 'movie' "
202 "AND program.airdate >= 2006 ");
203 examples.insert(tr(
"Prefer movies when shown at night (complete example)"),
204 "program.category_type = 'movie' "
205 "AND HOUR(program.starttime) < 6 ");
206 examples.insert(tr(
"Prefer a host for live sports with overtime (complete "
208 "RECTABLE.endoffset > 0 "
209 "AND program.category = 'Sports event' "
210 "AND capturecard.hostname = 'mythbox' ");
211 examples.insert(tr(
"Avoid poor signal quality (complete example)"),
212 "capturecard.cardid = 1 AND "
213 "channel.channum IN (3, 5, 39, 66) ");
215 QMapIterator<QString, QString> it(examples);
220 QVariant::fromValue(it.value()));
259 static const QRegularExpression kNonWhiteSpaceRE {
"\\S" };
260 if (desc.contains(kNonWhiteSpaceRE))
262 clause += item->
GetData().toString();
284 query.
prepare(
"DELETE FROM powerpriority WHERE priorityname = :NAME;");
290 query.
prepare(
"INSERT INTO powerpriority "
291 "(priorityname, recpriority, selectclause) "
292 "VALUES(:NAME,:VALUE,:CLAUSE);");
311 query.
prepare(
"DELETE FROM powerpriority "
312 "WHERE priorityname=:NAME;");
332 msg =
"Power Priority rules do not reqiure a leading \"AND\"";
334 else if (desc.contains(
';'))
336 msg =
"Power Priority rules cannot include semicolon ( ; ) ";
337 msg +=
"statement terminators.";
341 QString qstr = QString(
"SELECT (%1) FROM (recordmatch, record, "
342 "program, channel, capturecard, "
343 "oldrecorded) WHERE NULL").arg(desc);
346 int i = qstr.indexOf(
"RECTABLE");
348 qstr = qstr.replace(i, strlen(
"RECTABLE"),
"record");
360 msg = tr(
"An error was found when checking") +
":\n\n";
362 msg +=
"\n\n" + tr(
"The database error was") +
":\n";
380 QString ttable =
"powerpriority_tmp";
386 thequery =
"SELECT GET_LOCK(:LOCK, 2);";
388 query.
bindValue(
":LOCK",
"DiffSchedule");
392 QString(
"DB Error (Obtaining lock in testRecording): \n"
393 "Query was: %1 \nError was: %2 \n")
396 LOG(VB_GENERAL, LOG_ERR, msg);
400 thequery = QString(
"DROP TABLE IF EXISTS %1;").arg(ttable);
405 QString(
"DB Error (deleting old table in testRecording): \n"
406 "Query was: %1 \nError was: %2 \n")
409 LOG(VB_GENERAL, LOG_ERR, msg);
413 thequery = QString(
"CREATE TABLE %1 SELECT * FROM powerpriority;")
419 QString(
"DB Error (create new table): \n"
420 "Query was: %1 \nError was: %2 \n")
423 LOG(VB_GENERAL, LOG_ERR, msg);
427 query.
prepare(QString(
"DELETE FROM %1 WHERE priorityname = :NAME;")
434 thequery = QString(
"INSERT INTO %1 "
435 "(priorityname, recpriority, selectclause) "
436 "VALUES(:NAME,:VALUE,:CLAUSE);").arg(ttable);
445 QString ltitle = tr(
"Power Priority");
457 thequery =
"SELECT RELEASE_LOCK(:LOCK);";
459 query.
bindValue(
":LOCK",
"DiffSchedule");
463 QString(
"DB Error (free lock): \n"
464 "Query was: %1 \nError was: %2 \n")
467 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.