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 : qAsConst(hostnames))
49 auto *cardInfo =
new CardInfo(*
this);
67 query.
prepare(
"SELECT DISTINCT cardtype FROM profilegroups");
76 existing.push_back(query.
value(0).toString());
79 const std::array<const QString,4> profile_names {
80 "Default",
"Live TV",
"High Quality",
"Low Quality" };
84 for (
auto Itype = cardtypes.begin();
85 Itype != cardtypes.end(); ++Itype)
87 if (Itype.key().startsWith(
"V4L2:") && existing.indexOf(Itype.key()) == -1)
90 query.
prepare(
"INSERT INTO profilegroups SET name = "
91 ":CARDNAME, cardtype = :CARDTYPE, is_default = 1;");
92 query.
bindValue(
":CARDTYPE", Itype.key());
93 query.
bindValue(
":CARDNAME", Itype.value());
103 for (
const auto & name : profile_names)
106 query.
prepare(
"INSERT INTO recordingprofiles SET name = "
107 ":NAME, profilegroup = :GROUPID;");
113 "recordingprofile.", query);
130 "SELECT name, id, hostname, is_default, cardtype "
131 "FROM profilegroups");
139 while (result.
next())
141 QString name = result.
value(0).toString();
142 QString
id = result.
value(1).toString();
144 bool is_default = (
bool) result.
value(3).toInt();
145 QString cardtype = result.
value(4).toString();
149 bool have_cardtype = cardtypes.contains(cardtype);
150 if (is_default && (cardtype ==
"TRANSCODE") && !have_cardtype)
154 else if (have_cardtype)
157 name += QString(
" (%1)").arg(result.
value(2).toString());
166 profileGroup->loadByID(
id.toInt());
167 profileGroup->setLabel(name);
168 profileGroup->addChild(
185 result.
prepare(
"SELECT name from profilegroups WHERE id = :PROFILE_ID;");
189 return result.
value(0).toString();
198 QString querystr = QString(
"SELECT DISTINCT id FROM profilegroups WHERE "
199 "name = '%1' AND hostname = '%2';")
203 return !(result.
exec() && result.
next());
212 result.
prepare(
"SELECT DISTINCT hostname from capturecard");
216 while (result.
next())
217 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.