Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CProgressJob Class Reference

Basic implementation of a CJob with a progress bar to indicate the progress of the job being processed. More...

#include <ProgressJob.h>

Inheritance diagram for CProgressJob:
CJob ADDON::CRepositoryUpdateJob CFileOperationJob CMusicLibraryProgressJob CRefreshInfoJob CVideoLibraryProgressJob CMusicLibraryCleaningJob CMusicLibraryExportJob CMusicLibraryImportJob CVideoLibraryCleaningJob CVideoLibraryRefreshingJob

Public Member Functions

 ~CProgressJob () override
 
const char * GetType () const override
 Function that returns the type of job.
 
bool operator== (const CJob *job) const override
 
bool ShouldCancel (unsigned int progress, unsigned int total) const override
 Function for longer jobs to report progress and check whether they have been cancelled.
 
bool DoModal ()
 Executes the job showing a modal progress dialog.
 
void SetProgressIndicators (CGUIDialogProgressBarHandle *progressBar, CGUIDialogProgress *progressDialog, bool updateProgress=true, bool updateInformation=true)
 Sets the given progress indicators to be used during execution of the job.
 
bool HasProgressIndicator () const
 
- Public Member Functions inherited from CJob
 CJob ()
 
virtual ~CJob ()=default
 Destructor for job objects.
 
virtual bool DoWork ()=0
 Main workhorse function of CJob instances.
 

Protected Member Functions

 CProgressJob ()
 
 CProgressJob (CGUIDialogProgressBarHandle *progressBar)
 
bool IsModal () const
 Whether the job is being run modally or in the background.
 
CGUIDialogProgressBarHandleGetProgressBar () const
 Returns the progress bar indicating the progress of the job.
 
void SetProgressBar (CGUIDialogProgressBarHandle *progress)
 Sets the progress bar indicating the progress of the job.
 
CGUIDialogProgressGetProgressDialog () const
 Returns the progress dialog indicating the progress of the job.
 
void SetProgressDialog (CGUIDialogProgress *progressDialog)
 Sets the progress bar indicating the progress of the job.
 
bool GetAutoClose ()
 Whether to automatically close the progress indicator in MarkFinished().
 
void SetAutoClose (bool autoClose)
 Set whether to automatically close the progress indicator in MarkFinished().
 
bool GetUpdateProgress ()
 Whether to update the progress bar or not.
 
void SetUpdateProgress (bool updateProgress)
 Set whether to update the progress bar or not.
 
bool GetUpdateInformation ()
 Whether to update the progress information or not.
 
void SetUpdateInformation (bool updateInformation)
 Set whether to update the progress information or not.
 
void ShowProgressDialog () const
 Makes sure that the modal dialog is being shown.
 
void SetTitle (const std::string &title)
 Sets the given title as the title of the progress bar.
 
void SetText (const std::string &text)
 Sets the given text as the description of the progress bar.
 
void SetProgress (float percentage) const
 Sets the progress of the progress bar to the given value in percentage.
 
void SetProgress (int currentStep, int totalSteps) const
 Sets the progress of the progress bar to the given value.
 
void MarkFinished ()
 Marks the progress as finished by setting it to 100%.
 
bool IsCancelled () const
 Checks if the progress dialog has been cancelled.
 

Additional Inherited Members

- Public Types inherited from CJob
enum  PRIORITY {
  PRIORITY_LOW_PAUSABLE = 0 , PRIORITY_LOW , PRIORITY_NORMAL , PRIORITY_HIGH ,
  PRIORITY_DEDICATED
}
 Priority levels for jobs, specified by clients when adding jobs to the CJobManager. More...
 

Detailed Description

Basic implementation of a CJob with a progress bar to indicate the progress of the job being processed.

Constructor & Destructor Documentation

◆ ~CProgressJob()

CProgressJob::~CProgressJob ( )
override

◆ CProgressJob() [1/2]

CProgressJob::CProgressJob ( )
protected

◆ CProgressJob() [2/2]

CProgressJob::CProgressJob ( CGUIDialogProgressBarHandle * progressBar)
explicitprotected

Member Function Documentation

◆ DoModal()

bool CProgressJob::DoModal ( )

Executes the job showing a modal progress dialog.

◆ GetAutoClose()

bool CProgressJob::GetAutoClose ( )
inlineprotected

Whether to automatically close the progress indicator in MarkFinished().

◆ GetProgressBar()

CGUIDialogProgressBarHandle * CProgressJob::GetProgressBar ( ) const
inlineprotected

Returns the progress bar indicating the progress of the job.

