#ifndef PRGWID_H
#define PRGWID_H
//#include <qmainwindow.h>
#include <kmainwindow.h>
#include <kaction.h>
#include <ktoolbar.h>
#include <kled.h>
#include <kstatusbar.h>
#include <kprogress.h>

#include <qlabel.h>
#include <qcombobox.h>
#include "pic.hh"
#include "hardware.hh"
#include "progressListener.hh"
#include "ProgrammerBase.h"

class PrgWid : public KMainWindow, public progressListener
{
  Q_OBJECT
  QString     fileName ;
  pic 	*curpic ;
  ProgrammerBase *programmer ;


  // indicateur d'activite du programmeur
  KLed *progRunning ;
  QLabel *statusLabel ;

  // status Bar
  KStatusBar * statBar ;

  // progress bar
  KProgress *progress ;

  QLineEdit *fileNameLabel ;
  QLineEdit * detected , *revdetected ;

public:
  PrgWid(ProgrammerBase *pr, const QString& fn, QWidget *parent) ;
  virtual ~PrgWid() ;
  void go() ;
  /** Verify the currently plugged device type
  \return true if detected device type is compatible with current pic model
  or if device type is not autodetectable
  */
  bool verifyDeviceType(const QString& type);
  bool verifyDeviceType();
  /** Called before the widget is closed */
  virtual bool queryClose();
  /** No descriptions */
  QStringList parseProgOptions(const QString &op);
  /** specified by progressObserver interface*/
  virtual void updateProgressBar(int percent);
  virtual void updateProgressText(const char *);
private:
  void setStatus(bool active, const QString& txt) ;
  void setFileName(const QString &fname) ;

public slots:
  void quit() ;
  void saveHex() ;
  void saveHexAs() ;
  void loadHex() ;
  void loadHexAs() ;

  void readPic() ;
  void erasePic() ;
  void verifyPic() ;
  void programPic() ;
  /** Uses KEditToolbar and XML UI description to dynamically reconfigure toolbar */
  void slotConfigureToolbar();
  /** Apply slotConfigureToolbar() modifications */
  void slotApplyToolbarSettings();
  /** No descriptions */
  void slotDetectDeviceType();
  /** No descriptions */
  void slotProgOptionSelected(int opt);
    void slotExtraMenuManagement();
    void slotExecExtra(int function_number);

signals:
  void fileUpdated(const QString &) ;
  void bufferModified() ;
  void messageGenerated(QString&) ;
protected:
  /** Find a KAction "a" from the parent's actionCollection() */
  KAction * act(const char *a) const;
} ;
#endif
