Go to the documentation of this file.
13 template <
typename T,
typename arg_type>
18 bool operator()(
const arg_type &lhs,
const arg_type &rhs)
20 return m_c.sort(lhs, rhs);
41 m_insertSql = QString(
"INSERT INTO %1 (%2) VALUES (:NAME)")
43 m_fillSql = QString(
"SELECT %1, %2 FROM %3")
45 m_deleteSql = QString(
"DELETE FROM %1 WHERE %2 = :ID")
63 int add(
const QString &name)
74 if (query.
exec(
"SELECT LAST_INSERT_ID()") && query.
next())
76 id = query.
value(0).toInt();
77 m_entries.insert(entry_map::value_type(
id, name));
90 bool get(
int id, QString &value)
122 bool exists(
const QString &name,
int *
id =
nullptr)
146 call_sort<SingleValueImp, entry>(*
this));
166 entry_map::iterator
find(
const QString &name)
170 if (
p->second == name)
186 int id = query.
value(0).toInt();
187 QString val = query.
value(1).toString();
188 m_entries.insert(entry_map::value_type(
id, val));
263 QString value_name) :
m_tableName(std::move(table_name)),
267 m_insertSql = QString(
"INSERT INTO %1 (%2, %3) VALUES (:ID, :VALUE)")
269 m_fillSql = QString(
"SELECT %1, %2 FROM %3 ORDER BY %4")
291 int add(
int id,
int value)
293 bool db_insert =
false;
298 auto v =
std::find(va.begin(), va.end(), value);
309 e.
values.push_back(value);
310 m_valMap.insert(id_map::value_type(
id, e));
344 p->second.values.end(), value);
345 if (vp !=
p->second.values.end())
348 QString del_query = QString(
"DELETE FROM %1 WHERE %2 = :ID AND "
358 p->second.values.erase(vp);
369 QString del_query = QString(
"DELETE FROM %1 WHERE %2 = :ID")
387 std::find(
p->second.values.begin(),
p->second.values.end(),
389 return vp !=
p->second.values.end();
411 int id = query.
value(0).toInt();
412 int val = query.
value(1).toInt();
422 p =
m_valMap.insert(id_map::value_type(
id, e)).first;
425 p->second.values.push_back(val);
607 query.
prepare(
"UPDATE videotypes SET extension = :EXT, "
608 "playcommand = :PLAYCMD, f_ignore = :IGNORED, "
609 "use_default = :USEDEFAULT WHERE intid = :ID");
614 query.
prepare(
"INSERT INTO videotypes (extension, playcommand, "
615 "f_ignore, use_default) VALUES "
616 "(:EXT, :PLAYCMD, :IGNORED, :USEDEFAULT)");
628 if (query.
exec(
"SELECT LAST_INSERT_ID()") && query.
next())
630 ret_fa.
id = query.
value(0).toUInt();
640 *existing_fa = ret_fa;
678 query.
prepare(
"DELETE FROM videotypes WHERE intid = :ID");
697 ext_ignore.emplace_back(fa.extension, fa.ignore);
722 if (query.
exec(
"SELECT intid, extension, playcommand, f_ignore, "
723 "use_default FROM videotypes"))
728 query.
value(1).toString(),
729 query.
value(2).toString(),
730 query.
value(3).toBool(),
731 query.
value(4).toBool());
737 association_list::iterator
find(
const QString &ext)
742 if (
p->extension.length() == ext.length() &&
743 ext.indexOf(
p->extension) == 0)
751 association_list::iterator
find(
unsigned int id)
756 if (
p->id ==
id)
return p;
761 association_list::const_iterator
cfind(
const QString &ext)
const
766 if (
p->extension.length() == ext.length() &&
767 ext.indexOf(
p->extension) == 0)
775 association_list::const_iterator
cfind(
unsigned int id)
const
780 if (
p->id ==
id)
return p;
bool isActive(void) const
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
const entry_list & getList()
bool operator()(const arg_type &lhs, const arg_type &rhs)
bool exists(int id, int value)
void getExtensionIgnoreList(ext_ignore_list &ext_ignore) const
int add(const QString &name)
bool naturalSortCompare(const QString &a, const QString &b, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive)
naturalCompare as a std::sort compatible function (ignoring the third parameter, which is never used)...
void getExtensionIgnoreList(ext_ignore_list &ext_ignore) const
SimpleCleanup< SingleValueImp > m_cleanStub
association_list::const_iterator cfind(unsigned int id) const
QVariant value(int i) const
MultiValueImp(QString table_name, QString id_name, QString value_name)
bool add(file_association &fa)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
SimpleCleanup< MultiValueImp > m_cleanStub
bool remove(unsigned int id)
const association_list & getList() const
entry_map::iterator find(const QString &name)
SingleValueImp(QString table_name, QString id_name, QString value_name)
std::map< int, QString > entry_map
association_list::iterator find(const QString &ext)
static VideoGenreMap & getGenreMap()
int add(const QString &name)
bool get(int id, QString &value)
static VideoGenre & getGenre()
int add(int id, int value)
bool exists(int id, int value)
std::vector< entry > entry_list
std::vector< std::pair< QString, bool > > ext_ignore_list
bool get(unsigned int id, file_association &val) const
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
std::vector< file_association > association_list
static void DBError(const QString &where, const MSqlQuery &query)
FileAssociationsImp()=default
static VideoCountry & getCountry()
bool get(const QString &ext, file_association &val) const
association_list::iterator find(unsigned int id)
static VideoCategory & GetCategory()
association_list m_fileAssociations
FileAssociations::association_list association_list
std::vector< long > values_type
std::pair< int, QString > entry
association_list::const_iterator cfind(const QString &ext) const
static VideoCountryMap & getCountryMap()
bool exists(const QString &name, int *id=nullptr)
static FileAssociations & getFileAssociation()
FileAssociations::ext_ignore_list ext_ignore_list
void remove(int id, int value)
const entry_list & getList()
virtual ~SingleValueImp()=default
static VideoCast & GetCast()
bool get(int id, entry &values)
virtual bool sort(const entry &lhs, const entry &rhs)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
bool get(int id, entry &values)
void remove(int id, int value)
class FileAssociationsImp * m_imp
bool remove(unsigned int id)
int add(int id, int value)
bool get(unsigned int id, file_association &val) const
std::vector< entry > entry_list
static VideoCastMap & getCastMap()
const association_list & getList() const
bool add(file_association &fa)
std::map< int, entry > id_map
bool get(int id, QString &category)
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.