[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
Public Slots | Public Member Functions | Protected Member Functions | List of all members
KLFProgressDialog Class Reference

A Progress Dialog. More...

#include <klfguiutil.h>

Inheritance diagram for KLFProgressDialog:
Inheritance graph
[legend]
Collaboration diagram for KLFProgressDialog:
Collaboration graph
[legend]

Public Slots

virtual void setDescriptiveText (const QString &labelText)
 
virtual void startReportingProgress (KLFProgressReporter *progressReporter, const QString &descriptiveText)
 
virtual void startReportingProgress (KLFProgressReporter *progressReporter)
 
virtual void setValue (int value)
 

Public Member Functions

 KLFProgressDialog (QString labelText=QString(), QWidget *parent=NULL)
 
 KLFProgressDialog (bool canCancel, QString labelText, QWidget *parent)
 
virtual ~KLFProgressDialog ()
 

Protected Member Functions

void paintEvent (QPaintEvent *event)
 

Detailed Description

A Progress Dialog.

This class is a QProgressDialog derivative that is optimized to work for klatexformula's needs, especially making it easy to use with KLFProgressReporter.

Among others, this dialog provides a straightforward option to disable the Cancel button.

Basically this is just a wrapper around QProgressDialog's functions. Typical use is:

MyWidget::someLengthyOperation()
{
int number_of_steps = ...;
KLFProgressDialog pdlg(false, this); // disable cancel
KLFProgressReporter progressReporter(0, number_of_steps);
pdlg.startReportingProgress(&progressReporter, "Please wait until some long operation completes...");
...
int step = 0;
for (step = 0; step < number_of_steps; ++step) {
// an iteration step
...
progressReporter.doReportProgress(step)
}
}

The previous example is somewhat trivial and does not exhibit the advantages of the features of this class and of KLFProgressReporter over QProgressDialog; the example of KLFLibResourceEngine is more relevant:

// klflib.h : the library resource engine system (no GUI)
class KLFLibResourceEngine {
....
signals:
void operationStartReportingProgress(KLFProgressReporter *progressReporter, const QString& label);
...
};
// klflibbrowser.cpp : the library browser (GUI)
...
bool KLFLibBrowser::openResource(...)
{
...
connect(resource, SIGNAL(operationStartReportingProgress(KLFProgressReporter *, const QString&)),
this, SLOT(slotStartProgress(KLFProgressReporter *, const QString&)));
...
}
void KLFLibBrowser::slotStartProgress(KLFProgressReporter *progressReporter, const QString& label)
{
KLFProgressDialog *pdialog = new KLFProgressDialog(false, QString(), this);
pdialog->startReportingProgress(progressReporter, label);
...
}

which opens a progress dialog whenever the resource emits an operationStartReportingProgress() signal. Note that in this example, we have not provided the means to delete the progress dialog once it has completed; for details have a look at the source code of klflibbrowser.cpp.

For yet another example of inline (on-the-stack) usage of KLFProgressDialog, check out KLFLibBrowser::slotExport() in klflibbrowser.cpp.

Todo:
.... I'm not sure, but to delete the dialog, couldn't we simply connect KLFProgressReporter::finished() to KLFProgressDialog::deleteLater() ... ? needs a test.

Definition at line 171 of file klfguiutil.h.

Constructor & Destructor Documentation

◆ KLFProgressDialog() [1/2]

KLFProgressDialog::KLFProgressDialog ( QString  labelText = QString(),
QWidget *  parent = NULL 
)

Build a progress dialog with the given labelText and parent

Definition at line 73 of file klfguiutil.cpp.

◆ KLFProgressDialog() [2/2]

KLFProgressDialog::KLFProgressDialog ( bool  canCancel,
QString  labelText,
QWidget *  parent 
)

Build a progress dialog with a cancel button that is enabled or disabled (following the value of canCancel), with label labelText, and parent parent.

Definition at line 79 of file klfguiutil.cpp.

◆ ~KLFProgressDialog()

KLFProgressDialog::~KLFProgressDialog ( )
virtual

Definition at line 85 of file klfguiutil.cpp.

Member Function Documentation

◆ paintEvent()

void KLFProgressDialog::paintEvent ( QPaintEvent event)
protected

Definition at line 146 of file klfguiutil.cpp.

References KLF_DEBUG_BLOCK, and KLF_FUNC_NAME.

◆ setDescriptiveText

void KLFProgressDialog::setDescriptiveText ( const QString labelText)
virtualslot

same as QProgressDialog::setLabelText() but resizes the dialog a bit larger so that its looks nicer.

Definition at line 107 of file klfguiutil.cpp.

◆ setValue

void KLFProgressDialog::setValue ( int  value)
virtualslot

Calls directly QProgressDialog::setValue()

Definition at line 139 of file klfguiutil.cpp.

References klfDbg.

Referenced by startReportingProgress().

◆ startReportingProgress [1/2]

void KLFProgressDialog::startReportingProgress ( KLFProgressReporter progressReporter)
virtualslot

start reporting progress from progressReporter, without changing label text.

Note
This will disconnect the previously set progress reporter to the slot setValue()

Definition at line 127 of file klfguiutil.cpp.

References KLFProgressReporter::max(), KLFProgressReporter::min(), and setValue().

◆ startReportingProgress [2/2]

void KLFProgressDialog::startReportingProgress ( KLFProgressReporter progressReporter,
const QString descriptiveText 
)
virtualslot

start reporting progress from progressReporter and set label text to descriptiveText.

Note
This will disconnect the previously set progress reporter to the slot setValue()

Definition at line 112 of file klfguiutil.cpp.


The documentation for this class was generated from the following files:
KLFProgressDialog::startReportingProgress
virtual void startReportingProgress(KLFProgressReporter *progressReporter, const QString &descriptiveText)
Definition: klfguiutil.cpp:112
KLFProgressDialog::KLFProgressDialog
KLFProgressDialog(QString labelText=QString(), QWidget *parent=NULL)
Definition: klfguiutil.cpp:73
QString
KLFProgressReporter
Object that emits progress information of a (lengthy) operation.
Definition: klfguiutil.h:62
KLFProgressDialog
A Progress Dialog.
Definition: klfguiutil.h:171

Generated by doxygen 1.8.16