
#ifndef QRYOMOL_H
#define QRYOMOL_H

#include <vector>
#include <map>

#include "irspectrum.h"
#include "uvspectrum.h"
#include "quantumfile.h"
//Added by qt3to4:
#include <Q3ActionGroup>

#include <kparts/part.h>
#include <klibloader.h>
#include <kparts/browserextension.h>
#include <kparts/genericfactory.h>
#include <kaction.h>
#include <kapplication.h>


class Q3TextEdit;
class QHTMLTabWidget;
class QuantumParser;
class QAction;
class Q3ToolBar;
class Q3ActionGroup;
class QAction;
class KryoVisor;
class KToggleAction;
class KAction;
class KActionCollection;
class KryoMolExtension;

class KryoMolPart: public KParts::ReadOnlyPart
{
  Q_OBJECT
  friend class KryoMolExtension;
public:

  /**
   * Construct a new KParts plugin.
   */
  KryoMolPart( QWidget *parentWidget, QObject *parent, const QVariantList& );

  /**
   * Destructor.
   */
  virtual ~KryoMolPart();
  // Return information about the part
  static KAboutData* createAboutData();

protected:
  virtual bool openFile();
public slots:
  /** Paste clipboard contents, like for instance gaussian arquives*/
  void OnPaste();
  void OpenFile() { openFile(); }
  void ParseChimeScript(const QString& );
protected slots: // Protected slots
  void OnCopy();
  void OnPrint();
  void OnAbout();
  void OnExport();
  void OnRenumber();
  void OnSetDihedral();
private slots:
  /** Show (true) or hide (false) a simulated spectrum*/
  void OnShowSpectrum(bool bshow);
  /** the same for UV*/
  void OnShowUVSpectrum(bool bshow);
  /** hold here a pointer to the current visor*/
  void OnTabChanged(int index);
  void OnActionSelected(const QString& actiontext);
  void OnIRTypeChanged(IRSpectrum::SpectrumType);
  void OnUVTypeChanged(UVSpectrum::SpectrumType);
//  void OnCloseCurrent();
  void OnActionToggled(bool b);
  void OnFirstFrame();
  void OnLastFrame();
  void OnNextFrame();
  void OnPreviousFrame();
  void OnStartAnimation();
  void OnStopAnimation();
  void OnUpdateControls(bool );
private:
  void InitToolBars();
  bool Parse();
  void InitActions();
  void CheckGLSettings();
  void EnableNavigationActions(bool b);

private:
  QPrinter *printer;
  QString filename;
  /** name of the file to be opened*/
  QuantumParser* m_qparser;
  QHTMLTabWidget* m_tab;
  KToggleAction* m_distanceAction;
  KToggleAction* m_angleAction;
  KToggleAction* m_dihedralAction;
  KToggleAction* m_angleplanesAction;

  KToggleAction* m_rotbondAction;
  KToggleAction* m_createbondAction;
  KToggleAction* m_deletebondAction;

  KAction* m_startaction;
  KAction* m_stopaction;
  KAction* m_firstaction; 
  KAction* m_lastaction;
  KAction* m_nextaction;
  KAction* m_previousaction;
 
  static bool m_bcheckglsettings;
  /** pointer to the visor currently active*/
  KryoVisor* m_currentvisor;
  std::vector<KryoVisor*> m_visors;
  QuantumFile::qfiletype m_jobtype;
  /** browser extension for Konqueror integration */
  KryoMolExtension* m_extension;
  QWidget* m_parent;
  KActionCollection* m_actions;
  /** holds if we are inside a html part*/
  bool m_bisinsidehtml;

};

class KryoMolExtension : public KParts::BrowserExtension
{
  Q_OBJECT

public:
  KryoMolExtension(KryoMolPart* parent);
  virtual ~KryoMolExtension();
public slots: // Public slots
  /** access Konqueror paste Action */
  void paste();
  void copy();
  void print();
private:
  KryoMolPart* m_parent;

};

#endif
