mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
Qt: fix gamelist sorting for playtimes
This commit is contained in:
parent
c4a01875d0
commit
1759d6d90a
@ -373,10 +373,8 @@ QString game_list_frame::GetLastPlayedBySerial(const QString& serial)
|
||||
return m_persistent_settings->GetLastPlayed(serial);
|
||||
}
|
||||
|
||||
QString game_list_frame::GetPlayTimeBySerial(const QString& serial)
|
||||
QString game_list_frame::GetPlayTimeByMs(int elapsed_ms)
|
||||
{
|
||||
const qint64 elapsed_ms = m_persistent_settings->GetPlaytime(serial);
|
||||
|
||||
if (elapsed_ms <= 0)
|
||||
{
|
||||
return "";
|
||||
@ -1983,6 +1981,10 @@ int game_list_frame::PopulateGameList()
|
||||
app_version = tr("%0 (Update available: %1)").arg(app_version, game->compat.version);
|
||||
}
|
||||
|
||||
// Playtimes
|
||||
const qint64 elapsed_ms = m_persistent_settings->GetPlaytime(serial);
|
||||
const QString last_played = GetLastPlayedBySerial(serial);
|
||||
|
||||
m_gameList->setItem(row, gui::column_icon, icon_item);
|
||||
m_gameList->setItem(row, gui::column_name, title_item);
|
||||
m_gameList->setItem(row, gui::column_serial, serial_item);
|
||||
@ -1994,8 +1996,8 @@ int game_list_frame::PopulateGameList()
|
||||
m_gameList->setItem(row, gui::column_resolution, new custom_table_widget_item(GetStringFromU32(game->info.resolution, resolution::mode, true)));
|
||||
m_gameList->setItem(row, gui::column_sound, new custom_table_widget_item(GetStringFromU32(game->info.sound_format, sound::format, true)));
|
||||
m_gameList->setItem(row, gui::column_parental, new custom_table_widget_item(GetStringFromU32(game->info.parental_lvl, parental::level), Qt::UserRole, game->info.parental_lvl));
|
||||
m_gameList->setItem(row, gui::column_last_play, new custom_table_widget_item(GetLastPlayedBySerial(serial)));
|
||||
m_gameList->setItem(row, gui::column_playtime, new custom_table_widget_item(GetPlayTimeBySerial(serial)));
|
||||
m_gameList->setItem(row, gui::column_last_play, new custom_table_widget_item(last_played, Qt::UserRole, QDate::fromString(last_played, gui::persistent::last_played_date_format)));
|
||||
m_gameList->setItem(row, gui::column_playtime, new custom_table_widget_item(GetPlayTimeByMs(elapsed_ms), Qt::UserRole, elapsed_ms));
|
||||
m_gameList->setItem(row, gui::column_compat, compat_item);
|
||||
|
||||
if (selected_item == game->info.icon_path)
|
||||
|
@ -256,7 +256,7 @@ private:
|
||||
bool CreatePPUCache(const game_info& game);
|
||||
|
||||
QString GetLastPlayedBySerial(const QString& serial);
|
||||
QString GetPlayTimeBySerial(const QString& serial);
|
||||
QString GetPlayTimeByMs(int elapsed_ms);
|
||||
std::string GetCacheDirBySerial(const std::string& serial);
|
||||
std::string GetDataDirBySerial(const std::string& serial);
|
||||
std::string CurrentSelectionIconPath();
|
||||
|
@ -237,7 +237,7 @@ void gui_application::StopPlaytime()
|
||||
|
||||
const qint64 playtime = m_persistent_settings->GetPlaytime(serial) + m_timer_playtime.elapsed();
|
||||
m_persistent_settings->SetPlaytime(serial, playtime);
|
||||
m_persistent_settings->SetLastPlayed(serial, QDate::currentDate().toString("MMMM d yyyy"));
|
||||
m_persistent_settings->SetLastPlayed(serial, QDate::currentDate().toString(gui::persistent::last_played_date_format));
|
||||
m_timer_playtime.invalidate();
|
||||
}
|
||||
|
||||
|
@ -8,13 +8,13 @@ persistent_settings::persistent_settings(QObject* parent) : settings(parent)
|
||||
|
||||
void persistent_settings::SetPlaytime(const QString& serial, const qint64& elapsed)
|
||||
{
|
||||
m_playtime[serial] = elapsed;
|
||||
SetValue(gui::persistent::playtime, serial, elapsed);
|
||||
m_playtime[serial] = std::max<qint64>(0, elapsed);
|
||||
SetValue(gui::persistent::playtime, serial, m_playtime[serial]);
|
||||
}
|
||||
|
||||
qint64 persistent_settings::GetPlaytime(const QString& serial)
|
||||
{
|
||||
return m_playtime[serial];
|
||||
return std::max<qint64>(0, m_playtime[serial]);
|
||||
}
|
||||
|
||||
void persistent_settings::SetLastPlayed(const QString& serial, const QString& date)
|
||||
|
@ -12,6 +12,9 @@ namespace gui
|
||||
// Entry names
|
||||
const QString playtime = "Playtime";
|
||||
const QString last_played = "LastPlayed";
|
||||
|
||||
// Date format
|
||||
const QString last_played_date_format = "MMMM d yyyy";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user