11 QString idTag(
":WHEREID");
12 QString query(
"id = " + idTag);
21 QString idTag(
":SETID");
24 QString query(
"id = " + idTag +
", " +
35 QStringList hostnames;
37 for (
const auto &
hostname : std::as_const(hostnames))
49 auto *cardInfo =
new CardInfo(*
this);
68 query.
prepare(
"SELECT DISTINCT cardtype FROM profilegroups");
77 existing.push_back(query.
value(0).toString());
80 const std::array<const QString,4> profile_names {
81 "Default",
"Live TV",
"High Quality",
"Low Quality" };
85 for (
auto Itype = cardtypes.begin();
86 Itype != cardtypes.end(); ++Itype)
88 if (Itype.key().startsWith(
"V4L2:") && existing.indexOf(Itype.key()) == -1)
91 query.
prepare(
"INSERT INTO profilegroups SET name = "
92 ":CARDNAME, cardtype = :CARDTYPE, is_default = 1;");
93 query.
bindValue(
":CARDTYPE", Itype.key());
94 query.
bindValue(
":CARDNAME", Itype.value());
104 for (
const auto & name : profile_names)
107 query.
prepare(
"INSERT INTO recordingprofiles SET name = "
108 ":NAME, profilegroup = :GROUPID;");
114 "recordingprofile.", query);
131 "SELECT name, id, hostname, is_default, cardtype "
132 "FROM profilegroups");
140 while (result.
next())
142 QString name = result.
value(0).toString();
143 QString
id = result.
value(1).toString();
145 bool is_default = (
bool) result.
value(3).toInt();
146 QString cardtype = result.
value(4).toString();
150 bool have_cardtype = cardtypes.contains(cardtype);
151 if (is_default && (cardtype ==
"TRANSCODE") && !have_cardtype)
155 else if (have_cardtype)
158 name += QString(
" (%1)").arg(result.
value(2).toString());
167 profileGroup->loadByID(
id.toInt());
168 profileGroup->setLabel(name);
169 profileGroup->addChild(
186 result.
prepare(
"SELECT name from profilegroups WHERE id = :PROFILE_ID;");
190 return result.
value(0).toString();
199 QString querystr = QString(
"SELECT DISTINCT id FROM profilegroups WHERE "
200 "name = '%1' AND hostname = '%2';")
204 return !(result.
exec() && result.
next());
213 result.
prepare(
"SELECT DISTINCT hostname from capturecard");
217 while (result.
next())
218 hostnames->append(result.
value(0).toString());
static void fillSelections(MythUIComboBoxSetting *setting)
QMap< QString, QString > InputTypes
static InputTypes GetInputTypes(void)
QString GetColumnName(void) const
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
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
QVariant lastInsertId()
Return the id of the last inserted row.
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)
const ProfileGroup & m_parent
QString GetSetClause(MSqlBindings &bindings) const override
QString GetWhereClause(MSqlBindings &bindings) const override
int getProfileNum(void) const
bool allowedGroupName(void)
static void getHostNames(QStringList *hostnames)
virtual void loadByID(int id)
QString getName(void) const
static void fillSelections(GroupSetting *setting)
static bool addMissingDynamicProfiles(void)
virtual void addChild(StandardSetting *child)
virtual void clearSettings()
virtual void setValue(const QString &newValue)
virtual QString getValue(void) const
virtual void setLabel(QString str)
virtual QString GetDBValue(void) const =0
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.