25#define GAUGE_RANGE 1000
32 m_currentProgress( 0 ),
33 m_currentProgressTotal( 0 ),
36#if wxCHECK_VERSION( 3, 1, 0 )
38 m_appProgressIndicator( parent->GetParent(),
GAUGE_RANGE )
41#if wxCHECK_VERSION( 3, 1, 0 )
42 m_appProgressIndicator.Pulse();
49 if( !aShowDownloadSection )
73 std::lock_guard<std::mutex> guard(
m_mutex );
74 m_reports.push_back( std::make_pair( aText, aSeverity ) );
87 return ( aValue + 999 ) / 1000;
118 double current = ( total > 0 ) ? (
double( cp ) / double( total ) ) : 0;
121 current = ( phase + current ) / phases;
123 if( current > 1.0 || finished )
127#if wxCHECK_VERSION( 3, 1, 0 )
128 m_appProgressIndicator.SetValue( current *
GAUGE_RANGE );
144 if( current > 1.0 || finished )
150 std::lock_guard<std::mutex> guard(
m_mutex );
152 for(
const std::pair<wxString, SEVERITY>& pair :
m_reports )
Class DIALOG_PCM_PROGRESS_BASE.
wxPanel * m_panelDownload
wxButton * m_buttonCancel
wxGauge * m_downloadGauge
wxStaticText * m_downloadText
WX_HTML_REPORT_BOX * m_reporter
std::atomic_int64_t m_currentProgressTotal
std::atomic_int64_t m_currentProgress
void OnCloseClicked(wxCommandEvent &event) override
std::atomic_bool m_finished
void OnCancelClicked(wxCommandEvent &event) override
void AdvancePhase() override
Safe to call from non-UI thread. Disables cancel button, enables close button.
void SetDownloadProgress(uint64_t aDownloaded, uint64_t aTotal)
Safe to call from non-UI thread. Sets the download prgress of the current package.
void SetPackageProgress(uint64_t aProgress, uint64_t aTotal)
Safe to call from non-UI thread. Advances to the next package.
std::vector< std::pair< wxString, SEVERITY > > m_reports
void PCMReport(const wxString &aText, SEVERITY aSeverity)
Safe to call from non-UI thread. Sets the download progress of the current zip entry.
static uint64_t toKb(uint64_t aValue)
DIALOG_PCM_PROGRESS(wxWindow *parent, bool aShowDownloadSection=true)
Constructor.
std::atomic_int64_t m_downloadTotal
std::atomic_int64_t m_downloaded
This implements all the tricky bits for thread safety, but the GUI is left to derived classes.
virtual void AdvancePhase() override
Use the next available virtual zone of the dialog progress bar.
std::atomic_int m_numPhases
std::atomic_bool m_cancelled
std::atomic_int m_progress
void SetNumPhases(int aNumPhases) override
Set the number of phases.
std::atomic_int m_maxProgress
void SetImmediateMode()
In immediate mode, messages are flushed as they are added.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.