1414
1515#include " moc_gamelistrefreshthread.cpp"
1616
17- AsyncRefreshProgressCallback::AsyncRefreshProgressCallback ( GameListRefreshThread* parent ) : m_parent(parent )
17+ GameListRefreshThread:: GameListRefreshThread( bool invalidate_cache ) : QThread(), m_invalidate_cache(invalidate_cache )
1818{
1919}
2020
21- float AsyncRefreshProgressCallback::timeSinceStart () const
22- {
23- return m_start_time.GetTimeSeconds ();
24- }
21+ GameListRefreshThread::~GameListRefreshThread () = default ;
2522
26- void AsyncRefreshProgressCallback::Cancel ()
23+ void GameListRefreshThread::cancel ()
2724{
2825 // Not atomic, but we don't need to cancel immediately.
2926 m_cancelled = true ;
3027}
3128
32- void AsyncRefreshProgressCallback::PushState ()
29+ void GameListRefreshThread::run ()
30+ {
31+ GameList::Refresh (m_invalidate_cache, false , this );
32+ emit refreshComplete ();
33+ }
34+
35+ void GameListRefreshThread::PushState ()
3336{
3437 ProgressCallback::PushState ();
3538}
3639
37- void AsyncRefreshProgressCallback ::PopState ()
40+ void GameListRefreshThread ::PopState ()
3841{
3942 ProgressCallback::PopState ();
4043
@@ -46,7 +49,7 @@ void AsyncRefreshProgressCallback::PopState()
4649 fireUpdate ();
4750}
4851
49- void AsyncRefreshProgressCallback ::SetStatusText (const std::string_view text)
52+ void GameListRefreshThread ::SetStatusText (const std::string_view text)
5053{
5154 const QString new_text = QtUtils::StringViewToQString (text);
5255 if (new_text == m_status_text)
@@ -56,7 +59,7 @@ void AsyncRefreshProgressCallback::SetStatusText(const std::string_view text)
5659 fireUpdate ();
5760}
5861
59- void AsyncRefreshProgressCallback ::SetProgressRange (u32 range)
62+ void GameListRefreshThread ::SetProgressRange (u32 range)
6063{
6164 ProgressCallback::SetProgressRange (range);
6265 if (static_cast <int >(m_progress_range) == m_last_range)
@@ -66,7 +69,7 @@ void AsyncRefreshProgressCallback::SetProgressRange(u32 range)
6669 fireUpdate ();
6770}
6871
69- void AsyncRefreshProgressCallback ::SetProgressValue (u32 value)
72+ void GameListRefreshThread ::SetProgressValue (u32 value)
7073{
7174 ProgressCallback::SetProgressValue (value);
7275 if (static_cast <int >(m_progress_value) == m_last_value)
@@ -76,46 +79,24 @@ void AsyncRefreshProgressCallback::SetProgressValue(u32 value)
7679 fireUpdate ();
7780}
7881
79- void AsyncRefreshProgressCallback ::ModalError (const std::string_view message)
82+ void GameListRefreshThread ::ModalError (const std::string_view message)
8083{
8184 QMessageBox::critical (nullptr , QStringLiteral (" Error" ), QtUtils::StringViewToQString (message));
8285}
8386
84- bool AsyncRefreshProgressCallback ::ModalConfirmation (const std::string_view message)
87+ bool GameListRefreshThread ::ModalConfirmation (const std::string_view message)
8588{
8689 return QMessageBox::question (nullptr , QStringLiteral (" Question" ), QtUtils::StringViewToQString (message)) ==
8790 QMessageBox::Yes;
8891}
8992
90- void AsyncRefreshProgressCallback ::ModalInformation (const std::string_view message)
93+ void GameListRefreshThread ::ModalInformation (const std::string_view message)
9194{
9295 QMessageBox::information (nullptr , QStringLiteral (" Information" ), QtUtils::StringViewToQString (message));
9396}
9497
95- void AsyncRefreshProgressCallback::fireUpdate ()
96- {
97- m_parent->refreshProgress (m_status_text, m_last_value, m_last_range, m_start_time.GetTimeSeconds ());
98- }
99-
100- GameListRefreshThread::GameListRefreshThread (bool invalidate_cache)
101- : QThread(), m_progress(this ), m_invalidate_cache(invalidate_cache)
102- {
103- }
104-
105- GameListRefreshThread::~GameListRefreshThread () = default ;
106-
107- float GameListRefreshThread::timeSinceStart () const
98+ void GameListRefreshThread::fireUpdate ()
10899{
109- return m_progress.timeSinceStart ();
110- }
111-
112- void GameListRefreshThread::cancel ()
113- {
114- m_progress.Cancel ();
115- }
116-
117- void GameListRefreshThread::run ()
118- {
119- GameList::Refresh (m_invalidate_cache, false , &m_progress);
120- emit refreshComplete ();
100+ emit refreshProgress (m_status_text, m_last_value, m_last_range, static_cast <int >(GameList::GetEntryCount ()),
101+ m_start_time.GetTimeSeconds ());
121102}
0 commit comments