Qt: move ReadJSON in game compat to its own function
This commit is contained in:
@@ -15,11 +15,8 @@ game_compatibility::game_compatibility(std::shared_ptr<gui_settings> settings) :
|
|||||||
RequestCompatibility();
|
RequestCompatibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_compatibility::RequestCompatibility(bool online)
|
bool game_compatibility::ReadJSON(const QJsonObject& json_data, bool after_download)
|
||||||
{
|
{
|
||||||
// Creates new map from database
|
|
||||||
auto ReadJSON = [=](const QJsonObject& json_data, bool after_download)
|
|
||||||
{
|
|
||||||
int return_code = json_data["return_code"].toInt();
|
int return_code = json_data["return_code"].toInt();
|
||||||
|
|
||||||
if (return_code < 0)
|
if (return_code < 0)
|
||||||
@@ -81,8 +78,10 @@ void game_compatibility::RequestCompatibility(bool online)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
void game_compatibility::RequestCompatibility(bool online)
|
||||||
|
{
|
||||||
if (!online)
|
if (!online)
|
||||||
{
|
{
|
||||||
// Retrieve database from file
|
// Retrieve database from file
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class game_compatibility : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
const std::map<QString, compat_status> Status_Data =
|
const std::map<QString, compat_status> Status_Data =
|
||||||
{
|
{
|
||||||
{ "Playable", { 0, "", "#1ebc61", QObject::tr("Playable"), QObject::tr("Games that can be properly played from start to finish") } },
|
{ "Playable", { 0, "", "#1ebc61", QObject::tr("Playable"), QObject::tr("Games that can be properly played from start to finish") } },
|
||||||
@@ -49,6 +50,9 @@ class game_compatibility : public QObject
|
|||||||
std::unique_ptr<QNetworkAccessManager> m_network_access_manager;
|
std::unique_ptr<QNetworkAccessManager> m_network_access_manager;
|
||||||
std::map<std::string, compat_status> m_compat_database;
|
std::map<std::string, compat_status> m_compat_database;
|
||||||
|
|
||||||
|
/** Creates new map from the database */
|
||||||
|
bool ReadJSON(const QJsonObject& json_data, bool after_download);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Handles reads, writes and downloads for the compatibility database */
|
/** Handles reads, writes and downloads for the compatibility database */
|
||||||
game_compatibility(std::shared_ptr<gui_settings> settings);
|
game_compatibility(std::shared_ptr<gui_settings> settings);
|
||||||
|
|||||||
Reference in New Issue
Block a user