Go to the documentation of this file.
12 #define LOC_ERR QString("MythGame:ROMINFO Error: ")
13 #define LOC QString("MythGame:ROMINFO: ")
24 bool inserting =
false;
31 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Adding %1 - %2")
34 query.
prepare(
"INSERT INTO gamemetadata "
35 "(`system`, romname, gamename, genre, year, gametype, "
36 "rompath, country, crc_value, diskcount, display, plot, "
37 "publisher, version, fanart, boxart, screenshot) "
38 "VALUES (:SYSTEM, :ROMNAME, :GAMENAME, :GENRE, :YEAR, "
39 ":GAMETYPE, :ROMPATH, :COUNTRY, :CRC32, '1', '1', :PLOT, "
40 ":PUBLISHER, :VERSION, :FANART, :BOXART, :SCREENSHOT)");
60 query.
prepare(
"UPDATE gamemetadata "
61 "SET version = 'CUSTOM', "
62 " gamename = :GAMENAME,"
65 " country = :COUNTRY,"
67 " publisher = :PUBLISHER,"
68 " favorite = :FAVORITE,"
69 " screenshot = :SCREENSHOT,"
72 " inetref = :INETREF "
73 "WHERE gametype = :GAMETYPE AND "
74 " romname = :ROMNAME");
99 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Removing %1 - %2")
104 query.
prepare(
"DELETE FROM gamemetadata WHERE "
105 "romname = :ROMNAME AND "
106 "rompath = :ROMPATH ");
117 int romInDB(
const QString& rom,
const QString& gametype)
123 query.
prepare(
"SELECT count(*) FROM gamemetadata "
124 "WHERE gametype = :GAMETYPE "
125 "AND romname = :ROMNAME");
138 count = query.
value(0).toInt();
146 QStringList graphic_formats;
147 graphic_formats.append(
"png");
148 graphic_formats.append(
"gif");
149 graphic_formats.append(
"jpg");
150 graphic_formats.append(
"jpeg");
151 graphic_formats.append(
"xpm");
152 graphic_formats.append(
"bmp");
153 graphic_formats.append(
"pnm");
154 graphic_formats.append(
"tif");
155 graphic_formats.append(
"tiff");
157 int dotLocation = BaseFileName.lastIndexOf(
'.');
158 if (dotLocation == -1)
160 BaseFileName.append(
'.');
161 dotLocation = BaseFileName.length();
165 BaseFileName.truncate(dotLocation + 1);
166 return std::any_of(graphic_formats.cbegin(), graphic_formats.cend(),
167 [BaseFileName,result](
const auto & format)
168 { *result = BaseFileName + format;
169 return QFile::exists(*result); } );
174 if (field ==
"system")
176 else if (field ==
"gamename")
178 else if (field ==
"genre")
180 else if (field ==
"year")
182 else if (field ==
"favorite")
184 else if (field ==
"rompath")
186 else if (field ==
"screenshot")
188 else if (field ==
"fanart")
190 else if (field ==
"boxart")
192 else if (field ==
"country")
194 else if (field ==
"plot")
196 else if (field ==
"publisher")
198 else if (field ==
"crc_value")
200 else if (field ==
"inetref")
202 else if (field ==
"diskcount")
204 else if (field ==
"gametype")
206 else if (field ==
"romcount")
209 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Invalid field %1").arg(field));
221 query.
prepare(
"UPDATE gamemetadata SET favorite = :FAV "
222 "WHERE romname = :ROMNAME");
236 int pos =
Romname().lastIndexOf(
".");
240 pos =
Romname().length() - pos;
243 QString ext =
Romname().right(pos);
258 systemtype +=
" AND `system` = :SYSTEM ";
261 QString thequery =
"SELECT `system`,gamename,genre,year,romname,favorite,"
262 "rompath,country,crc_value,diskcount,gametype,plot,publisher,"
263 "version,screenshot,fanart,boxart,inetref,intid FROM gamemetadata "
264 "WHERE gamename = :GAMENAME "
265 + systemtype +
" ORDER BY diskcount DESC";
300 query.
prepare(
"SELECT DISTINCT `system` FROM gamemetadata "
301 "WHERE romname = :ROMNAME");
326 QString querystr =
"SELECT intid,`system`,romname,gamename,genre,year,publisher,"
327 "favorite,rompath,screenshot,fanart,plot,boxart,"
328 "gametype,diskcount,country,crc_value,inetref,display,"
329 "version FROM gamemetadata ORDER BY diskcount DESC";
342 query.
value(0).toInt(),
343 query.
value(2).toString(),
344 query.
value(1).toString(),
345 query.
value(3).toString(),
346 query.
value(4).toString(),
347 query.
value(5).toString(),
348 query.
value(7).toBool(),
349 query.
value(8).toString(),
350 query.
value(15).toString(),
351 query.
value(16).toString(),
352 query.
value(14).toInt(),
353 query.
value(13).toString(),
355 query.
value(11).toString(),
356 query.
value(6).toString(),
357 query.
value(19).toString(),
358 query.
value(9).toString(),
359 query.
value(10).toString(),
360 query.
value(12).toString(),
361 query.
value(17).toString());
374 QString querystr =
"SELECT intid,`system`,romname,gamename,genre,year,publisher,"
375 "favorite,rompath,screenshot,fanart,plot,boxart,"
376 "gametype,diskcount,country,crc_value,inetref,display,"
377 "version FROM gamemetadata WHERE intid = :INTID";
388 query.
value(0).toInt(),
389 query.
value(2).toString(),
390 query.
value(1).toString(),
391 query.
value(3).toString(),
392 query.
value(4).toString(),
393 query.
value(5).toString(),
394 query.
value(7).toBool(),
395 query.
value(8).toString(),
396 query.
value(15).toString(),
397 query.
value(16).toString(),
398 query.
value(14).toInt(),
399 query.
value(13).toString(),
401 query.
value(11).toString(),
402 query.
value(6).toString(),
403 query.
value(19).toString(),
404 query.
value(9).toString(),
405 query.
value(10).toString(),
406 query.
value(12).toString(),
407 query.
value(17).toString());
418 return QString (
"Rom Info:\n"
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
void setGameType(const QString &lgametype)
static bool FindImage(QString BaseFileName, QString *result)
void setBoxart(const QString &lboxart)
QVariant value(int i) const
void setCountry(const QString &lcountry)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
static QList< RomInfo * > GetAllRomInfo()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void setSystem(const QString &lsystem)
QString Screenshot() const
void setInetref(const QString &linetref)
void setGamename(const QString &lgamename)
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
void setVersion(const QString &lversion)
static void DBError(const QString &where, const MSqlQuery &query)
void setPublisher(const QString &lpublisher)
void setFavorite(bool updateDatabase=false)
void setFanart(const QString &lfanart)
void setPlot(const QString &lplot)
static RomInfo * GetRomInfoById(int id)
void setDiskCount(int ldiskcount)
QString Publisher() const
void setRomname(const QString &lromname)
void setRompath(const QString &lrompath)
bool operator==(const RomInfo &a, const RomInfo &b)
void setCRC_VALUE(const QString &lcrc_value)
void setRomCount(int lromcount)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
QString getExtension() const
void setYear(const QString &lyear)
void DeleteFromDatabase() const
void SaveToDatabase() const
int romInDB(const QString &rom, const QString &gametype)
RomInfo(int lid=0, QString lromname="", QString lsystem="", QString lgamename="", QString lgenre="", QString lyear="", bool lfavorite=false, QString lrompath="", QString lcountry="", QString lcrc_value="", int ldiskcount=0, QString lgametype="", int lromcount=0, QString lallsystems="", QString lplot="", QString lpublisher="", QString lversion="", QString lscreenshot="", QString lfanart="", QString lboxart="", QString linetref="")
void setField(const QString &field, const QString &data)
void setScreenshot(const QString &lscreenshot)
void setGenre(const QString &lgenre)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.