#ifndef PIKMAIN_H
#define    PIKMAIN_H

#include <kmainwindow.h>
#include <kmenubar.h>
#include <qstatusbar.h>
#include <qmenubar.h>
#include <qtoolbar.h>
#include <qstring.h>
#include <kaction.h>

#include "EditorManager.h"
#include <qtextedit.h>
#include <qvaluevector.h>
#include "PicFactory.hh"
#include "hardware.hh"
#include "PrgWid.h"
#include "ProjectWid.h"
#include "ProgrammerBase.h"

class ProjectWid ;
class KURL ;
class ConfigCenter ;

class PikMain : public KMainWindow
{
    Q_OBJECT
public:
    PikMain() ;
    int loadConfigFile() ;
    int saveConfigFile() ;
    KAction *act(const char *) ;
    /** Parse a source file to find which device has to be programmed.
    Device name is returned in device.

    returns 

    1 == OK
    0 == file not found
    */
    int snifDeviceName(const QString& filename, QString& device);
    /** Write a command to console, and execute it.
    Error messages are written back to the console with red ink
    \return satus of the executed command
    */
    int executeCommand(const QString& com) ;
    /** Accessor for the editors manager */
    EditorManager *editorManager();
    /** Accessor for the project widget */
    ProjectWid *projectWid();
    /** Perform clean up BEFORE the window is closed.
    */
    virtual bool queryClose();
    /** No descriptions */
    void CompileCproject();
    /** No descriptions */
    void removeEditor(const QString&);
    /** No descriptions */
    QValueVector<ProgrammerBase *>& programmersList();
    /** No descriptions */
    QString updateProgrammer();
    /** Build a list of processors from gpasm output */
    QStringList getProcList() ;
    /**  Build a list of processors from gpdasm output*/
    QStringList getDProcList();
    QTextEdit * getConsole();
    void createToolCollection();
public slots:
    void notImplemented() ;
    void assemblePrg() ;
    void assembleFile() ;
    void assembleProject() ;
    void compileCProject() ;
    void testWidget() ;
    void burnChip();
    void burnChipProject();
    void burnChipFile();
    void displayMessage(QString&) ;
    void consoleClicked() ;
    void programmerClosed() ;
    void exitApplication() ;
    /**  */
    void slotApplyToolbarSettings();
    /**  */
    void slotConfigureToolbar();
    /** Test stub */
    void testCode();
    /** No descriptions */
    void slotOpenRecentProject(const KURL &url) ;
    /** No descriptions */
    void slotOpenRecentFile(const KURL &url);
    /** No descriptions */
    void disAssemblePrg();
    /** No descriptions */
    void slotShowHex(const QString& fname) ;
    /** No descriptions */
    void confEditor();
    /** Try to   run the pikloops code generator for delays */
    void slotRunPikloops();
    /** No descriptions */
    void slotConfigCenter();
    /** No descriptions */
    void slotConfigCenterClosed();
    /** No descriptions */
    void slotWindowsMenuManagement();
    void slotRaiseWindow(int n);
private slots:
    void slotDisplayMenuManagement() ;
    void slotBookmarksManagement() ;
signals:
    void SigNewFile() ;
    void SigOpenFile() ;
    void SigSaveFile() ;
    void SigSaveAsFile() ;
    void SigCloseFile() ;
    void SigQuitPrg() ;

    void SigCutSelection() ;
    void SigCopySelection() ;
    void SigPasteSelection() ;

    void SigAssemble() ;
    void SigProgram() ;

    void SigAbout();


private:
    // unique toolbar
    KToolBar 	*toolbar ;

    EditorManager *edimanager ;
    QTextEdit  *console ;

    // programmer widget
    PrgWid 	    *programmer_widget ;
    // project widget
    QString     programmerFile ;
    /** project widget  */
    ProjectWid *project_wid    ;
    /**  */
    ConfigCenter * config_center;
    /** programmers  vector */
    QValueVector<ProgrammerBase *> the_programmers ;
    /** current programmer pointer (0 = none) */
    ProgrammerBase *current_programmer ;
} ;
#endif
