/***************************************************************************
                          kern.h  -  description
                             -------------------
    begin                : Sun Jul 13 03:14:52 EDT 2003
    copyright            : (C) 2003 by  Armando Navarro-Vazquez
    email                : qoajnv@usc.es
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef KRYONMR_H
#define KRYONMR_H

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

class KUrl;
class KInstance;
class KAction;
class KToggleAction;



class KAboutData;
class SpectrumContainer;
class KryoNMRExtension;
class KryoNMRSettingsDialog;
class SpectralWidget;
/** KryoNMR is a KPart for visualization of NMR FIDS into konqueror
  * It provides basic processing functionality. but in a easy to
  * use manner. So it should fill the lack of a basic and free 1D NMR processor
  * on UNIX enviroments
  */

class KryoNMR : public KParts::ReadOnlyPart
{
  Q_OBJECT
  friend class KryoNMRExtension;
public:
  KryoNMR( QWidget *parentWidget,
           QObject *parent, const QStringList &args );
  ~KryoNMR() {}

  // Return information about the part
  static KAboutData* createAboutData();

signals:
  void zoomtoggled(bool );
  void infotoggled(bool );
  void phasetoggled(bool );
  void integraltoggled(bool );
  void peakpickingtoggled(bool );
  void tmstoggled(bool );

private: // Private attributes
  SpectralWidget* m_spectrumwidget;
 /* KToggleAction* zoomAction;
  KToggleAction* integralAction;
  KToggleAction* peakpAction;
  KAction* printAction;
  KAction* upAction;
  KAction* downAction;
  KAction* leftAction;
  KAction* rightAction;
  KAction* plusAction ;
  KAction* minusAction;
  KToggleAction* phaseAction;
  KAction* fullAction;
  KToggleAction* tmsAction;
  KToggleAction* infoAction;
  KAction* baselineAction;
  KAction* handbookAction;
  KAction* configureAction;
  KAction* aboutAction;
  KAction* exportAction;*/
  /** browser extension for Konqueror integration */
  KryoNMRExtension* m_extension;

  /** Settings Dialog */
  KryoNMRSettingsDialog* m_settingsdialog;
protected: // Protected methods
  /** No descriptions */
  bool openUrl(const KUrl& url);
protected slots:
  /** Enter QWhatsThis mode */
  void OnWhatsThis();
  /** show users manual */
  void OnHandbook();
  /** open settings dialog */
  void OnPreferences();
  /** show a KAboutDialog */
  void OnAbout();
  /** No descriptions */
  void OnExport();
private: // Private methods
  void InitActions();
  virtual bool openFile();
  void ResetActions();
private slots:

  void OnZoom();
  void OnInfo();
  void OnPhase();
  void OnIntegral();
  void OnPeakPicking();
  void OnTMS();

public slots: // Public slots
  /** call this slot when FT is done to enable spectrum actions like reference.... */
  void enableSpectrumActions(bool b);
};

typedef KParts::GenericFactory<KryoNMR> KryoNMRFactory;

//this extension allows the use of konqueror actions
//thanks to D.Faure for his help with this issue
class KryoNMRExtension : public KParts::BrowserExtension
{
  Q_OBJECT

public:
  KryoNMRExtension(KryoNMR *parent);
  virtual ~KryoNMRExtension();
public slots: // Public slots
  /** access Konqueror print Action */
  void print();
  void saveas() {};
private:
  KryoNMR* m_parent;
};

#endif
