Go to the documentation of this file.
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());
bool allowedGroupName(void)
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
static void fillSelections(GroupSetting *setting)
virtual void setValue(const QString &newValue)
int getProfileNum(void) const
QVariant lastInsertId()
Return the id of the last inserted row.
virtual void loadByID(int id)
QString GetWhereClause(MSqlBindings &bindings) const override
QVariant value(int i) const
QString GetColumnName(void) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
virtual void clearSettings()
virtual QString GetDBValue(void) const =0
static void fillSelections(MythUIComboBoxSetting *setting)
virtual void addChild(StandardSetting *child)
QString getName(void) const
QString GetSetClause(MSqlBindings &bindings) const override
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
const ProfileGroup & m_parent
virtual QString getValue(void) const
virtual void setLabel(QString str)
void addSelection(const QString &label, QString value=QString(), bool select=false)
static void getHostNames(QStringList *hostnames)
QMap< QString, QString > InputTypes
static bool addMissingDynamicProfiles(void)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
static InputTypes GetInputTypes(void)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.