5#include <QCoreApplication>
26 QString querystr = QString(
"SELECT %1 FROM %2 WHERE %3='%4'")
36 querystr = QString(
"INSERT INTO %1 (%2) VALUES ('%3')")
45 LOG(VB_GENERAL, LOG_ERR, QString(
"ChannelID, Error: ") +
46 QString(
"Failed to insert into: %1").arg(
m_table));
53 QString fieldTag = (
":WHERE" +
m_id.
getField().toUpper());
66 QString query(
m_id.
getField() +
" = " + fieldTag +
", " +
77 QString fieldTag = (
":WHERE" +
m_id.
getField().toUpper());
90 QString query(
m_id.
getField() +
" = " + fieldTag +
", " +
109 setLabel(QCoreApplication::translate(
"(Common)",
"Channel Name"));
124 setLabel(QCoreApplication::translate(
"(Common)",
"Channel Number"));
125 setHelpText(QCoreApplication::translate(
"(Common)",
126 "This is the number by which the channel is known to MythTV."));
142 setLabel(QCoreApplication::translate(
"(Common)",
"Video Source"));
143 setHelpText(QCoreApplication::translate(
"(Common)",
144 "It is NOT a good idea to change this value as it only changes "
145 "the sourceid in table channel but not in dtv_multiplex. "
146 "The sourceid in dtv_multiplex cannot and should not be changed."));
169 addSelection(QCoreApplication::translate(
"(ChannelSettings)",
170 "[Not Selected]"),
"0");
173 query.
prepare(
"SELECT name, sourceid "
175 "ORDER BY sourceid");
187 query.
value(1).toString());
205 setLabel(QCoreApplication::translate(
"(Common)",
"Callsign"));
217 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
"TV Format"));
218 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
219 "If this channel uses a format other than TV Format in the General "
220 "Backend Setup screen, set it here."));
222 addSelection(QCoreApplication::translate(
"(Common)",
"Default"),
"Default");
225 for (
const QString& format : std::as_const(list))
238 list.push_back(
"NTSC");
239 list.push_back(
"NTSC-JP");
240 list.push_back(
"PAL");
241 list.push_back(
"PAL-60");
242 list.push_back(
"PAL-BG");
243 list.push_back(
"PAL-DK");
244 list.push_back(
"PAL-D");
245 list.push_back(
"PAL-I");
246 list.push_back(
"PAL-M");
247 list.push_back(
"PAL-N");
248 list.push_back(
"PAL-NC");
249 list.push_back(
"SECAM");
250 list.push_back(
"SECAM-D");
251 list.push_back(
"SECAM-DK");
263 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
264 "DataDirect Time Offset"));
266 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
267 "Offset (in minutes) to apply to the program guide data during "
268 "import. This can be used when the listings for a particular "
269 "channel are in a different time zone."));
285 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
"Priority"));
287 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
288 "Number of priority points to be added to any recording on this "
289 "channel during scheduling. Use a positive number as the priority "
290 "if you want this to be a preferred channel, a negative one to "
291 "depreciate this channel."));
306 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
"Icon"));
308 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
309 "Image file to use as the icon for this channel on various MythTV "
325 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
328 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
329 "Filters to be used when recording from this channel. Not used "
330 "with hardware encoding cards."));
347 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
348 "Playback filters"));
350 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
351 "Filters to be used when recordings from this channel are viewed. "
352 "Start with a plus to append to the global playback filters."));
368 setLabel(QCoreApplication::translate(
"(Common)",
"XMLTV ID"));
370 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
371 "ID used by listing services to get an exact correspondence "
372 "between a channel in your line-up and a channel in their "
373 "database. Normally this is set automatically when "
374 "'mythfilldatabase' is run."));
396 QFile
file(xmltvFile);
397 if (!
file.open(QIODevice::ReadOnly | QIODevice::Text))
402 while (!
file.atEnd())
404 QByteArray line =
file.readLine();
406 if (line.startsWith(
"channel="))
408 QString
id = line.mid(8, -1).trimmed();
415 for (
const QString& idName : std::as_const(idList))
429 -1, UINT16_MAX, 1, 1,
"NULL")
431 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
"Service ID"));
433 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
434 "Service ID (Program Number) of desired channel within the transport stream. "
435 "If there is only one channel, then setting this to anything will still find it."));
465 setLabel(QObject::tr(
"Transport ID"));
467 QObject::tr(
"The transport stream ID (tid) can be used to identify "
468 "the transport of this channel in the Transport Editor."));
480 QObject::tr(
"Frequency of the transport of this channel in Hz for "
481 "DVB-T/T2/C or in kHz plus polarization H or V for DVB-S/S2."));
491 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
492 "Commercial Detection Method"));
494 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
495 "Changes the method of commercial detection used for recordings on "
496 "this channel or skips detection by marking the channel as "
497 "Commercial Free."));
521 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
"Visible"));
523 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
524 "If set to Always Visible or Visible, the channel will be visible in the "
525 "EPG. Set to Always Visible or Never Visible to prevent MythTV and other "
526 "utilities from automatically managing the value for this "
529 addSelection(QCoreApplication::translate(
"(Common)",
"Always Visible"),
531 addSelection(QCoreApplication::translate(
"(Common)",
"Visible"),
533 addSelection(QCoreApplication::translate(
"(Common)",
"Not Visible"),
535 addSelection(QCoreApplication::translate(
"(Common)",
"Never Visible"),
551 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
552 "Use on air guide"));
554 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
555 "If enabled, guide information for this channel will be updated "
556 "using 'Over-the-Air' program listings."));
574 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
"URL"));
575 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
576 "URL for streaming of this channel. Used by the IPTV "
577 "capture card and obtained with an \"M3U Import\" or "
578 "with a \"HDHomeRun Channel Import\" loading of an XML file."));
597 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
599 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
600 "N.B. This setting is only used for analog channels. "
601 "Depending on the tuner type, specify either the exact "
602 "frequency (in kHz) or a valid channel "
603 "number that will be understood by your tuners."));
619 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
622 setHelpText(QCoreApplication::translate(
"(ChannelSettings)",
623 "Value to be added to your desired frequency (in kHz) for "
642 setLabel(QCoreApplication::translate(
"(Common)",
"Contrast"));
658 setLabel(QCoreApplication::translate(
"(Common)",
"Brightness"));
674 setLabel(QCoreApplication::translate(
"(Common)",
"Color"));
690 setLabel(QCoreApplication::translate(
"(Common)",
"Hue"));
700 uint default_sourceid,
bool add_freqid)
702 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
703 "Channel Options - Common"));
706 auto *source =
new Source(
id, default_sourceid);
708 auto *channum =
new Channum(
id);
748 "SELECT transportid, frequency, polarity, mod_sys FROM dtv_multiplex "
749 "JOIN channel ON channel.mplexid = dtv_multiplex.mplexid "
750 "WHERE channel.chanid = :CHANID");
758 else if (query.
next())
760 QString frequency = query.
value(1).toString();
766 QString polarization = query.
value(2).toString().toUpper();
767 frequency.append(polarization);
780 bool supports_eit =
true;
781 bool uses_eit_only =
false;
784 query.
prepare(
"SELECT cardtype "
785 "FROM capturecard, videosource "
786 "WHERE capturecard.sourceid = videosource.sourceid AND "
787 " videosource.sourceid = :SOURCEID");
794 supports_eit = (query.
size() == 0);
798 query.
value(0).toString().toUpper());
801 query.
prepare(
"SELECT xmltvgrabber "
803 "WHERE sourceid = :SOURCEID");
810 uses_eit_only = (query.
size() != 0);
813 uses_eit_only &= (query.
value(0).toString() ==
"eitonly");
825 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
826 "Channel Options - Filters"));
834 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
835 "Channel Options - IPTV"));
844 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
845 "Channel Options - Video4Linux"));
862 setLabel(QCoreApplication::translate(
"(ChannelSettings)",
863 "Channel Options - Raw Transport Stream"));
870 for (
uint i = 0; i < mx; i++)
873 m_pids[i]->setLabel(
"PID");
875 m_sids[i]->setLabel(
" StreamID");
876 for (
uint j = 0x101; j <= 0x1ff; j++)
883 .arg(desc).arg(j&0xff,2,16,QLatin1Char(
'0')),
884 QString::number(j),
false);
887 for (
uint j = 0x101; j <= 0x1ff; j++)
893 QString(
"0x%1").arg(j&0xff,2,16,QLatin1Char(
'0')),
894 QString::number(j),
false);
911 m_pcrs[i]->setLabel(
" Is PCR");
923 auto it = pid_cache.begin();
924 for (
uint i = 0; i <
kMaxPIDs && it != pid_cache.end(); )
926 if (!(it->IsPermanent()))
932 m_pids[i]->setValue(QString(
"0x%1")
933 .arg(it->GetPID(),2,16,QLatin1Char(
'0')));
934 m_sids[i]->setValue(QString::number(it->GetComposite()&0x1ff));
935 m_pcrs[i]->setValue(it->IsPCRPID());
950 uint pid =
m_pids[i]->getValue().toUInt(&ok, 0);
954 pid_cache.emplace_back(
std::vector< pid_cache_item_t > pid_cache_t
Brightness(const ChannelID &id)
Callsign(const ChannelID &id)
static bool IsEITCapable(const QString &rawtype)
QString GetWhereClause(MSqlBindings &bindings) const override
QString GetSetClause(MSqlBindings &bindings) const override
const QString & getField(void) const
int findHighest(int floor=1000)
void sourceChanged(const QString &sourceid)
Frequency_CO * m_frequency
TransportID_CO * m_transportId
ChannelOptionsCommon(const ChannelID &id, uint default_sourceid, bool add_freqid)
OnAirGuide * m_onAirGuide
static void onAirGuideChanged(bool fValue)
ChannelOptionsFilters(const ChannelID &id)
ChannelOptionsIPTV(const ChannelID &id)
std::vector< TransMythUICheckBoxSetting * > m_pcrs
ChannelOptionsRawTS(const ChannelID &id)
std::vector< TransTextEditSetting * > m_pids
std::vector< TransMythUIComboBoxSetting * > m_sids
static const uint kMaxPIDs
ChannelOptionsV4L(const ChannelID &id)
ChannelURL(const ChannelID &id)
static bool GetCachedPids(uint chanid, pid_cache_t &pid_cache)
Returns cached MPEG PIDs when given a Channel ID.
static bool SaveCachedPids(uint chanid, const pid_cache_t &_pid_cache, bool delete_all=false)
Saves PIDs for PSIP tables to database.
Channum(const ChannelID &id)
Colour(const ChannelID &id)
CommMethod(const ChannelID &id)
Contrast(const ChannelID &id)
QString GetColumnName(void) const
@ kModulationSystem_DVBS2
bool Parse(const QString &_value)
Finetune(const ChannelID &id)
Freqid(const ChannelID &id)
QString GetSetClause(MSqlBindings &bindings) const override
QString GetWhereClause(MSqlBindings &bindings) const override
Icon(const ChannelID &id)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
QVariant value(int i) const
int numRowsAffected() const
bool isActive(void) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
void addSelection(const QString &label, QString value=QString(), bool select=false)
void setValue(int value) override
Name(const ChannelID &id)
OnAirGuide(const ChannelID &id)
~OutputFilters() override
OutputFilters(const ChannelID &id)
Priority(const ChannelID &id)
QString getValue(void) const override
ServiceID(const ChannelID &id)
void fillSelections(void)
QMap< uint, uint > m_sourceIdToIndex
Source(const ChannelID &id, uint _default_sourceid)
virtual void addChild(StandardSetting *child)
virtual void setHelpText(const QString &str)
virtual void setValue(const QString &newValue)
Storage * GetStorage(void) const
void valueChanged(const QString &newValue)
virtual QString getValue(void) const
virtual void setEnabled(bool enabled)
virtual void setLabel(QString str)
virtual QString GetDBValue(void) const =0
static QString GetDescription(uint stream_id)
TimeOffset(const ChannelID &id)
VideoFilters(const ChannelID &id)
Visible(const ChannelID &id)
void fillSelections(void)
XmltvID(const ChannelID &id, QString _sourceName)
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static QString Source(const QNetworkRequest &request)
std::deque< int > GetPreferredSkipTypeCombinations(void)
QString SkipTypeToString(int flags)
static constexpr uint8_t Brightness
VERBOSE_PREAMBLE Most true