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#ifdef __cpp_lib_ranges_contains
299 if (!std::ranges::contains(va, value))
313 e.
values.push_back(value);
314 m_valMap.insert(id_map::value_type(
id, e));
348 p->second.values.end(), value);
349 if (vp !=
p->second.values.end())
352 QString del_query = QString(
"DELETE FROM %1 WHERE %2 = :ID AND "
362 p->second.values.erase(vp);
373 QString del_query = QString(
"DELETE FROM %1 WHERE %2 = :ID")
391 std::find(
p->second.values.begin(),
p->second.values.end(),
393 return vp !=
p->second.values.end();
415 int id = query.
value(0).toInt();
416 int val = query.
value(1).toInt();
426 p =
m_valMap.insert(id_map::value_type(
id, e)).first;
429 p->second.values.push_back(val);
611 query.
prepare(
"UPDATE videotypes SET extension = :EXT, "
612 "playcommand = :PLAYCMD, f_ignore = :IGNORED, "
613 "use_default = :USEDEFAULT WHERE intid = :ID");
618 query.
prepare(
"INSERT INTO videotypes (extension, playcommand, "
619 "f_ignore, use_default) VALUES "
620 "(:EXT, :PLAYCMD, :IGNORED, :USEDEFAULT)");
632 if (query.
exec(
"SELECT LAST_INSERT_ID()") && query.
next())
634 ret_fa.
id = query.
value(0).toUInt();
644 *existing_fa = ret_fa;
682 query.
prepare(
"DELETE FROM videotypes WHERE intid = :ID");
701 ext_ignore.emplace_back(fa.extension, fa.ignore);
726 if (query.
exec(
"SELECT intid, extension, playcommand, f_ignore, "
727 "use_default FROM videotypes"))
732 query.
value(1).toString(),
733 query.
value(2).toString(),
734 query.
value(3).toBool(),
735 query.
value(4).toBool());
741 association_list::iterator
find(
const QString &ext)
746 if (
p->extension.length() == ext.length() &&
747 ext.indexOf(
p->extension) == 0)
755 association_list::iterator
find(
unsigned int id)
760 if (
p->id ==
id)
return p;
765 association_list::const_iterator
cfind(
const QString &ext)
const
770 if (
p->extension.length() == ext.length() &&
771 ext.indexOf(
p->extension) == 0)
779 association_list::const_iterator
cfind(
unsigned int id)
const
784 if (
p->id ==
id)
return p;
FileAssociationsImp()=default
bool remove(unsigned int id)
bool get(unsigned int id, file_association &val) const
association_list::iterator find(unsigned int id)
association_list::const_iterator cfind(unsigned int id) const
void getExtensionIgnoreList(ext_ignore_list &ext_ignore) const
FileAssociations::ext_ignore_list ext_ignore_list
const association_list & getList() const
bool get(const QString &ext, file_association &val) const
association_list m_fileAssociations
FileAssociations::association_list association_list
bool add(file_association &fa)
association_list::const_iterator cfind(const QString &ext) const
association_list::iterator find(const QString &ext)
void getExtensionIgnoreList(ext_ignore_list &ext_ignore) const
std::vector< std::pair< QString, bool > > ext_ignore_list
bool add(file_association &fa)
bool remove(unsigned int id)
bool get(unsigned int id, file_association &val) const
static FileAssociations & getFileAssociation()
const association_list & getList() const
std::vector< file_association > association_list
class FileAssociationsImp * m_imp
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 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.
int add(int id, int value)
bool get(int id, entry &values)
std::map< int, entry > id_map
bool exists(int id, int value)
SimpleCleanup< MultiValueImp > m_cleanStub
MultiValueImp(QString table_name, QString id_name, QString value_name)
void remove(int id, int value)
int add(int id, int value)
bool get(int id, entry &values)
bool exists(int id, int value)
void remove(int id, int value)
static void DBError(const QString &where, const MSqlQuery &query)
entry_map::iterator find(const QString &name)
virtual ~SingleValueImp()=default
SingleValueImp(QString table_name, QString id_name, QString value_name)
std::map< int, QString > entry_map
int add(const QString &name)
bool exists(const QString &name, int *id=nullptr)
std::vector< entry > entry_list
virtual bool sort(const entry &lhs, const entry &rhs)
const entry_list & getList()
SimpleCleanup< SingleValueImp > m_cleanStub
bool get(int id, QString &value)
bool get(int id, QString &category)
std::pair< int, QString > entry
const entry_list & getList()
int add(const QString &name)
std::vector< entry > entry_list
static VideoCastMap & getCastMap()
static VideoCast & GetCast()
static VideoCategory & GetCategory()
static VideoCountryMap & getCountryMap()
static VideoCountry & getCountry()
static VideoGenreMap & getGenreMap()
static VideoGenre & getGenre()
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 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)...
std::vector< long > values_type
bool operator()(const arg_type &lhs, const arg_type &rhs)