[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
Public Slots | Public Member Functions | Protected Member Functions
KLFProgressDialog Class Reference

A Progress Dialog. More...

#include <klfguiutil.h>

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

List of all members.

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 ()
- Public Member Functions inherited from QProgressDialog
 QProgressDialog (QWidget *parent=0, Qt::WindowFlags f=0)
 QProgressDialog (const QString &labelText, const QString &cancelButtonText, int minimum, int maximum, QWidget *parent=0, Qt::WindowFlags f=0)
 cancel ()
 canceled ()
 forceShow ()
 reset ()
 setBar (QProgressBar *bar)
 setCancelButton (QPushButton *cancelButton)
 setCancelButtonText (const QString &cancelButtonText)
 setLabel (QLabel *label)
 setRange (int minimum, int maximum)
 sizeHint ()

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 172 of file klfguiutil.h.


Constructor & Destructor Documentation

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::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 ( )
virtual

Definition at line 85 of file klfguiutil.cpp.


Member Function Documentation

void KLFProgressDialog::paintEvent ( QPaintEvent event)
protected

Definition at line 146 of file klfguiutil.cpp.

References KLF_DEBUG_BLOCK, and KLF_FUNC_NAME.

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.

References QProgressDialog::sizeHint().

Referenced by startReportingProgress().

void KLFProgressDialog::setValue ( int  value)
virtualslot

Calls directly QProgressDialog::setValue()

Definition at line 139 of file klfguiutil.cpp.

References klfDbg.

Referenced by startReportingProgress().

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.

References KLFProgressReporter::max(), KLFProgressReporter::min(), QProgressDialog::reset(), setDescriptiveText(), QProgressDialog::setRange(), and setValue().

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(), QProgressDialog::reset(), QProgressDialog::setRange(), and setValue().


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

Generated by doxygen 1.8.1