◆ GetProgressDialog()

CGUIDialogProgress * CProgressJob::GetProgressDialog ( ) const
inlineprotected

Returns the progress dialog indicating the progress of the job.

◆ GetType()

const char * CProgressJob::GetType ( ) const
inlineoverridevirtual

Function that returns the type of job.

CJob subclasses may optionally implement this function to specify the type of job. This is useful for the CJobManager::AddLIFOJob() routine, which preempts similar jobs with the new job.

Returns
a unique character string describing the job.
See also
CJobManager

Reimplemented from CJob.

Reimplemented in CVideoLibraryCleaningJob, CVideoLibraryProgressJob, and CVideoLibraryRefreshingJob.

◆ GetUpdateInformation()

bool CProgressJob::GetUpdateInformation ( )
inlineprotected

Whether to update the progress information or not.

◆ GetUpdateProgress()

bool CProgressJob::GetUpdateProgress ( )
inlineprotected

Whether to update the progress bar or not.

◆ HasProgressIndicator()

bool CProgressJob::HasProgressIndicator ( ) const

◆ IsCancelled()

bool CProgressJob::IsCancelled ( ) const
protected

Checks if the progress dialog has been cancelled.

◆ IsModal()

bool CProgressJob::IsModal ( ) const
inlineprotected

Whether the job is being run modally or in the background.

◆ MarkFinished()

void CProgressJob::MarkFinished ( )
protected

Marks the progress as finished by setting it to 100%.

◆ operator==()

bool CProgressJob::operator== ( const CJob * job) const
inlineoverridevirtual

◆ SetAutoClose()

void CProgressJob::SetAutoClose ( bool autoClose)
inlineprotected

Set whether to automatically close the progress indicator in MarkFinished().

◆ SetProgress() [1/2]

void CProgressJob::SetProgress ( float percentage) const
protected

Sets the progress of the progress bar to the given value in percentage.

Parameters
[in]percentagePercentage to be set as the current progress

◆ SetProgress() [2/2]

void CProgressJob::SetProgress ( int currentStep,
int totalSteps ) const
protected

Sets the progress of the progress bar to the given value.

Parameters
[in]currentStepCurrent step being processed
[in]totalStepsTotal steps to be processed

◆ SetProgressBar()

void CProgressJob::SetProgressBar ( CGUIDialogProgressBarHandle * progress)
inlineprotected

Sets the progress bar indicating the progress of the job.

◆ SetProgressDialog()

void CProgressJob::SetProgressDialog ( CGUIDialogProgress * progressDialog)
inlineprotected

Sets the progress bar indicating the progress of the job.

◆ SetProgressIndicators()

void CProgressJob::SetProgressIndicators ( CGUIDialogProgressBarHandle * progressBar,
CGUIDialogProgress * progressDialog,
bool updateProgress = true,
bool updateInformation = true )

Sets the given progress indicators to be used during execution of the job.

This automatically disables auto-closing the given progress indicators once the job has been finished.

Parameters
progressBarProgress bar handle to be used.
progressDialogProgress dialog to be used.
updateProgress(optional) Whether to show progress updates.
updateInformation(optional) Whether to show progress information.

◆ SetText()

void CProgressJob::SetText ( const std::string & text)
protected

Sets the given text as the description of the progress bar.

Parameters
[in]textText to be set

◆ SetTitle()

void CProgressJob::SetTitle ( const std::string & title)
protected

Sets the given title as the title of the progress bar.

Parameters
[in]titleTitle to be set

◆ SetUpdateInformation()

void CProgressJob::SetUpdateInformation ( bool updateInformation)
inlineprotected

Set whether to update the progress information or not.

◆ SetUpdateProgress()

void CProgressJob::SetUpdateProgress ( bool updateProgress)
inlineprotected

Set whether to update the progress bar or not.

◆ ShouldCancel()

bool CProgressJob::ShouldCancel ( unsigned int progress,
unsigned int total ) const
overridevirtual

Function for longer jobs to report progress and check whether they have been cancelled.

Jobs that contain loops that may take time should check this routine each iteration of the loop, both to (optionally) report progress, and to check for cancellation.

Parameters
progressthe amount of the job performed, out of total.
totalthe total amount of processing to be performed
Returns
if true, the job has been asked to cancel.
See also
IJobCallback::OnJobProgress()

Reimplemented from CJob.

◆ ShowProgressDialog()

void CProgressJob::ShowProgressDialog ( ) const
protected

Makes sure that the modal dialog is being shown.


The documentation for this class was generated from the following files: