/**
 * @file ProgressBarQt.h
 * @brief Show a Progress-Bar with time estimation
 * @author Michael Koch
 * @date 25/03/2010

 */
#ifndef ProgressBarQtINCLUDE
#define ProgressBarQtINCLUDE

#include <qprogressdialog.h>
#include <qwidget.h>
#include <qlayout.h>

#include "core/image/ImageT.h"

namespace OBJREC {

/** @brief show a Progress-Bar with time estimation */
class ProgressBarQt
{

  protected:

    QGridLayout* layout;
    QWidget* dialogwindow;
    QProgressDialog* progressdialog;


    NICE::Image display;
    bool display_on;
    bool working;
    double start_time;
    double avg_time_step;
    double elapsed_time;
    double estimated_time;

    int step;

    int bar_width;
    int bar_height;
    int bar_top;
    int bar_borderx;

    int text_top;
    int text_height;

    std::string name;

    bool useGraphics;

	void timediff2str(char *text, double time);
	void displayTimeStat(int posy, char *text, double time);
	double getCurrentTime();
	bool graphicIsAvailable();

  public:

    /** constructor
     @param name name of the operation
     */
    ProgressBarQt ( const std::string & name, bool useGraphics = true );

    /** simple destructor */
    virtual ~ProgressBarQt();

    /** reset the progress bar and the corresponding
     name of the operation */

    void reset ( const std::string & name );

    /** show the progress bar */
    void show();
    /** hide the progress bar */
    void hide();

    void stop();

    /** update the progress bar
     @param count number of total steps of this operation
     */
    void update ( int count );

};
} // namespace

#endif
