#ifndef QSAS_BROWSE_H_
#define QSAS_BROWSE_H_

#include <QObject>
#include "Qdos.h"
#include "QbTimeWidgets_qt4.h"
#include "QbTimeEditors.h"
#include "QbEditors.h"
#define QBU_VERSION  "QBU V_1.2 [19 Feb 2004]"
#define QB_DOUBLE 0
#define QB_STRING 1

class QbObjViewer;
class DataBrowseWindow;

class xrefListItem : public Q3ListViewItem {
    
    public:
        xrefListItem(QdObject_var xobj, QdObject_var dobj, Q3ListView *parent=0, QString name=0 );
        ~xrefListItem(){;}
  
        QdObject_var xref_obj;
  
    public slots:

    signals:
   
    protected:
  
};

class xrefListView : public Q3ListView {

    Q_OBJECT
     
    public:
        xrefListView( QWidget *parent=0, char * name=0 );
        ~xrefListView(){;}
        QbObjViewer *viewer;

    public slots:

    signals:
   
    protected:
        virtual void dragEnterEvent(QDragEnterEvent* event);
        virtual void dropEvent(QDropEvent *event);
  
};

class arrDialog : public QDialog
{
    Q_OBJECT

    public slots:
        void editArray();

    public:
        arrDialog(QWidget *parent=0, const char *name=0, QbObjViewer* browser=0, bool modal=false);
        QguWLinput *dimSlot;
        QbObjViewer *parentBrowser;
        int arrType;

};

class QbObjViewer : public QGroupBox {

    Q_OBJECT

    public slots:
        void xrefEdit ( Q3ListViewItem *item );
        void newXref();
        void addTimeTags();
        void attachXref();
        void deleteXref();
        void refreshList();
        void createText();
        void createTextArr();
        void createTime();
        void createTInterval();
        void createArray();
        void createVConstant();
        void createConstant();
        void openParentFile();

    signals:
        void launchQdaWindow(const char *file);
 
    public:
        QbObjViewer( DataBrowseWindow * pWindow, QdObject_var dobj, QWidget *parent=0, const char *name=0);
        QdObject_var getUpdate();
        const char * objName();

        xrefListView *xrefList;
        QbTimeIntervalEditor* TI_window;
        QbEventTableEditor* TIS_window;
        QbTimeObjEditor* T_window;
        QbScalarEditor* S_window;
        QbScalarSeqEditor* Sseq_window;
        QbTtagEditor* Ttag_window;
        QbMatrixEditor* M_window;
        QbMatrixEditor* SM_window;
        QbMatrixSeqEditor* Mseq_window;
        QbMatrixSeqEditor* SMseq_window;  
        QbTextEditor* Str_window;
        QbTextSeqEditor* Strseq_window;
        QbEditor* activeEditor ;
        QDialog *objTypeSelector;
        arrDialog *arrTypeSelector;
        QPushButton *parentsBtn;
        QMenu *fileList;
        DataBrowseWindow *parentBrowser;
    protected:
  
};


class DataBrowseWindow : public QMainWindow {

    Q_OBJECT

            QMenuBar *_menu_bar;
    QStatusBar *msgBar;

    public slots:
        bool saveEdits();
        void saveEditsAndClose();
        void saveAs();
        void allowSave();
        void allowTimeSave();
        void allowSaveAs();
        void incRec();
        void decRec();
        void lastRec();
        void firstRec();
        void inputRec();
        void adjustRec(int);
        void launchVersion();
        void launchManBrowser();
        void launchManual();
        void dismiss();

    signals:
        void objChanged(const QString&);
  
    public:
    
        DataBrowseWindow(QdObject_var dobj, QString WLcontext,QWidget *parent=0, 
                         const char *name=0 );
				   
        ~DataBrowseWindow();
        void setObject(QdObject_var dataObject, QString WLcontext);
    
        QbObjViewer * browser;
        QString editObjectName;
        QString originalName;
        QdObject_var parentObject;
        //QGroupBox *browserVB;
	QWidget *browserVB;
        QGroupBox *buttons_groupbox;
        QGroupBox *recSlider;
        QguWLinput * recField;
        QSlider *recBar;
        QGroupBox *name_panel;
        QguWLinput *name_field;
        QPushButton *saveEditsBtn;
        QPushButton *dismissBtn;
        QPushButton *saveAsBtn;
        bool disallowSaves;
        QMenu * editMenu;

    protected:
        void keyPressEvent(QKeyEvent * e );
        virtual void dragEnterEvent(QDragEnterEvent *event);
};


class QbuAttachWindow : public QDialog
{

    Q_OBJECT

    public:
        QbuAttachWindow(QbObjViewer *parent=0, const char *name=0);
        QdObject_var dobj;
        QguWLinput *name_field;
        QguWLinput *object_field;
        QbObjViewer * thisViewer;
  
    public slots:
        void updateName();
        void attachObject();
   
};
   


 DataBrowseWindow * QbuLaunchBrowse( QdObject_var source, 
                                     QWidget *parent, const char * objectName, 
                                     QdObject_var dobj, QString WLcontext);

# endif // QSAS_BROWSE_H_
