//  qjui.h
//
//  Qsas - join Header File
//
//  Tony Allen
//  Dec 2001
//

#ifndef QSAS_DATA_JUIW_H_
#define QSAS_DATA_JUIW_H_

#include "qt_version.h"
#include <qobject.h>
#include <qsplitter.h>
#if QT_VERSION < 0x040000
#include "qgu.h"
#else
#include "qgu_qt4.h"
#endif
#include "qslot.h"

class QjuiWindow;

#define QJUI_VERSION  " V_1.2 [19 Feb 2004]"

class QjuiListItem;

Vostream& operator<<(Vostream&,QjuiListItem&);
Vistream& operator>>(Vistream&,QjuiListItem&);

class QjuiListItem : public QguListItem 
{

public:

   QjuiListItem(QguListView *parent=0,  QString txt=0, QString WL=0, QguListType type=ListTypeEntry, QguListItem *after=0);
   QjuiListItem(QguListItem *parent=0,  QString txt=0, QString WL=0, QguListType type=ListTypeEntry, QguListItem *after=0);
   void setChoices(int w);
//    ~QjuiListItem();

  QString I_width_field;
  QString I_gap_field;
  int I_algorithm;
  int I_gap;

private:

   
};

class QjuiListView;

Vostream& operator<<(Vostream&,QjuiListView&);
Vistream& operator>>(Vistream&,QjuiListView&);

class QjuiListView : public QguListView 
{
      Q_OBJECT
  friend Vostream& operator<<(Vostream&,QjuiListView&);
  friend Vistream& operator>>(Vistream&,QjuiListView&);

public:
   QjuiListView(QWidget *parent, QjuiWindow* QjW, const char *name=0);
   ~QjuiListView();
   void insertEntries(QguListItem *dropAt, QguListItem *item);
   void setItemChoices(int w);

   QjuiWindow* owner;

protected:
   void keyPressEvent(QKeyEvent * e );

   
signals:
  void pasteDetected();
    
public slots:
  void makeGroup();
  void paste();
  void setAlgorithm();
  void setWidthField();
  void setGap();
  void setGapField();
  void updateOnSelection();
  void update1OnSelection();
  void update2OnSelection();
  void update3OnSelection();
  void update4OnSelection();
  void editWLLink();
  
private:

};
   
class QjuiWindow : public QguWindow {

Q_OBJECT

#if QT_VERSION < 0x040000
  QGridLayout* _top_gl;
#else
//   QGridLayout* _top_gl;
#endif
  QSplitter * _top_splitter;
  QjuiListView* _join_listview;
  Q_POPUP_MENU* options_menu;
  int toggleID;
  
public slots:
  void save();
  void saveAs();
  void saveSession(QString);
  void defaultAll();
  void deleteAllItems();
  void verboseToggle();
  bool joinObjects(QdObjectSeq_var JoinedList,
                   vector<KVDataBase_var> &OptionList);
  void DoJoin();
  void writeFile();
  void keepChoices();
  void applyChoices();
  void setTTsource(int);
  void setTTivl(int);
  void setTimeFeedback();
  void messageHandler(QString txt);
  bool alreadyJoined();
  
  void launchManExport();
  void launchManJoin();
  void launchManual();
  void launchVersion();
  
signals:

public:
  QjuiWindow( QWidget *parent=0, const char *name=0 );
  ~QjuiWindow();
  void setDefaults();
  QdTimeInterval_var QjuiGetIntervalFromData();
  QdTimeSeq_var getTimeTags();
  bool disjointSeries(QdObject_var);
  QdTimeInterval_var QjuiGetInterval();

  virtual void save(Vostream&);
  virtual void restore(Vistream& v_is,bool replace=true);

  
#if QT_VERSION < 0x040000
  QHGroupBox *buttons_layout;
#else
  QBoxLayout *buttons_layout;
  QWidget * _buttons_widget;
#endif
  QPushButton *dismissBtn;
  QPushButton *WriteBtn;
  QPushButton *JoinBtn;
  QWidget*    _top_widget;

  QguWLinput* _width_field;
  QComboBox*  _gap;
  QguWLinput* _gap_field;
  QComboBox*  _algorithm;
  QComboBox*  _TimeIvlSelect;
  QguWLinput* _IvlSource;
  QComboBox*  _TimeTagSelect;
  QguWLinput* _TagSource;
  QLabel*     IvlSource_label;
  QLabel*     TagSource_label;
  QLabel* Start_field;
  QLabel* End_field;
  QLabel* Ntags_field;
  QLabel* spacing_field;
  
  QString  _width_field_Def;
  int  _gap_Def;
  QString  _gap_field_Def;
  int  _algorithm_Def;
  QString _IvlSource_Def;
  int  _TimeIvlSelect_Def;
  QString _TagSource_Def;
  int  _TimeTagSelect_Def;

  QString  _width_field_cpy;
  int  _gap_cpy;
  QString  _gap_field_cpy;
  int  _algorithm_cpy;
  QString _IvlSource_cpy;
  int  _TimeIvlSelect_cpy;
  QString _TagSource_cpy;
  int  _TimeTagSelect_cpy;
  
  bool verbose;

protected:
  void dragEnterEvent( QDragEnterEvent *event);

};


QjuiWindow * QJUICreatePopup(QWidget *parent, const char *Title);
void QJUImakeWindow(QWidget *parent, const char * Title);
void QEXPmakeWindow(QWidget *parent, const char * Title);
void QjuiShowJoin();
void QjuiShowExport();
extern QjuiWindow *QJUI_widget;
extern QjuiWindow *QJEX_widget;
                                                  
# endif // QSAS_DATA_JUIW_H_
