#ifndef QGSCOPEWORKBENCH_H
#define QGSCOPEWORKBENCH_H

#include <QObject>
#include <QVariant>

//class QMainWindow;
#include <QMainWindow>

//#include "qgscopedevice.h"

class QgScopeDevice;
class QgScopeChannel;

class QgScopeWorkbench;
class QgLogger;
class QgLoggerDockWidget;

class QDockWidget;
class QWindget;
class QToolBar;

class QgScopeChrono;
class QgRunSession;

class QMenu;

Q_DECLARE_OPAQUE_POINTER(QgScopeChrono)

typedef QMap<QString, QVariant> QgScopeObjMap;

//typedef QVariant<QString, QObject*> QgScopeObjMapVariant;
namespace ads
{
        class CDockWidget;
        class CDockManager;
}

class QgScopeScriptSiteAdaptor
{
public:
    virtual ~QgScopeScriptSiteAdaptor();

    virtual void registerObject(const QString& objName, QObject* obj) = 0;
};

class QgScopeWorkbench : public QObject
{
    Q_OBJECT

    Q_PROPERTY(QList<QgScopeDevice*> devicesList READ devicesList)

    Q_PROPERTY(const QString& version READ version)

    Q_PROPERTY(QgScopeChrono* chrono READ chrono)

    //Python-nice
    Q_PROPERTY(QList<QObject*> deviceObjectsList READ deviceObjectsList)
    Q_PROPERTY(QList<QObject*> channelObjectsList READ channelObjectsList)
    Q_PROPERTY(QObject* chronoObject READ chronoObject)

    Q_PROPERTY(QVariant objs READ objs)

    Q_PROPERTY(QgRunSession* runSession READ runSession)

public:
    static QgScopeWorkbench& instance();

    static const QString& version();

    void setScriptSiteAdptor(QgScopeScriptSiteAdaptor* adaptor);

    void setApplicationTitle(const QString&);
    void setProjectName(const QString&);

    void setAboutMessage(const QString& msg);

    void setClientInitilizer(void (*)(void));

    ads::CDockManager* dockManager();

    QMainWindow* mainWindow() const;
    void show() const;

    //void insertToolBar(QToolBar*);
    void initializeStdToolBars();

    ads::CDockWidget* addOuterPannel(Qt::DockWidgetArea area, QWidget* w, const QString& group=QString());

    QgLoggerDockWidget &loggerWidget();
    void log(const QString& );

    QList<QgScopeDevice*> devicesList() const;


    QgScopeChrono* chrono() const;

    //Phyton-nice
    QList<QObject*> deviceObjectsList() const;  //!devices as QObject, good for PythonQT
    QList<QObject*> channelObjectsList() const;  //!devices as QObject, good for PythonQT

    QObject* chronoObject() const;

    QVariant objs() const;

    QgRunSession* runSession() const;

    QMenu* wbMenu();

    QString defaultPerspectiveName() const ;

public slots:
    void addDevice(QgScopeDevice*);
    void addChannel(QgScopeChannel*);

    void restoreLayout(const QString& lyname=QString());

    void onAdsDockCreated(ads::CDockWidget* w, const QString& groupname);
    void onAppMenuCreated(QMenu*);
    void onAppReady();

public:
    explicit QgScopeWorkbench(QObject *parent = 0);
    explicit QgScopeWorkbench(const QgScopeWorkbench&);
    ~QgScopeWorkbench();

signals:

private:

};

#endif // QGSCOPEWORKBENCH_H
