Beispiel #1
0
QString RomInfo::getExtension()
{
    int pos = Romname().lastIndexOf(".");
    if (pos == -1)
        return nullptr;

    pos = Romname().length() - pos;
    pos--;

    QString ext = Romname().right(pos);
    return ext;
}
Beispiel #2
0
void RomInfo::DeleteFromDatabase()
{
    LOG(VB_GENERAL, LOG_INFO, LOC + QString("Removing %1 - %2").arg(Rompath())
            .arg(Romname()));

    MSqlQuery query(MSqlQuery::InitCon());

    query.prepare("DELETE FROM gamemetadata WHERE "
                  "romname = :ROMNAME AND "
                  "rompath = :ROMPATH ");

    query.bindValue(":ROMNAME",Romname());
    query.bindValue(":ROMPATH",Rompath());

    if (!query.exec())
        MythDB::DBError("purgeGameDB", query);

}
Beispiel #3
0
QString RomInfo::toString()
{
    return QString ("Rom Info:\n"
               "ID: %1\n"
               "Game Name: %2\n"
               "Rom Name: %3\n"
               "Rom Path: %4")
               .arg(Id()).arg(Gamename())
               .arg(Romname()).arg(Rompath());
}
Beispiel #4
0
void RomInfo::fillData()
{
    if (m_gamename == "")
    {
        return;
    }

    MSqlQuery query(MSqlQuery::InitCon());

    QString systemtype;
    if (m_system != "") {
        systemtype  += " AND system = :SYSTEM ";
    }

    QString thequery = "SELECT system,gamename,genre,year,romname,favorite,"
                       "rompath,country,crc_value,diskcount,gametype,plot,publisher,"
                       "version,screenshot,fanart,boxart,inetref,intid FROM gamemetadata "
                       "WHERE gamename = :GAMENAME "
                       + systemtype + " ORDER BY diskcount DESC";

    query.prepare(thequery);
    query.bindValue(":SYSTEM", m_system);
    query.bindValue(":GAMENAME", m_gamename);

    if (query.exec() && query.next())
    {
        setSystem(query.value(0).toString());
        setGamename(query.value(1).toString());
        setGenre(query.value(2).toString());
        setYear(query.value(3).toString());
        setRomname(query.value(4).toString());
        setField("favorite",query.value(5).toString());
        setRompath(query.value(6).toString());
        setCountry(query.value(7).toString());
        setCRC_VALUE(query.value(8).toString());
        setDiskCount(query.value(9).toInt());
        setGameType(query.value(10).toString());
        setPlot(query.value(11).toString());
        setPublisher(query.value(12).toString());
        setVersion(query.value(13).toString());
        setScreenshot(query.value(14).toString());
        setFanart(query.value(15).toString());
        setBoxart(query.value(16).toString());
        setInetref(query.value(17).toString());
        setId(query.value(18).toInt());
    }

    setRomCount(romInDB(m_romname,m_gametype));

    // If we have more than one instance of this rom in the DB fill in all
    // systems available to play it.
    if (RomCount() > 1)
    {
        query.prepare("SELECT DISTINCT system FROM gamemetadata "
                      "WHERE romname = :ROMNAME");
        query.bindValue(":ROMNAME", Romname());
        if (!query.exec())
            MythDB::DBError("RomInfo::fillData - selecting systems", query);

        while (query.next())
        {
            if (m_allsystems.isEmpty())
                m_allsystems = query.value(0).toString();
            else
                m_allsystems += "," + query.value(0).toString();
        }
    }
    else
    {
        m_allsystems = m_system;
    }
}
Beispiel #5
0
void RomInfo::SaveToDatabase()
{
    MSqlQuery query(MSqlQuery::InitCon());

    bool inserting = false;

    if (m_id == 0)
        inserting = true;

    if (inserting)
    {
        LOG(VB_GENERAL, LOG_INFO, LOC + QString("Adding %1 - %2").arg(Rompath())
            .arg(Romname()));

        query.prepare("INSERT INTO gamemetadata "
                      "(system, romname, gamename, genre, year, gametype, "
                      "rompath, country, crc_value, diskcount, display, plot, "
                      "publisher, version, fanart, boxart, screenshot) "
                      "VALUES (:SYSTEM, :ROMNAME, :GAMENAME, :GENRE, :YEAR, "
                      ":GAMETYPE, :ROMPATH, :COUNTRY, :CRC32, '1', '1', :PLOT, "
                      ":PUBLISHER, :VERSION, :FANART, :BOXART, :SCREENSHOT)");

        query.bindValue(":SYSTEM",System());
        query.bindValue(":ROMNAME",Romname());
        query.bindValue(":GAMENAME",Gamename());
        query.bindValue(":GENRE",Genre());
        query.bindValue(":YEAR",Year());
        query.bindValue(":GAMETYPE",GameType());
        query.bindValue(":ROMPATH",Rompath());
        query.bindValue(":COUNTRY",Country());
        query.bindValue(":CRC32", QString());
        query.bindValue(":PLOT", Plot());
        query.bindValue(":PUBLISHER", Publisher());
        query.bindValue(":VERSION", Version());
        query.bindValue(":FANART", Fanart());
        query.bindValue(":BOXART", Boxart());
        query.bindValue(":SCREENSHOT", Screenshot());
    }
    else
    {
        query.prepare("UPDATE gamemetadata "
                      "SET version = 'CUSTOM', "
                      "    gamename = :GAMENAME,"
                      "    genre = :GENRE,"
                      "    year = :YEAR,"
                      "    country = :COUNTRY,"
                      "    plot = :PLOT,"
                      "    publisher = :PUBLISHER,"
                      "    favorite = :FAVORITE,"
                      "    screenshot = :SCREENSHOT,"
                      "    fanart = :FANART,"
                      "    boxart = :BOXART, "
                      "    inetref = :INETREF "
                      "WHERE gametype = :GAMETYPE AND "
                      "      romname  = :ROMNAME");
        query.bindValue(":GAMENAME", Gamename());
        query.bindValue(":GENRE", Genre());
        query.bindValue(":YEAR", Year());
        query.bindValue(":COUNTRY", Country());
        query.bindValue(":PLOT", Plot());
        query.bindValue(":PUBLISHER", Publisher());
        query.bindValue(":FAVORITE", Favorite());
        query.bindValue(":SCREENSHOT", Screenshot());
        query.bindValue(":FANART", Fanart());
        query.bindValue(":BOXART", Boxart());
        query.bindValue(":INETREF", Inetref());
        query.bindValue(":GAMETYPE", GameType());
        query.bindValue(":ROMNAME", Romname());
    }

    if (!query.exec())
    {
        MythDB::DBError("RomInfo::SaveToDatabase", query);
        return;
    }
}
Beispiel #6
0
void RomInfo::UpdateDatabase()
{
    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare("SELECT gamename,genre,year,country,plot,publisher, "
                  "favorite,screenshot,fanart,boxart,inetref "
                  "FROM gamemetadata "
                  "WHERE gametype = :GAMETYPE "
                  "AND romname = :ROMNAME");

    query.bindValue(":GAMETYPE", GameType());
    query.bindValue(":ROMNAME", Romname());

    if (!query.exec())
    {
        MythDB::DBError("RomInfo::UpdateDatabase", query);
        return;
    }

    if (!query.next())
        return;

    QString t_gamename  = query.value(0).toString();
    QString t_genre     = query.value(1).toString();
    QString t_year      = query.value(2).toString();
    QString t_country   = query.value(3).toString();
    QString t_plot      = query.value(4).toString();
    QString t_publisher = query.value(5).toString();
    bool    t_favourite = query.value(6).toBool();
    QString t_screenshot = query.value(7).toString();
    QString t_fanart = query.value(8).toString();
    QString t_boxart = query.value(9).toString();
    QString t_inetref = query.value(10).toString();

    if ((t_gamename  != Gamename())  || (t_genre     != Genre())   ||
            (t_year      != Year())      || (t_country   != Country()) ||
            (t_plot      != Plot())      || (t_publisher != Publisher()) ||
            (t_favourite != Favorite())  || (t_screenshot != Screenshot()) ||
            (t_fanart    != Fanart())    || (t_boxart    != Boxart()) ||
            (t_inetref   != Inetref()))
    {
        query.prepare("UPDATE gamemetadata "
                      "SET version = 'CUSTOM', "
                      "    gamename = :GAMENAME,"
                      "    genre = :GENRE,"
                      "    year = :YEAR,"
                      "    country = :COUNTRY,"
                      "    plot = :PLOT,"
                      "    publisher = :PUBLISHER,"
                      "    favorite = :FAVORITE,"
                      "    screenshot = :SCREENSHOT,"
                      "    fanart = :FANART,"
                      "    boxart = :BOXART, "
                      "    inetref = :INETREF "
                      "WHERE gametype = :GAMETYPE AND "
                      "      romname  = :ROMNAME");
        query.bindValue(":GAMENAME", Gamename());
        query.bindValue(":GENRE", Genre());
        query.bindValue(":YEAR", Year());
        query.bindValue(":COUNTRY", Country());
        query.bindValue(":PLOT", Plot());
        query.bindValue(":PUBLISHER", Publisher());
        query.bindValue(":FAVORITE", Favorite());
        query.bindValue(":SCREENSHOT", Screenshot());
        query.bindValue(":FANART", Fanart());
        query.bindValue(":BOXART", Boxart());
        query.bindValue(":INETREF", Inetref());
        query.bindValue(":GAMETYPE", GameType());
        query.bindValue(":ROMNAME", Romname());

        if (!query.exec())
        {
            MythDB::DBError("RomInfo::UpdateDatabase", query);
            return;
        }
    }
}